github.com/gophercloud/gophercloud@v1.11.0/openstack/workflow/v2/workflows/doc.go (about)

     1  /*
     2  Package workflows provides interaction with the workflows API in the OpenStack Mistral service.
     3  
     4  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.
     5  Each workflow consists of tasks (at least one) describing what exact steps should be made during workflow execution.
     6  
     7  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
     8  
     9  List workflows
    10  
    11  	listOpts := workflows.ListOpts{
    12  		Namespace: "some-namespace",
    13  	}
    14  
    15  	allPages, err := workflows.List(mistralClient, listOpts).AllPages()
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	allWorkflows, err := workflows.ExtractWorkflows(allPages)
    21  	if err != nil {
    22  		panic(err)
    23  	}
    24  
    25  	for _, workflow := range allWorkflows {
    26  		fmt.Printf("%+v\n", workflow)
    27  	}
    28  
    29  Get a workflow
    30  
    31  	workflow, err := workflows.Get(mistralClient, "604a3a1e-94e3-4066-a34a-aa56873ef236").Extract()
    32  	if err != nil {
    33  		t.Fatalf("Unable to get workflow %s: %v", id, err)
    34  	}
    35  
    36  	fmt.Printf("%+v\n", workflow)
    37  
    38  Create a workflow
    39  
    40  		workflowDefinition := `---
    41  	      version: '2.0'
    42  
    43  	      workflow_echo:
    44  	        description: Simple workflow example
    45  	        type: direct
    46  	        input:
    47  	          - msg
    48  
    49  	        tasks:
    50  	          test:
    51  	            action: std.echo output="<% $.msg %>"`
    52  
    53  		createOpts := &workflows.CreateOpts{
    54  			Definition: strings.NewReader(workflowDefinition),
    55  			Scope: "private",
    56  			Namespace: "some-namespace",
    57  		}
    58  
    59  		workflow, err := workflows.Create(mistralClient, createOpts).Extract()
    60  		if err != nil {
    61  			panic(err)
    62  		}
    63  
    64  		fmt.Printf("%+v\n", workflow)
    65  
    66  Delete a workflow
    67  
    68  	res := workflows.Delete(fake.ServiceClient(), "604a3a1e-94e3-4066-a34a-aa56873ef236")
    69  	if res.Err != nil {
    70  		panic(res.Err)
    71  	}
    72  */
    73  package workflows