Documentation ¶
Overview ¶
Package client provides a GRR client object which handles associated API calls via an arbitrary transfer protocol.
Index ¶
- func EmailCCAddresses(emailAddresses []string) func(args *aupb.ApiCreateClientApprovalArgs)
- func KeepClientAlive() func(args *aupb.ApiCreateClientApprovalArgs)
- func SearchClients(ctx context.Context, conn Connector, query string, fn func(c *Client) error, ...) error
- func WithRunnerArgs(flowRunnerArgs *flowpb.FlowRunnerArgs) func(args *afpb.ApiCreateFlowArgs)
- type Approval
- type Client
- func (c *Client) AddLabels(ctx context.Context, Labels []string) error
- func (c *Client) Approval(id string, username string) *Approval
- func (c *Client) CreateApproval(ctx context.Context, reason string, notifiedUsers []string, ...) (*Approval, error)
- func (c *Client) CreateFlow(ctx context.Context, name string, flowArgs proto.Message, ...) (*flow.Flow, error)
- func (c *Client) File(path string) *vfs.File
- func (c *Client) Flow(id string) *flow.Flow
- func (c *Client) Get(ctx context.Context) error
- func (c *Client) ListApprovals(ctx context.Context, state *aupb.ApiListClientApprovalsArgs_State, ...) error
- func (c *Client) ListFlows(ctx context.Context, fn func(f *flow.Flow) error) error
- func (c *Client) RemoveLabels(ctx context.Context, Labels []string) error
- type Connector
- type SearchClientsOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmailCCAddresses ¶
func EmailCCAddresses(emailAddresses []string) func(args *aupb.ApiCreateClientApprovalArgs)
EmailCCAddresses is an optional argument that can be passed into CreateApproval to add email cc addresses for the operation. Example usage could look like this: CreateApproval(ctx, conn, EmailCCAddresses([]string{...})).
func KeepClientAlive ¶
func KeepClientAlive() func(args *aupb.ApiCreateClientApprovalArgs)
KeepClientAlive is an optional argument that can be passed into CreateApproval to keep client alive. Example usage could look like this: CreateApproval(ctx, conn, KeepClientAlive())
func SearchClients ¶
func SearchClients(ctx context.Context, conn Connector, query string, fn func(c *Client) error, options ...SearchClientsOption) error
SearchClients sends a request to GRR server to search for clients using given query and calls fn (a callback function) on each Client object. An optional argument can be passed (see function WithMaxCount).
func WithRunnerArgs ¶
func WithRunnerArgs(flowRunnerArgs *flowpb.FlowRunnerArgs) func(args *afpb.ApiCreateFlowArgs)
WithRunnerArgs is an optional argument that can be passed into CreateFlow to define the runner arguments of new flow. Example usage could look like this: CreateFlow(ctx, conn, WithRunnerArgs(&flowpb.FlowRunnerArgs{...})).
Types ¶
type Approval ¶
type Approval struct { ID string ClientID string Username string Data *aupb.ApiClientApproval // contains filtered or unexported fields }
Approval object is a helper object to send requests to GRR server via an arbitrary transfer protocol.
type Client ¶
Client object is a helper object to send requests to GRR server via an arbitrary transfer protocol.
func (*Client) Approval ¶
Approval returns a Approval ref with given approval id, username and current client id.
func (*Client) CreateApproval ¶
func (c *Client) CreateApproval(ctx context.Context, reason string, notifiedUsers []string, options ...func(args *aupb.ApiCreateClientApprovalArgs)) (*Approval, error)
CreateApproval sends a request to GRR server to create a new client approval with given reason and notify users. KeepClientAlive is set to false by default.
func (*Client) CreateFlow ¶
func (c *Client) CreateFlow(ctx context.Context, name string, flowArgs proto.Message, options ...func(args *afpb.ApiCreateFlowArgs)) (*flow.Flow, error)
CreateFlow sends a request to GRR server to create a new flow with given name and arguments of the flow.
func (*Client) Flow ¶
Flow returns a new flow object with given flow ID and current client id and connector.
func (*Client) Get ¶
Get sends a request to GRR server to get information for a client and fills it in Data field. If an error occurs, Data field will stay unchanged.
func (*Client) ListApprovals ¶
func (c *Client) ListApprovals(ctx context.Context, state *aupb.ApiListClientApprovalsArgs_State, fn func(a *Approval) error) error
ListApprovals sends a request to GRR server to list all approvals of the client and calls fn (a callback function) on each Approval object.
type Connector ¶
type Connector interface { // Adds given list of labels to given clients. AddClientsLabels(ctx context.Context, args *acpb.ApiAddClientsLabelsArgs) error // Removes given labels from given clients. RemoveClientsLabels(ctx context.Context, args *acpb.ApiRemoveClientsLabelsArgs) error // Returns information for a client approval with a given reason. GetClientApproval(ctx context.Context, args *aupb.ApiGetClientApprovalArgs) (*aupb.ApiClientApproval, error) // GetUsername returns username of the current user. GetUsername(ctx context.Context) (string, error) // Lists all the client approvals. ListClientApprovals(ctx context.Context, args *aupb.ApiListClientApprovalsArgs, fn func(m *aupb.ApiClientApproval) error) error // List flows on a given client. ListFlows(ctx context.Context, args *afpb.ApiListFlowsArgs, fn func(m *afpb.ApiFlow) error) error // Grant client approval. GrantClientApproval(ctx context.Context, args *aupb.ApiGrantClientApprovalArgs) (*aupb.ApiClientApproval, error) // Create a new client approval. CreateClientApproval(ctx context.Context, args *aupb.ApiCreateClientApprovalArgs) (*aupb.ApiClientApproval, error) // Start a new flow on a given client. CreateFlow(ctx context.Context, args *afpb.ApiCreateFlowArgs) (*afpb.ApiFlow, error) // Get client with a given client id. GetClient(ctx context.Context, args *acpb.ApiGetClientArgs) (*acpb.ApiClient, error) // Search for clients using a search query SearchClients(ctx context.Context, args *acpb.ApiSearchClientsArgs, fn func(m *acpb.ApiClient) error) error flow.Connector vfs.Connector }
Connector abstracts GRR communication protocols (i.e. HTTP, Stubby) and handles API calls related to clients.
type SearchClientsOption ¶
type SearchClientsOption func(args *acpb.ApiSearchClientsArgs)
SearchClientsOption is a function signature for avoiding repetitive typing.
func WithMaxCount ¶
func WithMaxCount(count int64) SearchClientsOption
WithMaxCount is an optional argument that can be passed into SearchClients to restrict the maximum number of clients returned from the response. Example usage could look like this: SearchClients(ctx, conn, WithMaxCount(1)).