Skip to content

Commit 69e094c

Browse files
feat(datawarehouse): add the CreateEndpoint and DeleteEndpoint methods for the CLI (#5311)
Co-authored-by: Jonathan Remy <jremy@scaleway.com>
1 parent 0d81d8a commit 69e094c

File tree

5 files changed

+122
-6
lines changed

5 files changed

+122
-6
lines changed

cmd/scw/testdata/test-all-usage-datawarehouse-endpoint-usage.golden

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
Manage endpoints associated with a deployment.
44

55
USAGE:
6-
scw datawarehouse endpoint
6+
scw datawarehouse endpoint <command>
7+
8+
AVAILABLE COMMANDS:
9+
create Create a new endpoint for a deployment
10+
delete Delete an endpoint from a deployment
711

812
FLAGS:
913
-h, --help help for endpoint
@@ -14,3 +18,5 @@ GLOBAL FLAGS:
1418
-D, --debug Enable debug mode
1519
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
1620
-p, --profile string The config profile to use
21+
22+
Use "scw datawarehouse endpoint [command] --help" for more information about a command.

docs/commands/datawarehouse.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Data Warehouse API.
1414
- [List deployments](#list-deployments)
1515
- [Update a deployment](#update-a-deployment)
1616
- [Endpoint management commands](#endpoint-management-commands)
17+
- [Create a new endpoint for a deployment](#create-a-new-endpoint-for-a-deployment)
18+
- [Delete an endpoint from a deployment](#delete-an-endpoint-from-a-deployment)
1719
- [List available presets](#list-available-presets)
1820
- [List available presets](#list-available-presets)
1921
- [User management commands](#user-management-commands)
@@ -241,15 +243,47 @@ scw datawarehouse deployment update <deployment-id ...> [arg=value ...]
241243

242244
Manage endpoints associated with a deployment.
243245

244-
Manage endpoints associated with a deployment.
246+
247+
### Create a new endpoint for a deployment
248+
249+
Create a new endpoint for a deployment.
250+
251+
**Usage:**
252+
253+
```
254+
scw datawarehouse endpoint create [arg=value ...]
255+
```
256+
257+
258+
**Args:**
259+
260+
| Name | | Description |
261+
|------|---|-------------|
262+
| deployment-id | | UUID of the deployment |
263+
| endpoint.private-network.private-network-id | | UUID of the Private Network |
264+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
265+
266+
267+
268+
### Delete an endpoint from a deployment
269+
270+
Delete an endpoint from a deployment.
245271

246272
**Usage:**
247273

248274
```
249-
scw datawarehouse endpoint
275+
scw datawarehouse endpoint delete [arg=value ...]
250276
```
251277

252278

279+
**Args:**
280+
281+
| Name | | Description |
282+
|------|---|-------------|
283+
| endpoint-id | Required | UUID of the Endpoint to delete |
284+
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
285+
286+
253287

254288
## List available presets
255289

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/mattn/go-isatty v0.0.20
2424
github.com/moby/buildkit v0.26.3
2525
github.com/opencontainers/go-digest v1.0.0
26-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260122164551-ccce19cd242c
26+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260130135251-d983e7b5616c
2727
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2828
github.com/spf13/cobra v1.10.2
2929
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
468468
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
469469
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
470470
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
471-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260122164551-ccce19cd242c h1:nCrW3tGV0n6zSbk4RPzfLYngOPCSnF3EvH+3ft8DAz0=
472-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260122164551-ccce19cd242c/go.mod h1:VbEqG0nAXcEFyHLKWwbhgbDNimnLf24Qat73/12DU9o=
471+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260130135251-d983e7b5616c h1:d+fekBfNNjEoRLITir9SgaYq/GyLDVLo1jE9RrsSwoc=
472+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260130135251-d983e7b5616c/go.mod h1:VbEqG0nAXcEFyHLKWwbhgbDNimnLf24Qat73/12DU9o=
473473
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
474474
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
475475
github.com/secure-systems-lab/go-securesystemslib v0.9.1 h1:nZZaNz4DiERIQguNy0cL5qTdn9lR8XKHf4RUyG1Sx3g=

internal/namespaces/datawarehouse/v1beta1/datawarehouse_cli.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func GetGeneratedCommands() *core.Commands {
3838
datawarehouseUserCreate(),
3939
datawarehouseUserUpdate(),
4040
datawarehouseUserDelete(),
41+
datawarehouseEndpointDelete(),
42+
datawarehouseEndpointCreate(),
4143
datawarehouseDatabaseList(),
4244
datawarehouseDatabaseCreate(),
4345
datawarehouseDatabaseDelete(),
@@ -706,6 +708,80 @@ func datawarehouseUserDelete() *core.Command {
706708
}
707709
}
708710

711+
func datawarehouseEndpointDelete() *core.Command {
712+
return &core.Command{
713+
Short: `Delete an endpoint from a deployment`,
714+
Long: `Delete an endpoint from a deployment.`,
715+
Namespace: "datawarehouse",
716+
Resource: "endpoint",
717+
Verb: "delete",
718+
// Deprecated: false,
719+
ArgsType: reflect.TypeOf(datawarehouse.DeleteEndpointRequest{}),
720+
ArgSpecs: core.ArgSpecs{
721+
{
722+
Name: "endpoint-id",
723+
Short: `UUID of the Endpoint to delete`,
724+
Required: true,
725+
Deprecated: false,
726+
Positional: false,
727+
},
728+
core.RegionArgSpec(scw.RegionFrPar),
729+
},
730+
Run: func(ctx context.Context, args any) (i any, e error) {
731+
request := args.(*datawarehouse.DeleteEndpointRequest)
732+
733+
client := core.ExtractClient(ctx)
734+
api := datawarehouse.NewAPI(client)
735+
e = api.DeleteEndpoint(request)
736+
if e != nil {
737+
return nil, e
738+
}
739+
740+
return &core.SuccessResult{
741+
Resource: "endpoint",
742+
Verb: "delete",
743+
}, nil
744+
},
745+
}
746+
}
747+
748+
func datawarehouseEndpointCreate() *core.Command {
749+
return &core.Command{
750+
Short: `Create a new endpoint for a deployment`,
751+
Long: `Create a new endpoint for a deployment.`,
752+
Namespace: "datawarehouse",
753+
Resource: "endpoint",
754+
Verb: "create",
755+
// Deprecated: false,
756+
ArgsType: reflect.TypeOf(datawarehouse.CreateEndpointRequest{}),
757+
ArgSpecs: core.ArgSpecs{
758+
{
759+
Name: "deployment-id",
760+
Short: `UUID of the deployment`,
761+
Required: false,
762+
Deprecated: false,
763+
Positional: false,
764+
},
765+
{
766+
Name: "endpoint.private-network.private-network-id",
767+
Short: `UUID of the Private Network`,
768+
Required: false,
769+
Deprecated: false,
770+
Positional: false,
771+
},
772+
core.RegionArgSpec(scw.RegionFrPar),
773+
},
774+
Run: func(ctx context.Context, args any) (i any, e error) {
775+
request := args.(*datawarehouse.CreateEndpointRequest)
776+
777+
client := core.ExtractClient(ctx)
778+
api := datawarehouse.NewAPI(client)
779+
780+
return api.CreateEndpoint(request)
781+
},
782+
}
783+
}
784+
709785
func datawarehouseDatabaseList() *core.Command {
710786
return &core.Command{
711787
Short: `List databases within a deployment`,

0 commit comments

Comments
 (0)