-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit.go
3849 lines (3826 loc) · 131 KB
/
init.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
package cli
import (
"fmt"
"github.com/centurylinkcloud/clc-go-cli/base"
"github.com/centurylinkcloud/clc-go-cli/commands"
"github.com/centurylinkcloud/clc-go-cli/help"
"github.com/centurylinkcloud/clc-go-cli/models"
"github.com/centurylinkcloud/clc-go-cli/models/affinity"
"github.com/centurylinkcloud/clc-go-cli/models/alert"
"github.com/centurylinkcloud/clc-go-cli/models/autoscale"
"github.com/centurylinkcloud/clc-go-cli/models/backup"
"github.com/centurylinkcloud/clc-go-cli/models/balancer"
"github.com/centurylinkcloud/clc-go-cli/models/billing"
"github.com/centurylinkcloud/clc-go-cli/models/crossdc_firewall"
"github.com/centurylinkcloud/clc-go-cli/models/customfields"
"github.com/centurylinkcloud/clc-go-cli/models/datacenter"
"github.com/centurylinkcloud/clc-go-cli/models/db"
"github.com/centurylinkcloud/clc-go-cli/models/firewall"
"github.com/centurylinkcloud/clc-go-cli/models/group"
"github.com/centurylinkcloud/clc-go-cli/models/ips"
"github.com/centurylinkcloud/clc-go-cli/models/network"
"github.com/centurylinkcloud/clc-go-cli/models/ospatch"
"github.com/centurylinkcloud/clc-go-cli/models/server"
"github.com/centurylinkcloud/clc-go-cli/models/vpn"
"github.com/centurylinkcloud/clc-go-cli/models/webhook"
)
var AllCommands []base.Command = make([]base.Command, 0)
func init() {
registerCommandBase(&server.CreateReq{}, &server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/servers/{accountAlias}",
Resource: "server",
Command: "create",
Help: help.Command{
Brief: []string{
"Creates a new server.",
"Use this API operation when you want to create a new server from a standard or custom template, or clone an existing server.",
},
Arguments: []help.Argument{
{
"--name",
[]string{
"Required. Name of the server to create. Alphanumeric characters and dashes only.",
"Must be between 1-8 characters depending on the length of the account alias.",
"The combination of account alias and server name here must be no more than 10 characters in length.",
"This name will be appended with a two digit number and prepended with the datacenter code",
"and account alias to make up the final server name.",
},
},
{
"--description",
[]string{"User-defined description of this server"},
},
{
"--group-id",
[]string{"Required unless --group-name is specified. ID of the parent group."},
},
{
"--group-name",
[]string{"Required unless --group-id is specified. Name of the parent group."},
},
{
"--source-server-id",
[]string{
"Required unless --template-name or --source-server-name is specified. ID of the server to use as a source.",
"Actually, it may be the name of a template, or when cloning, an existing server ID.",
},
},
{
"--source-server-name",
[]string{
"Required unless --source-server-id or --template-name is specified. Name of the server to use as a source.",
},
},
{
"--template-name",
[]string{
"Required unless --source-server-id or --source-server-name is specified. A template to create the server from.",
"If autocomplete is turned on, available template names are shown as options.",
},
},
{
"--is-managed-os",
[]string{
"Whether to create the server as managed or not. Default is false.",
"Ignored for bare metal servers.",
},
},
{
"--is-managed-backup",
[]string{
"Whether to add managed backup to the server. Must be a managed OS server.",
"Ignored for bare metal servers.",
},
},
{
"--primary-dns",
[]string{"Primary DNS to set on the server. If not supplied the default value set on the account will be used."},
},
{
"--secondary-dns",
[]string{"Secondary DNS to set on the server. If not supplied the default value set on the account will be used."},
},
{
"--network-id",
[]string{
"ID of the network to which to deploy the server. If not provided, a network will be chosen automatically.",
"If your account has not yet been assigned a network, leave this blank and one will be assigned automatically.",
},
},
{
"--network-name",
[]string{
"Name of the network to which to deploy the server. An alternative way to identify the network.",
},
},
{
"--ip-address",
[]string{
"IP address to assign to the server. If not provided, one will be assigned automatically.",
"Ignored for bare metal servers.",
},
},
{
"--root-password",
[]string{"Password of administrator or root user on server. If not provided, one will be generated automatically."},
},
{
"--source-server-password",
[]string{
"Password of the source server, used only when creating a clone from an existing server.",
"Ignored for bare metal servers.",
},
},
{
"--cpu",
[]string{"Required. Number of processors to configure the server with (1-16). Ignored for bare metal servers."},
},
{
"--cpu-autoscale-policy-id",
[]string{
"ID of the vertical CPU Autoscale policy to associate the server with.",
"Ignored for bare metal servers.",
},
},
{
"--memory-gb",
[]string{
"Required. Number of GB of memory to configure the server with (1-128).",
"Ignored for bare metal servers.",
},
},
{
"--type",
[]string{"Required. Whether to create a standard, hyperscale, or bareMetal server."},
},
{
"--anti-affinity-policy-id",
[]string{
"ID of the Anti-Affinity policy to associate the",
"server with. Only valid for hyperscale servers.",
},
},
{
"--anti-affinity-policy-name",
[]string{
"Name of the Anti-Affinity policy. An alternative way to identify the policy.",
},
},
{
"--custom-fields",
[]string{
"Collection of custom field ID-value pairs to set for the server.",
"Each object of a collection has keys 'id' and 'value'.",
},
},
{
"--additional-disks",
[]string{"Collection of disk parameters. Ignored for bare metal servers."},
},
{
"--ttl",
[]string{fmt.Sprintf("Date/time that the server should be deleted. The format is %s. Ignored for bare metal servers.", base.TIME_FORMAT)},
},
{
"--packages",
[]string{"Collection of packages to run on the server after it has been built. Ignored for bare metal servers."},
},
{
"--configuration-id",
[]string{
"Only required for bare metal servers. Specifies the identifier for the specific configuration type of bare metal server to deploy.",
"The list of valid bare metal configuration id's can be found by calling the 'clc data-center get-baremetal-capabilities' command.",
"Ignored for standard and hyperscale servers. ",
},
},
{
"--os-type",
[]string{
"Only required for bare metal servers. Specifies the OS to provision with the bare metal server. The list of valid operating",
"systems can be found by calling the 'clc data-center get-baremetal-capabilities' command.",
"Ignored for standard and hyperscale servers.",
},
},
},
},
})
registerCommandBase(&server.DeleteReq{}, &server.ServerRes{}, commands.CommandExcInfo{
Verb: "DELETE",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}",
Resource: "server",
Command: "delete",
Help: help.Command{
Brief: []string{"Sends the delete operation to a given server and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server to be deleted."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server to be deleted."},
},
},
},
})
registerCommandBase(&server.UpdateReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "PATCH",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}",
Resource: "server",
Command: "update",
Help: help.Command{
Brief: []string{"Changes the amount of CPU cores, memory (in GB), server credentials, custom fields, description, disks and server's group."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server being updated."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server being updated."},
},
{
"--cpu",
[]string{"The amount of CPU cores to set for the given server."},
},
{
"--memory-gb",
[]string{"The amount of memory (in GB) to set for the given server."},
},
{
"--root-password",
[]string{
"The current and new administrator/root password values.",
"Has to be an object with 2 fields:",
"1) current: the current administrator/root password used to login;",
"2) password: the new administrator/root password to change to.",
},
},
{
"--custom-fields",
[]string{
"A list of id-value pairs for all custom fields including all required values",
"and other custom field values that you wish to set.",
"",
"Note: You must specify the complete list of custom field values to set on the server.",
"If you want to change only one value, specify all existing field values",
"along with the new value for the field you wish to change.",
"To unset the value for an unrequired field, you may leave the field id-value pairing out,",
"however all required fields must be included.",
},
},
{
"--description",
[]string{"The description of the server to set"},
},
{
"--group-id",
[]string{"The unique identifier of the group to set as the parent."},
},
{
"--group-name",
[]string{"The name of the group to set as the parent. An alternative way to identify the group."},
},
{
"--disks",
[]string{
"A list of information for all disks to be on the server including type (raw or partition), size, and path",
"",
"Note: You must specify the complete list of disks to be on the server.",
"If you want to add or resize a disk, specify all existing disks/sizes",
"along with a new entry for the disk to add or the new size of an existing disk.",
"To delete a disk, just specify all the disks that should remain.",
},
},
},
},
})
registerCommandBase(&server.GetReq{}, &server.GetRes{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}",
Resource: "server",
Command: "get",
Help: help.Command{
Brief: []string{"Gets the details for a individual server."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server being queried."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server being queried."},
},
},
},
})
registerCommandBase(&server.GetCredentialsReq{}, &server.GetCredentialsRes{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/credentials",
Resource: "server",
Command: "get-credentials",
Help: help.Command{
Brief: []string{"Retrieves the administrator/root password on an existing server."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server with the credentials to return."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server with the credentials to return."},
},
},
},
})
registerCommandBase(&server.GetImportsReq{}, &server.GetImportsRes{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/vmImport/{accountAlias}/{DataCenter}/available",
Resource: "server",
Command: "get-imports",
Help: help.Command{
Brief: []string{"Gets the list of available servers that can be imported."},
Arguments: []help.Argument{
{
"--data-center",
[]string{"Required. Data center location identifier."},
},
},
},
})
registerCommandBase(&server.GetIPAddressReq{}, &server.GetIPAddressRes{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/publicIPAddresses/{PublicIp}",
Resource: "server",
Command: "get-public-ip-address",
Help: help.Command{
Brief: []string{"Gets the details for the public IP address of a server, including the specific set of protocols and ports allowed and any source IP restrictions."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server being queried."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server being queried."},
},
{
"--public-ip",
[]string{"Required. The specific public IP to return details about."},
},
},
},
})
registerCommandBase(&server.AddIPAddressReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/publicIPAddresses",
Resource: "server",
Command: "add-public-ip-address",
Help: help.Command{
Brief: []string{
"Claims a public IP address and associates it with a server, allowing access to it on a given set of protocols and ports.",
"It may also be set to restrict access based on a source IP range.",
},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server being queried."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server being queried."},
},
{
"--internal-ip-address",
[]string{
"The internal (private) IP address to map to the new public IP address.",
"If not provided, one will be assigned for you.",
},
},
{
"--ports",
[]string{
"Required. The set of ports and protocols to allow access to for the new public IP address.",
"Only these specified ports on the respective protocols will be accessible",
"when accessing the server using the public IP address claimed here.",
"Has to be a list of objects with fields port, portTo and protocol.",
},
},
{
"--source-restrictions",
[]string{
"A list of the source IP address ranges allowed to access the new public IP address.",
"Used to restrict access to only the specified ranges of source IPs.",
},
},
},
},
})
registerCommandBase(&server.RemoveIPAddressReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "DELETE",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/publicIPAddresses/{PublicIp}",
Resource: "server",
Command: "remove-public-ip-address",
Help: help.Command{
Brief: []string{
"Releases the given public IP address of a server so that it is no longer associated with the server",
"and available to be claimed again by another server.",
},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server being queried."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server being queried."},
},
{
"--public-ip",
[]string{"Required. The specific public IP to remove."},
},
},
},
})
registerCommandBase(&server.UpdateIPAddressReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "PUT",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/publicIPAddresses/{PublicIp}",
Resource: "server",
Command: "update-public-ip-address",
Help: help.Command{
Brief: []string{
"Updates a public IP address on an existing server, allowing access to it on a given set of protocols and ports",
"as well as restricting access based on a source IP range.",
},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server being queried."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server being queried."},
},
{
"--public-ip",
[]string{"Required. The specific public IP to update."},
},
{
"--ports",
[]string{
"Required. The set of ports and protocols to allow access to for the public IP address.",
"Only these specified ports on the respective protocols will be accessible",
"when accessing the server using the public IP address claimed here.",
"Has to be a list of objects with fields port, portTo and protocol.",
},
},
{
"--source-restrictions",
[]string{
"A list of the source IP address ranges allowed to access the public IP address.",
"Used to restrict access to only the specified ranges of source IPs.",
},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/powerOn",
Resource: "server",
Command: "power-on",
Help: help.Command{
Brief: []string{"Sends the power on operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform power on operation on."},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/powerOff",
Resource: "server",
Command: "power-off",
Help: help.Command{
Brief: []string{"Sends the power off operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform power off operation on."},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/pause",
Resource: "server",
Command: "pause",
Help: help.Command{
Brief: []string{"Sends the pause operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform pause operation on."},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/reboot",
Resource: "server",
Command: "reboot",
Help: help.Command{
Brief: []string{"Sends the reboot operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform reboot operation on."},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/reset",
Resource: "server",
Command: "reset",
Help: help.Command{
Brief: []string{"Sends the reset operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform reset operation on."},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/shutDown",
Resource: "server",
Command: "shut-down",
Help: help.Command{
Brief: []string{"Sends the shut-down operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform shut-down operation on."},
},
},
},
})
registerCommandBase(&server.PowerReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/archive",
Resource: "server",
Command: "archive",
Help: help.Command{
Brief: []string{"Sends the archive operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to perform archive operation on."},
},
},
},
})
registerCommandBase(&server.RestoreReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/restore",
Resource: "server",
Command: "restore",
Help: help.Command{
Brief: []string{"Restores a given archived server to a specified group."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required. ID of the archived server to restore."},
},
{
"--target-group-id",
[]string{"Required. The unique identifier of the target group to restore the server to."},
},
},
},
})
registerCommandBase(&server.CreateSnapshotReq{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/createSnapshot",
Resource: "server",
Command: "create-snapshot",
Help: help.Command{
Brief: []string{"Sends the create snapshot operation to a list of servers (along with the number of days to keep the snapshot for) and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server names to perform create snapshot operation on."},
},
{
"--snapshot-expiration-days",
[]string{"Required. Number of days to keep the snapshot for (must be between 1 and 10)."},
},
},
},
})
registerCommandBase(&server.RevertToSnapshotReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/snapshots/{SnapshotId}/restore",
Resource: "server",
Command: "revert-to-snapshot",
Help: help.Command{
Brief: []string{"Reverts a server to a snapshot."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server with the snapshot to restore."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server with the snapshot to restore."},
},
{
"--snapshot-id",
[]string{"Required. ID of the snapshot to restore."},
},
},
},
})
registerCommandBase(&server.DeleteSnapshotReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "DELETE",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/snapshots/{SnapshotId}",
Resource: "server",
Command: "delete-snapshot",
Help: help.Command{
Brief: []string{"Deletes a given server snapshot."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server with the snapshot to delete."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server with the snapshot to delete."},
},
{
"--snapshot-id",
[]string{"Required. ID of the snapshot to delete."},
},
},
},
})
registerCommandBase(&server.MaintenanceRequest{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/startMaintenance",
Resource: "server",
Command: "start-maintenance-mode",
Help: help.Command{
Brief: []string{"Sends a start maintenance mode operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to start maintenance mode on."},
},
},
},
})
registerCommandBase(&server.MaintenanceRequest{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/stopMaintenance",
Resource: "server",
Command: "stop-maintenance-mode",
Help: help.Command{
Brief: []string{"Sends a stop maintenance mode operation to a list of servers and adds operation to queue."},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. List of server IDs to stop maintenance mode on."},
},
},
},
})
registerCommandBase(&server.Import{}, &server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/vmImport/{accountAlias}",
Resource: "server",
Command: "import",
Help: help.Command{
Brief: []string{"Imports a new server from an uploaded OVF."},
Arguments: []help.Argument{
{
"--name",
[]string{
"Required. Name of the server to create. Alphanumeric characters and dashes only.",
"Must be between 1-8 characters depending on the length of the account alias.",
"The combination of account alias and server name here must be no more than 10 characters in length.",
"This name will be appended with a two digit number and prepended with the datacenter code",
"and account alias to make up the final server name.",
},
},
{
"--description",
[]string{"User-defined description of this server."},
},
{
"--group-id",
[]string{"Required unless --group-name is specified. ID of the parent group."},
},
{
"--group-name",
[]string{"Required unless --group-id is specified. Name of the parent group."},
},
{
"--primary-dns",
[]string{"Primary DNS to set on the server. If not supplied the default value set on the account will be used."},
},
{
"--secondary-dns",
[]string{"Secondary DNS to set on the server. If not supplied the default value set on the account will be used."},
},
{
"--network-id",
[]string{
"ID of the network to which to deploy the server. If not provided, a network will be chosen automatically.",
"If your account has not yet been assigned a network, leave this blank and one will be assigned automatically.",
},
},
{
"--network-name",
[]string{
"Name of the network to which to deploy the server. An alternative way to identify the network.",
},
},
{
"--root-password",
[]string{
"Required. Password of administrator or root user on server. This password must match",
"the one set on the server being imported or the import will fail.",
},
},
{
"--cpu",
[]string{
"Required. Number of processors to configure the server with (1-16). If this value is different from the one specified in the OVF,",
"the import process will resize the server according to the value specified here.",
},
},
{
"--memory-gb",
[]string{
"Required. Number of GB of memory to configure the server with (1-128). If this value is different from the one specified in the OVF,",
"the import process will resize the server according to the value specified here.",
},
},
{
"--type",
[]string{"Required. Whether to create standard or hyperscale server"},
},
{
"--custom-fields",
[]string{
"Collection of custom field ID-value pairs to set for the server.",
"Each object of a collection has keys 'id' and 'value'.",
},
},
{
"--ovf-id",
[]string{"Required. The identifier of the OVF that defines the server to import."},
},
{
"--ovf-os-type",
[]string{
"Required. The OS type of the server being imported. Currently, the only supported OS types",
"are redHat6_64Bit, windows2008R2DataCenter_64bit, and windows2012R2DataCenter_64Bit.",
},
},
},
},
})
registerCommandBase(&server.AddNetwork{}, &models.Status{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/networks",
Resource: "server",
Command: "add-secondary-network",
Help: help.Command{
Brief: []string{"Adds a secondary network adapter to a given server in a given account."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server."},
},
{
"--network-id",
[]string{"Required unless --network-name is specified. ID of the network."},
},
{
"--network-name",
[]string{"Required unless --network-id is specified. Name of the network."},
},
{
"--ip-address",
[]string{"Optional IP address for the network ID."},
},
},
},
})
registerCommandBase(&server.RemoveNetwork{}, &models.Status{}, commands.CommandExcInfo{
Verb: "DELETE",
Url: "https://api.ctl.io/v2/servers/{accountAlias}/{ServerId}/networks/{NetworkId}",
Resource: "server",
Command: "remove-secondary-network",
Help: help.Command{
Brief: []string{"Removes a secondary network adapter from a given server in a given account."},
Arguments: []help.Argument{
{
"--server-id",
[]string{"Required unless --server-name is specified. ID of the server."},
},
{
"--server-name",
[]string{"Required unless --server-id is specified. Name of the server."},
},
{
"--network-id",
[]string{"Required unless --network-name is specified. ID of the network."},
},
{
"--network-name",
[]string{"Required unless --network-id is specified. Name of the network."},
},
},
},
})
registerCommandBase(&server.ExecutePackage{}, &[]server.ServerRes{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/operations/{accountAlias}/servers/executePackage",
Resource: "server",
Command: "execute-package",
Help: help.Command{
Brief: []string{"Executes a single package on one or more servers"},
Arguments: []help.Argument{
{
"--server-ids",
[]string{"Required. A list of server IDs to execute the package on"},
},
{
"--package",
[]string{
"Required. The package entity describing which package to run on the specified servers.",
"It has to contain the following fields:",
" package-id: unique identifier of the package to execute",
" paramaters: a JSON string containing a set of key-value pairs for setting the package-specific parameters defined",
},
},
},
},
})
registerCommandBase(&group.GetReq{}, &group.Entity{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/groups/{accountAlias}/{GroupId}",
Resource: "group",
Command: "get",
Help: help.Command{
Brief: []string{"Gets the details for a individual server group and any sub-groups and servers that it contains."},
Arguments: []help.Argument{
{
"--group-id",
[]string{"Required unless --group-name is specified. ID of the group being queried."},
},
{
"--group-name",
[]string{"Required unless --group-id is specified. Name of the group being queried."},
},
},
},
})
registerCommandBase(&group.CreateReq{}, &group.Entity{}, commands.CommandExcInfo{
Verb: "POST",
Url: "https://api.ctl.io/v2/groups/{accountAlias}",
Resource: "group",
Command: "create",
Help: help.Command{
Brief: []string{"Creates a new group."},
Arguments: []help.Argument{
{
"--name",
[]string{"Required. Name of the group to create."},
},
{
"--description",
[]string{"User-defined description of this group."},
},
{
"--parent-group-id",
[]string{"Required unless --parent-group-name is specified. ID of the parent group."},
},
{
"--parent-group-name",
[]string{"Required unless --parent-group-id is specified. Name of the parent group."},
},
{
"--custom-fields",
[]string{
"Collection of custom field ID-value pairs to set for the server.",
"Each object of a collection has keys 'id' and 'value'.",
},
},
},
},
})
registerCommandBase(&group.DeleteReq{}, &models.LinkEntity{}, commands.CommandExcInfo{
Verb: "DELETE",
Url: "https://api.ctl.io/v2/groups/{accountAlias}/{GroupId}",
Resource: "group",
Command: "delete",
Help: help.Command{
Brief: []string{"Sends the delete operation to a given group and adds operation to queue."},
Arguments: []help.Argument{
{
"--group-id",
[]string{"Required unless --group-name is specified. ID of the group being deleted."},
},
{
"--group-name",
[]string{"Required unless --group-id is specified. Name of the group being deleted."},
},
},
},
})
registerCommandBase(&group.GetBillingReq{}, &group.GetBillingRes{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/groups/{accountAlias}/{GroupId}/billing",
Resource: "group",
Command: "get-billing-details",
Help: help.Command{
Brief: []string{"Gets the current and estimated charges for each server in a designated group hierarchy."},
Arguments: []help.Argument{
{
"--group-id",
[]string{"Required unless --group-name is specified. ID of the group being queried."},
},
{
"--group-name",
[]string{"Required unless --group-id is specified. Name of the group being queried."},
},
},
},
})
registerCommandBase(&group.GetStatsReq{}, &[]group.GetStatsRes{}, commands.CommandExcInfo{
Verb: "GET",
Url: "https://api.ctl.io/v2/groups/{accountAlias}/{GroupId}/statistics?start={Start}&end={End}&sampleInterval={SampleInterval}&type={Type}",
Resource: "group",
Command: "get-monitoring-statistics",
Help: help.Command{
Brief: []string{
"Gets the resource consumption details for whatever window specified in the request.",
"Data can be retrieved for a variety of time windows and intervals.",
},
Arguments: []help.Argument{
{
"--group-id",
[]string{"Required unless --group-name is specified. ID of the group being queried."},
},
{
"--group-name",
[]string{"Required unless --group-id is specified. Name of the group being queried."},
},