|
| 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 project`, |
| 51 | + Long: `Create project.`, |
| 52 | + Namespace: "account", |
| 53 | + Resource: "project", |
| 54 | + Verb: "create", |
| 55 | + // Deprecated: false, |
| 56 | + ArgsType: reflect.TypeOf(account.CreateProjectRequest{}), |
| 57 | + ArgSpecs: core.ArgSpecs{ |
| 58 | + { |
| 59 | + Name: "name", |
| 60 | + Short: `The name of the project`, |
| 61 | + Required: false, |
| 62 | + Deprecated: false, |
| 63 | + Positional: false, |
| 64 | + }, |
| 65 | + { |
| 66 | + Name: "description", |
| 67 | + Short: `The description of the project`, |
| 68 | + Required: false, |
| 69 | + Deprecated: false, |
| 70 | + Positional: false, |
| 71 | + }, |
| 72 | + core.OrganizationIDArgSpec(), |
| 73 | + }, |
| 74 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 75 | + request := args.(*account.CreateProjectRequest) |
| 76 | + |
| 77 | + client := core.ExtractClient(ctx) |
| 78 | + api := account.NewAPI(client) |
| 79 | + return api.CreateProject(request) |
| 80 | + |
| 81 | + }, |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +func accountProjectList() *core.Command { |
| 86 | + return &core.Command{ |
| 87 | + Short: `List projects`, |
| 88 | + Long: `List projects.`, |
| 89 | + Namespace: "account", |
| 90 | + Resource: "project", |
| 91 | + Verb: "list", |
| 92 | + // Deprecated: false, |
| 93 | + ArgsType: reflect.TypeOf(account.ListProjectsRequest{}), |
| 94 | + ArgSpecs: core.ArgSpecs{ |
| 95 | + { |
| 96 | + Name: "name", |
| 97 | + Short: `The name of the project`, |
| 98 | + Required: false, |
| 99 | + Deprecated: false, |
| 100 | + Positional: false, |
| 101 | + }, |
| 102 | + { |
| 103 | + Name: "order-by", |
| 104 | + Short: `The sort order of the returned projects`, |
| 105 | + Required: false, |
| 106 | + Deprecated: false, |
| 107 | + Positional: false, |
| 108 | + EnumValues: []string{"created_at_asc", "created_at_desc", "name_asc", "name_desc"}, |
| 109 | + }, |
| 110 | + core.OrganizationIDArgSpec(), |
| 111 | + }, |
| 112 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 113 | + request := args.(*account.ListProjectsRequest) |
| 114 | + |
| 115 | + client := core.ExtractClient(ctx) |
| 116 | + api := account.NewAPI(client) |
| 117 | + resp, err := api.ListProjects(request, scw.WithAllPages()) |
| 118 | + if err != nil { |
| 119 | + return nil, err |
| 120 | + } |
| 121 | + return resp.Projects, nil |
| 122 | + |
| 123 | + }, |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +func accountProjectGet() *core.Command { |
| 128 | + return &core.Command{ |
| 129 | + Short: `Get project`, |
| 130 | + Long: `Get project.`, |
| 131 | + Namespace: "account", |
| 132 | + Resource: "project", |
| 133 | + Verb: "get", |
| 134 | + // Deprecated: false, |
| 135 | + ArgsType: reflect.TypeOf(account.GetProjectRequest{}), |
| 136 | + ArgSpecs: core.ArgSpecs{ |
| 137 | + core.ProjectIDArgSpec(), |
| 138 | + }, |
| 139 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 140 | + request := args.(*account.GetProjectRequest) |
| 141 | + |
| 142 | + client := core.ExtractClient(ctx) |
| 143 | + api := account.NewAPI(client) |
| 144 | + return api.GetProject(request) |
| 145 | + |
| 146 | + }, |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +func accountProjectDelete() *core.Command { |
| 151 | + return &core.Command{ |
| 152 | + Short: `Delete project`, |
| 153 | + Long: `Delete project.`, |
| 154 | + Namespace: "account", |
| 155 | + Resource: "project", |
| 156 | + Verb: "delete", |
| 157 | + // Deprecated: false, |
| 158 | + ArgsType: reflect.TypeOf(account.DeleteProjectRequest{}), |
| 159 | + ArgSpecs: core.ArgSpecs{ |
| 160 | + core.ProjectIDArgSpec(), |
| 161 | + }, |
| 162 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 163 | + request := args.(*account.DeleteProjectRequest) |
| 164 | + |
| 165 | + client := core.ExtractClient(ctx) |
| 166 | + api := account.NewAPI(client) |
| 167 | + e = api.DeleteProject(request) |
| 168 | + if e != nil { |
| 169 | + return nil, e |
| 170 | + } |
| 171 | + return &core.SuccessResult{ |
| 172 | + Resource: "project", |
| 173 | + Verb: "delete", |
| 174 | + }, nil |
| 175 | + }, |
| 176 | + } |
| 177 | +} |
| 178 | + |
| 179 | +func accountProjectUpdate() *core.Command { |
| 180 | + return &core.Command{ |
| 181 | + Short: `Update project`, |
| 182 | + Long: `Update project.`, |
| 183 | + Namespace: "account", |
| 184 | + Resource: "project", |
| 185 | + Verb: "update", |
| 186 | + // Deprecated: false, |
| 187 | + ArgsType: reflect.TypeOf(account.UpdateProjectRequest{}), |
| 188 | + ArgSpecs: core.ArgSpecs{ |
| 189 | + core.ProjectIDArgSpec(), |
| 190 | + { |
| 191 | + Name: "name", |
| 192 | + Short: `The name of the project`, |
| 193 | + Required: false, |
| 194 | + Deprecated: false, |
| 195 | + Positional: false, |
| 196 | + }, |
| 197 | + { |
| 198 | + Name: "description", |
| 199 | + Short: `The description of the project`, |
| 200 | + Required: false, |
| 201 | + Deprecated: false, |
| 202 | + Positional: false, |
| 203 | + }, |
| 204 | + }, |
| 205 | + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { |
| 206 | + request := args.(*account.UpdateProjectRequest) |
| 207 | + |
| 208 | + client := core.ExtractClient(ctx) |
| 209 | + api := account.NewAPI(client) |
| 210 | + return api.UpdateProject(request) |
| 211 | + |
| 212 | + }, |
| 213 | + } |
| 214 | +} |
0 commit comments