Skip to content

Commit

Permalink
feat(account/v3): add support for account/v3 (#3289)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot committed Jul 17, 2023
1 parent fb5705d commit 60be459
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/moby/buildkit v0.11.6
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230710160943-efc922e1f661
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.19.0.20230717114303-9b6e07d6384b
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230710160943-efc922e1f661 h1:/FNBbwxEzMriXGudqXTGOg0nIeNO+0xpqXChZk6auBE=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230710160943-efc922e1f661/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.19.0.20230717114303-9b6e07d6384b h1:b5kG1Uzb4Fst6BoLXsgowQHj6WOkECIj+UkM1YwTIQY=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.19.0.20230717114303-9b6e07d6384b/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
223 changes: 223 additions & 0 deletions internal/namespaces/account/v3/account_cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.

package account

import (
"context"
"reflect"

"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/account/v3"
"github.com/scaleway/scaleway-sdk-go/scw"
)

// always import dependencies
var (
_ = scw.RegionFrPar
)

func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
accountRoot(),
accountProject(),
accountProjectCreate(),
accountProjectList(),
accountProjectGet(),
accountProjectDelete(),
accountProjectUpdate(),
)
}
func accountRoot() *core.Command {
return &core.Command{
Short: `This API allows you to manage projects`,
Long: `This API allows you to manage projects.`,
Namespace: "account",
}
}

func accountProject() *core.Command {
return &core.Command{
Short: `Project management commands`,
Long: `Project management commands.`,
Namespace: "account",
Resource: "project",
}
}

func accountProjectCreate() *core.Command {
return &core.Command{
Short: `Create a new Project for an Organization`,
Long: `Generate a new Project for an Organization, specifying its configuration including name and description.`,
Namespace: "account",
Resource: "project",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(account.ProjectAPICreateProjectRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name of the Project`,
Required: false,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("proj"),
},
{
Name: "description",
Short: `Description of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.ProjectAPICreateProjectRequest)

client := core.ExtractClient(ctx)
api := account.NewProjectAPI(client)
return api.CreateProject(request)

},
}
}

func accountProjectList() *core.Command {
return &core.Command{
Short: `List all Projects of an Organization`,
Long: `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.`,
Namespace: "account",
Resource: "project",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(account.ProjectAPIListProjectsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "name",
Short: `Name of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order-by",
Short: `Sort order of the returned Projects`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"},
},
{
Name: "project-ids.{index}",
Short: `Project IDs to filter for. The results will be limited to any Projects with an ID in this array`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.ProjectAPIListProjectsRequest)

client := core.ExtractClient(ctx)
api := account.NewProjectAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
resp, err := api.ListProjects(request, opts...)
if err != nil {
return nil, err
}
return resp.Projects, nil

},
}
}

func accountProjectGet() *core.Command {
return &core.Command{
Short: `Get an existing Project`,
Long: `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.`,
Namespace: "account",
Resource: "project",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(account.ProjectAPIGetProjectRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.ProjectAPIGetProjectRequest)

client := core.ExtractClient(ctx)
api := account.NewProjectAPI(client)
return api.GetProject(request)

},
}
}

func accountProjectDelete() *core.Command {
return &core.Command{
Short: `Delete an existing Project`,
Long: `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.`,
Namespace: "account",
Resource: "project",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(account.ProjectAPIDeleteProjectRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.ProjectAPIDeleteProjectRequest)

client := core.ExtractClient(ctx)
api := account.NewProjectAPI(client)
e = api.DeleteProject(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "project",
Verb: "delete",
}, nil
},
}
}

func accountProjectUpdate() *core.Command {
return &core.Command{
Short: `Update Project`,
Long: `Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.`,
Namespace: "account",
Resource: "project",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(account.ProjectAPIUpdateProjectRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "name",
Short: `Name of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "description",
Short: `Description of the Project`,
Required: false,
Deprecated: false,
Positional: false,
},
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*account.ProjectAPIUpdateProjectRequest)

client := core.ExtractClient(ctx)
api := account.NewProjectAPI(client)
return api.UpdateProject(request)

},
}
}

0 comments on commit 60be459

Please sign in to comment.