From f13fef2238cec0388687c4b5d020fc4c9355335c Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 21 Nov 2023 17:35:40 +0000 Subject: [PATCH] feat: update generated APIs --- ...-usage-iam-application-create-usage.golden | 1 + ...ll-usage-iam-application-list-usage.golden | 1 + ...-usage-iam-application-update-usage.golden | 1 + ...st-all-usage-iam-group-create-usage.golden | 1 + ...test-all-usage-iam-group-list-usage.golden | 1 + ...st-all-usage-iam-group-update-usage.golden | 7 +- ...t-all-usage-iam-policy-create-usage.golden | 1 + ...est-all-usage-iam-policy-list-usage.golden | 1 + ...t-all-usage-iam-policy-update-usage.golden | 1 + ...est-all-usage-iam-user-create-usage.golden | 1 + .../test-all-usage-iam-user-list-usage.golden | 1 + docs/commands/iam.md | 11 + go.mod | 2 +- go.sum | 4 +- internal/namespaces/jobs/v1alpha1/jobs_cli.go | 469 ++++++++++++++++++ 15 files changed, 497 insertions(+), 6 deletions(-) create mode 100644 internal/namespaces/jobs/v1alpha1/jobs_cli.go diff --git a/cmd/scw/testdata/test-all-usage-iam-application-create-usage.golden b/cmd/scw/testdata/test-all-usage-iam-application-create-usage.golden index 5c179c758c..e06bb5d710 100644 --- a/cmd/scw/testdata/test-all-usage-iam-application-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-application-create-usage.golden @@ -8,6 +8,7 @@ USAGE: ARGS: name= Name of the application to create (max length is 64 characters) [description] Description of the application (max length is 200 characters) + [tags.{index}] Tags associated with the application (maximum of 10 tags) [organization-id] Organization ID to use. If none is passed the default organization ID will be used FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-iam-application-list-usage.golden b/cmd/scw/testdata/test-all-usage-iam-application-list-usage.golden index 352d6fc8b6..67412feac1 100644 --- a/cmd/scw/testdata/test-all-usage-iam-application-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-application-list-usage.golden @@ -10,6 +10,7 @@ ARGS: [name] Name of the application to filter [editable] Defines whether to filter out editable applications or not [application-ids.{index}] Filter by list of IDs + [tag] Filter by tags containing a given string [organization-id=] Organization ID to use. If none is passed the default organization ID will be used FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-iam-application-update-usage.golden b/cmd/scw/testdata/test-all-usage-iam-application-update-usage.golden index 56a129cc95..b26a216522 100644 --- a/cmd/scw/testdata/test-all-usage-iam-application-update-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-application-update-usage.golden @@ -9,6 +9,7 @@ ARGS: application-id ID of the application to update [name] New name for the application (max length is 64 chars) [description] New description for the application (max length is 200 chars) + [tags.{index}] New tags for the application (maximum of 10 tags) FLAGS: -h, --help help for update diff --git a/cmd/scw/testdata/test-all-usage-iam-group-create-usage.golden b/cmd/scw/testdata/test-all-usage-iam-group-create-usage.golden index 64c9e993c3..607f9641cf 100644 --- a/cmd/scw/testdata/test-all-usage-iam-group-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-group-create-usage.golden @@ -12,6 +12,7 @@ EXAMPLES: ARGS: name= Name of the group to create (max length is 64 chars). MUST be unique inside an Organization [description] Description of the group to create (max length is 200 chars) + [tags.{index}] Tags associated with the group (maximum of 10 tags) [organization-id] Organization ID to use. If none is passed the default organization ID will be used FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-iam-group-list-usage.golden b/cmd/scw/testdata/test-all-usage-iam-group-list-usage.golden index 9914cde11b..d83f802426 100644 --- a/cmd/scw/testdata/test-all-usage-iam-group-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-group-list-usage.golden @@ -11,6 +11,7 @@ ARGS: [application-ids.{index}] Filter by a list of application IDs [user-ids.{index}] Filter by a list of user IDs [group-ids.{index}] Filter by a list of group IDs + [tag] Filter by tags containing a given string [organization-id=] Organization ID to use. If none is passed the default organization ID will be used FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-iam-group-update-usage.golden b/cmd/scw/testdata/test-all-usage-iam-group-update-usage.golden index e198f86c11..e6f2f5eb8d 100644 --- a/cmd/scw/testdata/test-all-usage-iam-group-update-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-group-update-usage.golden @@ -6,9 +6,10 @@ USAGE: scw iam group update [arg=value ...] ARGS: - group-id ID of the group to update - [name] New name for the group (max length is 64 chars). MUST be unique inside an Organization - [description] New description for the group (max length is 200 chars) + group-id ID of the group to update + [name] New name for the group (max length is 64 chars). MUST be unique inside an Organization + [description] New description for the group (max length is 200 chars) + [tags.{index}] New tags for the group (maximum of 10 tags) FLAGS: -h, --help help for update diff --git a/cmd/scw/testdata/test-all-usage-iam-policy-create-usage.golden b/cmd/scw/testdata/test-all-usage-iam-policy-create-usage.golden index 04e14d82bb..5713db717c 100644 --- a/cmd/scw/testdata/test-all-usage-iam-policy-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-policy-create-usage.golden @@ -15,6 +15,7 @@ ARGS: [rules.{index}.permission-set-names.{index}] Names of permission sets bound to the rule [rules.{index}.project-ids.{index}] List of Project IDs the rule is scoped to [rules.{index}.organization-id] ID of Organization the rule is scoped to + [tags.{index}] Tags associated with the policy (maximum of 10 tags) [user-id] ID of user attributed to the policy [group-id] ID of group attributed to the policy [application-id] ID of application attributed to the policy diff --git a/cmd/scw/testdata/test-all-usage-iam-policy-list-usage.golden b/cmd/scw/testdata/test-all-usage-iam-policy-list-usage.golden index 282dfde8dd..e64ad3d23b 100644 --- a/cmd/scw/testdata/test-all-usage-iam-policy-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-policy-list-usage.golden @@ -13,6 +13,7 @@ ARGS: [application-ids.{index}] Filter by a list of application IDs [no-principal] Defines whether or not the policy is attributed to a principal [policy-name] Name of the policy to fetch + [tag] Filter by tags containing a given string [organization-id=] Organization ID to use. If none is passed the default organization ID will be used FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-iam-policy-update-usage.golden b/cmd/scw/testdata/test-all-usage-iam-policy-update-usage.golden index 83cc93eec3..b3c25224b1 100644 --- a/cmd/scw/testdata/test-all-usage-iam-policy-update-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-policy-update-usage.golden @@ -9,6 +9,7 @@ ARGS: policy-id Id of policy to update [name] New name for the policy (max length is 64 characters) [description] New description of policy (max length is 200 characters) + [tags.{index}] New tags for the policy (maximum of 10 tags) [user-id] New ID of user attributed to the policy [group-id] New ID of group attributed to the policy [application-id] New ID of application attributed to the policy diff --git a/cmd/scw/testdata/test-all-usage-iam-user-create-usage.golden b/cmd/scw/testdata/test-all-usage-iam-user-create-usage.golden index dd7004eb39..7cf6e6bc12 100644 --- a/cmd/scw/testdata/test-all-usage-iam-user-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-user-create-usage.golden @@ -7,6 +7,7 @@ USAGE: ARGS: email Email of the user + [tags.{index}] Tags associated with the user [organization-id] Organization ID to use. If none is passed the default organization ID will be used FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-iam-user-list-usage.golden b/cmd/scw/testdata/test-all-usage-iam-user-list-usage.golden index e3f130563f..62c7ecf4ba 100644 --- a/cmd/scw/testdata/test-all-usage-iam-user-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iam-user-list-usage.golden @@ -9,6 +9,7 @@ ARGS: [order-by=created_at_asc] Criteria for sorting results (created_at_asc | created_at_desc | updated_at_asc | updated_at_desc | email_asc | email_desc | last_login_asc | last_login_desc) [user-ids.{index}] Filter by list of IDs [mfa] Filter by MFA status + [tag] Filter by tags containing a given string organization-id= ID of the Organization to filter FLAGS: diff --git a/docs/commands/iam.md b/docs/commands/iam.md index 1b8a4f390b..515853a270 100644 --- a/docs/commands/iam.md +++ b/docs/commands/iam.md @@ -201,6 +201,7 @@ scw iam application create [arg=value ...] |------|---|-------------| | name | Required
Default: `` | Name of the application to create (max length is 64 characters) | | description | | Description of the application (max length is 200 characters) | +| tags.{index} | | Tags associated with the application (maximum of 10 tags) | | organization-id | | Organization ID to use. If none is passed the default organization ID will be used | @@ -262,6 +263,7 @@ scw iam application list [arg=value ...] | name | | Name of the application to filter | | editable | | Defines whether to filter out editable applications or not | | application-ids.{index} | | Filter by list of IDs | +| tag | | Filter by tags containing a given string | | organization-id | Default: `` | Organization ID to use. If none is passed the default organization ID will be used | @@ -284,6 +286,7 @@ scw iam application update [arg=value ...] | application-id | Required | ID of the application to update | | name | | New name for the application (max length is 64 chars) | | description | | New description for the application (max length is 200 chars) | +| tags.{index} | | New tags for the application (maximum of 10 tags) | @@ -351,6 +354,7 @@ scw iam group create [arg=value ...] |------|---|-------------| | name | Required
Default: `` | Name of the group to create (max length is 64 chars). MUST be unique inside an Organization | | description | | Description of the group to create (max length is 200 chars) | +| tags.{index} | | Tags associated with the group (maximum of 10 tags) | | organization-id | | Organization ID to use. If none is passed the default organization ID will be used | @@ -433,6 +437,7 @@ scw iam group list [arg=value ...] | application-ids.{index} | | Filter by a list of application IDs | | user-ids.{index} | | Filter by a list of user IDs | | group-ids.{index} | | Filter by a list of group IDs | +| tag | | Filter by tags containing a given string | | organization-id | Default: `` | Organization ID to use. If none is passed the default organization ID will be used | @@ -497,6 +502,7 @@ scw iam group update [arg=value ...] | group-id | Required | ID of the group to update | | name | | New name for the group (max length is 64 chars). MUST be unique inside an Organization | | description | | New description for the group (max length is 200 chars) | +| tags.{index} | | New tags for the group (maximum of 10 tags) | @@ -633,6 +639,7 @@ scw iam policy create [arg=value ...] | rules.{index}.permission-set-names.{index} | | Names of permission sets bound to the rule | | rules.{index}.project-ids.{index} | | List of Project IDs the rule is scoped to | | rules.{index}.organization-id | | ID of Organization the rule is scoped to | +| tags.{index} | | Tags associated with the policy (maximum of 10 tags) | | user-id | | ID of user attributed to the policy | | group-id | | ID of group attributed to the policy | | application-id | | ID of application attributed to the policy | @@ -711,6 +718,7 @@ scw iam policy list [arg=value ...] | application-ids.{index} | | Filter by a list of application IDs | | no-principal | | Defines whether or not the policy is attributed to a principal | | policy-name | | Name of the policy to fetch | +| tag | | Filter by tags containing a given string | | organization-id | Default: `` | Organization ID to use. If none is passed the default organization ID will be used | @@ -733,6 +741,7 @@ scw iam policy update [arg=value ...] | policy-id | Required | Id of policy to update | | name | | New name for the policy (max length is 64 characters) | | description | | New description of policy (max length is 200 characters) | +| tags.{index} | | New tags for the policy (maximum of 10 tags) | | user-id | | New ID of user attributed to the policy | | group-id | | New ID of group attributed to the policy | | application-id | | New ID of application attributed to the policy | @@ -947,6 +956,7 @@ scw iam user create [arg=value ...] | Name | | Description | |------|---|-------------| | email | Required | Email of the user | +| tags.{index} | | Tags associated with the user | | organization-id | | Organization ID to use. If none is passed the default organization ID will be used | @@ -1007,6 +1017,7 @@ scw iam user list [arg=value ...] | order-by | Default: `created_at_asc`
One of: `created_at_asc`, `created_at_desc`, `updated_at_asc`, `updated_at_desc`, `email_asc`, `email_desc`, `last_login_asc`, `last_login_desc` | Criteria for sorting results | | user-ids.{index} | | Filter by list of IDs | | mfa | | Filter by MFA status | +| tag | | Filter by tags containing a given string | | organization-id | Required
Default: `` | ID of the Organization to filter | diff --git a/go.mod b/go.mod index 9aad613a30..f9f689173b 100644 --- a/go.mod +++ b/go.mod @@ -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.21.0.20231117155000-b7672127ea65 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231121104036-359c065b044a github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 3bbeb2d135..080a7955b5 100644 --- a/go.sum +++ b/go.sum @@ -490,8 +490,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN 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.21.0.20231117155000-b7672127ea65 h1:ecI+ocsfBfEGGRPWs9pLazW2klg2G8s/JHVQzSEZoBQ= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231117155000-b7672127ea65/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231121104036-359c065b044a h1:AekI2JQPYxW6UUM2bWOVg9jCWnRLdHYLxkdzgqpt1Qk= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231121104036-359c065b044a/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= diff --git a/internal/namespaces/jobs/v1alpha1/jobs_cli.go b/internal/namespaces/jobs/v1alpha1/jobs_cli.go new file mode 100644 index 0000000000..aaf9229798 --- /dev/null +++ b/internal/namespaces/jobs/v1alpha1/jobs_cli.go @@ -0,0 +1,469 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +package jobs + +import ( + "context" + "reflect" + + "github.com/scaleway/scaleway-cli/v2/internal/core" + "github.com/scaleway/scaleway-sdk-go/api/jobs/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +// always import dependencies +var ( + _ = scw.RegionFrPar +) + +func GetGeneratedCommands() *core.Commands { + return core.NewCommands( + jobsRoot(), + jobsRun(), + jobsDefinition(), + jobsDefinitionCreate(), + jobsDefinitionGet(), + jobsDefinitionList(), + jobsDefinitionUpdate(), + jobsDefinitionDelete(), + jobsDefinitionStart(), + jobsRunGet(), + jobsRunStop(), + jobsRunList(), + ) +} +func jobsRoot() *core.Command { + return &core.Command{ + Short: `Serverless Jobs API`, + Long: `Serverless Jobs API.`, + Namespace: "jobs", + } +} + +func jobsRun() *core.Command { + return &core.Command{ + Short: ``, + Long: ``, + Namespace: "jobs", + Resource: "run", + } +} + +func jobsDefinition() *core.Command { + return &core.Command{ + Short: ``, + Long: ``, + Namespace: "jobs", + Resource: "definition", + } +} + +func jobsDefinitionCreate() *core.Command { + return &core.Command{ + Short: `Create jobs resources`, + Long: `Create jobs resources.`, + Namespace: "jobs", + Resource: "definition", + Verb: "create", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.CreateJobDefinitionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "name", + Required: true, + Deprecated: false, + Positional: false, + Default: core.RandomValueGenerator("job"), + }, + { + Name: "cpu-limit", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "memory-limit", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "image-uri", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "command", + Required: false, + Deprecated: false, + Positional: false, + }, + core.ProjectIDArgSpec(), + { + Name: "environment-variables.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "job-timeout.seconds", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "job-timeout.nanos", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.CreateJobDefinitionRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + return api.CreateJobDefinition(request) + + }, + } +} + +func jobsDefinitionGet() *core.Command { + return &core.Command{ + Short: `Get jobs resources`, + Long: `Get jobs resources.`, + Namespace: "jobs", + Resource: "definition", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.GetJobDefinitionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.GetJobDefinitionRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + return api.GetJobDefinition(request) + + }, + } +} + +func jobsDefinitionList() *core.Command { + return &core.Command{ + Short: `List jobs resources`, + Long: `List jobs resources.`, + Namespace: "jobs", + Resource: "definition", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.ListJobDefinitionsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "project-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw, scw.Region(core.AllLocalities)), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.ListJobDefinitionsRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + opts := []scw.RequestOption{scw.WithAllPages()} + if request.Region == scw.Region(core.AllLocalities) { + opts = append(opts, scw.WithRegions(api.Regions()...)) + request.Region = "" + } + resp, err := api.ListJobDefinitions(request, opts...) + if err != nil { + return nil, err + } + return resp.JobDefinitions, nil + + }, + } +} + +func jobsDefinitionUpdate() *core.Command { + return &core.Command{ + Short: `Update jobs resources`, + Long: `Update jobs resources.`, + Namespace: "jobs", + Resource: "definition", + Verb: "update", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.UpdateJobDefinitionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "id", + Required: true, + Deprecated: false, + Positional: true, + }, + { + Name: "name", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "cpu-limit", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "memory-limit", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "image-uri", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "command", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "environment-variables.{key}", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "description", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "job-timeout.seconds", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "job-timeout.nanos", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.UpdateJobDefinitionRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + return api.UpdateJobDefinition(request) + + }, + } +} + +func jobsDefinitionDelete() *core.Command { + return &core.Command{ + Short: `Delete jobs resources`, + Long: `Delete jobs resources.`, + Namespace: "jobs", + Resource: "definition", + Verb: "delete", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.DeleteJobDefinitionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.DeleteJobDefinitionRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + e = api.DeleteJobDefinition(request) + if e != nil { + return nil, e + } + return &core.SuccessResult{ + Resource: "definition", + Verb: "delete", + }, nil + }, + } +} + +func jobsDefinitionStart() *core.Command { + return &core.Command{ + Short: `Start jobs resources`, + Long: `Start jobs resources.`, + Namespace: "jobs", + Resource: "definition", + Verb: "start", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.StartJobDefinitionRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.StartJobDefinitionRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + return api.StartJobDefinition(request) + + }, + } +} + +func jobsRunGet() *core.Command { + return &core.Command{ + Short: `Get jobs resources`, + Long: `Get jobs resources.`, + Namespace: "jobs", + Resource: "run", + Verb: "get", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.GetJobRunRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.GetJobRunRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + return api.GetJobRun(request) + + }, + } +} + +func jobsRunStop() *core.Command { + return &core.Command{ + Short: `Stop jobs resources`, + Long: `Stop jobs resources.`, + Namespace: "jobs", + Resource: "run", + Verb: "stop", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.StopJobRunRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "id", + Required: true, + Deprecated: false, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.StopJobRunRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + return api.StopJobRun(request) + + }, + } +} + +func jobsRunList() *core.Command { + return &core.Command{ + Short: `List jobs resources`, + Long: `List jobs resources.`, + Namespace: "jobs", + Resource: "run", + Verb: "list", + // Deprecated: false, + ArgsType: reflect.TypeOf(jobs.ListJobRunsRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "order-by", + Required: false, + Deprecated: false, + Positional: false, + EnumValues: []string{"created_at_asc", "created_at_desc"}, + }, + { + Name: "id", + Required: false, + Deprecated: false, + Positional: false, + }, + { + Name: "project-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw, scw.Region(core.AllLocalities)), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*jobs.ListJobRunsRequest) + + client := core.ExtractClient(ctx) + api := jobs.NewAPI(client) + opts := []scw.RequestOption{scw.WithAllPages()} + if request.Region == scw.Region(core.AllLocalities) { + opts = append(opts, scw.WithRegions(api.Regions()...)) + request.Region = "" + } + resp, err := api.ListJobRuns(request, opts...) + if err != nil { + return nil, err + } + return resp.JobRuns, nil + + }, + } +}