-
Notifications
You must be signed in to change notification settings - Fork 9
/
transformation.go
46 lines (39 loc) · 1.27 KB
/
transformation.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 Transformation struct {
Uid string `json:"uid"`
Name string `json:"name"`
Selector string `json:"selector"`
Sequence int `json:"sequence"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at_iso"`
UpdatedAt time.Time `json:"updated_at_iso"`
Tags []string `json:"tags"`
}
func (t Transformation) String() string {
return t.Name
}
func (c *Client) AddTransformations(stackUid string, formationUid string, transformations []*Transformation, message string) ([]Transformation, error) {
var transformationsRes []Transformation = make([]Transformation, 0)
var singleRes *Transformation
for _, transformation := range transformations {
params := struct {
Message string `json:"message"`
Transformation *Transformation `json:"transformation"`
}{
Message: message,
Transformation: transformation,
}
singleRes = nil
req, err := c.NewRequest("POST", "/stacks/"+stackUid+"/formations/"+formationUid+"/transformations.json", params, nil)
if err != nil {
return nil, err
}
err = c.DoReq(req, &singleRes, nil)
if err != nil {
return nil, err
}
transformationsRes = append(transformationsRes, *singleRes)
}
return transformationsRes, nil
}