-
Notifications
You must be signed in to change notification settings - Fork 6
/
natgateway.go
333 lines (306 loc) · 12.4 KB
/
natgateway.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
package resources
import (
"context"
"github.com/fatih/structs"
"github.com/ionos-cloud/ionosctl/pkg/config"
ionoscloud "github.com/ionos-cloud/sdk-go/v6"
)
type NatGateway struct {
ionoscloud.NatGateway
}
type NatGatewayRule struct {
ionoscloud.NatGatewayRule
}
type NatGatewayLanProperties struct {
ionoscloud.NatGatewayLanProperties
}
type NatGatewayRuleProperties struct {
ionoscloud.NatGatewayRuleProperties
}
type NatGatewayRules struct {
ionoscloud.NatGatewayRules
}
type NatGatewayProperties struct {
ionoscloud.NatGatewayProperties
}
type NatGateways struct {
ionoscloud.NatGateways
}
// NatGatewaysService is a wrapper around ionoscloud.NatGateway
type NatGatewaysService interface {
List(datacenterId string, params ListQueryParams) (NatGateways, *Response, error)
Get(datacenterId, natGatewayId string, params QueryParams) (*NatGateway, *Response, error)
Create(datacenterId string, input NatGateway, params QueryParams) (*NatGateway, *Response, error)
Update(datacenterId, natGatewayId string, input NatGatewayProperties, params QueryParams) (*NatGateway, *Response, error)
Delete(datacenterId, natGatewayId string, params QueryParams) (*Response, error)
ListRules(datacenterId, natGatewayId string, params ListQueryParams) (NatGatewayRules, *Response, error)
GetRule(datacenterId, natGatewayId, ruleId string, params QueryParams) (*NatGatewayRule, *Response, error)
CreateRule(datacenterId, natGatewayId string, input NatGatewayRule, params QueryParams) (*NatGatewayRule, *Response, error)
UpdateRule(datacenterId, natGatewayId, ruleId string, input NatGatewayRuleProperties, params QueryParams) (*NatGatewayRule, *Response, error)
DeleteRule(datacenterId, natGatewayId, ruleId string, params QueryParams) (*Response, error)
ListFlowLogs(datacenterId, natGatewayId string, params ListQueryParams) (FlowLogs, *Response, error)
GetFlowLog(datacenterId, natGatewayId, flowlogId string, params QueryParams) (*FlowLog, *Response, error)
CreateFlowLog(datacenterId, natGatewayId string, input FlowLog, params QueryParams) (*FlowLog, *Response, error)
UpdateFlowLog(datacenterId, natGatewayId, flowlogId string, input *FlowLogProperties, params QueryParams) (*FlowLog, *Response, error)
DeleteFlowLog(datacenterId, natGatewayId, flowlogId string, params QueryParams) (*Response, error)
}
type natGatewaysService struct {
client *ionoscloud.APIClient
context context.Context
}
var _ NatGatewaysService = &natGatewaysService{}
func NewNatGatewayService(client *config.Client, ctx context.Context) NatGatewaysService {
return &natGatewaysService{
client: client.CloudClient,
context: ctx,
}
}
func (ds *natGatewaysService) List(datacenterId string, params ListQueryParams) (NatGateways, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysGet(ds.context, datacenterId)
if !structs.IsZero(params) {
if params.Filters != nil {
for k, v := range *params.Filters {
req = req.Filter(k, v)
}
}
if params.OrderBy != nil {
req = req.OrderBy(*params.OrderBy)
}
if params.MaxResults != nil {
req = req.MaxResults(*params.MaxResults)
}
if !structs.IsZero(params.QueryParams) {
if params.QueryParams.Depth != nil {
req = req.Depth(*params.QueryParams.Depth)
}
if params.QueryParams.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.QueryParams.Pretty)
}
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysGetExecute(req)
return NatGateways{s}, &Response{*res}, err
}
func (ds *natGatewaysService) Get(datacenterId, natGatewayId string, params QueryParams) (*NatGateway, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysFindByNatGatewayId(ds.context, datacenterId, natGatewayId)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
datacenter, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysFindByNatGatewayIdExecute(req)
return &NatGateway{datacenter}, &Response{*res}, err
}
func (ds *natGatewaysService) Create(datacenterId string, input NatGateway, params QueryParams) (*NatGateway, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysPost(ds.context, datacenterId).NatGateway(input.NatGateway)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
datacenter, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysPostExecute(req)
return &NatGateway{datacenter}, &Response{*res}, err
}
func (ds *natGatewaysService) Update(datacenterId, natGatewayId string, input NatGatewayProperties, params QueryParams) (*NatGateway, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysPatch(ds.context, datacenterId, natGatewayId).NatGatewayProperties(input.NatGatewayProperties)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
datacenter, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysPatchExecute(req)
return &NatGateway{datacenter}, &Response{*res}, err
}
func (ds *natGatewaysService) Delete(datacenterId, natGatewayId string, params QueryParams) (*Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysDelete(ds.context, datacenterId, natGatewayId)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysDeleteExecute(req)
return &Response{*res}, err
}
func (ds *natGatewaysService) ListRules(datacenterId, natGatewayId string, params ListQueryParams) (NatGatewayRules, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesGet(ds.context, datacenterId, natGatewayId)
if !structs.IsZero(params) {
if params.Filters != nil {
for k, v := range *params.Filters {
req = req.Filter(k, v)
}
}
if params.OrderBy != nil {
req = req.OrderBy(*params.OrderBy)
}
if params.MaxResults != nil {
req = req.MaxResults(*params.MaxResults)
}
if !structs.IsZero(params.QueryParams) {
if params.QueryParams.Depth != nil {
req = req.Depth(*params.QueryParams.Depth)
}
if params.QueryParams.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.QueryParams.Pretty)
}
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesGetExecute(req)
return NatGatewayRules{s}, &Response{*res}, err
}
func (ds *natGatewaysService) GetRule(datacenterId, natGatewayId, ruleId string, params QueryParams) (*NatGatewayRule, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesFindByNatGatewayRuleId(ds.context, datacenterId, natGatewayId, ruleId)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesFindByNatGatewayRuleIdExecute(req)
return &NatGatewayRule{s}, &Response{*res}, err
}
func (ds *natGatewaysService) CreateRule(datacenterId, natGatewayId string, input NatGatewayRule, params QueryParams) (*NatGatewayRule, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesPost(ds.context, datacenterId, natGatewayId).NatGatewayRule(input.NatGatewayRule)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesPostExecute(req)
return &NatGatewayRule{s}, &Response{*res}, err
}
func (ds *natGatewaysService) UpdateRule(datacenterId, natGatewayId, ruleId string, input NatGatewayRuleProperties, params QueryParams) (*NatGatewayRule, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesPatch(ds.context, datacenterId, natGatewayId, ruleId).NatGatewayRuleProperties(input.NatGatewayRuleProperties)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesPatchExecute(req)
return &NatGatewayRule{s}, &Response{*res}, err
}
func (ds *natGatewaysService) DeleteRule(datacenterId, natGatewayId, ruleId string, params QueryParams) (*Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesDelete(ds.context, datacenterId, natGatewayId, ruleId)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysRulesDeleteExecute(req)
return &Response{*res}, err
}
func (ds *natGatewaysService) ListFlowLogs(datacenterId, natGatewayId string, params ListQueryParams) (FlowLogs, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsGet(ds.context, datacenterId, natGatewayId)
if !structs.IsZero(params) {
if params.Filters != nil {
for k, v := range *params.Filters {
req = req.Filter(k, v)
}
}
if params.OrderBy != nil {
req = req.OrderBy(*params.OrderBy)
}
if params.MaxResults != nil {
req = req.MaxResults(*params.MaxResults)
}
if !structs.IsZero(params.QueryParams) {
if params.QueryParams.Depth != nil {
req = req.Depth(*params.QueryParams.Depth)
}
if params.QueryParams.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.QueryParams.Pretty)
}
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsGetExecute(req)
return FlowLogs{s}, &Response{*res}, err
}
func (ds *natGatewaysService) GetFlowLog(datacenterId, natGatewayId, flowlogId string, params QueryParams) (*FlowLog, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsFindByFlowLogId(ds.context, datacenterId, natGatewayId, flowlogId)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsFindByFlowLogIdExecute(req)
return &FlowLog{s}, &Response{*res}, err
}
func (ds *natGatewaysService) CreateFlowLog(datacenterId, natGatewayId string, input FlowLog, params QueryParams) (*FlowLog, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsPost(ds.context, datacenterId, natGatewayId).NatGatewayFlowLog(input.FlowLog)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsPostExecute(req)
return &FlowLog{s}, &Response{*res}, err
}
func (ds *natGatewaysService) UpdateFlowLog(datacenterId, natGatewayId, flowlogId string, input *FlowLogProperties, params QueryParams) (*FlowLog, *Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsPatch(ds.context, datacenterId, natGatewayId, flowlogId).NatGatewayFlowLogProperties(input.FlowLogProperties)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
s, res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsPatchExecute(req)
return &FlowLog{s}, &Response{*res}, err
}
func (ds *natGatewaysService) DeleteFlowLog(datacenterId, natGatewayId, flowlogId string, params QueryParams) (*Response, error) {
req := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsDelete(ds.context, datacenterId, natGatewayId, flowlogId)
if !structs.IsZero(params) {
if params.Depth != nil {
req = req.Depth(*params.Depth)
}
if params.Pretty != nil {
// Currently not implemented
req = req.Pretty(*params.Pretty)
}
}
res, err := ds.client.NATGatewaysApi.DatacentersNatgatewaysFlowlogsDeleteExecute(req)
return &Response{*res}, err
}