Skip to content

Commit 8b85f7a

Browse files
committed
iotclient: implement device show
1 parent 0182e27 commit 8b85f7a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/iot/client.go

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Client interface {
1313
DeviceCreate(fqbn, name, serial, devType string) (string, error)
1414
DeviceDelete(id string) error
1515
DeviceList() ([]iotclient.ArduinoDevicev2, error)
16+
DeviceShow(id string) (*iotclient.ArduinoDevicev2, error)
1617
CertificateCreate(id, csr string) (*iotclient.ArduinoCompressedv2, error)
1718
ThingCreate(thing *iotclient.Thing, force bool) (string, error)
1819
ThingUpdate(id string, thing *iotclient.Thing, force bool) error
@@ -77,6 +78,17 @@ func (cl *client) DeviceList() ([]iotclient.ArduinoDevicev2, error) {
7778
return devices, nil
7879
}
7980

81+
// DeviceShow allows to retrieve a specific device, given its id,
82+
// from Arduino IoT Cloud.
83+
func (cl *client) DeviceShow(id string) (*iotclient.ArduinoDevicev2, error) {
84+
dev, _, err := cl.api.DevicesV2Api.DevicesV2Show(cl.ctx, id)
85+
if err != nil {
86+
err = fmt.Errorf("retrieving device, %w", errorDetail(err))
87+
return nil, err
88+
}
89+
return &dev, nil
90+
}
91+
8092
// CertificateCreate allows to upload a certificate on Arduino IoT Cloud.
8193
// It returns the certificate parameters populated by the cloud.
8294
func (cl *client) CertificateCreate(id, csr string) (*iotclient.ArduinoCompressedv2, error) {

0 commit comments

Comments
 (0)