Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iot): add support for get-ca command #1863

Merged
merged 2 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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