forked from rancher/go-rancher
/
generated_template_version.go
103 lines (78 loc) · 3.32 KB
/
generated_template_version.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package catalog
const (
TEMPLATE_VERSION_TYPE = "templateVersion"
)
type TemplateVersion struct {
Resource `yaml:"-"`
Actions map[string]string `json:"actions,omitempty" yaml:"actions,omitempty"`
Bindings map[string]string `json:"bindings,omitempty" yaml:"bindings,omitempty"`
Files map[string]string `json:"files,omitempty" yaml:"files,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
Links map[string]string `json:"links,omitempty" yaml:"links,omitempty"`
MaximumRancherVersion string `json:"maximumRancherVersion,omitempty" yaml:"maximum_rancher_version,omitempty"`
MinimumRancherVersion string `json:"minimumRancherVersion,omitempty" yaml:"minimum_rancher_version,omitempty"`
Questions []Question `json:"questions,omitempty" yaml:"questions,omitempty"`
TemplateId string `json:"templateId,omitempty" yaml:"template_id,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
UpgradeFrom string `json:"upgradeFrom,omitempty" yaml:"upgrade_from,omitempty"`
UpgradeVersionLinks map[string]string `json:"upgradeVersionLinks,omitempty" yaml:"upgrade_version_links,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
type TemplateVersionCollection struct {
Collection
Data []TemplateVersion `json:"data,omitempty"`
client *TemplateVersionClient
}
type TemplateVersionClient struct {
rancherClient *RancherClient
}
type TemplateVersionOperations interface {
List(opts *ListOpts) (*TemplateVersionCollection, error)
Create(opts *TemplateVersion) (*TemplateVersion, error)
Update(existing *TemplateVersion, updates interface{}) (*TemplateVersion, error)
ById(id string) (*TemplateVersion, error)
Delete(container *TemplateVersion) error
}
func newTemplateVersionClient(rancherClient *RancherClient) *TemplateVersionClient {
return &TemplateVersionClient{
rancherClient: rancherClient,
}
}
func (c *TemplateVersionClient) Create(container *TemplateVersion) (*TemplateVersion, error) {
resp := &TemplateVersion{}
err := c.rancherClient.doCreate(TEMPLATE_VERSION_TYPE, container, resp)
return resp, err
}
func (c *TemplateVersionClient) Update(existing *TemplateVersion, updates interface{}) (*TemplateVersion, error) {
resp := &TemplateVersion{}
err := c.rancherClient.doUpdate(TEMPLATE_VERSION_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *TemplateVersionClient) List(opts *ListOpts) (*TemplateVersionCollection, error) {
resp := &TemplateVersionCollection{}
err := c.rancherClient.doList(TEMPLATE_VERSION_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *TemplateVersionCollection) Next() (*TemplateVersionCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &TemplateVersionCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *TemplateVersionClient) ById(id string) (*TemplateVersion, error) {
resp := &TemplateVersion{}
err := c.rancherClient.doById(TEMPLATE_VERSION_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *TemplateVersionClient) Delete(container *TemplateVersion) error {
return c.rancherClient.doResourceDelete(TEMPLATE_VERSION_TYPE, &container.Resource)
}