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): migrate to IoT API v1 #1688

Merged
merged 4 commits into from
Jan 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ARGS:
[message-filters.publish.topics.{index}]
[message-filters.subscribe.policy] (unknown | accept | reject)
[message-filters.subscribe.topics.{index}]
[description] Device description
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ USAGE:

ARGS:
device-id Device ID
period=hour Period over which the metrics span (hour | day | week | month | year)
start-date=hour Start date used to compute the best scale for the returned metrics
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
Expand Down
16 changes: 6 additions & 10 deletions cmd/scw/testdata/test-all-usage-iot-device-list-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ USAGE:
scw iot device list [arg=value ...]

ARGS:
[order-by] Ordering of requested devices (name_asc | name_desc | status_asc | status_desc | hub_id_asc | hub_id_desc | created_at_asc | created_at_desc | updated_at_asc | updated_at_desc | allow_insecure_asc | allow_insecure_desc)
[name] Filter on the name
[hub-id] Filter on the hub
[allow-insecure] Filter on the allow_insecure flag
[organization-id] Filter on the organization
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

DEPRECATED ARGS:
[enabled] Deprecated, ignored filter
[is-connected] Deprecated, ignored filter
[order-by] Ordering of requested devices (name_asc | name_desc | status_asc | status_desc | hub_id_asc | hub_id_desc | created_at_asc | created_at_desc | updated_at_asc | updated_at_desc | allow_insecure_asc | allow_insecure_desc)
[name] Filter on the name
[hub-id] Filter on the hub
[allow-insecure] Filter on the allow_insecure flag
[status] Device status (enabled, disabled, etc.) (unknown | error | enabled | disabled)
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for list
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Renew a device certificate.

USAGE:
scw iot device renew-certificate <device-id ...> [arg=value ...]

ARGS:
device-id Device 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 renew-certificate

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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ USAGE:

ARGS:
device-id Device ID
[name] Device name
[description] Device description
[allow-insecure] Allow plain and server-authenticated SSL connections in addition to mutually-authenticated ones
[allow-multiple-connections] Allow multiple physical devices to connect with this device's credentials
[message-filters.publish.policy] (unknown | accept | reject)
Expand Down
17 changes: 9 additions & 8 deletions cmd/scw/testdata/test-all-usage-iot-device-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ USAGE:
scw iot device <command>

AVAILABLE COMMANDS:
create Add a device
delete Remove a device
disable Disable a device
enable Enable a device
get Get a device
get-metrics Get a device's metrics
list List devices
update Update a device
create Add a device
delete Remove a device
disable Disable a device
enable Enable a device
get Get a device
get-metrics Get a device's metrics
list List devices
renew-certificate Renew a device certificate
update Update a device

FLAGS:
-h, --help help for device
Expand Down
4 changes: 2 additions & 2 deletions cmd/scw/testdata/test-all-usage-iot-hub-create-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ USAGE:

ARGS:
name=<generated> Hub name (up to 255 characters)
[project-id] Project ID to use. If none is passed the default project ID will be used
product-plan=plan_shared Hub feature set (plan_unknown | plan_shared | plan_dedicated | plan_ha)
[disable-events] Disable Hub events (default false)
[disable-events] Disable Hub events
[events-topic-prefix] Hub events topic prefix (default '$SCW/events')
[organization-id] Organization ID to use. If none is passed the default organization ID will be used
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ USAGE:

ARGS:
[order-by] Ordering of requested hub (name_asc | name_desc | status_asc | status_desc | product_plan_asc | product_plan_desc | created_at_asc | created_at_desc | updated_at_asc | updated_at_desc)
[project-id] Filter on project
[name] Filter on the name
[organization-id] Filter on the organization
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
Expand Down
13 changes: 7 additions & 6 deletions cmd/scw/testdata/test-all-usage-iot-hub-update-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ USAGE:
scw iot hub update <hub-id ...> [arg=value ...]

ARGS:
hub-id Hub ID
[name] Hub name (up to 255 characters)
[product-plan] Hub feature set (plan_unknown | plan_shared | plan_dedicated | plan_ha)
[disable-events] Disable Hub events
[events-topic-prefix] Hub events topic prefix
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
hub-id Hub ID
[name] Hub name (up to 255 characters)
[product-plan] Hub feature set (plan_unknown | plan_shared | plan_dedicated | plan_ha)
[disable-events] Disable Hub events
[events-topic-prefix] Hub events topic prefix
[enable-device-auto-provisioning] Enable device auto provisioning
[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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ USAGE:
scw iot network create [arg=value ...]

ARGS:
name=<generated> Network name
type Type of network to connect with (unknown | sigfox | rest)
hub-id Hub ID to connect the Network to
topic-prefix Topic prefix for the Network
[organization-id] Organization ID to use. If none is passed the default organization ID will be used
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
name=<generated> Network name
type Type of network to connect with (unknown | sigfox | rest)
hub-id Hub ID to connect the Network to
topic-prefix Topic prefix for the Network
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for create
Expand Down
11 changes: 5 additions & 6 deletions cmd/scw/testdata/test-all-usage-iot-network-list-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ USAGE:
scw iot network list [arg=value ...]

ARGS:
[order-by] Ordering of requested routes (name_asc | name_desc | type_asc | type_desc | created_at_asc | created_at_desc)
[name] Filter on Network name
[hub-id] Filter on the hub
[topic-prefix] Filter on the topic prefix
[organization-id] Filter on the organization
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
[order-by] Ordering of requested routes (name_asc | name_desc | type_asc | type_desc | created_at_asc | created_at_desc)
[name] Filter on Network name
[hub-id] Filter on the hub
[topic-prefix] Filter on the topic prefix
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)

