Skip to content

Commit

Permalink
feat: update generated cli (#1904)
Browse files Browse the repository at this point in the history
Co-authored-by: Rémy Léone <rleone@scaleway.com>
  • Loading branch information
scaleway-bot and remyleone authored May 10, 2021
1 parent 6c31ac1 commit 372d954
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get a device's certificate.

USAGE:
scw iot device get-certificate <device-id ...> [arg=value ...]

ARGS:
device-id Device ID
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for get-certificate

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Set a custom certificate on a device.

USAGE:
scw iot device set-certificate <device-id ...> [arg=value ...]

ARGS:
device-id Device ID
certificate-pem The PEM-encoded custom certificate
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for set-certificate

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
2 changes: 2 additions & 0 deletions cmd/scw/testdata/test-all-usage-iot-device-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ AVAILABLE COMMANDS:
disable Disable a device
enable Enable a device
get Get a device
get-certificate Get a device's certificate
get-metrics Get a device's metrics
list List devices
renew-certificate Renew a device certificate
set-certificate Set a custom certificate on a device
update Update a device

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ARGS:
[db-config.username]
[db-config.password]
[db-config.query]
[db-config.engine] (unknown | postgresql | mysql)
[rest-config.verb] (unknown | get | post | put | patch | delete)
[rest-config.uri]
[rest-config.headers.{key}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ARGS:
[db-config.username]
[db-config.password]
[db-config.query]
[db-config.engine] (unknown | postgresql | mysql)
[rest-config.verb] (unknown | get | post | put | patch | delete)
[rest-config.uri]
[rest-config.headers.value.{key}]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/mattn/go-colorable v0.1.7
github.com/mattn/go-isatty v0.0.12
github.com/pkg/errors v0.9.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210427121621-c670eb8c8e8f
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210510090404-0b46577f308f
github.com/sergi/go-diff v1.1.0 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
Expand Down
92 changes: 2 additions & 90 deletions go.sum

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions internal/namespaces/iot/v1/iot_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func GetGeneratedCommands() *core.Commands {
iotDeviceEnable(),
iotDeviceDisable(),
iotDeviceRenewCertificate(),
iotDeviceSetCertificate(),
iotDeviceGetCertificate(),
iotDeviceDelete(),
iotDeviceGetMetrics(),
iotRouteList(),
Expand Down Expand Up @@ -918,6 +920,73 @@ func iotDeviceRenewCertificate() *core.Command {
}
}

func iotDeviceSetCertificate() *core.Command {
return &core.Command{
Short: `Set a custom certificate on a device`,
Long: `Set a custom certificate on a device.`,
Namespace: "iot",
Resource: "device",
Verb: "set-certificate",
// Deprecated: false,
ArgsType: reflect.TypeOf(iot.SetDeviceCertificateRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "device-id",
Short: `Device ID`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "certificate-pem",
Short: `The PEM-encoded custom certificate`,
Required: true,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iot.SetDeviceCertificateRequest)

client := core.ExtractClient(ctx)
api := iot.NewAPI(client)
return api.SetDeviceCertificate(request)

},
}
}

func iotDeviceGetCertificate() *core.Command {
return &core.Command{
Short: `Get a device's certificate`,
Long: `Get a device's certificate.`,
Namespace: "iot",
Resource: "device",
Verb: "get-certificate",
// Deprecated: false,
ArgsType: reflect.TypeOf(iot.GetDeviceCertificateRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "device-id",
Short: `Device ID`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iot.GetDeviceCertificateRequest)

client := core.ExtractClient(ctx)
api := iot.NewAPI(client)
return api.GetDeviceCertificate(request)

},
}
}

func iotDeviceDelete() *core.Command {
return &core.Command{
Short: `Remove a device`,
Expand Down Expand Up @@ -1164,6 +1233,13 @@ func iotRouteCreate() *core.Command {
Deprecated: false,
Positional: false,
},
{
Name: "db-config.engine",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "postgresql", "mysql"},
},
{
Name: "rest-config.verb",
Required: false,
Expand Down Expand Up @@ -1288,6 +1364,13 @@ func iotRouteUpdate() *core.Command {
Deprecated: false,
Positional: false,
},
{
Name: "db-config.engine",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "postgresql", "mysql"},
},
{
Name: "rest-config.verb",
Required: false,
Expand Down

0 comments on commit 372d954

Please sign in to comment.