|
| 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/v3" |
| 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: `This API allows you to manage projects`, |
| 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: `Generate a new Project for an Organization, specifying its configuration including name and description.`, |
| 52 | + Namespace: "account", |
| 53 | + Resource: "project", |
| 54 | + Verb: "create", |
| 55 | + // Deprecated: false, |
| 56 | + ArgsType: reflect.TypeOf(account.ProjectAPICreateProjectRequest{}), |
| 57 | + ArgSpecs: core.ArgSpecs{ |
| 58 | + { |
| 59 | + Name: "name", |
| 60 | + Short: `Name of the Project`, |
| 61 | + Required: false, |
| 62 | + Deprecated: false, |
| 63 | + Positional: false, |
| 64 | + Default: core.RandomValueGenerator("proj"), |
| 65 | + }, |
| 66 | + { |
| 67 | + Name: "description", |
| 68 | + Short: `Description of the Project`, |
| 69 | + Required: false, |
| 70 | + Deprecated: false, |
| 71 | + Positional: false, |
| 72 | + }, |
| 73 | + core.OrganizationIDArgSpec(), |
| 74 | + }, |
| 75 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 76 | + request := args.(*account.ProjectAPICreateProjectRequest) |
| 77 | + |
| 78 | + client := core.ExtractClient(ctx) |
| 79 | + api := account.NewProjectAPI(client) |
| 80 | + return api.CreateProject(request) |
| 81 | + |
| 82 | + }, |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +func accountProjectList() *core.Command { |
| 87 | + return &core.Command{ |
| 88 | + Short: `List all Projects of an Organization`, |
| 89 | + 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.`, |
| 90 | + Namespace: "account", |
| 91 | + Resource: "project", |
| 92 | + Verb: "list", |
| 93 | + // Deprecated: false, |
| 94 | + ArgsType: reflect.TypeOf(account.ProjectAPIListProjectsRequest{}), |
| 95 | + ArgSpecs: core.ArgSpecs{ |
| 96 | + { |
| 97 | + Name: "name", |
| 98 | + Short: `Name of the Project`, |
| 99 | + Required: false, |
| 100 | + Deprecated: false, |
| 101 | + Positional: false, |
| 102 | + }, |
| 103 | + { |
| 104 | + Name: "order-by", |
| 105 | + Short: `Sort order of the returned Projects`, |
| 106 | + Required: false, |
| 107 | + Deprecated: false, |
| 108 | + Positional: false, |
| 109 | + EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"}, |
| 110 | + }, |
| 111 | + { |
| 112 | + Name: "project-ids.{index}", |
| 113 | + Short: `Project IDs to filter for. The results will be limited to any Projects with an ID in this array`, |
| 114 | + Required: false, |
| 115 | + Deprecated: false, |
| 116 | + Positional: false, |
| 117 | + }, |
| 118 | + core.OrganizationIDArgSpec(), |
| 119 | + }, |
| 120 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 121 | + request := args.(*account.ProjectAPIListProjectsRequest) |
| 122 | + |
| 123 | + client := core.ExtractClient(ctx) |
| 124 | + api := account.NewProjectAPI(client) |
| 125 | + opts := []scw.RequestOption{scw.WithAllPages()} |
| 126 | + resp, err := api.ListProjects(request, opts...) |
| 127 | + if err != nil { |
| 128 | + return nil, err |
| 129 | + } |
| 130 | + return resp.Projects, nil |
| 131 | + |
| 132 | + }, |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +func accountProjectGet() *core.Command { |
| 137 | + return &core.Command{ |
| 138 | + Short: `Get an existing Project`, |
| 139 | + 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.`, |
| 140 | + Namespace: "account", |
| 141 | + Resource: "project", |
| 142 | + Verb: "get", |
| 143 | + // Deprecated: false, |
| 144 | + ArgsType: reflect.TypeOf(account.ProjectAPIGetProjectRequest{}), |
| 145 | + ArgSpecs: core.ArgSpecs{ |
| 146 | + core.ProjectIDArgSpec(), |
| 147 | + }, |
| 148 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 149 | + request := args.(*account.ProjectAPIGetProjectRequest) |
| 150 | + |
| 151 | + client := core.ExtractClient(ctx) |
| 152 | + api := account.NewProjectAPI(client) |
| 153 | + return api.GetProject(request) |
| 154 | + |
| 155 | + }, |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +func accountProjectDelete() *core.Command { |
| 160 | + return &core.Command{ |
| 161 | + Short: `Delete an existing Project`, |
| 162 | + 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.`, |
| 163 | + Namespace: "account", |
| 164 | + Resource: "project", |
| 165 | + Verb: "delete", |
| 166 | + // Deprecated: false, |
| 167 | + ArgsType: reflect.TypeOf(account.ProjectAPIDeleteProjectRequest{}), |
| 168 | + ArgSpecs: core.ArgSpecs{ |
| 169 | + core.ProjectIDArgSpec(), |
| 170 | + }, |
| 171 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 172 | + request := args.(*account.ProjectAPIDeleteProjectRequest) |
| 173 | + |
| 174 | + client := core.ExtractClient(ctx) |
| 175 | + api := account.NewProjectAPI(client) |
| 176 | + e = api.DeleteProject(request) |
| 177 | + if e != nil { |
| 178 | + return nil, e |
| 179 | + } |
| 180 | + return &core.SuccessResult{ |
| 181 | + Resource: "project", |
| 182 | + Verb: "delete", |
| 183 | + }, nil |
| 184 | + }, |
| 185 | + } |
| 186 | +} |
| 187 | + |
| 188 | +func accountProjectUpdate() *core.Command { |
| 189 | + return &core.Command{ |
| 190 | + Short: `Update Project`, |
| 191 | + Long: `Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description.`, |
| 192 | + Namespace: "account", |
| 193 | + Resource: "project", |
| 194 | + Verb: "update", |
| 195 | + // Deprecated: false, |
| 196 | + ArgsType: reflect.TypeOf(account.ProjectAPIUpdateProjectRequest{}), |
| 197 | + ArgSpecs: core.ArgSpecs{ |
| 198 | + core.ProjectIDArgSpec(), |
| 199 | + { |
| 200 | + Name: "name", |
| 201 | + Short: `Name of the Project`, |
| 202 | + Required: false, |
| 203 | + Deprecated: false, |
| 204 | + Positional: false, |
| 205 | + }, |
| 206 | + { |
| 207 | + Name: "description", |
| 208 | + Short: `Description of the Project`, |
| 209 | + Required: false, |
| 210 | + Deprecated: false, |
| 211 | + Positional: false, |
| 212 | + }, |
| 213 | + }, |
| 214 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 215 | + request := args.(*account.ProjectAPIUpdateProjectRequest) |
| 216 | + |
| 217 | + client := core.ExtractClient(ctx) |
| 218 | + api := account.NewProjectAPI(client) |
| 219 | + return api.UpdateProject(request) |
| 220 | + |
| 221 | + }, |
| 222 | + } |
| 223 | +} |
0 commit comments