@@ -16,6 +16,7 @@ type Client interface {
16
16
ListDevices () ([]iotclient.ArduinoDevicev2 , error )
17
17
AddCertificate (id , csr string ) (* iotclient.ArduinoCompressedv2 , error )
18
18
AddThing (thing * iotclient.Thing , force bool ) (string , error )
19
+ UpdateThing (id string , thing * iotclient.Thing , force bool ) error
19
20
DeleteThing (id string ) error
20
21
GetThing (id string ) (* iotclient.ArduinoThing , error )
21
22
ListThings (ids []string , device * string , props bool ) ([]iotclient.ArduinoThing , error )
@@ -108,6 +109,16 @@ func (cl *client) AddThing(thing *iotclient.Thing, force bool) (string, error) {
108
109
return newThing .Id , nil
109
110
}
110
111
112
+ // AddThing updates a thing on Arduino IoT Cloud.
113
+ func (cl * client ) UpdateThing (id string , thing * iotclient.Thing , force bool ) error {
114
+ opt := & iotclient.ThingsV2UpdateOpts {Force : optional .NewBool (force )}
115
+ _ , _ , err := cl .api .ThingsV2Api .ThingsV2Update (cl .ctx , id , * thing , opt )
116
+ if err != nil {
117
+ return fmt .Errorf ("%s: %v" , "updating thing" , err )
118
+ }
119
+ return nil
120
+ }
121
+
111
122
// DeleteThing deletes a thing from Arduino IoT Cloud.
112
123
func (cl * client ) DeleteThing (id string ) error {
113
124
_ , err := cl .api .ThingsV2Api .ThingsV2Delete (cl .ctx , id , nil )
0 commit comments