forked from ao-space/platform-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteDevice.go
More file actions
37 lines (29 loc) · 731 Bytes
/
DeleteDevice.go
File metadata and controls
37 lines (29 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package platform
import (
"fmt"
"github.com/ao-space/platform-sdk-go/utils"
"github.com/jinzhu/copier"
"net/http"
"net/url"
)
// DeleteDevice 删除设备
func (c *Client) DeleteDevice() error {
if !c.IsAvailable(uriDeleteDevice, http.MethodDelete) {
return fmt.Errorf("the ability is not available: [%v] %v ", http.MethodDelete, uriDeleteDevice)
}
path := fmt.Sprintf("/platform/boxes/%v", c.BoxUUID)
URL := new(url.URL)
copier.Copy(URL, c.BaseURL)
URL = URL.JoinPath(path)
op := new(Operation)
op.SetOperation(http.MethodDelete, URL)
resp, err := c.Send(op, nil)
if err != nil {
return err
}
if resp.StatusCode != http.StatusNoContent {
err = utils.GetBody(resp, nil)
return err
}
return nil
}