diff --git a/cmd/scw/testdata/test-all-usage-iot-hub-get-ca-usage.golden b/cmd/scw/testdata/test-all-usage-iot-hub-get-ca-usage.golden new file mode 100644 index 0000000000..49811721dd --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-iot-hub-get-ca-usage.golden @@ -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 diff --git a/cmd/scw/testdata/test-all-usage-iot-hub-usage.golden b/cmd/scw/testdata/test-all-usage-iot-hub-usage.golden index 316e4ce569..aaad2c37c8 100644 --- a/cmd/scw/testdata/test-all-usage-iot-hub-usage.golden +++ b/cmd/scw/testdata/test-all-usage-iot-hub-usage.golden @@ -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 diff --git a/internal/namespaces/iot/v1/iot_cli.go b/internal/namespaces/iot/v1/iot_cli.go index 44b38f2ebf..2dd14f4a60 100644 --- a/internal/namespaces/iot/v1/iot_cli.go +++ b/internal/namespaces/iot/v1/iot_cli.go @@ -32,6 +32,7 @@ func GetGeneratedCommands() *core.Commands { iotHubDisable(), iotHubDelete(), iotHubSetCa(), + iotHubGetCa(), iotDeviceList(), iotDeviceCreate(), iotDeviceGet(), @@ -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`,