Skip to content

Commit 0dacbb8

Browse files
authored
feat(account): migrate to v3 api (#3291)
1 parent 60be459 commit 0dacbb8

10 files changed

+17
-18
lines changed

cmd/scw/testdata/test-all-usage-account-project-create-usage.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Deprecated in favor of Account API v3.
43
Generate a new Project for an Organization, specifying its configuration including name and description.
54

65
USAGE:

cmd/scw/testdata/test-all-usage-account-project-delete-usage.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Deprecated in favor of Account API v3.
43
Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone.
54

65
USAGE:

cmd/scw/testdata/test-all-usage-account-project-get-usage.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Deprecated in favor of Account API v3.
43
Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object.
54

65
USAGE:

cmd/scw/testdata/test-all-usage-account-project-list-usage.golden

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Deprecated in favor of Account API v3.
4-
List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names and IDs. Other information include the creation and update date of the Project.
3+
List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names, and IDs. Other information includes the creation and update date of the Project.
54

65
USAGE:
76
scw account project list [arg=value ...]

cmd/scw/testdata/test-all-usage-account-project-update-usage.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Deprecated in favor of Account API v3.
43
Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.
54

65
USAGE:

cmd/scw/testdata/test-main-usage-usage.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ USAGE:
44
scw <command>
55

66
AVAILABLE COMMANDS:
7-
account User related data
7+
account This API allows you to manage projects
88
apple-silicon Apple silicon API
99
autocomplete Autocomplete related commands
1010
baremetal Elastic Metal API

docs/commands/account.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Project management commands.
1717

1818
### Create a new Project for an Organization
1919

20-
Deprecated in favor of Account API v3.
2120
Generate a new Project for an Organization, specifying its configuration including name and description.
2221

2322
**Usage:**
@@ -39,7 +38,6 @@ scw account project create [arg=value ...]
3938

4039
### Delete an existing Project
4140

42-
Deprecated in favor of Account API v3.
4341
Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone.
4442

4543
**Usage:**
@@ -59,7 +57,6 @@ scw account project delete [arg=value ...]
5957

6058
### Get an existing Project
6159

62-
Deprecated in favor of Account API v3.
6360
Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object.
6461

6562
**Usage:**
@@ -79,8 +76,7 @@ scw account project get [arg=value ...]
7976

8077
### List all Projects of an Organization
8178

82-
Deprecated in favor of Account API v3.
83-
List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names and IDs. Other information include the creation and update date of the Project.
79+
List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names, and IDs. Other information includes the creation and update date of the Project.
8480

8581
**Usage:**
8682

@@ -102,7 +98,6 @@ scw account project list [arg=value ...]
10298

10399
### Update Project
104100

105-
Deprecated in favor of Account API v3.
106101
Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.
107102

108103
**Usage:**
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package account
2+
3+
import "github.com/scaleway/scaleway-cli/v2/internal/core"
4+
5+
func GetCommands() *core.Commands {
6+
cmds := GetGeneratedCommands()
7+
8+
return cmds
9+
}

internal/namespaces/get_commands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"os"
55

66
"github.com/scaleway/scaleway-cli/v2/internal/core"
7-
accountv2 "github.com/scaleway/scaleway-cli/v2/internal/namespaces/account/v2"
7+
accountv3 "github.com/scaleway/scaleway-cli/v2/internal/namespaces/account/v3"
88
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/alias"
99
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
1010
autocompleteNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/autocomplete"
@@ -61,7 +61,7 @@ func GetCommands() *core.Commands {
6161
marketplace.GetCommands(),
6262
initNamespace.GetCommands(),
6363
configNamespace.GetCommands(),
64-
accountv2.GetCommands(),
64+
accountv3.GetCommands(),
6565
autocompleteNamespace.GetCommands(),
6666
object.GetCommands(),
6767
versionNamespace.GetCommands(),

internal/namespaces/init/prompt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/scaleway/scaleway-cli/v2/internal/core"
99
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
1010
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
11-
"github.com/scaleway/scaleway-sdk-go/api/account/v2"
11+
"github.com/scaleway/scaleway-sdk-go/api/account/v3"
1212
"github.com/scaleway/scaleway-sdk-go/logger"
1313
"github.com/scaleway/scaleway-sdk-go/scw"
1414
"github.com/scaleway/scaleway-sdk-go/validation"
@@ -54,9 +54,9 @@ func promptProjectID(ctx context.Context, accessKey string, secretKey string, or
5454
}
5555

5656
client := core.ExtractClient(ctx)
57-
api := account.NewAPI(client)
57+
api := account.NewProjectAPI(client)
5858

59-
res, err := api.ListProjects(&account.ListProjectsRequest{
59+
res, err := api.ListProjects(&account.ProjectAPIListProjectsRequest{
6060
OrganizationID: organizationID,
6161
}, scw.WithAllPages(), scw.WithContext(ctx), scw.WithAuthRequest(accessKey, secretKey))
6262
if err != nil {

0 commit comments

Comments
 (0)