forked from rancher/go-rancher
/
generated_external_handler.go
186 lines (123 loc) · 5.57 KB
/
generated_external_handler.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package client
const (
EXTERNAL_HANDLER_TYPE = "externalHandler"
)
type ExternalHandler struct {
Resource
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Priority int64 `json:"priority,omitempty" yaml:"priority,omitempty"`
ProcessConfigs []interface{} `json:"processConfigs,omitempty" yaml:"process_configs,omitempty"`
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
Retries int64 `json:"retries,omitempty" yaml:"retries,omitempty"`
State string `json:"state,omitempty" yaml:"state,omitempty"`
TimeoutMillis int64 `json:"timeoutMillis,omitempty" yaml:"timeout_millis,omitempty"`
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}
type ExternalHandlerCollection struct {
Collection
Data []ExternalHandler `json:"data,omitempty"`
client *ExternalHandlerClient
}
type ExternalHandlerClient struct {
rancherClient *RancherClient
}
type ExternalHandlerOperations interface {
List(opts *ListOpts) (*ExternalHandlerCollection, error)
Create(opts *ExternalHandler) (*ExternalHandler, error)
Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error)
ById(id string) (*ExternalHandler, error)
Delete(container *ExternalHandler) error
ActionActivate(*ExternalHandler) (*ExternalHandler, error)
ActionCreate(*ExternalHandler) (*ExternalHandler, error)
ActionDeactivate(*ExternalHandler) (*ExternalHandler, error)
ActionPurge(*ExternalHandler) (*ExternalHandler, error)
ActionRemove(*ExternalHandler) (*ExternalHandler, error)
ActionRestore(*ExternalHandler) (*ExternalHandler, error)
ActionUpdate(*ExternalHandler) (*ExternalHandler, error)
}
func newExternalHandlerClient(rancherClient *RancherClient) *ExternalHandlerClient {
return &ExternalHandlerClient{
rancherClient: rancherClient,
}
}
func (c *ExternalHandlerClient) Create(container *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_TYPE, container, resp)
return resp, err
}
func (c *ExternalHandlerClient) Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *ExternalHandlerClient) List(opts *ListOpts) (*ExternalHandlerCollection, error) {
resp := &ExternalHandlerCollection{}
err := c.rancherClient.doList(EXTERNAL_HANDLER_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *ExternalHandlerCollection) Next() (*ExternalHandlerCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &ExternalHandlerCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *ExternalHandlerClient) ById(id string) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doById(EXTERNAL_HANDLER_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *ExternalHandlerClient) Delete(container *ExternalHandler) error {
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_TYPE, &container.Resource)
}
func (c *ExternalHandlerClient) ActionActivate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "activate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionCreate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "create", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionDeactivate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "deactivate", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionPurge(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "purge", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionRemove(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "remove", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionRestore(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "restore", &resource.Resource, nil, resp)
return resp, err
}
func (c *ExternalHandlerClient) ActionUpdate(resource *ExternalHandler) (*ExternalHandler, error) {
resp := &ExternalHandler{}
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "update", &resource.Resource, nil, resp)
return resp, err
}