@@ -16,6 +16,7 @@ type Client interface {
1616 ListDevices () ([]iotclient.ArduinoDevicev2 , error )
1717 AddCertificate (id , csr string ) (* iotclient.ArduinoCompressedv2 , error )
1818 AddThing (thing * iotclient.Thing , force bool ) (string , error )
19+ UpdateThing (id string , thing * iotclient.Thing , force bool ) error
1920 DeleteThing (id string ) error
2021 GetThing (id string ) (* iotclient.ArduinoThing , error )
2122 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) {
108109 return newThing .Id , nil
109110}
110111
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+
111122// DeleteThing deletes a thing from Arduino IoT Cloud.
112123func (cl * client ) DeleteThing (id string ) error {
113124 _ , err := cl .api .ThingsV2Api .ThingsV2Delete (cl .ctx , id , nil )
0 commit comments