-
Notifications
You must be signed in to change notification settings - Fork 151
/
vpc_cli.go
295 lines (275 loc) · 8.84 KB
/
vpc_cli.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
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
package vpc
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/vpc/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
vpcRoot(),
vpcPrivateNetwork(),
vpcPrivateNetworkList(),
vpcPrivateNetworkCreate(),
vpcPrivateNetworkGet(),
vpcPrivateNetworkUpdate(),
vpcPrivateNetworkDelete(),
)
}
func vpcRoot() *core.Command {
return &core.Command{
Short: `VPC API`,
Long: `VPC API.`,
Namespace: "vpc",
}
}
func vpcPrivateNetwork() *core.Command {
return &core.Command{
Short: `Private network management command`,
Long: `A Private Network allows you to interconnect your Scaleway resources in an
isolated and private network. Network reachability is limited
to resources that are on the same Private Network. Note that a resource can
be part of multiple Private Networks.
`,
Namespace: "vpc",
Resource: "private-network",
}
}
func vpcPrivateNetworkList() *core.Command {
return &core.Command{
Short: `List Private Networks`,
Long: `List existing Private Networks in a specified Availability Zone. By default, the Private Networks returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field.`,
Namespace: "vpc",
Resource: "private-network",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpc.ListPrivateNetworksRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "order-by",
Short: `Sort order of the returned Private Networks`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"},
},
{
Name: "name",
Short: `Name to filter for. Only Private Networks with names containing this string will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `Tags to filter for. Only Private Networks with one or more matching tags will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "project-id",
Short: `Project ID to filter for. Only Private Networks belonging to this Project will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-network-ids.{index}",
Short: `Private Network IDs to filter for. Only Private Networks with one of these IDs will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "include-regional",
Short: `Defines whether to include regional Private Networks in the response`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization-id",
Short: `Organization ID to filter for. Only Private Networks belonging to this Organization will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpc.ListPrivateNetworksRequest)
client := core.ExtractClient(ctx)
api := vpc.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Zone == scw.Zone(core.AllLocalities) {
opts = append(opts, scw.WithZones(api.Zones()...))
request.Zone = ""
}
resp, err := api.ListPrivateNetworks(request, opts...)
if err != nil {
return nil, err
}
return resp.PrivateNetworks, nil
},
}
}
func vpcPrivateNetworkCreate() *core.Command {
return &core.Command{
Short: `Create a Private Network`,
Long: `Create a new Private Network. Once created, you can attach Scaleway resources in the same Availability Zone.`,
Namespace: "vpc",
Resource: "private-network",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpc.CreatePrivateNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name for the Private Network`,
Required: true,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("pn"),
},
core.ProjectIDArgSpec(),
{
Name: "tags.{index}",
Short: `Tags for the Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "subnets.{index}",
Short: `Private Network subnets CIDR`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpc.CreatePrivateNetworkRequest)
client := core.ExtractClient(ctx)
api := vpc.NewAPI(client)
return api.CreatePrivateNetwork(request)
},
}
}
func vpcPrivateNetworkGet() *core.Command {
return &core.Command{
Short: `Get a Private Network`,
Long: `Retrieve information about an existing Private Network, specified by its Private Network ID. Its full details are returned in the response object.`,
Namespace: "vpc",
Resource: "private-network",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpc.GetPrivateNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "private-network-id",
Short: `Private Network ID`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpc.GetPrivateNetworkRequest)
client := core.ExtractClient(ctx)
api := vpc.NewAPI(client)
return api.GetPrivateNetwork(request)
},
}
}
func vpcPrivateNetworkUpdate() *core.Command {
return &core.Command{
Short: `Update Private Network`,
Long: `Update parameters (such as name or tags) of an existing Private Network, specified by its Private Network ID.`,
Namespace: "vpc",
Resource: "private-network",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpc.UpdatePrivateNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "private-network-id",
Short: `Private Network ID`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `Name of the private network`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `Tags for the Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "subnets.{index}",
Short: `Private Network subnets CIDR (deprecated)`,
Required: false,
Deprecated: true,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpc.UpdatePrivateNetworkRequest)
client := core.ExtractClient(ctx)
api := vpc.NewAPI(client)
return api.UpdatePrivateNetwork(request)
},
}
}
func vpcPrivateNetworkDelete() *core.Command {
return &core.Command{
Short: `Delete a Private Network`,
Long: `Delete an existing Private Network. Note that you must first detach all resources from the network, in order to delete it.`,
Namespace: "vpc",
Resource: "private-network",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpc.DeletePrivateNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "private-network-id",
Short: `Private Network ID`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpc.DeletePrivateNetworkRequest)
client := core.ExtractClient(ctx)
api := vpc.NewAPI(client)
e = api.DeletePrivateNetwork(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "private-network",
Verb: "delete",
}, nil
},
}
}