-
Notifications
You must be signed in to change notification settings - Fork 151
/
instance_cli.go
3856 lines (3661 loc) · 115 KB
/
instance_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 instance
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
instanceRoot(),
instanceImage(),
instanceIP(),
instancePlacementGroup(),
instanceSecurityGroup(),
instanceServer(),
instanceServerType(),
instanceVolumeType(),
instanceSnapshot(),
instanceUserData(),
instanceVolume(),
instancePrivateNic(),
instanceServerTypeGet(),
instanceServerTypeList(),
instanceVolumeTypeList(),
instanceServerList(),
instanceServerGet(),
instanceServerUpdate(),
instanceServerListActions(),
instanceUserDataList(),
instanceUserDataDelete(),
instanceUserDataSet(),
instanceUserDataGet(),
instanceImageList(),
instanceImageGet(),
instanceImageCreate(),
instanceImageUpdate(),
instanceImageDelete(),
instanceSnapshotList(),
instanceSnapshotCreate(),
instanceSnapshotGet(),
instanceSnapshotUpdate(),
instanceSnapshotDelete(),
instanceSnapshotExport(),
instanceVolumeList(),
instanceVolumeCreate(),
instanceVolumeGet(),
instanceVolumeUpdate(),
instanceVolumeDelete(),
instanceSecurityGroupList(),
instanceSecurityGroupCreate(),
instanceSecurityGroupGet(),
instanceSecurityGroupDelete(),
instanceSecurityGroupUpdate(),
instanceSecurityGroupListDefaultRules(),
instanceSecurityGroupListRules(),
instanceSecurityGroupCreateRule(),
instanceSecurityGroupSetRules(),
instanceSecurityGroupDeleteRule(),
instanceSecurityGroupGetRule(),
instanceSecurityGroupUpdateRule(),
instancePlacementGroupList(),
instancePlacementGroupCreate(),
instancePlacementGroupGet(),
instancePlacementGroupSet(),
instancePlacementGroupUpdate(),
instancePlacementGroupDelete(),
instancePlacementGroupGetServers(),
instancePlacementGroupSetServers(),
instancePlacementGroupUpdateServers(),
instanceIPList(),
instanceIPCreate(),
instanceIPGet(),
instanceIPUpdate(),
instanceIPDelete(),
instancePrivateNicList(),
instancePrivateNicCreate(),
instancePrivateNicGet(),
instancePrivateNicUpdate(),
instancePrivateNicDelete(),
)
}
func instanceRoot() *core.Command {
return &core.Command{
Short: `Instance API`,
Long: `Instance API.`,
Namespace: "instance",
}
}
func instanceImage() *core.Command {
return &core.Command{
Short: `Image management commands`,
Long: `Images are backups of your Instances.
One image will contain all the volumes of your Instance and can be used to restore your Instance and its data. You can also use it to create a series of Instances with a predefined configuration.
To copy not all but only one specified volume of an Instance, you can use the snapshot feature instead.`,
Namespace: "instance",
Resource: "image",
}
}
func instanceIP() *core.Command {
return &core.Command{
Short: `IP management commands`,
Long: `A flexible IP address is an IP address which you hold independently of any Instance.
You can attach it to any of your Instances and do live migration of the IP address between your Instances.
Note that attaching a flexible IP address to an Instance removes its previous public IP and interrupts any ongoing public connection to the Instance. This does not apply if you have migrated your server to the new Network stack and have at least one flexible IP attached to the Instance.`,
Namespace: "instance",
Resource: "ip",
}
}
func instancePlacementGroup() *core.Command {
return &core.Command{
Short: `Placement group management commands`,
Long: `Placement groups allow the user to express a preference regarding
the physical position of a group of Instances. The feature lets the user
choose to either group Instances on the same physical hardware for
best network throughput and low latency or to spread Instances across
physically distanced hardware to reduce the risk of physical failure.
The operating mode is selected by a ` + "`" + `policy_type` + "`" + `. Two policy
types are available:
- ` + "`" + `low_latency` + "`" + ` will group Instances on the same hypervisors
- ` + "`" + `max_availability` + "`" + ` will spread Instances across physically distanced hypervisors
The ` + "`" + `policy_type` + "`" + ` is set to ` + "`" + `max_availability` + "`" + ` by default.
For each policy types, one of the two ` + "`" + `policy_mode` + "`" + ` may be selected:
- ` + "`" + `optional` + "`" + ` will start your Instances even if the constraint is not respected
- ` + "`" + `enforced` + "`" + ` guarantees that if the Instance starts, the constraint is respected
The ` + "`" + `policy_mode` + "`" + ` is set by default to ` + "`" + `optional` + "`" + `.`,
Namespace: "instance",
Resource: "placement-group",
}
}
func instanceSecurityGroup() *core.Command {
return &core.Command{
Short: `Security group management commands`,
Long: `A security group is a set of firewall rules on a set of Instances.
Security groups enable you to create rules that either drop or allow incoming traffic from certain ports of your Instances.
Security groups are stateful by default which means return traffic is automatically allowed, regardless of any rules.
As a contrary, you have to switch in a stateless mode to define explicitly allowed.`,
Namespace: "instance",
Resource: "security-group",
}
}
func instanceServer() *core.Command {
return &core.Command{
Short: `Instance management commands`,
Long: `Instances are computing units providing resources to run your applications on.
Scaleway offers various Instance types including **Virtual Instances** and **dedicated GPU Instances**.
**Note: Instances can be referenced as "servers" in API endpoints.**`,
Namespace: "instance",
Resource: "server",
}
}
func instanceServerType() *core.Command {
return &core.Command{
Short: `Instance type management commands`,
Long: `All Instance types available in a specified zone.
Each type contains all the features of the Instance (CPU, RAM, Storage) as well as their associated pricing.`,
Namespace: "instance",
Resource: "server-type",
}
}
func instanceVolumeType() *core.Command {
return &core.Command{
Short: `Volume type management commands`,
Long: `All volume types available in a specified zone.
Each of these types will contains all the capabilities and constraints of the volume (min size, max size, snapshot).`,
Namespace: "instance",
Resource: "volume-type",
}
}
func instanceSnapshot() *core.Command {
return &core.Command{
Short: `Snapshot management commands`,
Long: `Snapshots contain the data of a specified volume at a particular point in time.
The data can include the Instance's operating system,
configuration information and/or files stored on the volume.
A snapshot can be done from a specified volume, e.g. you
have one Instance with a volume containing the OS and another one
containing the application data, and you want to use different
snapshot strategies on both volumes.
A snapshot's volume type is its original volume's type (` + "`" + `l_ssd` + "`" + ` or ` + "`" + `b_ssd` + "`" + `).
Volumes can be created from snapshots of their own type.`,
Namespace: "instance",
Resource: "snapshot",
}
}
func instanceUserData() *core.Command {
return &core.Command{
Short: `User data management commands`,
Long: `User data is a key/value store you can use to provide your instance with introspective data.
As an example of use, Scaleway images contain the ` + "`" + `scw-generate-ssh-keys` + "`" + ` script, which generates the SSH server’s host keys, then stores their fingerprints as user data under the ` + "`" + `ssh-host-fingerprints` + "`" + ` key.
This way, before connecting to the instance using SSH, one can query the fingerprints to ensure that the remote host is the expected one, thus avoiding any man-in-the-middle attack.
There are two ways of accessing user data:
- **From within a running Instance**, by requesting the Metadata API at http://169.254.42.42/user_data (or http://[fd00:42::42]/user_data using IPv6).
The ` + "`" + `scaleway-ecosystem` + "`" + ` package, installed by default on all OS images provided by Scaleway, ships with the ` + "`" + `scw-userdata` + "`" + ` helper command that allows you to easily query the user data from the instance.
For security reasons, viewing and editing user data is only allowed to queries originating from a port below 1024 (by default, only the super-user can bind to ports below 1024).
To specify the source port with cURL, use the ` + "`" + `--local-port` + "`" + ` option (e.g. ` + "`" + `curl --local-port 1-1024 http://169.254.42.42/user_data` + "`" + `).
- **From the Instance API** by using the methods described below.`,
Namespace: "instance",
Resource: "user-data",
}
}
func instanceVolume() *core.Command {
return &core.Command{
Short: `Volume management commands`,
Long: `A volume is where you store your data inside your Instance. It
appears as a block device on Linux that you can use to create
a filesystem and mount it.
Two different types of volume (` + "`" + `volume_type` + "`" + `) are available:
- ` + "`" + `l_ssd` + "`" + ` is a local block storage: your data is downloaded on
the hypervisor and you need to power off your Instance to attach
or detach a volume.
- ` + "`" + `b_ssd` + "`" + ` is a remote block storage: your data is stored on a
centralized cluster. You can plug and unplug a volume while
your Instance is running.
Minimum and maximum volume sizes for each volume types can be queried
from the zone ` + "`" + `/products/volumes` + "`" + ` API endpoint. _I.e_ for:
- ` + "`" + `fr-par-1` + "`" + ` use https://api.scaleway.com/instance/v1/zones/fr-par-1/products/volumes
- ` + "`" + `nl-ams-1` + "`" + ` use https://api.scaleway.com/instance/v1/zones/nl-ams-1/products/volumes
Each type of volume is also subject to a global quota for the sum of all the
volumes. This quota depends of the level of support and may be
changed on demand.
Be wary that when terminating an Instance, if you want to keep
your block storage volume, **you must** detach it before you
issue the ` + "`" + `terminate` + "`" + ` call.
When using multiple block devices, it's advised to mount them by
using their UUID instead of their device name. A device name is
subject to change depending on the volumes order. Block devices
UUIDs can be found in ` + "`" + `/dev/disk/by-id/` + "`" + `.`,
Namespace: "instance",
Resource: "volume",
}
}
func instancePrivateNic() *core.Command {
return &core.Command{
Short: `Private NIC management commands`,
Long: `A Private NIC is the network interface that connects an Instance to a
Private Network. An Instance can have multiple private NICs at the same
time, but each NIC must belong to a different Private Network.`,
Namespace: "instance",
Resource: "private-nic",
}
}
func instanceServerTypeGet() *core.Command {
return &core.Command{
Short: `Get availability`,
Long: `Get availability for all Instance types.`,
Namespace: "instance",
Resource: "server-type",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.GetServerTypesAvailabilityRequest{}),
ArgSpecs: core.ArgSpecs{
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.GetServerTypesAvailabilityRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.GetServerTypesAvailability(request)
},
}
}
func instanceServerTypeList() *core.Command {
return &core.Command{
Short: `List Instance types`,
Long: `List available Instance types and their technical details.`,
Namespace: "instance",
Resource: "server-type",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServersTypesRequest{}),
ArgSpecs: core.ArgSpecs{
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.ListServersTypesRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListServersTypes(request)
},
Examples: []*core.Example{
{
Short: "List all server-types in the default zone",
ArgsJSON: `null`,
},
{
Short: "List all server-types in fr-par-1 zone",
ArgsJSON: `{"zone":"fr-par-1"}`,
},
},
}
}
func instanceVolumeTypeList() *core.Command {
return &core.Command{
Short: `List volume types`,
Long: `List all volume types and their technical details.`,
Namespace: "instance",
Resource: "volume-type",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListVolumesTypesRequest{}),
ArgSpecs: core.ArgSpecs{
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.ListVolumesTypesRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListVolumesTypes(request)
},
Examples: []*core.Example{
{
Short: "List all volume-types in the default zone",
ArgsJSON: `null`,
},
{
Short: "List all volume-types in fr-par-1 zone",
ArgsJSON: `{"zone":"fr-par-1"}`,
},
},
}
}
func instanceServerList() *core.Command {
return &core.Command{
Short: `List all Instances`,
Long: `List all Instances in a specified Availability Zone, e.g. ` + "`" + `fr-par-1` + "`" + `.`,
Namespace: "instance",
Resource: "server",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServersRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "project",
Short: `List only Instances of this Project ID`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Filter Instances by name (eg. "server1" will return "server100" and "server1" but not "foo")`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-ip",
Short: `List Instances by private_ip`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "without-ip",
Short: `List Instances that are not attached to a public IP`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "commercial-type",
Short: `List Instances of this commercial type`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "state",
Short: `List Instances in this state`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"running", "stopped", "stopped in place", "starting", "stopping", "locked"},
},
{
Name: "tags",
Short: `List Instances with these exact tags (to filter with several tags, use commas to separate them)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-network",
Short: `List Instances in this Private Network`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order",
Short: `Define the order of the returned servers`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"creation_date_desc", "creation_date_asc", "modification_date_desc", "modification_date_asc"},
},
{
Name: "private-networks",
Short: `List Instances from the given Private Networks (use commas to separate them)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nic-mac-address",
Short: `List Instances associated with the given private NIC MAC address`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "servers",
Short: `List Instances from these server ids (use commas to separate them)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization",
Short: `List only Instances of this Organization ID`,
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.ZonePlWaw3, scw.Zone(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.ListServersRequest)
client := core.ExtractClient(ctx)
api := instance.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.ListServers(request, opts...)
if err != nil {
return nil, err
}
return resp.Servers, nil
},
Examples: []*core.Example{
{
Short: "List all Instances on your default zone",
ArgsJSON: `null`,
},
{
Short: "List Instances of this commercial type",
ArgsJSON: `{"commercial_type":"DEV1-S"}`,
},
{
Short: "List Instances that are not attached to a public IP",
ArgsJSON: `{"without_ip":true}`,
},
{
Short: "List Instances that match the specified name ('server1' will return 'server100' and 'server1' but not 'foo')",
ArgsJSON: `{"name":"server1"}`,
},
},
}
}
func instanceServerGet() *core.Command {
return &core.Command{
Short: `Get an Instance`,
Long: `Get the details of a specified Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.GetServerRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the Instance you want to get`,
Required: true,
Deprecated: false,
Positional: true,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.GetServerRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.GetServer(request)
},
Examples: []*core.Example{
{
Short: "Get the Instance with its specified ID",
ArgsJSON: `{"server_id":"94ededdf-358d-4019-9886-d754f8a2e78d"}`,
},
},
}
}
func instanceServerUpdate() *core.Command {
return &core.Command{
Short: `Update an Instance`,
Long: `Update the Instance information, such as name, boot mode, or tags.`,
Namespace: "instance",
Resource: "server",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.UpdateServerRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the Instance`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `Name of the Instance`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "boot-type",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"local", "bootscript", "rescue"},
},
{
Name: "tags.{index}",
Short: `Tags of the Instance`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.id",
Short: `UUID of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.boot",
Short: `Force the Instance to boot on this volume`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.DefaultValueSetter("false"),
},
{
Name: "volumes.{key}.name",
Short: `Name of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.size",
Short: `Disk size of the volume, must be a multiple of 512`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.volume-type",
Short: `Type of the volume`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"l_ssd", "b_ssd", "unified", "scratch", "sbs_volume", "sbs_snapshot"},
},
{
Name: "volumes.{key}.base-snapshot",
Short: `ID of the snapshot on which this volume will be based`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.project",
Short: `Project ID of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "volumes.{key}.organization",
Short: `Organization ID of the volume`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "bootscript",
Required: false,
Deprecated: true,
Positional: false,
},
{
Name: "dynamic-ip-required",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "routed-ip-enabled",
Short: `True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "public-ips.{index}",
Short: `A list of reserved IP IDs to attach to the Instance`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-ipv6",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "protected",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "security-group.id",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "security-group.name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "placement-group",
Short: `Placement group ID if Instance must be part of a placement group`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-nics.{index}",
Short: `Instance private NICs`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "commercial-type",
Short: `Set the commercial_type for this Instance.`,
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.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.UpdateServerRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.UpdateServer(request)
},
Examples: []*core.Example{
{
Short: "Update the name of a specified Instance",
ArgsJSON: `{"name":"foobar","server_id":"11111111-1111-1111-1111-111111111111"}`,
},
{
Short: "Switch a specified Instance to rescue mode (reboot is required to access rescue mode)",
ArgsJSON: `{"boot_type":"rescue","server_id":"11111111-1111-1111-1111-111111111111"}`,
},
{
Short: "Overwrite tags of a specified Instance",
ArgsJSON: `{"server_id":"11111111-1111-1111-1111-111111111111","tags":["foo","bar"]}`,
},
{
Short: "Enable IPv6 on a specified Instance. Assigns an IPv6 block to the specified Instance and configures the first IP of the block.",
ArgsJSON: `{"enable_ipv6":true,"server_id":"11111111-1111-1111-1111-111111111111"}`,
},
{
Short: "Apply the specified security group to a specified server",
Raw: `scw instance server server update 11111111-1111-1111-1111-111111111111 security-group-id=11111111-1111-1111-1111-111111111111`,
},
{
Short: "Put a specified Instance in the specified placement group. Instance must be off",
Raw: `scw instance server server update 11111111-1111-1111-1111-111111111111 placement-group-id=11111111-1111-1111-1111-111111111111`,
},
},
}
}
func instanceServerListActions() *core.Command {
return &core.Command{
Short: `List Instance actions`,
Long: `List all actions (e.g. power on, power off, reboot) that can currently be performed on an Instance.`,
Namespace: "instance",
Resource: "server",
Verb: "list-actions",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServerActionsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.ListServerActionsRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListServerActions(request)
},
}
}
func instanceUserDataList() *core.Command {
return &core.Command{
Short: `List user data`,
Long: `List all user data keys registered on a specified Instance.`,
Namespace: "instance",
Resource: "user-data",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the Instance`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.ListServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.ListServerUserData(request)
},
}
}
func instanceUserDataDelete() *core.Command {
return &core.Command{
Short: `Delete user data`,
Long: `Delete the specified key from an Instance's user data.`,
Namespace: "instance",
Resource: "user-data",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.DeleteServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the Instance`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `Key of the user data to delete`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.DeleteServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
e = api.DeleteServerUserData(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "user-data",
Verb: "delete",
}, nil
},
}
}
func instanceUserDataSet() *core.Command {
return &core.Command{
Short: `Add/set user data`,
Long: `Add or update a user data with the specified key on an Instance.`,
Namespace: "instance",
Resource: "user-data",
Verb: "set",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.SetServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the Instance`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `Key of the user data to set`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "content.name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "content.content-type",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "content.content",
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.ZonePlWaw3),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*instance.SetServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
e = api.SetServerUserData(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "user-data",
Verb: "set",
}, nil
},
}
}
func instanceUserDataGet() *core.Command {
return &core.Command{
Short: `Get user data`,
Long: `Get the content of a user data with the specified key on an Instance.`,
Namespace: "instance",
Resource: "user-data",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.GetServerUserDataRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "server-id",
Short: `UUID of the Instance`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "key",
Short: `Key of the user data to get`,
Required: true,
Deprecated: false,
Positional: false,
},
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.GetServerUserDataRequest)
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)
return api.GetServerUserData(request)
},
}
}
func instanceImageList() *core.Command {
return &core.Command{
Short: `List Instance images`,
Long: `List all existing Instance images.`,
Namespace: "instance",
Resource: "image",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(instance.ListImagesRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "public",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "arch",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "project",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization",
Required: false,
Deprecated: false,
Positional: false,
},