Skip to content

Commit dfb6545

Browse files
scaleway-botLaure-di
authored andcommitted
feat(instance): add support for scw instance server get-compatible-types (scaleway#4561)
1 parent 0c8d896 commit dfb6545

File tree

6 files changed

+113
-25
lines changed

6 files changed

+113
-25
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Get compatible commercial types that can be used to update the Instance. The compatibility of an Instance offer is based on:
4+
* the CPU architecture
5+
* the OS type
6+
* the required l_ssd storage size
7+
* the required scratch storage size
8+
If the specified Instance offer is flagged as end of service, the best compatible offer is the first returned.
9+
10+
USAGE:
11+
scw instance server get-compatible-types <server-id ...> [arg=value ...]
12+
13+
ARGS:
14+
server-id UUID of the Instance you want to get
15+
[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 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3)
16+
17+
FLAGS:
18+
-h, --help help for get-compatible-types
19+
20+
GLOBAL FLAGS:
21+
-c, --config string The path to the config file
22+
-D, --debug Enable debug mode
23+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
24+
-p, --profile string The config profile to use
25+
--web open console page for the current ressource

cmd/scw/testdata/test-all-usage-instance-server-usage.golden

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,31 @@ USAGE:
88
scw instance server <command>
99

1010
AVAILABLE COMMANDS:
11-
action Perform a raw API action on a server
12-
attach-ip Attach an IP to a server
13-
attach-volume Attach a volume to a server
14-
backup Backup server
15-
console Connect to the serial console of an instance
16-
create Create server
17-
delete Delete server
18-
detach-ip Detach an IP from a server
19-
detach-volume Detach a volume from its server
20-
enable-routed-ip Migrate server to IP mobility
21-
get Get an Instance
22-
get-rdp-password Get your server rdp password and decrypt it using your ssh key
23-
list List all Instances
24-
list-actions List Instance actions
25-
reboot Reboot server
26-
ssh SSH into a server
27-
standby Put server in standby mode
28-
start Power on server
29-
stop Power off server
30-
terminate Terminate server
31-
update Update an Instance
11+
action Perform a raw API action on a server
12+
attach-ip Attach an IP to a server
13+
attach-volume Attach a volume to a server
14+
backup Backup server
15+
console Connect to the serial console of an instance
16+
create Create server
17+
delete Delete server
18+
detach-ip Detach an IP from a server
19+
detach-volume Detach a volume from its server
20+
enable-routed-ip Migrate server to IP mobility
21+
get Get an Instance
22+
get-compatible-types Get Instance compatible types
23+
get-rdp-password Get your server rdp password and decrypt it using your ssh key
24+
list List all Instances
25+
list-actions List Instance actions
26+
reboot Reboot server
27+
ssh SSH into a server
28+
standby Put server in standby mode
29+
start Power on server
30+
stop Power off server
31+
terminate Terminate server
32+
update Update an Instance
3233

3334
WORKFLOW COMMANDS:
34-
wait Wait for server to reach a stable state
35+
wait Wait for server to reach a stable state
3536

3637
FLAGS:
3738
-h, --help help for server

docs/commands/instance.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ This API allows you to manage your Instances.
6060
- [Detach a volume from its server](#detach-a-volume-from-its-server)
6161
- [Migrate server to IP mobility](#migrate-server-to-ip-mobility)
6262
- [Get an Instance](#get-an-instance)
63+
- [Get Instance compatible types](#get-instance-compatible-types)
6364
- [Get your server rdp password and decrypt it using your ssh key](#get-your-server-rdp-password-and-decrypt-it-using-your-ssh-key)
6465
- [List all Instances](#list-all-instances)
6566
- [List Instance actions](#list-instance-actions)
@@ -1941,6 +1942,31 @@ scw instance server get 94ededdf-358d-4019-9886-d754f8a2e78d
19411942

19421943

19431944

1945+
### Get Instance compatible types
1946+
1947+
Get compatible commercial types that can be used to update the Instance. The compatibility of an Instance offer is based on:
1948+
* the CPU architecture
1949+
* the OS type
1950+
* the required l_ssd storage size
1951+
* the required scratch storage size
1952+
If the specified Instance offer is flagged as end of service, the best compatible offer is the first returned.
1953+
1954+
**Usage:**
1955+
1956+
```
1957+
scw instance server get-compatible-types <server-id ...> [arg=value ...]
1958+
```
1959+
1960+
1961+
**Args:**
1962+
1963+
| Name | | Description |
1964+
|------|---|-------------|
1965+
| server-id | Required | UUID of the Instance you want to get |
1966+
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config |
1967+
1968+
1969+
19441970
### Get your server rdp password and decrypt it using your ssh key
19451971

19461972

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/mattn/go-isatty v0.0.20
2626
github.com/moby/buildkit v0.13.2
2727
github.com/opencontainers/go-digest v1.0.0
28-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250227160344-4d0065cc52da
28+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250303152806-55c4ed050ada
2929
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
3030
github.com/spf13/cobra v1.9.1
3131
github.com/spf13/pflag v1.0.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
458458
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
459459
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
460460
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
461-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250227160344-4d0065cc52da h1:2l4es/nkKYzsuMQl4JnrJDBCZKM+yfBzVlr5SpuajaU=
462-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250227160344-4d0065cc52da/go.mod h1:792k1RTU+5JeMXm35/e2Wgp71qPH/DmDoZrRc+EFZDk=
461+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250303152806-55c4ed050ada h1:jY2pM9GG2D3xSAtE73+CNuHEjyhTW0XhN5fU4CMdWIM=
462+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.32.0.20250303152806-55c4ed050ada/go.mod h1:792k1RTU+5JeMXm35/e2Wgp71qPH/DmDoZrRc+EFZDk=
463463
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
464464
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
465465
github.com/secure-systems-lab/go-securesystemslib v0.8.0 h1:mr5An6X45Kb2nddcFlbmfHkLguCE9laoZCUzEEpIZXA=

internal/namespaces/instance/v1/instance_cli.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func GetGeneratedCommands() *core.Commands {
4242
instanceUserDataDelete(),
4343
instanceUserDataSet(),
4444
instanceUserDataGet(),
45+
instanceServerGetCompatibleTypes(),
4546
instanceImageList(),
4647
instanceImageGet(),
4748
instanceImageCreate(),
@@ -958,6 +959,41 @@ func instanceUserDataGet() *core.Command {
958959
}
959960
}
960961

962+
func instanceServerGetCompatibleTypes() *core.Command {
963+
return &core.Command{
964+
Short: `Get Instance compatible types`,
965+
Long: `Get compatible commercial types that can be used to update the Instance. The compatibility of an Instance offer is based on:
966+
* the CPU architecture
967+
* the OS type
968+
* the required l_ssd storage size
969+
* the required scratch storage size
970+
If the specified Instance offer is flagged as end of service, the best compatible offer is the first returned.`,
971+
Namespace: "instance",
972+
Resource: "server",
973+
Verb: "get-compatible-types",
974+
// Deprecated: false,
975+
ArgsType: reflect.TypeOf(instance.GetServerCompatibleTypesRequest{}),
976+
ArgSpecs: core.ArgSpecs{
977+
{
978+
Name: "server-id",
979+
Short: `UUID of the Instance you want to get`,
980+
Required: true,
981+
Deprecated: false,
982+
Positional: true,
983+
},
984+
core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3),
985+
},
986+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
987+
request := args.(*instance.GetServerCompatibleTypesRequest)
988+
989+
client := core.ExtractClient(ctx)
990+
api := instance.NewAPI(client)
991+
return api.GetServerCompatibleTypes(request)
992+
993+
},
994+
}
995+
}
996+
961997
func instanceImageList() *core.Command {
962998
return &core.Command{
963999
Short: `List Instance images`,

0 commit comments

Comments
 (0)