9
9
"net/http"
10
10
"net/http/cookiejar"
11
11
"net/url"
12
+ "strings"
12
13
"time"
13
14
14
15
"github.com/mrmarble/deco/utils"
@@ -51,7 +52,7 @@ type ClientListResp struct {
51
52
Name string `json:"name"`
52
53
Online bool `json:"online"`
53
54
OwnerID string `json:"owner_id"`
54
- RemainTime int `json:"remain_time"`
55
+ RemainTime int `json:"remain_time"`
55
56
SpaceID string `json:"space_id"`
56
57
UpSpeed uint `json:"up_speed"`
57
58
WireType string `json:"wire_type"`
@@ -192,7 +193,7 @@ func (c *Client) ClientList() (*ClientListResp, error) {
192
193
var result ClientListResp
193
194
request := request {
194
195
Operation : "read" ,
195
- Params : map [string ]string {"device_mac" : "default" },
196
+ Params : map [string ]interface {} {"device_mac" : "default" },
196
197
}
197
198
jsonRequest , _ := json .Marshal (request )
198
199
err := c .doEncryptedPost (fmt .Sprintf (";stok=%s/admin/client" , c .stok ), EndpointArgs {form : "client_list" }, jsonRequest , false , & result )
@@ -208,6 +209,33 @@ func (c *Client) ClientList() (*ClientListResp, error) {
208
209
return & result , nil
209
210
}
210
211
212
+ // Reboot the deco nodes by mac address
213
+ func (c * Client ) Reboot (macAddrs ... string ) (map [string ]interface {}, error ) {
214
+ var result map [string ]interface {}
215
+ var macList []map [string ]string
216
+
217
+ for _ , mac := range macAddrs {
218
+ macList = append (macList , map [string ]string {
219
+ "mac" : strings .ToUpper (mac ),
220
+ })
221
+ }
222
+
223
+ request := request {
224
+ Operation : "reboot" ,
225
+ Params : map [string ]interface {}{
226
+ "mac_list" : macList ,
227
+ },
228
+ }
229
+
230
+ jsonRequest , _ := json .Marshal (request )
231
+ err := c .doEncryptedPost (fmt .Sprintf (";stok=%s/admin/device" , c .stok ), EndpointArgs {form : "system" }, jsonRequest , false , & result )
232
+ if err != nil {
233
+ return nil , err
234
+ }
235
+
236
+ return result , nil
237
+ }
238
+
211
239
// Custom lets you make a custom request
212
240
func (c * Client ) Custom (path string , params EndpointArgs , body []byte ) (interface {}, error ) {
213
241
var result interface {}
0 commit comments