diff --git a/cmd/scw/testdata/test-all-usage-instance-placement-group-get-servers-usage.golden b/cmd/scw/testdata/test-all-usage-instance-placement-group-get-servers-usage.golden new file mode 100644 index 0000000000..85070fd1cf --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-placement-group-get-servers-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get all servers belonging to the given placement group. + +USAGE: + scw instance placement-group get-servers [arg=value ...] + +ARGS: + placement-group-id + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for get-servers + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-placement-group-set-servers-usage.golden b/cmd/scw/testdata/test-all-usage-instance-placement-group-set-servers-usage.golden new file mode 100644 index 0000000000..73eeac732a --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-placement-group-set-servers-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Set all servers belonging to the given placement group. + +USAGE: + scw instance placement-group set-servers [arg=value ...] + +EXAMPLES: + Update the complete set of instances in a given placement group. (All instances must be down) + scw instance placement-group set-servers placement-group-id=ced0fd4d-bcf0-4479-85b6-7027e54456e6 servers.0=5a250608-24ec-4c31-9631-b3ded8c861cb servers.1=e54fd249-0787-4794-ab14-af6ee74df274 + +ARGS: + placement-group-id + [servers.{index}] + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for set-servers + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-placement-group-set-usage.golden b/cmd/scw/testdata/test-all-usage-instance-placement-group-set-usage.golden new file mode 100644 index 0000000000..da3cab9603 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-placement-group-set-usage.golden @@ -0,0 +1,25 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Set all parameters of the given placement group. + +USAGE: + scw instance placement-group set [arg=value ...] + +ARGS: + placement-group-id + [name] + [policy-mode] (optional | enforced) + [policy-type] (max_availability | low_latency) + [project] Project ID to use. If none is passed the default project ID will be used + [tags.{index}] + [organization] Organization ID to use. If none is passed the default organization ID will be used + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for set + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-placement-group-update-servers-usage.golden b/cmd/scw/testdata/test-all-usage-instance-placement-group-update-servers-usage.golden new file mode 100644 index 0000000000..62810c2a4c --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-placement-group-update-servers-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Update all servers belonging to the given placement group. + +USAGE: + scw instance placement-group update-servers [arg=value ...] + +ARGS: + placement-group-id UUID of the placement group + servers.{index} + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for update-servers + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-placement-group-usage.golden b/cmd/scw/testdata/test-all-usage-instance-placement-group-usage.golden index c16e76f7fe..d74162d2f3 100644 --- a/cmd/scw/testdata/test-all-usage-instance-placement-group-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-placement-group-usage.golden @@ -23,11 +23,15 @@ USAGE: scw instance placement-group AVAILABLE COMMANDS: - create Create a placement group - delete Delete the given placement group - get Get a placement group - list List placement groups - update Update a placement group + create Create a placement group + delete Delete the given placement group + get Get a placement group + get-servers Get placement group servers + list List placement groups + set Set placement group + set-servers Set placement group servers + update Update a placement group + update-servers Update placement group servers FLAGS: -h, --help help for placement-group diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-create-rule-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-create-rule-usage.golden new file mode 100644 index 0000000000..46d570bd00 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-create-rule-usage.golden @@ -0,0 +1,43 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Create rule. + +USAGE: + scw instance security-group create-rule [arg=value ...] + +EXAMPLES: + Allow incoming SSH + scw instance security-group create-rule security-group-id=1248283f-17de-464a-b03b-3f975ada3fa8 protocol=TCP direction=inbound action=accept ip-range= dest-port-from=22 + + Allow HTTP + scw instance security-group create-rule security-group-id=e8ba77c1-9ccb-4c0c-b08d-555cfd7f57e4 protocol=TCP direction=inbound action=accept ip-range= dest-port-from=80 + + Allow HTTPS + scw instance security-group create-rule security-group-id=e5906437-8650-4fe2-8ca7-32e1d7320c1b protocol=TCP direction=inbound action=accept ip-range= dest-port-from=443 + + Allow a specific IP range + scw instance security-group create-rule security-group-id=b6a58155-a2f8-48bd-9da9-3ff9783fa0d4 protocol=ANY direction=inbound action=accept ip-range=10.0.0.0/16 + + Allow FTP + scw instance security-group create-rule security-group-id=9c46df03-83c2-46fb-936c-16ecb44860e1 protocol=TCP direction=inbound action=accept ip-range= dest-port-from=20 dest-port-to=21 + +ARGS: + security-group-id UUID of the security group + protocol (TCP | UDP | ICMP | ANY) + direction (inbound | outbound) + action (accept | drop) + ip-range=0.0.0.0/0 + [dest-port-from] The beginning of the range of ports to apply this rule to (inclusive) + [dest-port-to] The end of the range of ports to apply this rule to (inclusive) + [position] The position of this rule in the security group rules list + [editable] Indicates if this rule is editable (will be ignored) + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for create-rule + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-delete-rule-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-delete-rule-usage.golden new file mode 100644 index 0000000000..1527b3c7d6 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-delete-rule-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Delete a security group rule with the given ID. + +USAGE: + scw instance security-group delete-rule [arg=value ...] + +EXAMPLES: + Delete a Security Group Rule with the given ID + scw instance security-group delete-rule security-group-id=a01a36e5-5c0c-42c1-ae06-167e587b7ac4 security-group-rule-id=b8c773ef-a6ea-4b50-a7c1-737864290a3f + +ARGS: + security-group-id + security-group-rule-id + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for delete-rule + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-get-rule-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-get-rule-usage.golden new file mode 100644 index 0000000000..cb0ef2ddeb --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-get-rule-usage.golden @@ -0,0 +1,24 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get details of a security group rule with the given ID. + +USAGE: + scw instance security-group get-rule [arg=value ...] + +EXAMPLES: + Get details of a security group rule with the given ID + scw instance security-group get-rule security-group-id=d900fa38-2f0d-4b09-b6d7-f3e46a13f34c security-group-rule-id=1f9a16a5-7229-4c03-9327-253e257cf38a + +ARGS: + security-group-id + security-group-rule-id + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for get-rule + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-list-default-rules-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-list-default-rules-usage.golden new file mode 100644 index 0000000000..aa8de0aba1 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-list-default-rules-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Lists the default rules applied to all the security groups. + +USAGE: + scw instance security-group list-default-rules [arg=value ...] + +ARGS: + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for list-default-rules + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-list-rules-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-list-rules-usage.golden new file mode 100644 index 0000000000..31695154da --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-list-rules-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List rules. + +USAGE: + scw instance security-group list-rules [arg=value ...] + +ARGS: + security-group-id UUID of the security group + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2 | all) + +FLAGS: + -h, --help help for list-rules + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-set-rules-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-set-rules-usage.golden new file mode 100644 index 0000000000..6706437c97 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-set-rules-usage.golden @@ -0,0 +1,29 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Replaces the rules of the security group with the rules provided. This endpoint supports the update of existing rules, creation of new rules and deletion of existing rules when they are not passed in the request. + +USAGE: + scw instance security-group set-rules [arg=value ...] + +ARGS: + security-group-id UUID of the security group to update the rules on + [rules.{index}.id] UUID of the security rule to update. If no value is provided, a new rule will be created + [rules.{index}.action] Action to apply when the rule matches a packet (accept | drop) + [rules.{index}.protocol] Protocol family this rule applies to (TCP | UDP | ICMP | ANY) + [rules.{index}.direction] Direction the rule applies to (inbound | outbound) + [rules.{index}.ip-range] The range of IP address this rules applies to + [rules.{index}.dest-port-from] Beginning of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY + [rules.{index}.dest-port-to] End of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY, or if it is equal to dest_port_from + [rules.{index}.position] Position of this rule in the security group rules list. If several rules are passed with the same position, the resulting order is undefined + [rules.{index}.editable] Indicates if this rule is editable. Rules with the value false will be ignored + [rules.{index}.zone] Zone of the rule. This field is ignored + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for set-rules + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-security-group-usage.golden b/cmd/scw/testdata/test-all-usage-instance-security-group-usage.golden index b036e3256f..8081b2705a 100644 --- a/cmd/scw/testdata/test-all-usage-instance-security-group-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-security-group-usage.golden @@ -10,12 +10,18 @@ USAGE: scw instance security-group AVAILABLE COMMANDS: - clear Remove all rules of a security group - create Create a security group - delete Delete a security group - get Get a security group - list List security groups - update Update security group + clear Remove all rules of a security group + create Create a security group + create-rule Create rule + delete Delete a security group + delete-rule Delete rule + get Get a security group + get-rule Get rule + list List security groups + list-default-rules Get default rules + list-rules List rules + set-rules Update all the rules of a security group + update Update security group FLAGS: -h, --help help for security-group diff --git a/cmd/scw/testdata/test-all-usage-instance-server-list-actions-usage.golden b/cmd/scw/testdata/test-all-usage-instance-server-list-actions-usage.golden new file mode 100644 index 0000000000..c3ab2408ea --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-server-list-actions-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +List all actions that can currently be performed on a server. + +USAGE: + scw instance server list-actions [arg=value ...] + +ARGS: + server-id + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for list-actions + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-server-type-get-usage.golden b/cmd/scw/testdata/test-all-usage-instance-server-type-get-usage.golden new file mode 100644 index 0000000000..3389e329a5 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-instance-server-type-get-usage.golden @@ -0,0 +1,18 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get availability for all server types. + +USAGE: + scw instance server-type get [arg=value ...] + +ARGS: + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | pl-waw-1 | pl-waw-2) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-instance-server-type-usage.golden b/cmd/scw/testdata/test-all-usage-instance-server-type-usage.golden index e4d8f63fdf..e29b353909 100644 --- a/cmd/scw/testdata/test-all-usage-instance-server-type-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-server-type-usage.golden @@ -7,6 +7,7 @@ USAGE: scw instance server-type AVAILABLE COMMANDS: + get Get availability list List server types FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-instance-server-usage.golden b/cmd/scw/testdata/test-all-usage-instance-server-usage.golden index fc2bf7e917..aa8a9e56fa 100644 --- a/cmd/scw/testdata/test-all-usage-instance-server-usage.golden +++ b/cmd/scw/testdata/test-all-usage-instance-server-usage.golden @@ -45,6 +45,7 @@ AVAILABLE COMMANDS: detach-volume Detach a volume from its server get Get a server list List all servers + list-actions List server actions reboot Reboot server ssh SSH into a server standby Put server in standby mode diff --git a/docs/commands/instance.md b/docs/commands/instance.md index 1e496ee568..621b15b694 100644 --- a/docs/commands/instance.md +++ b/docs/commands/instance.md @@ -21,8 +21,12 @@ Instance API. - [Create a placement group](#create-a-placement-group) - [Delete the given placement group](#delete-the-given-placement-group) - [Get a placement group](#get-a-placement-group) + - [Get placement group servers](#get-placement-group-servers) - [List placement groups](#list-placement-groups) + - [Set placement group](#set-placement-group) + - [Set placement group servers](#set-placement-group-servers) - [Update a placement group](#update-a-placement-group) + - [Update placement group servers](#update-placement-group-servers) - [Private NIC management commands](#private-nic-management-commands) - [Create a private NIC connecting a server to a private network](#create-a-private-nic-connecting-a-server-to-a-private-network) - [Delete a private NIC](#delete-a-private-nic) @@ -32,9 +36,15 @@ Instance API. - [Security group management commands](#security-group-management-commands) - [Remove all rules of a security group](#remove-all-rules-of-a-security-group) - [Create a security group](#create-a-security-group) + - [Create rule](#create-rule) - [Delete a security group](#delete-a-security-group) + - [Delete rule](#delete-rule) - [Get a security group](#get-a-security-group) + - [Get rule](#get-rule) - [List security groups](#list-security-groups) + - [Get default rules](#get-default-rules) + - [List rules](#list-rules) + - [Update all the rules of a security group](#update-all-the-rules-of-a-security-group) - [Update security group](#update-security-group) - [Server management commands](#server-management-commands) - [Attach an IP to a server](#attach-an-ip-to-a-server) @@ -47,6 +57,7 @@ Instance API. - [Detach a volume from its server](#detach-a-volume-from-its-server) - [Get a server](#get-a-server) - [List all servers](#list-all-servers) + - [List server actions](#list-server-actions) - [Reboot server](#reboot-server) - [SSH into a server](#ssh-into-a-server) - [Put server in standby mode](#put-server-in-standby-mode) @@ -56,6 +67,7 @@ Instance API. - [Update a server](#update-a-server) - [Wait for server to reach a stable state](#wait-for-server-to-reach-a-stable-state) - [Server type management commands](#server-type-management-commands) + - [Get availability](#get-availability) - [List server types](#list-server-types) - [Snapshot management commands](#snapshot-management-commands) - [Create a snapshot from a given volume or from a QCOW2 file](#create-a-snapshot-from-a-given-volume-or-from-a-qcow2-file) @@ -741,6 +753,26 @@ scw instance placement-group get 6c15f411-3b6f-402d-8eba-ae24ef9254e9 +### Get placement group servers + +Get all servers belonging to the given placement group. + +**Usage:** + +``` +scw instance placement-group get-servers [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| placement-group-id | Required | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + ### List placement groups List all placement groups. @@ -779,6 +811,63 @@ scw instance placement-group list name=cluster1 +### Set placement group + +Set all parameters of the given placement group. + +**Usage:** + +``` +scw instance placement-group set [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| placement-group-id | Required | | +| name | | | +| policy-mode | One of: `optional`, `enforced` | | +| policy-type | One of: `max_availability`, `low_latency` | | +| project | | Project ID to use. If none is passed the default project ID will be used | +| tags.{index} | | | +| organization | | Organization ID to use. If none is passed the default organization ID will be used | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + +### Set placement group servers + +Set all servers belonging to the given placement group. + +**Usage:** + +``` +scw instance placement-group set-servers [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| placement-group-id | Required | | +| servers.{index} | | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + +**Examples:** + + +Update the complete set of instances in a given placement group. (All instances must be down) +``` +scw instance placement-group set-servers placement-group-id=ced0fd4d-bcf0-4479-85b6-7027e54456e6 servers.0=5a250608-24ec-4c31-9631-b3ded8c861cb servers.1=e54fd249-0787-4794-ab14-af6ee74df274 +``` + + + + ### Update a placement group Update one or more parameter of the given placement group. @@ -823,6 +912,27 @@ scw instance placement-group update 0954ec26-9917-47b6-8c5c-7bc81d7bb9d2 policy- +### Update placement group servers + +Update all servers belonging to the given placement group. + +**Usage:** + +``` +scw instance placement-group update-servers [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| placement-group-id | Required | UUID of the placement group | +| servers.{index} | Required | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + ## Private NIC management commands A Private NIC is the network interface that connects a server to a @@ -1063,6 +1173,64 @@ scw instance security-group create +### Create rule + +Create rule. + +**Usage:** + +``` +scw instance security-group create-rule [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| security-group-id | Required | UUID of the security group | +| protocol | Required
One of: `TCP`, `UDP`, `ICMP`, `ANY` | | +| direction | Required
One of: `inbound`, `outbound` | | +| action | Required
One of: `accept`, `drop` | | +| ip-range | Required
Default: `0.0.0.0/0` | | +| dest-port-from | | The beginning of the range of ports to apply this rule to (inclusive) | +| dest-port-to | | The end of the range of ports to apply this rule to (inclusive) | +| position | | The position of this rule in the security group rules list | +| editable | | Indicates if this rule is editable (will be ignored) | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + +**Examples:** + + +Allow incoming SSH +``` +scw instance security-group create-rule security-group-id=1248283f-17de-464a-b03b-3f975ada3fa8 protocol=TCP direction=inbound action=accept ip-range= dest-port-from=22 +``` + +Allow HTTP +``` +scw instance security-group create-rule security-group-id=e8ba77c1-9ccb-4c0c-b08d-555cfd7f57e4 protocol=TCP direction=inbound action=accept ip-range= dest-port-from=80 +``` + +Allow HTTPS +``` +scw instance security-group create-rule security-group-id=e5906437-8650-4fe2-8ca7-32e1d7320c1b protocol=TCP direction=inbound action=accept ip-range= dest-port-from=443 +``` + +Allow a specific IP range +``` +scw instance security-group create-rule security-group-id=b6a58155-a2f8-48bd-9da9-3ff9783fa0d4 protocol=ANY direction=inbound action=accept ip-range=10.0.0.0/16 +``` + +Allow FTP +``` +scw instance security-group create-rule security-group-id=9c46df03-83c2-46fb-936c-16ecb44860e1 protocol=TCP direction=inbound action=accept ip-range= dest-port-from=20 dest-port-to=21 +``` + + + + ### Delete a security group Delete a security group. @@ -1093,6 +1261,37 @@ scw instance security-group delete 69e17c83-9945-47ac-8b29-8c1ad050ee83 +### Delete rule + +Delete a security group rule with the given ID. + +**Usage:** + +``` +scw instance security-group delete-rule [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| security-group-id | Required | | +| security-group-rule-id | Required | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + +**Examples:** + + +Delete a Security Group Rule with the given ID +``` +scw instance security-group delete-rule security-group-id=a01a36e5-5c0c-42c1-ae06-167e587b7ac4 security-group-rule-id=b8c773ef-a6ea-4b50-a7c1-737864290a3f +``` + + + + ### Get a security group Get the details of a Security Group with the given ID. @@ -1123,6 +1322,37 @@ scw instance security-group get a3244331-5d32-4e36-9bf9-b60233e201c7 +### Get rule + +Get details of a security group rule with the given ID. + +**Usage:** + +``` +scw instance security-group get-rule [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| security-group-id | Required | | +| security-group-rule-id | Required | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + +**Examples:** + + +Get details of a security group rule with the given ID +``` +scw instance security-group get-rule security-group-id=d900fa38-2f0d-4b09-b6d7-f3e46a13f34c security-group-rule-id=1f9a16a5-7229-4c03-9327-253e257cf38a +``` + + + + ### List security groups List all security groups available in an account. @@ -1157,6 +1387,75 @@ scw instance security-group list name=foobar +### Get default rules + +Lists the default rules applied to all the security groups. + +**Usage:** + +``` +scw instance security-group list-default-rules [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + +### List rules + +List rules. + +**Usage:** + +``` +scw instance security-group list-rules [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| security-group-id | Required | UUID of the security group | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2`, `all` | Zone to target. If none is passed will use default zone from the config | + + + +### Update all the rules of a security group + +Replaces the rules of the security group with the rules provided. This endpoint supports the update of existing rules, creation of new rules and deletion of existing rules when they are not passed in the request. + +**Usage:** + +``` +scw instance security-group set-rules [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| security-group-id | Required | UUID of the security group to update the rules on | +| rules.{index}.id | | UUID of the security rule to update. If no value is provided, a new rule will be created | +| rules.{index}.action | One of: `accept`, `drop` | Action to apply when the rule matches a packet | +| rules.{index}.protocol | One of: `TCP`, `UDP`, `ICMP`, `ANY` | Protocol family this rule applies to | +| rules.{index}.direction | One of: `inbound`, `outbound` | Direction the rule applies to | +| rules.{index}.ip-range | | The range of IP address this rules applies to | +| rules.{index}.dest-port-from | | Beginning of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY | +| rules.{index}.dest-port-to | | End of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY, or if it is equal to dest_port_from | +| rules.{index}.position | | Position of this rule in the security group rules list. If several rules are passed with the same position, the resulting order is undefined | +| rules.{index}.editable | | Indicates if this rule is editable. Rules with the value false will be ignored | +| rules.{index}.zone | | Zone of the rule. This field is ignored | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + ### Update security group Update security group. @@ -1628,6 +1927,26 @@ scw instance server list name=server1 +### List server actions + +List all actions that can currently be performed on a server. + +**Usage:** + +``` +scw instance server list-actions [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| server-id | Required | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + ### Reboot server @@ -1947,6 +2266,25 @@ Each of these types will contains all the features of the instance (CPU, RAM, St +### Get availability + +Get availability for all server types. + +**Usage:** + +``` +scw instance server-type get [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `pl-waw-1`, `pl-waw-2` | Zone to target. If none is passed will use default zone from the config | + + + ### List server types Get server types technical details. diff --git a/internal/namespaces/instance/v1/instance_cli.go b/internal/namespaces/instance/v1/instance_cli.go index 21be1c4bfb..600fe1b3a0 100644 --- a/internal/namespaces/instance/v1/instance_cli.go +++ b/internal/namespaces/instance/v1/instance_cli.go @@ -31,11 +31,13 @@ func GetGeneratedCommands() *core.Commands { instanceUserData(), instanceVolume(), instancePrivateNic(), + instanceServerTypeGet(), instanceServerTypeList(), instanceVolumeTypeList(), instanceServerList(), instanceServerGet(), instanceServerUpdate(), + instanceServerListActions(), instanceUserDataList(), instanceUserDataDelete(), instanceUserDataSet(), @@ -58,11 +60,21 @@ func GetGeneratedCommands() *core.Commands { instanceSecurityGroupCreate(), instanceSecurityGroupGet(), instanceSecurityGroupDelete(), + instanceSecurityGroupListDefaultRules(), + instanceSecurityGroupListRules(), + instanceSecurityGroupCreateRule(), + instanceSecurityGroupSetRules(), + instanceSecurityGroupDeleteRule(), + instanceSecurityGroupGetRule(), instancePlacementGroupList(), instancePlacementGroupCreate(), instancePlacementGroupGet(), + instancePlacementGroupSet(), instancePlacementGroupUpdate(), instancePlacementGroupDelete(), + instancePlacementGroupGetServers(), + instancePlacementGroupSetServers(), + instancePlacementGroupUpdateServers(), instanceIPList(), instanceIPCreate(), instanceIPGet(), @@ -309,6 +321,29 @@ server to a network. } } +func instanceServerTypeGet() *core.Command { + return &core.Command{ + Short: `Get availability`, + Long: `Get availability for all server 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.ZonePlWaw1, scw.ZonePlWaw2), + }, + 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 server types`, @@ -754,6 +789,35 @@ func instanceServerUpdate() *core.Command { } } +func instanceServerListActions() *core.Command { + return &core.Command{ + Short: `List server actions`, + Long: `List all actions that can currently be performed on a server.`, + 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.ZonePlWaw1, scw.ZonePlWaw2), + }, + 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`, @@ -2128,6 +2192,367 @@ func instanceSecurityGroupDelete() *core.Command { } } +func instanceSecurityGroupListDefaultRules() *core.Command { + return &core.Command{ + Short: `Get default rules`, + Long: `Lists the default rules applied to all the security groups.`, + Namespace: "instance", + Resource: "security-group", + Verb: "list-default-rules", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.ListDefaultSecurityGroupRulesRequest{}), + ArgSpecs: core.ArgSpecs{ + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.ListDefaultSecurityGroupRulesRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.ListDefaultSecurityGroupRules(request) + + }, + } +} + +func instanceSecurityGroupListRules() *core.Command { + return &core.Command{ + Short: `List rules`, + Long: `List rules.`, + Namespace: "instance", + Resource: "security-group", + Verb: "list-rules", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.ListSecurityGroupRulesRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "security-group-id", + Short: `UUID of the security group`, + Required: true, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, 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.(*instance.ListSecurityGroupRulesRequest) + + 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.ListSecurityGroupRules(request, opts...) + if err != nil { + return nil, err + } + return resp.Rules, nil + + }, + } +} + +func instanceSecurityGroupCreateRule() *core.Command { + return &core.Command{ + Short: `Create rule`, + Long: `Create rule.`, + Namespace: "instance", + Resource: "security-group", + Verb: "create-rule", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.CreateSecurityGroupRuleRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "security-group-id", + Short: `UUID of the security group`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "protocol", + Required: true, + Deprecated: false, + Positional: false, + EnumValues: []string{"TCP", "UDP", "ICMP", "ANY"}, + }, + { + Name: "direction", + Required: true, + Deprecated: false, + Positional: false, + EnumValues: []string{"inbound", "outbound"}, + }, + { + Name: "action", + Required: true, + Deprecated: false, + Positional: false, + EnumValues: []string{"accept", "drop"}, + }, + { + Name: "ip-range", + Required: true, + Deprecated: false, + Positional: false, + Default: core.DefaultValueSetter("0.0.0.0/0"), + }, + { + Name: "dest-port-from", + Short: `The beginning of the range of ports to apply this rule to (inclusive)`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "dest-port-to", + Short: `The end of the range of ports to apply this rule to (inclusive)`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "position", + Short: `The position of this rule in the security group rules list`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "editable", + Short: `Indicates if this rule is editable (will be ignored)`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.CreateSecurityGroupRuleRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.CreateSecurityGroupRule(request) + + }, + Examples: []*core.Example{ + { + Short: "Allow incoming SSH", + ArgsJSON: `{"action":"accept","dest_port_from":22,"direction":"inbound","protocol":"TCP","security_group_id":"1248283f-17de-464a-b03b-3f975ada3fa8"}`, + }, + { + Short: "Allow HTTP", + ArgsJSON: `{"action":"accept","dest_port_from":80,"direction":"inbound","protocol":"TCP","security_group_id":"e8ba77c1-9ccb-4c0c-b08d-555cfd7f57e4"}`, + }, + { + Short: "Allow HTTPS", + ArgsJSON: `{"action":"accept","dest_port_from":443,"direction":"inbound","protocol":"TCP","security_group_id":"e5906437-8650-4fe2-8ca7-32e1d7320c1b"}`, + }, + { + Short: "Allow a specific IP range", + ArgsJSON: `{"action":"accept","direction":"inbound","ip_range":"10.0.0.0/16","protocol":"ANY","security_group_id":"b6a58155-a2f8-48bd-9da9-3ff9783fa0d4"}`, + }, + { + Short: "Allow FTP", + ArgsJSON: `{"action":"accept","dest_port_from":20,"dest_port_to":21,"direction":"inbound","protocol":"TCP","security_group_id":"9c46df03-83c2-46fb-936c-16ecb44860e1"}`, + }, + }, + } +} + +func instanceSecurityGroupSetRules() *core.Command { + return &core.Command{ + Short: `Update all the rules of a security group`, + Long: `Replaces the rules of the security group with the rules provided. This endpoint supports the update of existing rules, creation of new rules and deletion of existing rules when they are not passed in the request.`, + Namespace: "instance", + Resource: "security-group", + Verb: "set-rules", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.SetSecurityGroupRulesRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "security-group-id", + Short: `UUID of the security group to update the rules on`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.id", + Short: `UUID of the security rule to update. If no value is provided, a new rule will be created`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.action", + Short: `Action to apply when the rule matches a packet`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"accept", "drop"}, + }, + { + Name: "rules.{index}.protocol", + Short: `Protocol family this rule applies to`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"TCP", "UDP", "ICMP", "ANY"}, + }, + { + Name: "rules.{index}.direction", + Short: `Direction the rule applies to`, + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"inbound", "outbound"}, + }, + { + Name: "rules.{index}.ip-range", + Short: `The range of IP address this rules applies to`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.dest-port-from", + Short: `Beginning of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.dest-port-to", + Short: `End of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY, or if it is equal to dest_port_from`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.position", + Short: `Position of this rule in the security group rules list. If several rules are passed with the same position, the resulting order is undefined`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.editable", + Short: `Indicates if this rule is editable. Rules with the value false will be ignored`, + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "rules.{index}.zone", + Short: `Zone of the rule. This field is ignored`, + Required: false, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.SetSecurityGroupRulesRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.SetSecurityGroupRules(request) + + }, + } +} + +func instanceSecurityGroupDeleteRule() *core.Command { + return &core.Command{ + Short: `Delete rule`, + Long: `Delete a security group rule with the given ID.`, + Namespace: "instance", + Resource: "security-group", + Verb: "delete-rule", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.DeleteSecurityGroupRuleRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "security-group-id", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "security-group-rule-id", + Required: true, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.DeleteSecurityGroupRuleRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + e = api.DeleteSecurityGroupRule(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "security-group", + Verb: "delete-rule", + }, nil + }, + Examples: []*core.Example{ + { + Short: "Delete a Security Group Rule with the given ID", + ArgsJSON: `{"security_group_id":"a01a36e5-5c0c-42c1-ae06-167e587b7ac4","security_group_rule_id":"b8c773ef-a6ea-4b50-a7c1-737864290a3f"}`, + }, + }, + } +} + +func instanceSecurityGroupGetRule() *core.Command { + return &core.Command{ + Short: `Get rule`, + Long: `Get details of a security group rule with the given ID.`, + Namespace: "instance", + Resource: "security-group", + Verb: "get-rule", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.GetSecurityGroupRuleRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "security-group-id", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "security-group-rule-id", + Required: true, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.GetSecurityGroupRuleRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.GetSecurityGroupRule(request) + + }, + Examples: []*core.Example{ + { + Short: "Get details of a security group rule with the given ID", + ArgsJSON: `{"security_group_id":"d900fa38-2f0d-4b09-b6d7-f3e46a13f34c","security_group_rule_id":"1f9a16a5-7229-4c03-9327-253e257cf38a"}`, + }, + }, + } +} + func instancePlacementGroupList() *core.Command { return &core.Command{ Short: `List placement groups`, @@ -2316,6 +2741,63 @@ func instancePlacementGroupGet() *core.Command { } } +func instancePlacementGroupSet() *core.Command { + return &core.Command{ + Short: `Set placement group`, + Long: `Set all parameters of the given placement group.`, + Namespace: "instance", + Resource: "placement-group", + Verb: "set", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.SetPlacementGroupRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "placement-group-id", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "name", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "policy-mode", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"optional", "enforced"}, + }, + { + Name: "policy-type", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"max_availability", "low_latency"}, + }, + core.ProjectArgSpec(), + { + Name: "tags.{index}", + Required: false, + Deprecated: false, + Positional: false, + }, + core.OrganizationArgSpec(), + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.SetPlacementGroupRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.SetPlacementGroup(request) + + }, + } +} + func instancePlacementGroupUpdate() *core.Command { return &core.Command{ Short: `Update a placement group`, @@ -2436,6 +2918,112 @@ func instancePlacementGroupDelete() *core.Command { } } +func instancePlacementGroupGetServers() *core.Command { + return &core.Command{ + Short: `Get placement group servers`, + Long: `Get all servers belonging to the given placement group.`, + Namespace: "instance", + Resource: "placement-group", + Verb: "get-servers", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.GetPlacementGroupServersRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "placement-group-id", + Required: true, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.GetPlacementGroupServersRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.GetPlacementGroupServers(request) + + }, + } +} + +func instancePlacementGroupSetServers() *core.Command { + return &core.Command{ + Short: `Set placement group servers`, + Long: `Set all servers belonging to the given placement group.`, + Namespace: "instance", + Resource: "placement-group", + Verb: "set-servers", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.SetPlacementGroupServersRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "placement-group-id", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "servers.{index}", + Required: false, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.SetPlacementGroupServersRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.SetPlacementGroupServers(request) + + }, + Examples: []*core.Example{ + { + Short: "Update the complete set of instances in a given placement group. (All instances must be down)", + ArgsJSON: `{"placement_group_id":"ced0fd4d-bcf0-4479-85b6-7027e54456e6","servers":["5a250608-24ec-4c31-9631-b3ded8c861cb","e54fd249-0787-4794-ab14-af6ee74df274"]}`, + }, + }, + } +} + +func instancePlacementGroupUpdateServers() *core.Command { + return &core.Command{ + Short: `Update placement group servers`, + Long: `Update all servers belonging to the given placement group.`, + Namespace: "instance", + Resource: "placement-group", + Verb: "update-servers", + // Deprecated: false, + ArgsType: reflect.TypeOf(instance.UpdatePlacementGroupServersRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "placement-group-id", + Short: `UUID of the placement group`, + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "servers.{index}", + Required: true, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*instance.UpdatePlacementGroupServersRequest) + + client := core.ExtractClient(ctx) + api := instance.NewAPI(client) + return api.UpdatePlacementGroupServers(request) + + }, + } +} + func instanceIPList() *core.Command { return &core.Command{ Short: `List all flexible IPs`,