Documentation
¶
Overview ¶
Package workflows provides interaction with the workflows API in the OpenStack Mistral service.
Workflow represents a process that can be described in a various number of ways and that can do some job interesting to the end user. Each workflow consists of tasks (at least one) describing what exact steps should be made during workflow execution.
Workflow definition is written in Mistral Workflow Language v2. You can find all specification here: https://docs.openstack.org/mistral/latest/user/wf_lang_v2.html
List workflows
listOpts := workflows.ListOpts{
Namespace: "some-namespace",
}
allPages, err := workflows.List(mistralClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allWorkflows, err := workflows.ExtractWorkflows(allPages)
if err != nil {
panic(err)
}
for _, workflow := range allWorkflows {
fmt.Printf("%+v\n", workflow)
}
Get a workflow
workflow, err := workflows.Get(mistralClient, "604a3a1e-94e3-4066-a34a-aa56873ef236").Extract()
if err != nil {
t.Fatalf("Unable to get workflow %s: %v", id, err)
}
fmt.Printf("%+v\n", workflow)
Create a workflow
workflowDefinition := `---
version: '2.0'
workflow_echo:
description: Simple workflow example
type: direct
input:
- msg
tasks:
test:
action: std.echo output="<% $.msg %>"`
createOpts := &workflows.CreateOpts{
Definition: strings.NewReader(workflowDefinition),
Scope: "private",
Namespace: "some-namespace",
}
workflow, err := workflows.Create(mistralClient, opts).Extract()
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", workflow)
Delete a workflow
res := workflows.Delete(fake.ServiceClient(), "604a3a1e-94e3-4066-a34a-aa56873ef236")
if res.Err != nil {
panic(res.Err)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List performs a call to list cron triggers. You may provide options to filter the results.
Types ¶
type CreateOpts ¶
type CreateOpts struct {
// Scope is the scope of the workflow.
// Allowed values are "private" and "public".
Scope string `q:"scope"`
// Namespace will define the namespace of the workflow.
Namespace string `q:"namespace"`
// Definition is the workflow definition written in Mistral Workflow Language v2.
Definition io.Reader
}
CreateOpts specifies parameters used to create a cron trigger.
func (CreateOpts) ToWorkflowCreateParams ¶
func (opts CreateOpts) ToWorkflowCreateParams() (io.Reader, string, error)
ToWorkflowCreateParams constructs a request query string from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extension to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
gophercloud.Result
}
CreateResult is the response of a Post operations. Call its Extract method to interpret it as a list of Workflows.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new execution.
func (CreateResult) Extract ¶
func (r CreateResult) Extract() ([]Workflow, error)
Extract helps to get created Workflow struct from a Create function.
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 GetResult ¶
type GetResult struct {
gophercloud.Result
}
GetResult is the response of Get operations. Call its Extract method to interpret it as a Workflow.
func Get ¶
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves details of a single execution. Use Extract to convert its result into an Workflow.
type ListOpts ¶
type ListOpts struct {
// Name allows to filter by workflow name.
Name string `q:"name"`
// Namespace allows to filter by workflow namespace.
Namespace string `q:"namespace"`
// Definition allows to filter by workflow definition.
Definition string `q:"definition"`
// Scope filters by the workflow's scope.
// Values can be "private" or "public".
Scope string `q:"scope"`
// SortDir allows to select sort direction.
// It can be "asc" or "desc" (default).
SortDir string `q:"sort_dir"`
// SortKey allows to sort by one of the cron trigger attributes.
SortKey string `q:"sort_key"`
// 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
// cron triggers.
Limit int `q:"limit"`
}
ListOpts filters the result returned by the List() function.
func (ListOpts) ToWorkflowListQuery ¶
ToWorkflowListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extension to add additional parameters to the List request.
type Workflow ¶
type Workflow struct {
// ID is the workflow's unique ID.
ID string `json:"id"`
// Definition is the workflow definition in Mistral v2 DSL.
Definition string `json:"definition"`
// Name is the name of the workflow.
Name string `json:"name"`
// Namespace is the namespace of the workflow.
Namespace string `json:"namespace"`
// Input represents the needed input to execute the workflow.
// This parameter is a list of each input, comma separated.
Input string `json:"input"`
// ProjectID is the project id owner of the workflow.
ProjectID string `json:"project_id"`
// Scope is the scope of the workflow.
// Values can be "private" or "public".
Scope string `json:"scope"`
// Tags is a list of tags associated to the workflow.
Tags []string `json:"tags"`
// CreatedAt is the creation date of the workflow.
CreatedAt time.Time `json:"-"`
// UpdatedAt is the last update date of the workflow.
UpdatedAt *time.Time `json:"-"`
}
Workflow represents a workflow execution on OpenStack mistral API.
func ExtractWorkflows ¶
func ExtractWorkflows(r pagination.Page) ([]Workflow, error)
ExtractWorkflows get the list of cron triggers from a page acquired from the List call.
func (*Workflow) UnmarshalJSON ¶
UnmarshalJSON implements unmarshalling custom types
type WorkflowPage ¶
type WorkflowPage struct {
pagination.LinkedPageBase
}
WorkflowPage contains a single page of all workflows from a List call.
func (WorkflowPage) IsEmpty ¶
func (r WorkflowPage) IsEmpty() (bool, error)
IsEmpty checks if an WorkflowPage contains any results.
func (WorkflowPage) NextPageURL ¶
func (r WorkflowPage) NextPageURL() (string, error)
NextPageURL finds the next page URL in a page in order to navigate to the next page of results.