action

package
v0.0.0-...-b9bb202 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 9 Imported by: 1

Documentation

Overview

Package action defines the API client for the Action facade. This client is used by the Juju CLI to trigger action runs and receive results.

Index

Constants

This section is empty.

Variables

View Source
var WithTracer = base.WithTracer

WithTracer returns an Option that configures the Client to use the supplied tracer.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID         string
	Receiver   string
	Name       string
	Parameters map[string]interface{}
}

Action is a named task to execute on a unit or machine.

type ActionMessage

type ActionMessage struct {
	Timestamp time.Time
	Message   string
}

ActionMessage represents a logged message on an action.

type ActionResult

type ActionResult struct {
	Action    *Action
	Enqueued  time.Time
	Started   time.Time
	Completed time.Time
	Status    string
	Message   string
	Log       []ActionMessage
	Output    map[string]interface{}
	Error     error
}

ActionResult is the result of running an action.

type ActionSpec

type ActionSpec struct {
	Description string
	Params      map[string]interface{}
}

ActionSpec is a definition of the parameters and traits of an Action. The Params map is expected to conform to JSON-Schema Draft 4 as defined at http://json-schema.org/draft-04/schema# (see http://json-schema.org/latest/json-schema-core.html)

type Client

type Client struct {
	base.ClientFacade
	// contains filtered or unexported fields
}

Client provides access to the action facade.

func NewClient

func NewClient(st base.APICallCloser, options ...Option) *Client

NewClient returns a new actions client.

func (*Client) Actions

func (c *Client) Actions(ctx context.Context, actionIDs []string) ([]ActionResult, error)

Actions takes a list of action IDs, and returns the full Action for each ID.

func (*Client) ApplicationCharmActions

func (c *Client) ApplicationCharmActions(ctx context.Context, appName string) (map[string]ActionSpec, error)

ApplicationCharmActions is a single query which uses ApplicationsCharmsActions to get the charm.Actions for a single Application by tag.

func (*Client) Cancel

func (c *Client) Cancel(ctx context.Context, actionIDs []string) ([]ActionResult, error)

Cancel attempts to cancel a queued up Action from running.

func (*Client) EnqueueOperation

func (c *Client) EnqueueOperation(ctx context.Context, actions []Action) (EnqueuedActions, error)

EnqueueOperation takes a list of Actions and queues them up to be executed as an operation, each action running as a task on the the designated ActionReceiver. We return the ID of the overall operation and each individual task.

func (*Client) ListOperations

func (c *Client) ListOperations(ctx context.Context, arg OperationQueryArgs) (Operations, error)

ListOperations fetches the operation summaries for specified apps/units.

func (*Client) Operation

func (c *Client) Operation(ctx context.Context, id string) (Operation, error)

Operation fetches the operation with the specified ID.

func (*Client) Run

func (c *Client) Run(ctx context.Context, run RunParams) (EnqueuedActions, error)

Run the Commands specified on the machines identified through the ids provided in the machines, applications and units slices.

func (*Client) RunOnAllMachines

func (c *Client) RunOnAllMachines(ctx context.Context, commands string, timeout time.Duration) (EnqueuedActions, error)

RunOnAllMachines runs the command on all the machines with the specified timeout.

func (*Client) WatchActionProgress

func (c *Client) WatchActionProgress(ctx context.Context, actionId string) (watcher.StringsWatcher, error)

WatchActionProgress returns a watcher that reports on action log messages. The result strings are json formatted core.actions.ActionMessage objects.

type EnqueuedActions

type EnqueuedActions struct {
	OperationID string
	Actions     []ActionResult
}

EnqueuedActions represents the result of enqueuing actions to run.

type Operation

type Operation struct {
	ID        string
	Summary   string
	Fail      string
	Enqueued  time.Time
	Started   time.Time
	Completed time.Time
	Status    string
	Actions   []ActionResult
	Error     error
}

Operation holds a list of actions run as part of the operation

type OperationQueryArgs

type OperationQueryArgs struct {
	Applications []string
	Units        []string
	Machines     []string
	ActionNames  []string
	Status       []string

	// These attributes are used to support client side
	// batching of results.
	Offset *int
	Limit  *int
}

OperationQueryArgs holds args for listing operations.

type Operations

type Operations struct {
	Operations []Operation
	Truncated  bool
}

Operations holds a list of operations and whether the list has been truncated (used for batch queries).

type Option

type Option = base.Option

Option is a function that can be used to configure a Client.

type RunParams

type RunParams struct {
	Commands       string
	Timeout        time.Duration
	Machines       []string
	Applications   []string
	Units          []string
	Parallel       *bool
	ExecutionGroup *string

	// WorkloadContext for CAAS is true when the Commands should be run on
	// the workload not the operator.
	WorkloadContext bool
}

RunParams is used to provide the parameters to the Run method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL