-
Notifications
You must be signed in to change notification settings - Fork 151
/
lb_cli.go
3276 lines (3108 loc) · 101 KB
/
lb_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
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 lb
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/lb/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
lbRoot(),
lbLB(),
lbIP(),
lbBackend(),
lbFrontend(),
lbCertificate(),
lbACL(),
lbLBTypes(),
lbPrivateNetwork(),
lbRoute(),
lbSubscriber(),
lbLBList(),
lbLBCreate(),
lbLBGet(),
lbLBUpdate(),
lbLBDelete(),
lbLBMigrate(),
lbIPList(),
lbIPCreate(),
lbIPGet(),
lbIPDelete(),
lbIPUpdate(),
lbBackendList(),
lbBackendCreate(),
lbBackendGet(),
lbBackendUpdate(),
lbBackendDelete(),
lbBackendAddServers(),
lbBackendRemoveServers(),
lbBackendSetServers(),
lbBackendUpdateHealthcheck(),
lbFrontendList(),
lbFrontendCreate(),
lbFrontendGet(),
lbFrontendUpdate(),
lbFrontendDelete(),
lbRouteList(),
lbRouteCreate(),
lbRouteGet(),
lbRouteUpdate(),
lbRouteDelete(),
lbLBGetStats(),
lbBackendListStatistics(),
lbACLList(),
lbACLCreate(),
lbACLGet(),
lbACLUpdate(),
lbACLDelete(),
lbACLSet(),
lbCertificateCreate(),
lbCertificateList(),
lbCertificateGet(),
lbCertificateUpdate(),
lbCertificateDelete(),
lbLBTypesList(),
lbSubscriberCreate(),
lbSubscriberGet(),
lbSubscriberList(),
lbSubscriberUpdate(),
lbSubscriberDelete(),
lbSubscriberSubscribe(),
lbSubscriberUnsubscribe(),
lbPrivateNetworkList(),
lbPrivateNetworkAttach(),
lbPrivateNetworkDetach(),
)
}
func lbRoot() *core.Command {
return &core.Command{
Short: `This API allows you to manage your Scaleway Load Balancer services`,
Long: `Load Balancer API.`,
Namespace: "lb",
}
}
func lbLB() *core.Command {
return &core.Command{
Short: `Load balancer management commands`,
Long: `Load balancer management commands.`,
Namespace: "lb",
Resource: "lb",
}
}
func lbIP() *core.Command {
return &core.Command{
Short: `IP management commands`,
Long: `IP management commands.`,
Namespace: "lb",
Resource: "ip",
}
}
func lbBackend() *core.Command {
return &core.Command{
Short: `Backend management commands`,
Long: `Backend management commands.`,
Namespace: "lb",
Resource: "backend",
}
}
func lbFrontend() *core.Command {
return &core.Command{
Short: `Frontend management commands`,
Long: `Frontend management commands.`,
Namespace: "lb",
Resource: "frontend",
}
}
func lbCertificate() *core.Command {
return &core.Command{
Short: `TLS certificate management commands`,
Long: `TLS certificate management commands.`,
Namespace: "lb",
Resource: "certificate",
}
}
func lbACL() *core.Command {
return &core.Command{
Short: `Access Control List (ACL) management commands`,
Long: `Access Control List (ACL) management commands.`,
Namespace: "lb",
Resource: "acl",
}
}
func lbLBTypes() *core.Command {
return &core.Command{
Short: `Load balancer types management commands`,
Long: `Load balancer types management commands.`,
Namespace: "lb",
Resource: "lb-types",
}
}
func lbPrivateNetwork() *core.Command {
return &core.Command{
Short: `Private networks management commands`,
Long: `Private networks management commands.`,
Namespace: "lb",
Resource: "private-network",
}
}
func lbRoute() *core.Command {
return &core.Command{
Short: `Route rules management commands`,
Long: `Route rules management commands.`,
Namespace: "lb",
Resource: "route",
}
}
func lbSubscriber() *core.Command {
return &core.Command{
Short: `Subscriber management commands`,
Long: `Subscriber management commands.`,
Namespace: "lb",
Resource: "subscriber",
}
}
func lbLBList() *core.Command {
return &core.Command{
Short: `List Load Balancers`,
Long: `List all Load Balancers in the specified zone, for a Scaleway Organization or Scaleway Project. By default, the Load Balancers returned in the list are ordered by creation date in ascending order, though this can be modified via the ` + "`" + `order_by` + "`" + ` field.`,
Namespace: "lb",
Resource: "lb",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIListLBsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Load Balancer name to filter for`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order-by",
Short: `Sort order of Load Balancers in the response`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"},
},
{
Name: "project-id",
Short: `Project ID to filter for, only Load Balancers from this Project will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization-id",
Short: `Organization ID to filter for, only Load Balancers from this Organization will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIListLBsRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(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.ListLBs(request, opts...)
if err != nil {
return nil, err
}
return resp.LBs, nil
},
}
}
func lbLBCreate() *core.Command {
return &core.Command{
Short: `Create a Load Balancer`,
Long: `Create a new Load Balancer. Note that the Load Balancer will be created without frontends or backends; these must be created separately via the dedicated endpoints.`,
Namespace: "lb",
Resource: "lb",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPICreateLBRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "name",
Short: `Name for the Load Balancer`,
Required: true,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("lb"),
},
{
Name: "description",
Short: `Description for the Load Balancer`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ip-id",
Short: `ID of an existing flexible IP address to attach to the Load Balancer`,
Required: false,
Deprecated: true,
Positional: false,
},
{
Name: "assign-flexible-ip",
Short: `Defines whether to automatically assign a flexible public IP to lb. Default value is ` + "`" + `false` + "`" + ` (do not assign).`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `List of tags for the Load Balancer`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "type",
Short: `Load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ssl-compatibility-level",
Short: `Determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and do not need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"ssl_compatibility_level_unknown", "ssl_compatibility_level_intermediate", "ssl_compatibility_level_modern", "ssl_compatibility_level_old"},
},
core.OrganizationIDArgSpec(),
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPICreateLBRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.CreateLB(request)
},
}
}
func lbLBGet() *core.Command {
return &core.Command{
Short: `Get a Load Balancer`,
Long: `Retrieve information about an existing Load Balancer, specified by its Load Balancer ID. Its full details, including name, status and IP address, are returned in the response object.`,
Namespace: "lb",
Resource: "lb",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIGetLBRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "lb-id",
Short: `Load Balancer ID`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIGetLBRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.GetLB(request)
},
}
}
func lbLBUpdate() *core.Command {
return &core.Command{
Short: `Update a Load Balancer`,
Long: `Update the parameters of an existing Load Balancer, specified by its Load Balancer ID. Note that the request type is PUT and not PATCH. You must set all parameters.`,
Namespace: "lb",
Resource: "lb",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIUpdateLBRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "lb-id",
Short: `Load Balancer ID`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `Load Balancer name`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "description",
Short: `Load Balancer description`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `List of tags for the Load Balancer`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ssl-compatibility-level",
Short: `Determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and don't need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"ssl_compatibility_level_unknown", "ssl_compatibility_level_intermediate", "ssl_compatibility_level_modern", "ssl_compatibility_level_old"},
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIUpdateLBRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.UpdateLB(request)
},
}
}
func lbLBDelete() *core.Command {
return &core.Command{
Short: `Delete a Load Balancer`,
Long: `Delete an existing Load Balancer, specified by its Load Balancer ID. Deleting a Load Balancer is permanent, and cannot be undone. The Load Balancer's flexible IP address can either be deleted with the Load Balancer, or kept in your account for future use.`,
Namespace: "lb",
Resource: "lb",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIDeleteLBRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "lb-id",
Short: `ID of the Load Balancer to delete`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "release-ip",
Short: `Defines whether the Load Balancer's flexible IP should be deleted. Set to true to release the flexible IP, or false to keep it available in your account for future Load Balancers`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIDeleteLBRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
e = api.DeleteLB(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "lb",
Verb: "delete",
}, nil
},
}
}
func lbLBMigrate() *core.Command {
return &core.Command{
Short: `Migrate a Load Balancer`,
Long: `Migrate an existing Load Balancer from one commercial type to another. Allows you to scale your Load Balancer up or down in terms of bandwidth or multi-cloud provision.`,
Namespace: "lb",
Resource: "lb",
Verb: "migrate",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIMigrateLBRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "lb-id",
Short: `Load Balancer ID`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "type",
Short: `Load Balancer type to migrate to (use the List all Load Balancer offer types endpoint to get a list of available offer types)`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIMigrateLBRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.MigrateLB(request)
},
}
}
func lbIPList() *core.Command {
return &core.Command{
Short: `List IP addresses`,
Long: `List the Load Balancer flexible IP addresses held in the account (filtered by Organization ID or Project ID). It is also possible to search for a specific IP address.`,
Namespace: "lb",
Resource: "ip",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIListIPsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "ip-address",
Short: `IP address to filter for`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "project-id",
Short: `Project ID to filter for, only Load Balancer IP addresses from this Project will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization-id",
Short: `Organization ID to filter for, only Load Balancer IP addresses from this Organization will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIListIPsRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(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.ListIPs(request, opts...)
if err != nil {
return nil, err
}
return resp.IPs, nil
},
}
}
func lbIPCreate() *core.Command {
return &core.Command{
Short: `Create an IP address`,
Long: `Create a new Load Balancer flexible IP address, in the specified Scaleway Project. This can be attached to new Load Balancers created in the future.`,
Namespace: "lb",
Resource: "ip",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPICreateIPRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "reverse",
Short: `Reverse DNS (domain name) for the IP address`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPICreateIPRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.CreateIP(request)
},
}
}
func lbIPGet() *core.Command {
return &core.Command{
Short: `Get an IP address`,
Long: `Retrieve the full details of a Load Balancer flexible IP address.`,
Namespace: "lb",
Resource: "ip",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIGetIPRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "ip-id",
Short: `IP address ID`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIGetIPRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.GetIP(request)
},
}
}
func lbIPDelete() *core.Command {
return &core.Command{
Short: `Delete an IP address`,
Long: `Delete a Load Balancer flexible IP address. This action is irreversible, and cannot be undone.`,
Namespace: "lb",
Resource: "ip",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIReleaseIPRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "ip-id",
Short: `IP address ID`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIReleaseIPRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
e = api.ReleaseIP(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "ip",
Verb: "delete",
}, nil
},
}
}
func lbIPUpdate() *core.Command {
return &core.Command{
Short: `Update an IP address`,
Long: `Update the reverse DNS of a Load Balancer flexible IP address.`,
Namespace: "lb",
Resource: "ip",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIUpdateIPRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "ip-id",
Short: `IP address ID`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "reverse",
Short: `Reverse DNS (domain name) for the IP address`,
Required: false,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIUpdateIPRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(client)
return api.UpdateIP(request)
},
}
}
func lbBackendList() *core.Command {
return &core.Command{
Short: `List the backends of a given Load Balancer`,
Long: `List all the backends of a Load Balancer, specified by its Load Balancer ID. By default, results are returned in ascending order by the creation date of each backend. The response is an array of backend objects, containing full details of each one including their configuration parameters such as protocol, port and forwarding algorithm.`,
Namespace: "lb",
Resource: "backend",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPIListBackendsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "lb-id",
Short: `Load Balancer ID`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Name of the backend to filter for`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order-by",
Short: `Sort order of backends in the response`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"},
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*lb.ZonedAPIListBackendsRequest)
client := core.ExtractClient(ctx)
api := lb.NewZonedAPI(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.ListBackends(request, opts...)
if err != nil {
return nil, err
}
return resp.Backends, nil
},
}
}
func lbBackendCreate() *core.Command {
return &core.Command{
Short: `Create a backend for a given Load Balancer`,
Long: `Create a new backend for a given Load Balancer, specifying its full configuration including protocol, port and forwarding algorithm.`,
Namespace: "lb",
Resource: "backend",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(lb.ZonedAPICreateBackendRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name for the backend`,
Required: true,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("lbb"),
},
{
Name: "forward-protocol",
Short: `Protocol to be used by the backend when forwarding traffic to backend servers`,
Required: true,
Deprecated: false,
Positional: false,
EnumValues: []string{"tcp", "http"},
},
{
Name: "forward-port",
Short: `Port to be used by the backend when forwarding traffic to backend servers`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "forward-port-algorithm",
Short: `Load balancing algorithm to be used when determining which backend server to forward new traffic to`,
Required: true,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("roundrobin"),
EnumValues: []string{"roundrobin", "leastconn", "first"},
},
{
Name: "sticky-sessions",
Short: `Defines whether to activate sticky sessions (binding a particular session to a particular backend server) and the method to use if so. None disables sticky sessions. Cookie-based uses an HTTP cookie TO stick a session to a backend server. Table-based uses the source (client) IP address to stick a session to a backend server`,
Required: true,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("none"),
EnumValues: []string{"none", "cookie", "table"},
},
{
Name: "sticky-sessions-cookie-name",
Short: `Cookie name for cookie-based sticky sessions`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "lb-id",
Short: `Load Balancer ID`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.port",
Short: `Port to use for the backend server health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.check-delay",
Short: `Time to wait between two consecutive health checks`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("3s"),
},
{
Name: "health-check.check-timeout",
Short: `Maximum time a backend server has to reply to the health check`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("1s"),
},
{
Name: "health-check.check-max-retries",
Short: `Number of consecutive unsuccessful health checks after which the server will be considered dead`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.mysql-config.user",
Short: `MySQL user to use for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.pgsql-config.user",
Short: `PostgreSQL user to use for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.http-config.uri",
Short: `HTTP URI used for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.http-config.method",
Short: `HTTP method used for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.http-config.code",
Short: `HTTP response code expected for a successful health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.http-config.host-header",
Short: `HTTP host header used for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.https-config.uri",
Short: `HTTP URI used for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.https-config.method",
Short: `HTTP method used for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.https-config.code",
Short: `HTTP response code expected for a successful health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.https-config.host-header",
Short: `HTTP host header used for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.https-config.sni",
Short: `SNI used for SSL health checks`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.check-send-proxy",
Short: `Defines whether proxy protocol should be activated for the health check`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.transient-check-delay.seconds",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "health-check.transient-check-delay.nanos",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "server-ip.{index}",
Short: `List of backend server IP addresses (IPv4 or IPv6) the backend should forward traffic to`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "send-proxy-v2",
Short: `Deprecated in favor of proxy_protocol field`,
Required: false,
Deprecated: true,
Positional: false,
},
{
Name: "timeout-server",
Short: `Maximum allowed time for a backend server to process a request`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("5m"),
},
{
Name: "timeout-connect",
Short: `Maximum allowed time for establishing a connection to a backend server`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("5s"),
},
{
Name: "timeout-tunnel",
Short: `Maximum allowed tunnel inactivity time after Websocket is established (takes precedence over client and server timeout)`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("15m"),
},
{
Name: "on-marked-down-action",
Short: `Action to take when a backend server is marked as down`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"on_marked_down_action_none", "shutdown_sessions"},
},
{
Name: "proxy-protocol",
Short: `Protocol to use between the Load Balancer and backend servers. Allows the backend servers to be informed of the client's real IP address. The PROXY protocol must be supported by the backend servers' software`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"proxy_protocol_unknown", "proxy_protocol_none", "proxy_protocol_v1", "proxy_protocol_v2", "proxy_protocol_v2_ssl", "proxy_protocol_v2_ssl_cn"},
},
{
Name: "failover-host",
Short: `Scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ssl-bridging",
Short: `Defines whether to enable SSL bridging between the Load Balancer and backend servers`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ignore-ssl-server-verify",
Short: `Defines whether the server certificate verification should be ignored`,
Required: false,
Deprecated: false,
Positional: false,
},