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 route update method #1873

Merged
merged 3 commits into from
Apr 14, 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
34 changes: 34 additions & 0 deletions cmd/scw/testdata/test-all-usage-iot-route-update-usage.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Update a route.

USAGE:
scw iot route update [arg=value ...]

ARGS:
route-id Route id
[name] Route name
[topic] Topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters
[s3-config.bucket-region]
[s3-config.bucket-name]
[s3-config.object-prefix]
[s3-config.strategy] (unknown | per_topic | per_message)
[db-config.host]
[db-config.port]
[db-config.dbname]
[db-config.username]
[db-config.password]
[db-config.query]
[rest-config.verb] (unknown | get | post | put | patch | delete)
[rest-config.uri]
[rest-config.headers.value.{key}]
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for update

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-route-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AVAILABLE COMMANDS:
delete Delete a route
get Get a route
list List routes
update Update a route

FLAGS:
-h, --help help for route
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.20210407085633-043be10c857c
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210414083420-b36f019ca892
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210407085633-043be10c857c h1:4M4kfxtwv3TmvNLOVDP1PcJTo/u3PfYpZMqTc/i3XLE=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210407085633-043be10c857c/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210414083420-b36f019ca892 h1:8de9MJs8kRtUlc71A9+0wG5ToP9nk+Ujn/W03X/FGEg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210414083420-b36f019ca892/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
Expand Down
125 changes: 125 additions & 0 deletions internal/namespaces/iot/v1/iot_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func GetGeneratedCommands() *core.Commands {
iotDeviceGetMetrics(),
iotRouteList(),
iotRouteCreate(),
iotRouteUpdate(),
iotRouteGet(),
iotRouteDelete(),
iotNetworkList(),
Expand Down Expand Up @@ -1194,6 +1195,130 @@ func iotRouteCreate() *core.Command {
}
}

func iotRouteUpdate() *core.Command {
return &core.Command{
Short: `Update a route`,
Long: `Update a route.`,
Namespace: "iot",
Resource: "route",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(iot.UpdateRouteRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "route-id",
Short: `Route id`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Route name`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "topic",
Short: `Topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "s3-config.bucket-region",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "s3-config.bucket-name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "s3-config.object-prefix",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "s3-config.strategy",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "per_topic", "per_message"},
},
{
Name: "db-config.host",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "db-config.port",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "db-config.dbname",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "db-config.username",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "db-config.password",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "db-config.query",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "rest-config.verb",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "get", "post", "put", "patch", "delete"},
},
{
Name: "rest-config.uri",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "rest-config.headers.value.{key}",
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*iot.UpdateRouteRequest)

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

},
}
}

func iotRouteGet() *core.Command {
return &core.Command{
Short: `Get a route`,
Expand Down