-
Notifications
You must be signed in to change notification settings - Fork 9
/
workflow.go
43 lines (35 loc) · 948 Bytes
/
workflow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cloud66
import (
"time"
)
type Workflow struct {
Uid string `json:"uid"`
Name string `json:"name"`
Body string `json:"body"`
Default bool `json:"default"`
CreatedAt time.Time `json:"created_at_iso"`
UpdatedAt time.Time `json:"updated_at_iso"`
Tags []string `json:"tags"`
}
func (p Workflow) String() string {
return p.Name
}
func (c *Client) AddWorkflow(stackUid string, formationUid string, workflow *Workflow, message string) (*Workflow, error) {
var workflowRes *Workflow = nil
params := struct {
Message string `json:"message"`
Workflow *Workflow `json:"workflow"`
}{
Message: message,
Workflow: workflow,
}
req, err := c.NewRequest("POST", "/stacks/"+stackUid+"/formations/"+formationUid+"/workflows.json", params, nil)
if err != nil {
return nil, err
}
err = c.DoReq(req, &workflowRes, nil)
if err != nil {
return nil, err
}
return workflowRes, nil
}