forked from scaleway/scaleway-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvpcgw_cli.go
More file actions
2298 lines (2183 loc) · 70.7 KB
/
vpcgw_cli.go
File metadata and controls
2298 lines (2183 loc) · 70.7 KB
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
package vpcgw
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/core"
"github.com/scaleway/scaleway-sdk-go/api/vpcgw/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
vpcGwRoot(),
vpcGwGateway(),
vpcGwGatewayNetwork(),
vpcGwDHCP(),
vpcGwDHCPEntry(),
vpcGwPatRule(),
vpcGwIP(),
vpcGwGatewayType(),
vpcGwGatewayList(),
vpcGwGatewayGet(),
vpcGwGatewayCreate(),
vpcGwGatewayUpdate(),
vpcGwGatewayDelete(),
vpcGwGatewayUpgrade(),
vpcGwGatewayEnableIPMobility(),
vpcGwGatewayNetworkList(),
vpcGwGatewayNetworkGet(),
vpcGwGatewayNetworkCreate(),
vpcGwGatewayNetworkUpdate(),
vpcGwGatewayNetworkDelete(),
vpcGwDHCPList(),
vpcGwDHCPGet(),
vpcGwDHCPCreate(),
vpcGwDHCPUpdate(),
vpcGwDHCPDelete(),
vpcGwDHCPEntryList(),
vpcGwDHCPEntryGet(),
vpcGwDHCPEntryCreate(),
vpcGwDHCPEntryUpdate(),
vpcGwDHCPEntrySet(),
vpcGwDHCPEntryDelete(),
vpcGwPatRuleList(),
vpcGwPatRuleGet(),
vpcGwPatRuleCreate(),
vpcGwPatRuleUpdate(),
vpcGwPatRuleSet(),
vpcGwPatRuleDelete(),
vpcGwGatewayTypeList(),
vpcGwIPList(),
vpcGwIPGet(),
vpcGwIPCreate(),
vpcGwIPUpdate(),
vpcGwIPDelete(),
vpcGwGatewayRefreshSSHKeys(),
vpcGwGatewayMigrateToV2(),
)
}
func vpcGwRoot() *core.Command {
return &core.Command{
Short: `This API allows you to manage your Public Gateways`,
Long: `This API allows you to manage your Public Gateways.`,
Namespace: "vpc-gw",
}
}
func vpcGwGateway() *core.Command {
return &core.Command{
Short: `Public Gateway management`,
Long: `Public Gateways are building blocks for your infrastructure on Scaleway's shared public cloud. They provide a set of managed network services and features for Scaleway's Private Networks such as DHCP, NAT and routing.`,
Namespace: "vpc-gw",
Resource: "gateway",
}
}
func vpcGwGatewayNetwork() *core.Command {
return &core.Command{
Short: `Gateway Networks management`,
Long: `A Gateway Network represents the connection of a Private Network to a Public Gateway. It holds configuration options relative to this specific connection, such as the DHCP configuration.`,
Namespace: "vpc-gw",
Resource: "gateway-network",
}
}
func vpcGwDHCP() *core.Command {
return &core.Command{
Short: `DHCP configuration management`,
Long: `These objects define a DHCP configuration, i.e. how IP addresses should be assigned to devices on a Private Network attached to a Public Gateway. Definable parameters include the subnet for the DHCP server, the validity period for DHCP entries, whether to use dynamic pooling, and more. A DHCP configuration object has a DHCP ID, which can then be used as part of a call to create or update a Gateway Network. This lets you attach an existing DHCP configuration to a Public Gateway attached to a Private Network. Similarly, you can use a DHCP ID as a query parameter to list Gateway Networks which use this DHCP configuration object.`,
Namespace: "vpc-gw",
Resource: "dhcp",
}
}
func vpcGwDHCPEntry() *core.Command {
return &core.Command{
Short: `DHCP entries management`,
Long: `DHCP entries belong to a specified Gateway Network (Public Gateway / Private Network connection). A DHCP entry can hold either a dynamic DHCP lease (an IP address dynamically assigned by the Public Gateway to a device) or a static, user-created DHCP reservation.`,
Namespace: "vpc-gw",
Resource: "dhcp-entry",
}
}
func vpcGwPatRule() *core.Command {
return &core.Command{
Short: `PAT rules management`,
Long: `PAT (Port Address Translation) rules, aka static NAT rules, belong to a specified Public Gateway. They define the forwarding of a public port to a specific device on a Private Network, enabling enables ingress traffic from the public Internet to reach the correct device in the Private Network.`,
Namespace: "vpc-gw",
Resource: "pat-rule",
}
}
func vpcGwIP() *core.Command {
return &core.Command{
Short: `IP address management`,
Long: `Public, flexible IP addresses for Public Gateways, allowing the gateway to reach the public internet, as well as forward (masquerade) traffic from member devices of attached Private Networks.`,
Namespace: "vpc-gw",
Resource: "ip",
}
}
func vpcGwGatewayType() *core.Command {
return &core.Command{
Short: `Gateway types information`,
Long: `Public Gateways come in various shapes, sizes and prices, which are described by gateway types. They represent the different commercial offer types for Public Gateways available at Scaleway.`,
Namespace: "vpc-gw",
Resource: "gateway-type",
}
}
func vpcGwGatewayList() *core.Command {
return &core.Command{
Short: `List Public Gateways`,
Long: `List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.ListGatewaysRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "order-by",
Short: `Order in which to return results`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc", "type_asc", "type_desc", "status_asc", "status_desc"},
},
{
Name: "project-id",
Short: `Include only gateways in this Project`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Filter for gateways which have this search term in their name`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `Filter for gateways with these tags`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "type",
Short: `Filter for gateways of this type`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "status",
Short: `Filter for gateways with this current status. Use ` + "`" + `unknown` + "`" + ` to include all statuses`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "stopped", "allocating", "configuring", "running", "stopping", "failed", "deleting", "deleted", "locked"},
},
{
Name: "private-network-id",
Short: `Filter for gateways attached to this Private nNetwork`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization-id",
Short: `Include only gateways in this Organization`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.ListGatewaysRequest)
client := core.ExtractClient(ctx)
api := vpcgw.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.ListGateways(request, opts...)
if err != nil {
return nil, err
}
return resp.Gateways, nil
},
View: &core.View{Fields: []*core.ViewField{
{
FieldName: "ID",
},
{
FieldName: "Name",
},
{
FieldName: "Status",
},
{
FieldName: "Tags",
},
{
FieldName: "GatewayNetworks",
},
{
FieldName: "UpstreamDNSServers",
},
{
FieldName: "UpdatedAt",
},
{
FieldName: "CreatedAt",
},
{
FieldName: "Zone",
},
{
FieldName: "ProjectID",
},
{
FieldName: "OrganizationID",
},
}},
}
}
func vpcGwGatewayGet() *core.Command {
return &core.Command{
Short: `Get a Public Gateway`,
Long: `Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.GetGatewayRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-id",
Short: `ID of the gateway to fetch`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.GetGatewayRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.GetGateway(request)
},
}
}
func vpcGwGatewayCreate() *core.Command {
return &core.Command{
Short: `Create a Public Gateway`,
Long: `Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.CreateGatewayRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "name",
Short: `Name for the gateway`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("gw"),
},
{
Name: "tags.{index}",
Short: `Tags for the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "type",
Short: `Gateway type (commercial offer type)`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("VPC-GW-S"),
},
{
Name: "upstream-dns-servers.{index}",
Short: `Array of DNS server IP addresses to override the gateway's default recursive DNS servers`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ip-id",
Short: `Existing IP address to attach to the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-smtp",
Short: `Defines whether SMTP traffic should be allowed pass through the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-bastion",
Short: `Defines whether SSH bastion should be enabled the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "bastion-port",
Short: `Port of the SSH bastion`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.CreateGatewayRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.CreateGateway(request)
},
}
}
func vpcGwGatewayUpdate() *core.Command {
return &core.Command{
Short: `Update a Public Gateway`,
Long: `Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.UpdateGatewayRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-id",
Short: `ID of the gateway to update`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `Name for the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `Tags for the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "upstream-dns-servers.{index}",
Short: `Array of DNS server IP addresses to override the gateway's default recursive DNS servers`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-bastion",
Short: `Defines whether SSH bastion should be enabled the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "bastion-port",
Short: `Port of the SSH bastion`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-smtp",
Short: `Defines whether SMTP traffic should be allowed to pass through the gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.UpdateGatewayRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.UpdateGateway(request)
},
}
}
func vpcGwGatewayDelete() *core.Command {
return &core.Command{
Short: `Delete a Public Gateway`,
Long: `Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.DeleteGatewayRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-id",
Short: `ID of the gateway to delete`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "cleanup-dhcp",
Short: `Defines whether to clean up attached DHCP configurations (if any, and if not attached to another Gateway Network)`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.DeleteGatewayRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
e = api.DeleteGateway(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "gateway",
Verb: "delete",
}, nil
},
}
}
func vpcGwGatewayUpgrade() *core.Command {
return &core.Command{
Short: `Upgrade a Public Gateway to the latest version and/or to a different commercial offer type`,
Long: `Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "upgrade",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.UpgradeGatewayRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-id",
Short: `ID of the gateway to upgrade`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "type",
Short: `Gateway type (commercial offer)`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.UpgradeGatewayRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.UpgradeGateway(request)
},
}
}
func vpcGwGatewayEnableIPMobility() *core.Command {
return &core.Command{
Short: `Upgrade a Public Gateway to IP mobility`,
Long: `Upgrade a Public Gateway to IP mobility (move from NAT IP to routed IP). This is idempotent: repeated calls after the first will return no error but have no effect.`,
Namespace: "vpc-gw",
Resource: "gateway",
Verb: "enable-ip-mobility",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.EnableIPMobilityRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-id",
Short: `ID of the gateway to upgrade to IP mobility`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.EnableIPMobilityRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
e = api.EnableIPMobility(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "gateway",
Verb: "enable-ip-mobility",
}, nil
},
}
}
func vpcGwGatewayNetworkList() *core.Command {
return &core.Command{
Short: `List Public Gateway connections to Private Networks`,
Long: `List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by ` + "`" + `gateway-id` + "`" + ` to list all Private Networks attached to the specified Public Gateway, or by ` + "`" + `private_network_id` + "`" + ` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network.`,
Namespace: "vpc-gw",
Resource: "gateway-network",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.ListGatewayNetworksRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "order-by",
Short: `Order in which to return results`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "status_asc", "status_desc"},
},
{
Name: "gateway-id",
Short: `Filter for GatewayNetworks connected to this gateway`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-network-id",
Short: `Filter for GatewayNetworks connected to this Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-masquerade",
Short: `Filter for GatewayNetworks with this ` + "`" + `enable_masquerade` + "`" + ` setting`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "dhcp-id",
Short: `Filter for GatewayNetworks using this DHCP configuration`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "status",
Short: `Filter for GatewayNetworks with this current status this status. Use ` + "`" + `unknown` + "`" + ` to include all statuses`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "created", "attaching", "configuring", "ready", "detaching", "deleted"},
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.ListGatewayNetworksRequest)
client := core.ExtractClient(ctx)
api := vpcgw.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.ListGatewayNetworks(request, opts...)
if err != nil {
return nil, err
}
return resp.GatewayNetworks, nil
},
View: &core.View{Fields: []*core.ViewField{
{
FieldName: "ID",
},
{
FieldName: "GatewayID",
},
{
FieldName: "PrivateNetworkID",
},
{
FieldName: "Status",
},
{
FieldName: "Address",
},
{
FieldName: "MacAddress",
},
{
FieldName: "EnableDHCP",
},
{
FieldName: "EnableMasquerade",
},
{
FieldName: "CreatedAt",
},
{
FieldName: "UpdatedAt",
},
{
FieldName: "Zone",
},
}},
}
}
func vpcGwGatewayNetworkGet() *core.Command {
return &core.Command{
Short: `Get a Public Gateway connection to a Private Network`,
Long: `Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its ` + "`" + `gateway_network_id` + "`" + `. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings.`,
Namespace: "vpc-gw",
Resource: "gateway-network",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.GetGatewayNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-network-id",
Short: `ID of the GatewayNetwork to fetch`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.GetGatewayNetworkRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.GetGatewayNetwork(request)
},
}
}
func vpcGwGatewayNetworkCreate() *core.Command {
return &core.Command{
Short: `Attach a Public Gateway to a Private Network`,
Long: `Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including DHCP settings, whether to enable masquerade (dynamic NAT), and more.`,
Namespace: "vpc-gw",
Resource: "gateway-network",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.CreateGatewayNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-id",
Short: `Public Gateway to connect`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-network-id",
Short: `Private Network to connect`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-masquerade",
Short: `Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork.`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-dhcp",
Short: `Defines whether to enable DHCP on this Private Network.`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "dhcp-id",
Short: `ID of an existing DHCP configuration object to use for this GatewayNetwork`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "address",
Short: `Static IP address in CIDR format to to use without DHCP`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ipam-config.push-default-route",
Short: `Enabling the default route also enables masquerading`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ipam-config.ipam-ip-id",
Short: `Use this IPAM-booked IP ID as the Gateway's IP in this Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.CreateGatewayNetworkRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.CreateGatewayNetwork(request)
},
}
}
func vpcGwGatewayNetworkUpdate() *core.Command {
return &core.Command{
Short: `Update a Public Gateway's connection to a Private Network`,
Long: `Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include DHCP settings and whether to enable traffic masquerade (dynamic NAT).`,
Namespace: "vpc-gw",
Resource: "gateway-network",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.UpdateGatewayNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-network-id",
Short: `ID of the GatewayNetwork to update`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "enable-masquerade",
Short: `Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork.`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-dhcp",
Short: `Defines whether to enable DHCP on this Private Network.`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "dhcp-id",
Short: `ID of the new DHCP configuration object to use with this GatewayNetwork`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "address",
Short: `New static IP address`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ipam-config.push-default-route",
Short: `Enabling the default route also enables masquerading`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ipam-config.ipam-ip-id",
Short: `Use this IPAM-booked IP ID as the Gateway's IP in this Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.UpdateGatewayNetworkRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
return api.UpdateGatewayNetwork(request)
},
}
}
func vpcGwGatewayNetworkDelete() *core.Command {
return &core.Command{
Short: `Detach a Public Gateway from a Private Network`,
Long: `Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id.`,
Namespace: "vpc-gw",
Resource: "gateway-network",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.DeleteGatewayNetworkRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "gateway-network-id",
Short: `ID of the GatewayNetwork to delete`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "cleanup-dhcp",
Short: `Defines whether to clean up attached DHCP configurations (if any, and if not attached to another Gateway Network)`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.DeleteGatewayNetworkRequest)
client := core.ExtractClient(ctx)
api := vpcgw.NewAPI(client)
e = api.DeleteGatewayNetwork(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "gateway-network",
Verb: "delete",
}, nil
},
}
}
func vpcGwDHCPList() *core.Command {
return &core.Command{
Short: `List DHCP configurations`,
Long: `List DHCP configurations, optionally filtering by Organization, Project, Public Gateway IP address or more. The response is an array of DHCP configuration objects, each identified by a DHCP ID and containing configuration settings for the assignment of IP addresses to devices on a Private Network attached to a Public Gateway. Note that the response does not contain the IDs of any Private Network / Public Gateway the configuration is attached to. Use the ` + "`" + `List Public Gateway connections to Private Networks` + "`" + ` method for that purpose, filtering on DHCP ID.`,
Namespace: "vpc-gw",
Resource: "dhcp",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(vpcgw.ListDHCPsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "order-by",
Short: `Order in which to return results`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "subnet_asc", "subnet_desc"},
},
{
Name: "project-id",
Short: `Include only DHCP configuration objects in this Project`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "address",
Short: `Filter for DHCP configuration objects with this DHCP server IP address (the gateway's address in the Private Network)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "has-address",
Short: `Filter for DHCP configuration objects with subnets containing this IP address`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization-id",
Short: `Include only DHCP configuration objects in this Organization`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*vpcgw.ListDHCPsRequest)
client := core.ExtractClient(ctx)
api := vpcgw.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.ListDHCPs(request, opts...)
if err != nil {
return nil, err
}
return resp.Dhcps, nil
},
View: &core.View{Fields: []*core.ViewField{
{
FieldName: "ID",
},
{
FieldName: "Subnet",
},
{
FieldName: "Address",
},
{
FieldName: "EnableDynamic",
},
{
FieldName: "PoolLow",
},
{
FieldName: "PoolHigh",
},
{
FieldName: "PushDefaultRoute",
},
{
FieldName: "PushDNSServer",
},
{
FieldName: "DNSLocalName",
},
{
FieldName: "DNSServersOverride",
},
{
FieldName: "DNSSearch",
},
{
FieldName: "ValidLifetime",