FLAGS:
-h, --help help for list
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.20210118180419-87b8b277149c
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210121150854-477be02b8e21
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 @@ -118,8 +118,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.20210118180419-87b8b277149c h1:NDAovDzT4JfgX7k/ED0Y5/swOtsIsDCRQMzzqPh3yA0=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210118180419-87b8b277149c/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210121150854-477be02b8e21 h1:wocARfcjkGYbI4vAVtX3kmAlvgt+Wymdd2dE4zcykwI=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.7.0.20210121150854-477be02b8e21/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
6 changes: 3 additions & 3 deletions internal/namespaces/get_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"github.com/scaleway/scaleway-cli/internal/core"
account "github.com/scaleway/scaleway-cli/internal/namespaces/account/v2alpha1"
autocompleteNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/autocomplete"
baremetal "github.com/scaleway/scaleway-cli/internal/namespaces/baremetal/v1"
"github.com/scaleway/scaleway-cli/internal/namespaces/baremetal/v1"
configNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/config"
"github.com/scaleway/scaleway-cli/internal/namespaces/feedback"
"github.com/scaleway/scaleway-cli/internal/namespaces/help"
"github.com/scaleway/scaleway-cli/internal/namespaces/info"
initNamespace "github.com/scaleway/scaleway-cli/internal/namespaces/init"
"github.com/scaleway/scaleway-cli/internal/namespaces/instance/v1"
iot "github.com/scaleway/scaleway-cli/internal/namespaces/iot/v1beta1"
k8s "github.com/scaleway/scaleway-cli/internal/namespaces/k8s/v1"
"github.com/scaleway/scaleway-cli/internal/namespaces/iot/v1"
"github.com/scaleway/scaleway-cli/internal/namespaces/k8s/v1"
"github.com/scaleway/scaleway-cli/internal/namespaces/lb/v1"
"github.com/scaleway/scaleway-cli/internal/namespaces/marketplace/v1"
"github.com/scaleway/scaleway-cli/internal/namespaces/object/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package iot
import (
"github.com/scaleway/scaleway-cli/internal/core"
"github.com/scaleway/scaleway-cli/internal/human"
iot "github.com/scaleway/scaleway-sdk-go/api/iot/v1beta1"
"github.com/scaleway/scaleway-sdk-go/api/iot/v1"
)

func GetCommands() *core.Commands {
cmds := GetGeneratedCommands()

human.RegisterMarshalerFunc(iot.HubStatus(""), human.EnumMarshalFunc(hubStatusMarshalSpecs))
human.RegisterMarshalerFunc(iot.DeviceMessageFiltersPolicy(""), human.EnumMarshalFunc(deviceMessageFiltersPolicyMarshalSpecs))
human.RegisterMarshalerFunc(iot.DeviceMessageFiltersRulePolicy(""), human.EnumMarshalFunc(deviceMessageFiltersRulePolicyMarshalSpecs))
human.RegisterMarshalerFunc(iot.DeviceStatus(""), human.EnumMarshalFunc(deviceStatusMarshalSpecs))

return cmds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package iot
import (
"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/internal/human"
iot "github.com/scaleway/scaleway-sdk-go/api/iot/v1beta1"
"github.com/scaleway/scaleway-sdk-go/api/iot/v1"
)

var (
deviceMessageFiltersPolicyMarshalSpecs = human.EnumMarshalSpecs{
iot.DeviceMessageFiltersPolicyAccept: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "accept"},
iot.DeviceMessageFiltersPolicyReject: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "reject"},
deviceMessageFiltersRulePolicyMarshalSpecs = human.EnumMarshalSpecs{
iot.DeviceMessageFiltersRulePolicyAccept: &human.EnumMarshalSpec{Attribute: color.FgGreen, Value: "accept"},
iot.DeviceMessageFiltersRulePolicyReject: &human.EnumMarshalSpec{Attribute: color.FgRed, Value: "reject"},
}

deviceStatusMarshalSpecs = human.EnumMarshalSpecs{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package iot
import (
"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/internal/human"
iot "github.com/scaleway/scaleway-sdk-go/api/iot/v1beta1"
"github.com/scaleway/scaleway-sdk-go/api/iot/v1"
)

var (
Expand Down
Loading