diff --git a/go.mod b/go.mod index 39085ba4..97605f53 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/arduino/go-paths-helper v1.6.1 github.com/arduino/go-properties-orderedmap v1.7.0 // indirect github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b - github.com/arduino/iot-client-go v1.4.0 + github.com/arduino/iot-client-go v1.4.2 github.com/gofrs/uuid v4.2.0+incompatible github.com/google/go-cmp v0.5.6 github.com/h2non/filetype v1.1.3 // indirect diff --git a/go.sum b/go.sum index 9eec5407..d625b24d 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ github.com/arduino/go-properties-orderedmap v1.7.0/go.mod h1:DKjD2VXY/NZmlingh4l github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b/go.mod h1:uwGy5PpN4lqW97FiLnbcx+xx8jly5YuPMJWfVwwjJiQ= github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b h1:3PjgYG5gVPA7cipp7vIR2lF96KkEJIFBJ+ANnuv6J20= github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b/go.mod h1:iIPnclBMYm1g32Q5kXoqng4jLhMStReIP7ZxaoUC2y8= -github.com/arduino/iot-client-go v1.4.0 h1:pWaWgfrh77JkrdqOORYG6kwAeOg96CngACnrn9diZWI= -github.com/arduino/iot-client-go v1.4.0/go.mod h1:gYvpMt7Qw+OSScTLyIlCnpbvy9y96ey/2zhB4w6FoK0= +github.com/arduino/iot-client-go v1.4.2 h1:uZC8A26ytxSkuxNBFL2b/4w0TYjsR3ny2BbB5aVe4kw= +github.com/arduino/iot-client-go v1.4.2/go.mod h1:gYvpMt7Qw+OSScTLyIlCnpbvy9y96ey/2zhB4w6FoK0= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= diff --git a/internal/iot/client.go b/internal/iot/client.go index 5a3e6df9..fc82c268 100644 --- a/internal/iot/client.go +++ b/internal/iot/client.go @@ -54,7 +54,7 @@ func (cl *Client) DeviceCreate(fqbn, name, serial, dType string) (*iotclient.Ard Serial: serial, Type: dType, } - dev, _, err := cl.api.DevicesV2Api.DevicesV2Create(cl.ctx, payload) + dev, _, err := cl.api.DevicesV2Api.DevicesV2Create(cl.ctx, payload, nil) if err != nil { err = fmt.Errorf("creating device, %w", errorDetail(err)) return nil, err @@ -105,7 +105,7 @@ func (cl *Client) DevicePassSet(id string) (*iotclient.ArduinoDevicev2Pass, erro // DeviceDelete deletes the device corresponding to the passed ID // from Arduino IoT Cloud. func (cl *Client) DeviceDelete(id string) error { - _, err := cl.api.DevicesV2Api.DevicesV2Delete(cl.ctx, id) + _, err := cl.api.DevicesV2Api.DevicesV2Delete(cl.ctx, id, nil) if err != nil { err = fmt.Errorf("deleting device: %w", errorDetail(err)) return err @@ -137,7 +137,7 @@ func (cl *Client) DeviceList(tags map[string]string) ([]iotclient.ArduinoDevicev // DeviceShow allows to retrieve a specific device, given its id, // from Arduino IoT Cloud. func (cl *Client) DeviceShow(id string) (*iotclient.ArduinoDevicev2, error) { - dev, _, err := cl.api.DevicesV2Api.DevicesV2Show(cl.ctx, id) + dev, _, err := cl.api.DevicesV2Api.DevicesV2Show(cl.ctx, id, nil) if err != nil { err = fmt.Errorf("retrieving device, %w", errorDetail(err)) return nil, err @@ -150,6 +150,7 @@ func (cl *Client) DeviceShow(id string) (*iotclient.ArduinoDevicev2, error) { func (cl *Client) DeviceOTA(id string, file *os.File, expireMins int) error { opt := &iotclient.DevicesV2OtaUploadOpts{ ExpireInMins: optional.NewInt32(int32(expireMins)), + Async: optional.NewBool(true), } _, err := cl.api.DevicesV2OtaApi.DevicesV2OtaUpload(cl.ctx, id, file, opt) if err != nil { @@ -313,7 +314,7 @@ func (cl *Client) ThingTagsDelete(id string, keys []string) error { // DashboardCreate adds a new dashboard on Arduino IoT Cloud. func (cl *Client) DashboardCreate(dashboard *iotclient.Dashboardv2) (*iotclient.ArduinoDashboardv2, error) { - newDashboard, _, err := cl.api.DashboardsV2Api.DashboardsV2Create(cl.ctx, *dashboard) + newDashboard, _, err := cl.api.DashboardsV2Api.DashboardsV2Create(cl.ctx, *dashboard, nil) if err != nil { return nil, fmt.Errorf("%s: %w", "adding new dashboard", errorDetail(err)) } @@ -323,7 +324,7 @@ func (cl *Client) DashboardCreate(dashboard *iotclient.Dashboardv2) (*iotclient. // DashboardShow allows to retrieve a specific dashboard, given its id, // from Arduino IoT Cloud. func (cl *Client) DashboardShow(id string) (*iotclient.ArduinoDashboardv2, error) { - dashboard, _, err := cl.api.DashboardsV2Api.DashboardsV2Show(cl.ctx, id) + dashboard, _, err := cl.api.DashboardsV2Api.DashboardsV2Show(cl.ctx, id, nil) if err != nil { err = fmt.Errorf("retrieving dashboard, %w", errorDetail(err)) return nil, err @@ -343,7 +344,7 @@ func (cl *Client) DashboardList() ([]iotclient.ArduinoDashboardv2, error) { // DashboardDelete deletes a dashboard from Arduino IoT Cloud. func (cl *Client) DashboardDelete(id string) error { - _, err := cl.api.DashboardsV2Api.DashboardsV2Delete(cl.ctx, id) + _, err := cl.api.DashboardsV2Api.DashboardsV2Delete(cl.ctx, id, nil) if err != nil { err = fmt.Errorf("deleting dashboard: %w", errorDetail(err)) return err @@ -362,8 +363,6 @@ func (cl *Client) setup(client, secret, organization string) error { // We use the token to create a context that will be passed to any API call cl.ctx = context.WithValue(context.Background(), iotclient.ContextAccessToken, tok.AccessToken) - // Create an instance of the iot-api Go client, we pass an empty config - // because defaults are ok config := iotclient.NewConfiguration() if organization != "" { config.DefaultHeader = map[string]string{"X-Organization": organization}