|
| 1 | +// This file was automatically generated. DO NOT EDIT. |
| 2 | +// If you have any remark or suggestion do not hesitate to open an issue. |
| 3 | + |
| 4 | +package account |
| 5 | + |
| 6 | +import ( |
| 7 | + "context" |
| 8 | + "reflect" |
| 9 | + |
| 10 | + "github.com/scaleway/scaleway-cli/v2/internal/core" |
| 11 | + "github.com/scaleway/scaleway-sdk-go/api/account/v2" |
| 12 | + "github.com/scaleway/scaleway-sdk-go/scw" |
| 13 | +) |
| 14 | + |
| 15 | +// always import dependencies |
| 16 | +var ( |
| 17 | + _ = scw.RegionFrPar |
| 18 | +) |
| 19 | + |
| 20 | +func GetGeneratedCommands() *core.Commands { |
| 21 | + return core.NewCommands( |
| 22 | + accountRoot(), |
| 23 | + accountProject(), |
| 24 | + accountProjectCreate(), |
| 25 | + accountProjectList(), |
| 26 | + accountProjectGet(), |
| 27 | + accountProjectDelete(), |
| 28 | + accountProjectUpdate(), |
| 29 | + ) |
| 30 | +} |
| 31 | +func accountRoot() *core.Command { |
| 32 | + return &core.Command{ |
| 33 | + Short: `User related data`, |
| 34 | + Long: `This API allows you to manage projects.`, |
| 35 | + Namespace: "account", |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +func accountProject() *core.Command { |
| 40 | + return &core.Command{ |
| 41 | + Short: `Project management commands`, |
| 42 | + Long: `Project management commands.`, |
| 43 | + Namespace: "account", |
| 44 | + Resource: "project", |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +func accountProjectCreate() *core.Command { |
| 49 | + return &core.Command{ |
| 50 | + Short: `Create a new Project for an Organization`, |
| 51 | + Long: `Deprecated in favor of Account API v3. |
| 52 | +Generate a new Project for an Organization, specifying its configuration including name and description.`, |
| 53 | + Namespace: "account", |
| 54 | + Resource: "project", |
| 55 | + Verb: "create", |
| 56 | + // Deprecated: true, |
| 57 | + ArgsType: reflect.TypeOf(account.CreateProjectRequest{}), |
| 58 | + ArgSpecs: core.ArgSpecs{ |
| 59 | + { |
| 60 | + Name: "name", |
| 61 | + Short: `Name of the Project`, |
| 62 | + Required: false, |
| 63 | + Deprecated: false, |
| 64 | + Positional: false, |
| 65 | + Default: core.RandomValueGenerator("proj"), |
| 66 | + }, |
| 67 | + { |
| 68 | + Name: "description", |
| 69 | + Short: `Description of the Project`, |
| 70 | + Required: false, |
| 71 | + Deprecated: false, |
| 72 | + Positional: false, |
| 73 | + }, |
| 74 | + core.OrganizationIDArgSpec(), |
| 75 | + }, |
| 76 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 77 | + request := args.(*account.CreateProjectRequest) |
| 78 | + |
| 79 | + client := core.ExtractClient(ctx) |
| 80 | + api := account.NewAPI(client) |
| 81 | + return api.CreateProject(request) |
| 82 | + |
| 83 | + }, |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +func accountProjectList() *core.Command { |
| 88 | + return &core.Command{ |
| 89 | + Short: `List all Projects of an Organization`, |
| 90 | + Long: `Deprecated in favor of Account API v3. |
| 91 | +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.`, |
| 92 | + Namespace: "account", |
| 93 | + Resource: "project", |
| 94 | + Verb: "list", |
| 95 | + // Deprecated: true, |
| 96 | + ArgsType: reflect.TypeOf(account.ListProjectsRequest{}), |
| 97 | + ArgSpecs: core.ArgSpecs{ |
| 98 | + { |
| 99 | + Name: "name", |
| 100 | + Short: `Name of the Project`, |
| 101 | + Required: false, |
| 102 | + Deprecated: false, |
| 103 | + Positional: false, |
| 104 | + }, |
| 105 | + { |
| 106 | + Name: "order-by", |
| 107 | + Short: `Sort order of the returned Projects`, |
| 108 | + Required: false, |
| 109 | + Deprecated: false, |
| 110 | + Positional: false, |
| 111 | + EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"}, |
| 112 | + }, |
| 113 | + { |
| 114 | + Name: "project-ids.{index}", |
| 115 | + Short: `Project IDs to filter for. The results will be limited to any Projects with an ID in this array`, |
| 116 | + Required: false, |
| 117 | + Deprecated: false, |
| 118 | + Positional: false, |
| 119 | + }, |
| 120 | + core.OrganizationIDArgSpec(), |
| 121 | + }, |
| 122 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 123 | + request := args.(*account.ListProjectsRequest) |
| 124 | + |
| 125 | + client := core.ExtractClient(ctx) |
| 126 | + api := account.NewAPI(client) |
| 127 | + opts := []scw.RequestOption{scw.WithAllPages()} |
| 128 | + resp, err := api.ListProjects(request, opts...) |
| 129 | + if err != nil { |
| 130 | + return nil, err |
| 131 | + } |
| 132 | + return resp.Projects, nil |
| 133 | + |
| 134 | + }, |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +func accountProjectGet() *core.Command { |
| 139 | + return &core.Command{ |
| 140 | + Short: `Get an existing Project`, |
| 141 | + Long: `Deprecated in favor of Account API v3. |
| 142 | +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.`, |
| 143 | + Namespace: "account", |
| 144 | + Resource: "project", |
| 145 | + Verb: "get", |
| 146 | + // Deprecated: true, |
| 147 | + ArgsType: reflect.TypeOf(account.GetProjectRequest{}), |
| 148 | + ArgSpecs: core.ArgSpecs{ |
| 149 | + core.ProjectIDArgSpec(), |
| 150 | + }, |
| 151 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 152 | + request := args.(*account.GetProjectRequest) |
| 153 | + |
| 154 | + client := core.ExtractClient(ctx) |
| 155 | + api := account.NewAPI(client) |
| 156 | + return api.GetProject(request) |
| 157 | + |
| 158 | + }, |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +func accountProjectDelete() *core.Command { |
| 163 | + return &core.Command{ |
| 164 | + Short: `Delete an existing Project`, |
| 165 | + Long: `Deprecated in favor of Account API v3. |
| 166 | +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.`, |
| 167 | + Namespace: "account", |
| 168 | + Resource: "project", |
| 169 | + Verb: "delete", |
| 170 | + // Deprecated: true, |
| 171 | + ArgsType: reflect.TypeOf(account.DeleteProjectRequest{}), |
| 172 | + ArgSpecs: core.ArgSpecs{ |
| 173 | + core.ProjectIDArgSpec(), |
| 174 | + }, |
| 175 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 176 | + request := args.(*account.DeleteProjectRequest) |
| 177 | + |
| 178 | + client := core.ExtractClient(ctx) |
| 179 | + api := account.NewAPI(client) |
| 180 | + e = api.DeleteProject(request) |
| 181 | + if e != nil { |
| 182 | + return nil, e |
| 183 | + } |
| 184 | + return &core.SuccessResult{ |
| 185 | + Resource: "project", |
| 186 | + Verb: "delete", |
| 187 | + }, nil |
| 188 | + }, |
| 189 | + } |
| 190 | +} |
| 191 | + |
| 192 | +func accountProjectUpdate() *core.Command { |
| 193 | + return &core.Command{ |
| 194 | + Short: `Update Project`, |
| 195 | + Long: `Deprecated in favor of Account API v3. |
| 196 | +Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.`, |
| 197 | + Namespace: "account", |
| 198 | + Resource: "project", |
| 199 | + Verb: "update", |
| 200 | + // Deprecated: true, |
| 201 | + ArgsType: reflect.TypeOf(account.UpdateProjectRequest{}), |
| 202 | + ArgSpecs: core.ArgSpecs{ |
| 203 | + core.ProjectIDArgSpec(), |
| 204 | + { |
| 205 | + Name: "name", |
| 206 | + Short: `Name of the Project`, |
| 207 | + Required: false, |
| 208 | + Deprecated: false, |
| 209 | + Positional: false, |
| 210 | + }, |
| 211 | + { |
| 212 | + Name: "description", |
| 213 | + Short: `Description of the Project`, |
| 214 | + Required: false, |
| 215 | + Deprecated: false, |
| 216 | + Positional: false, |
| 217 | + }, |
| 218 | + }, |
| 219 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 220 | + request := args.(*account.UpdateProjectRequest) |
| 221 | + |
| 222 | + client := core.ExtractClient(ctx) |
| 223 | + api := account.NewAPI(client) |
| 224 | + return api.UpdateProject(request) |
| 225 | + |
| 226 | + }, |
| 227 | + } |
| 228 | +} |
0 commit comments