Skip to content

Commit

Permalink
feat(iot): add support for get-ca command (#1863)
Browse files Browse the repository at this point in the history
Co-authored-by: Rémy Léone <[email protected]>
  • Loading branch information
scaleway-bot and remyleone authored Apr 7, 2021
1 parent 3f22bad commit b026188
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/scw/testdata/test-all-usage-iot-hub-get-ca-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Get the certificate authority of a hub.

USAGE:
scw iot hub get-ca [arg=value ...]

ARGS:
hub-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-ca

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
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-iot-hub-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ AVAILABLE COMMANDS:
disable Disable a hub
enable Enable a hub
get Get a hub
get-ca Get the certificate authority of a hub
list List hubs
set-ca Set the certificate authority of a hub
update Update a hub
Expand Down
30 changes: 30 additions & 0 deletions internal/namespaces/iot/v1/iot_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func GetGeneratedCommands() *core.Commands {
iotHubDisable(),
iotHubDelete(),
iotHubSetCa(),
iotHubGetCa(),
iotDeviceList(),
iotDeviceCreate(),
iotDeviceGet(),
Expand Down Expand Up @@ -496,6 +497,35 @@ func iotHubSetCa() *core.Command {
}
}

func iotHubGetCa() *core.Command {
return &core.Command{
Short: `Get the certificate authority of a hub`,
Long: `Get the certificate authority of a hub.`,
Namespace: "iot",
Resource: "hub",
Verb: "get-ca",
// Deprecated: false,
ArgsType: reflect.TypeOf(iot.GetHubCARequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "hub-id",
Required: true,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iot.GetHubCARequest)

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

},
}
}

func iotDeviceList() *core.Command {
return &core.Command{
Short: `List devices`,
Expand Down

0 comments on commit b026188

Please sign in to comment.