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

     1  /*
     2  Package crontriggers provides interaction with the cron triggers API in the OpenStack Mistral service.
     3  
     4  Cron trigger is an object that allows to run Mistral workflows according to a time pattern (Unix crontab patterns format).
     5  Once a trigger is created it will run a specified workflow according to its properties: pattern, first_execution_time and remaining_executions.
     6  
     7  # List cron triggers
     8  
     9  To filter cron triggers from a list request, you can use advanced filters with special FilterType to check for equality, non equality, values greater or lower, etc.
    10  Default Filter checks equality, but you can override it with provided filter type.
    11  
    12  	listOpts := crontriggers.ListOpts{
    13  		WorkflowName: &executions.ListFilter{
    14  			Value: "Workflow1,Workflow2",
    15  			Filter: executions.FilterIN,
    16  		},
    17  		CreatedAt: &executions.ListDateFilter{
    18  			Value: time.Date(2018, time.January, 1, 0, 0, 0, 0, time.UTC),
    19  			Filter: executions.FilterGTE,
    20  		},
    21  	}
    22  
    23  	allPages, err := crontriggers.List(mistralClient, listOpts).AllPages()
    24  	if err != nil {
    25  		panic(err)
    26  	}
    27  
    28  	allCrontriggers, err := crontriggers.ExtractCronTriggers(allPages)
    29  	if err != nil {
    30  		panic(err)
    31  	}
    32  
    33  	for _, ct := range allCrontriggers {
    34  		fmt.Printf("%+v\n", ct)
    35  	}
    36  
    37  Create a cron trigger. This example will start the workflow "echo" each day at 8am, and it will end after 10 executions.
    38  
    39  	createOpts := &crontriggers.CreateOpts{
    40  		Name:                "daily",
    41  		Pattern:             "0 8 * * *",
    42  		WorkflowName:        "echo",
    43  		RemainingExecutions: 10,
    44  		WorkflowParams: map[string]interface{}{
    45  			"msg": "hello",
    46  		},
    47  		WorkflowInput: map[string]interface{}{
    48  			"msg": "world",
    49  		},
    50  	}
    51  	crontrigger, err := crontriggers.Create(mistralClient, createOpts).Extract()
    52  	if err != nil {
    53  		panic(err)
    54  	}
    55  
    56  Get a cron trigger
    57  
    58  	crontrigger, err := crontriggers.Get(mistralClient, "0520ffd8-f7f1-4f2e-845b-55d953a1cf46").Extract()
    59  	if err != nil {
    60  		panic(err)
    61  	}
    62  
    63  	fmt.Printf(%+v\n", crontrigger)
    64  
    65  Delete a cron trigger
    66  
    67  	res := crontriggers.Delete(mistralClient, "0520ffd8-f7f1-4f2e-845b-55d953a1cf46")
    68  	if res.Err != nil {
    69  		panic(res.Err)
    70  	}
    71  */
    72  package crontriggers