Skip to content

Commit

Permalink
feat(account): migrate to v3 api (#3291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax committed Jul 17, 2023
1 parent 60be459 commit 0dacbb8
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Deprecated in favor of Account API v3.
Generate a new Project for an Organization, specifying its configuration including name and description.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Deprecated in favor of Account API v3.
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.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Deprecated in favor of Account API v3.
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.

USAGE:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Deprecated in favor of Account API v3.
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.
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.

USAGE:
scw account project list [arg=value ...]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Deprecated in favor of Account API v3.
Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.

USAGE:
Expand Down
2 changes: 1 addition & 1 deletion cmd/scw/testdata/test-main-usage-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USAGE:
scw <command>

AVAILABLE COMMANDS:
account User related data
account This API allows you to manage projects
apple-silicon Apple silicon API
autocomplete Autocomplete related commands
baremetal Elastic Metal API
Expand Down
7 changes: 1 addition & 6 deletions docs/commands/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Project management commands.

### Create a new Project for an Organization

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

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

### Delete an existing Project

Deprecated in favor of Account API v3.
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.

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

### Get an existing Project

Deprecated in favor of Account API v3.
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.

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

### List all Projects of an Organization

Deprecated in favor of Account API v3.
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.
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.

**Usage:**

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

### Update Project

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

**Usage:**
Expand Down
9 changes: 9 additions & 0 deletions internal/namespaces/account/v3/custom.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package account

import "github.com/scaleway/scaleway-cli/v2/internal/core"

func GetCommands() *core.Commands {
cmds := GetGeneratedCommands()

return cmds
}
4 changes: 2 additions & 2 deletions internal/namespaces/get_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

"github.com/scaleway/scaleway-cli/v2/internal/core"
accountv2 "github.com/scaleway/scaleway-cli/v2/internal/namespaces/account/v2"
accountv3 "github.com/scaleway/scaleway-cli/v2/internal/namespaces/account/v3"
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/alias"
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
autocompleteNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/autocomplete"
Expand Down Expand Up @@ -61,7 +61,7 @@ func GetCommands() *core.Commands {
marketplace.GetCommands(),
initNamespace.GetCommands(),
configNamespace.GetCommands(),
accountv2.GetCommands(),
accountv3.GetCommands(),
autocompleteNamespace.GetCommands(),
object.GetCommands(),
versionNamespace.GetCommands(),
Expand Down
6 changes: 3 additions & 3 deletions internal/namespaces/init/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/interactive"
"github.com/scaleway/scaleway-cli/v2/internal/terminal"
"github.com/scaleway/scaleway-sdk-go/api/account/v2"
"github.com/scaleway/scaleway-sdk-go/api/account/v3"
"github.com/scaleway/scaleway-sdk-go/logger"
"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/scaleway/scaleway-sdk-go/validation"
Expand Down Expand Up @@ -54,9 +54,9 @@ func promptProjectID(ctx context.Context, accessKey string, secretKey string, or
}

client := core.ExtractClient(ctx)
api := account.NewAPI(client)
api := account.NewProjectAPI(client)

res, err := api.ListProjects(&account.ListProjectsRequest{
res, err := api.ListProjects(&account.ProjectAPIListProjectsRequest{
OrganizationID: organizationID,
}, scw.WithAllPages(), scw.WithContext(ctx), scw.WithAuthRequest(accessKey, secretKey))
if err != nil {
Expand Down

0 comments on commit 0dacbb8

Please sign in to comment.