-
Notifications
You must be signed in to change notification settings - Fork 9
/
onprem.go
43 lines (36 loc) · 1009 Bytes
/
onprem.go
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
38
39
40
41
42
43
package cloud66
import (
"fmt"
"time"
)
type Onprem struct {
Uid string `json:"uid"`
Name string `json:"name"`
Config interface{} `json:"config"`
CreatedAt time.Time `json:"created_at_iso"`
UpdatedAt time.Time `json:"updated_at_iso"`
}
func (c *Client) ListOnprems() ([]Onprem, error) {
req, err := c.NewRequest("GET", "/onprems.json", nil, nil)
if err != nil {
return nil, err
}
var result []Onprem
return result, c.DoReq(req, &result, nil)
}
func (c *Client) SaveOnprem(onprem Onprem) (*Onprem, error) {
req, err := c.NewRequest("PUT", fmt.Sprintf("/onprems/%s.json", onprem.Uid), onprem, nil)
if err != nil {
return nil, err
}
var onpremRes *Onprem
return onpremRes, c.DoReq(req, &onpremRes, nil)
}
func (c *Client) GetOnprem(uid string) (*Onprem, error) {
req, err := c.NewRequest("GET", fmt.Sprintf("/onprems/%s.json", uid), nil, nil)
if err != nil {
return nil, err
}
var onpremRes *Onprem
return onpremRes, c.DoReq(req, &onpremRes, nil)
}