Documentation ¶
Overview ¶
Package executions provides interaction with the execution API in the OpenStack Mistral service.
An execution is a one-shot execution of a specific workflow. Each execution contains all information about workflow itself, about execution process, state, input and output data.
An execution represents also the execution of a cron trigger. Each run of a cron trigger will generate an execution.
List executions ¶
To filter executions from a list request, you can use advanced filters with special FilterType to check for equality, non equality, values greater or lower, etc. Default Filter checks equality, but you can override it with provided filter type.
// List all executions from a given workflow list with a creation date upper than 2018-01-01 00:00:00 listOpts := executions.ListOpts{ WorkflowName: &executions.ListFilter{ Value: "Workflow1,Workflow2", Filter: executions.FilterIN, }, CreatedAt: &executions.ListDateFilter{ Value: time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC), Filter: executions.FilterGTE, }, } allPages, err := executions.List(mistralClient, listOpts).AllPages() if err != nil { panic(err) } allExecutions, err := executions.ExtractExecutions(allPages) if err != nil { panic(err) } for _, ex := range allExecutions { fmt.Printf("%+v\n", ex) }
Create an execution
createOpts := &executions.CreateOpts{ WorkflowID: "6656c143-a009-4bcb-9814-cc100a20bbfa", Input: map[string]interface{}{ "msg": "Hello", }, Description: "this is a description", } execution, err := executions.Create(mistralClient, opts).Extract() if err != nil { panic(err) }
Get an execution
execution, err := executions.Get(mistralClient, "50bb59f1-eb77-4017-a77f-6d575b002667").Extract() if err != nil { panic(err) } fmt.Printf(%+v\n", execution)
Delete an execution
res := executions.Delete(mistralClient, "50bb59f1-eb77-4017-a77f-6d575b002667") if res.Err != nil { panic(res.Err) }
Index ¶
- Constants
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type Execution
- type ExecutionPage
- type FilterType
- type GetResult
- type ListDateFilter
- type ListFilter
- type ListOpts
- type ListOptsBuilder
Constants ¶
const ( // FilterEQ checks equality. FilterEQ = "eq" // FilterNEQ checks non equality. FilterNEQ = "neq" // FilterIN checks for belonging in a list, comma separated. FilterIN = "in" // FilterNIN checks for values that does not belong from a list, comma separated. FilterNIN = "nin" // FilterGT checks for values strictly greater. FilterGT = "gt" // FilterGTE checks for values greater or equal. FilterGTE = "gte" // FilterLT checks for values strictly lower. FilterLT = "lt" // FilterLTE checks for values lower or equal. FilterLTE = "lte" // FilterHas checks for values that contains the requested parameter. FilterHas = "has" )
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List performs a call to list executions. You may provide options to filter the executions.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // ID is the unique ID of the execution. ID string `json:"id,omitempty"` // SourceExecutionID can be set to create an execution based on another existing execution. SourceExecutionID string `json:"source_execution_id,omitempty"` // WorkflowID is the unique id of the workflow. WorkflowID string `json:"workflow_id,omitempty" or:"WorkflowName"` // WorkflowName is the name identifier of the workflow. WorkflowName string `json:"workflow_name,omitempty" or:"WorkflowID"` // WorkflowNamespace is the namespace of the workflow. WorkflowNamespace string `json:"workflow_namespace,omitempty"` // Input is a JSON structure containing workflow input values, serialized as string. Input map[string]interface{} `json:"input,omitempty"` // Params define workflow type specific parameters. Params map[string]interface{} `json:"params,omitempty"` // Description is the description of the workflow execution. Description string `json:"description,omitempty"` }
CreateOpts specifies parameters used to create an execution.
func (CreateOpts) ToExecutionCreateMap ¶
func (opts CreateOpts) ToExecutionCreateMap() (map[string]interface{}, error)
ToExecutionCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extension to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult is the response of a Post operations. Call its Extract method to interpret it as an Execution.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new execution.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the result from a Delete operation. Call its ExtractErr method to determine the success of the call.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)
Delete deletes the specified execution.
type Execution ¶
type Execution struct { // ID is the execution's unique ID. ID string `json:"id"` // CreatedAt contains the execution creation date. CreatedAt time.Time `json:"-"` // UpdatedAt is the last update of the execution. UpdatedAt time.Time `json:"-"` // RootExecutionID is the parent execution ID. RootExecutionID *string `json:"root_execution_id"` // TaskExecutionID is the task execution ID. TaskExecutionID *string `json:"task_execution_id"` // Description is the description of the execution. Description string `json:"description"` // Input contains the workflow input values. Input map[string]interface{} `json:"-"` // Ouput contains the workflow output values. Output map[string]interface{} `json:"-"` // Params contains workflow type specific parameters. Params map[string]interface{} `json:"-"` // ProjectID is the project id owner of the execution. ProjectID string `json:"project_id"` // State is the current state of the execution. State can be one of: IDLE, RUNNING, SUCCESS, ERROR, PAUSED, CANCELLED. State string `json:"state"` // StateInfo contains an optional state information string. StateInfo *string `json:"state_info"` // WorkflowID is the ID of the workflow linked to the execution. WorkflowID string `json:"workflow_id"` // WorkflowName is the name of the workflow linked to the execution. WorkflowName string `json:"workflow_name"` // WorkflowNamespace is the namespace of the workflow linked to the execution. WorkflowNamespace string `json:"workflow_namespace"` }
Execution represents a workflow execution on OpenStack mistral API.
func ExtractExecutions ¶
func ExtractExecutions(r pagination.Page) ([]Execution, error)
ExtractExecutions get the list of executions from a page acquired from the List call.
func (*Execution) UnmarshalJSON ¶
UnmarshalJSON implements unmarshalling custom types
type ExecutionPage ¶
type ExecutionPage struct {
pagination.LinkedPageBase
}
ExecutionPage contains a single page of all executions from a List call.
func (ExecutionPage) IsEmpty ¶
func (r ExecutionPage) IsEmpty() (bool, error)
IsEmpty checks if an ExecutionPage contains any results.
func (ExecutionPage) NextPageURL ¶
func (r ExecutionPage) NextPageURL() (string, error)
NextPageURL finds the next page URL in a page in order to navigate to the next page of results.
type FilterType ¶
type FilterType string
FilterType represents a valid filter to use for filtering executions.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response of Get operations. Call its Extract method to interpret it as an Execution.
func Get ¶
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves details of a single execution. Use ExtractExecution to convert its result into an Execution.
type ListDateFilter ¶
type ListDateFilter struct { Filter FilterType Value time.Time }
ListDateFilter allows to filter date parameters with different filters. Empty value for Filter checks for equality.
func (ListDateFilter) String ¶
func (l ListDateFilter) String() string
type ListFilter ¶
type ListFilter struct { Filter FilterType Value string }
ListFilter allows to filter string parameters with different filters. Empty value for Filter checks for equality.
func (ListFilter) String ¶
func (l ListFilter) String() string
type ListOpts ¶
type ListOpts struct { // WorkflowName allows to filter by workflow name. WorkflowName *ListFilter `q:"-"` // WorkflowID allows to filter by workflow id. WorkflowID string `q:"workflow_id"` // Description allows to filter by execution description. Description *ListFilter `q:"-"` // Params allows to filter by specific parameters. Params map[string]interface{} `q:"-"` // TaskExecutionID allows to filter with a specific task execution id. TaskExecutionID string `q:"task_execution_id"` // RootExecutionID allows to filter with a specific root execution id. RootExecutionID string `q:"root_execution_id"` // State allows to filter by execution state. // Possible values are IDLE, RUNNING, PAUSED, SUCCESS, ERROR, CANCELLED. State *ListFilter `q:"-"` // StateInfo allows to filter by state info. StateInfo *ListFilter `q:"-"` // Input allows to filter by specific input. Input map[string]interface{} `q:"-"` // Output allows to filter by specific output. Output map[string]interface{} `q:"-"` // CreatedAt allows to filter by execution creation date. CreatedAt *ListDateFilter `q:"-"` // UpdatedAt allows to filter by last execution update date. UpdatedAt *ListDateFilter `q:"-"` // IncludeOutput requests to include the output for all executions in the list. IncludeOutput bool `q:"-"` // ProjectID allows to filter by given project id. Admin required. ProjectID string `q:"project_id"` // AllProjects requests to get executions of all projects. Admin required. AllProjects int `q:"all_projects"` // SortDir allows to select sort direction. // It can be "asc" or "desc" (default). SortDirs string `q:"sort_dirs"` // SortKey allows to sort by one of the execution attributes. SortKeys string `q:"sort_keys"` // Marker and Limit control paging. // Marker instructs List where to start listing from. Marker string `q:"marker"` // Limit instructs List to refrain from sending excessively large lists of // executions. Limit int `q:"limit"` }
ListOpts filters the result returned by the List() function.
func (ListOpts) ToExecutionListQuery ¶
ToExecutionListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extension to add additional parameters to the List request.