Skip to content

feat(iot): add route update method #1873

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

Merged
merged 3 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
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