forked from cloud66-oss/cloud66
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stencil_group.go
46 lines (39 loc) · 1.09 KB
/
stencil_group.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
44
45
46
package cloud66
import (
"time"
)
type StencilGroup struct {
Uid string `json:"uid"`
Name string `json:"name"`
Rules string `json:"rules"`
CreatedAt time.Time `json:"created_at_iso"`
UpdatedAt time.Time `json:"updated_at_iso"`
Tags []string `json:"tags"`
}
func (s StencilGroup) String() string {
return s.Name
}
func (c *Client) AddStencilGroups(stackUid string, formationUid string, groups []*StencilGroup, message string) ([]StencilGroup, error) {
var groupRes = make([]StencilGroup, 0)
var singleRes *StencilGroup
for _, stencilGroup := range groups {
params := struct {
Message string `json:"message"`
StencilGroup *StencilGroup `json:"stencil_group"`
}{
Message: message,
StencilGroup: stencilGroup,
}
singleRes = nil
req, err := c.NewRequest("POST", "/stacks/"+stackUid+"/formations/"+formationUid+"/stencil_groups.json", params, nil)
if err != nil {
return nil, err
}
err = c.DoReq(req, &singleRes, nil)
if err != nil {
return nil, err
}
groupRes = append(groupRes, *singleRes)
}
return groupRes, nil
}