@@ -10,15 +10,15 @@ import (
10
10
11
11
// Client can be used to perform actions on Arduino IoT Cloud.
12
12
type Client interface {
13
- AddDevice (fqbn , name , serial , devType string ) (string , error )
14
- DeleteDevice (id string ) error
15
- ListDevices () ([]iotclient.ArduinoDevicev2 , error )
16
- AddCertificate (id , csr string ) (* iotclient.ArduinoCompressedv2 , error )
17
- AddThing (thing * iotclient.Thing , force bool ) (string , error )
18
- UpdateThing (id string , thing * iotclient.Thing , force bool ) error
19
- DeleteThing (id string ) error
20
- GetThing (id string ) (* iotclient.ArduinoThing , error )
21
- ListThings (ids []string , device * string , props bool ) ([]iotclient.ArduinoThing , error )
13
+ DeviceCreate (fqbn , name , serial , devType string ) (string , error )
14
+ DeviceDelete (id string ) error
15
+ DeviceList () ([]iotclient.ArduinoDevicev2 , error )
16
+ CertificateCreate (id , csr string ) (* iotclient.ArduinoCompressedv2 , error )
17
+ ThingCreate (thing * iotclient.Thing , force bool ) (string , error )
18
+ ThingUpdate (id string , thing * iotclient.Thing , force bool ) error
19
+ ThingDelete (id string ) error
20
+ ThingShow (id string ) (* iotclient.ArduinoThing , error )
21
+ ThingList (ids []string , device * string , props bool ) ([]iotclient.ArduinoThing , error )
22
22
}
23
23
24
24
type client struct {
@@ -38,9 +38,9 @@ func NewClient(clientID, secretID string) (Client, error) {
38
38
return cl , nil
39
39
}
40
40
41
- // AddDevice allows to create a new device on Arduino IoT Cloud.
41
+ // DeviceCreate allows to create a new device on Arduino IoT Cloud.
42
42
// It returns the ID associated to the new device, and an error.
43
- func (cl * client ) AddDevice (fqbn , name , serial , dType string ) (string , error ) {
43
+ func (cl * client ) DeviceCreate (fqbn , name , serial , dType string ) (string , error ) {
44
44
payload := iotclient.CreateDevicesV2Payload {
45
45
Fqbn : fqbn ,
46
46
Name : name ,
@@ -55,9 +55,9 @@ func (cl *client) AddDevice(fqbn, name, serial, dType string) (string, error) {
55
55
return dev .Id , nil
56
56
}
57
57
58
- // DeleteDevice deletes the device corresponding to the passed ID
58
+ // DeviceDelete deletes the device corresponding to the passed ID
59
59
// from Arduino IoT Cloud.
60
- func (cl * client ) DeleteDevice (id string ) error {
60
+ func (cl * client ) DeviceDelete (id string ) error {
61
61
_ , err := cl .api .DevicesV2Api .DevicesV2Delete (cl .ctx , id )
62
62
if err != nil {
63
63
err = fmt .Errorf ("deleting device: %w" , errorDetail (err ))
@@ -66,9 +66,9 @@ func (cl *client) DeleteDevice(id string) error {
66
66
return nil
67
67
}
68
68
69
- // ListDevices retrieves and returns a list of all Arduino IoT Cloud devices
69
+ // DeviceList retrieves and returns a list of all Arduino IoT Cloud devices
70
70
// belonging to the user performing the request.
71
- func (cl * client ) ListDevices () ([]iotclient.ArduinoDevicev2 , error ) {
71
+ func (cl * client ) DeviceList () ([]iotclient.ArduinoDevicev2 , error ) {
72
72
devices , _ , err := cl .api .DevicesV2Api .DevicesV2List (cl .ctx , nil )
73
73
if err != nil {
74
74
err = fmt .Errorf ("listing devices: %w" , errorDetail (err ))
@@ -77,9 +77,9 @@ func (cl *client) ListDevices() ([]iotclient.ArduinoDevicev2, error) {
77
77
return devices , nil
78
78
}
79
79
80
- // AddCertifcate allows to upload a certificate on Arduino IoT Cloud.
80
+ // CertificateCreate allows to upload a certificate on Arduino IoT Cloud.
81
81
// It returns the certificate parameters populated by the cloud.
82
- func (cl * client ) AddCertificate (id , csr string ) (* iotclient.ArduinoCompressedv2 , error ) {
82
+ func (cl * client ) CertificateCreate (id , csr string ) (* iotclient.ArduinoCompressedv2 , error ) {
83
83
cert := iotclient.CreateDevicesV2CertsPayload {
84
84
Ca : "Arduino" ,
85
85
Csr : csr ,
@@ -95,8 +95,8 @@ func (cl *client) AddCertificate(id, csr string) (*iotclient.ArduinoCompressedv2
95
95
return & newCert .Compressed , nil
96
96
}
97
97
98
- // AddThing adds a new thing on Arduino IoT Cloud.
99
- func (cl * client ) AddThing (thing * iotclient.Thing , force bool ) (string , error ) {
98
+ // ThingCreate adds a new thing on Arduino IoT Cloud.
99
+ func (cl * client ) ThingCreate (thing * iotclient.Thing , force bool ) (string , error ) {
100
100
opt := & iotclient.ThingsV2CreateOpts {Force : optional .NewBool (force )}
101
101
newThing , _ , err := cl .api .ThingsV2Api .ThingsV2Create (cl .ctx , * thing , opt )
102
102
if err != nil {
@@ -105,8 +105,8 @@ func (cl *client) AddThing(thing *iotclient.Thing, force bool) (string, error) {
105
105
return newThing .Id , nil
106
106
}
107
107
108
- // AddThing updates a thing on Arduino IoT Cloud.
109
- func (cl * client ) UpdateThing (id string , thing * iotclient.Thing , force bool ) error {
108
+ // ThingUpdate updates a thing on Arduino IoT Cloud.
109
+ func (cl * client ) ThingUpdate (id string , thing * iotclient.Thing , force bool ) error {
110
110
opt := & iotclient.ThingsV2UpdateOpts {Force : optional .NewBool (force )}
111
111
_ , _ , err := cl .api .ThingsV2Api .ThingsV2Update (cl .ctx , id , * thing , opt )
112
112
if err != nil {
@@ -115,8 +115,8 @@ func (cl *client) UpdateThing(id string, thing *iotclient.Thing, force bool) err
115
115
return nil
116
116
}
117
117
118
- // DeleteThing deletes a thing from Arduino IoT Cloud.
119
- func (cl * client ) DeleteThing (id string ) error {
118
+ // ThingDelete deletes a thing from Arduino IoT Cloud.
119
+ func (cl * client ) ThingDelete (id string ) error {
120
120
_ , err := cl .api .ThingsV2Api .ThingsV2Delete (cl .ctx , id , nil )
121
121
if err != nil {
122
122
err = fmt .Errorf ("deleting thing: %w" , errorDetail (err ))
@@ -125,9 +125,9 @@ func (cl *client) DeleteThing(id string) error {
125
125
return nil
126
126
}
127
127
128
- // GetThing allows to retrieve a specific thing, given its id,
128
+ // ThingShow allows to retrieve a specific thing, given its id,
129
129
// from Arduino IoT Cloud.
130
- func (cl * client ) GetThing (id string ) (* iotclient.ArduinoThing , error ) {
130
+ func (cl * client ) ThingShow (id string ) (* iotclient.ArduinoThing , error ) {
131
131
thing , _ , err := cl .api .ThingsV2Api .ThingsV2Show (cl .ctx , id , nil )
132
132
if err != nil {
133
133
err = fmt .Errorf ("retrieving thing, %w" , errorDetail (err ))
@@ -136,8 +136,8 @@ func (cl *client) GetThing(id string) (*iotclient.ArduinoThing, error) {
136
136
return & thing , nil
137
137
}
138
138
139
- // ListThings returns a list of things on Arduino IoT Cloud.
140
- func (cl * client ) ListThings (ids []string , device * string , props bool ) ([]iotclient.ArduinoThing , error ) {
139
+ // ThingList returns a list of things on Arduino IoT Cloud.
140
+ func (cl * client ) ThingList (ids []string , device * string , props bool ) ([]iotclient.ArduinoThing , error ) {
141
141
opts := & iotclient.ThingsV2ListOpts {}
142
142
opts .ShowProperties = optional .NewBool (props )
143
143
0 commit comments