forked from fredericalix/ovhcli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
caas.go
45 lines (40 loc) · 1.48 KB
/
caas.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
44
45
package ovh
import "fmt"
// ContainersService is a representation of a Containers Service
type ContainersService struct {
Cluster string `json:"cluster,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Frameworks []string `json:"frameworks,omitempty"`
LoadBalancer string `json:"loadBalancer,omitempty"`
Metrics *struct {
Resources *struct {
CPU int `json:"cpu,omitempty"`
Mem int `json:"mem,omitempty"`
} `json:"resources,omitempty"`
UsedResources *struct {
CPU float64 `json:"cpu,omitempty"`
Mem int `json:"mem,omitempty"`
} `json:"usedResources,omitempty"`
} `json:"metrics,omitempty"`
Name string `json:"name,omitempty"`
Slaves []string `json:"slaves,omitempty"`
State string `json:"state,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
// ContainersServicesList ...
func (c *Client) ContainersServicesList() ([]ContainersService, error) {
var contlist []string
e := c.OVHClient.Get("/caas/containers", &contlist)
containersservices := []ContainersService{}
for _, cont := range contlist {
containersservices = append(containersservices, ContainersService{Name: cont})
}
return containersservices, e
}
// ContainersServiceInfo ...
func (c *Client) ContainersServiceInfo(containerservid string) (*ContainersService, error) {
containersservice := &ContainersService{}
path := fmt.Sprintf("/caas/containers/%s", containerservid)
e := c.OVHClient.Get(path, &containersservice)
return containersservice, e
}