-
Notifications
You must be signed in to change notification settings - Fork 9
/
manifest-yaml.go
81 lines (65 loc) · 1.84 KB
/
manifest-yaml.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package cloud66
import (
"strconv"
"time"
)
type ManifestYaml struct {
Uid string `json:"uid"`
Body string `json:"body"`
Comments string `json:"comments"`
CreatedAt time.Time `json:"created_at_iso"`
UpdatedAt time.Time `json:"updated_at_iso"`
}
func (c *Client) ManifestYamlList(stackUid string, include_body bool) ([]ManifestYaml, error) {
queryStrings := make(map[string]string)
queryStrings["page"] = "1"
queryStrings["include_body"] = strconv.FormatBool(include_body)
var p Pagination
var result []ManifestYaml
var manifestYamlRes []ManifestYaml
for {
req, err := c.NewRequest("GET", "/stacks/"+stackUid+"/manifest_yaml.json", nil, queryStrings)
if err != nil {
return nil, err
}
manifestYamlRes = nil
err = c.DoReq(req, &manifestYamlRes, &p)
if err != nil {
return nil, err
}
result = append(result, manifestYamlRes...)
if p.Current < p.Next {
queryStrings["page"] = strconv.Itoa(p.Next)
} else {
break
}
}
return result, nil
}
func (c *Client) ManifestYamlInfo(stackUid string, version string) (*ManifestYaml, error) {
var manifestYamlRes ManifestYaml
req, err := c.NewRequest("GET", "/stacks/"+stackUid+"/manifest_yaml/"+version+".json", nil, nil)
if err != nil {
return nil, err
}
err = c.DoReq(req, &manifestYamlRes, nil)
if err != nil {
return nil, err
}
return &manifestYamlRes, nil
}
func (c *Client) CreateManifestYaml(stackUid, manifestYaml, comments string) (*ManifestYaml, error) {
params := struct {
ManifestYaml string `json:"manifest_yaml"`
Comments string `json:"comments"`
}{
ManifestYaml: manifestYaml,
Comments: comments,
}
req, err := c.NewRequest("POST", "/stacks/"+stackUid+"/manifest_yaml", params, nil)
if err != nil {
return nil, err
}
var manifestYamlRes *ManifestYaml
return manifestYamlRes, c.DoReq(req, &manifestYamlRes, nil)
}