-
Notifications
You must be signed in to change notification settings - Fork 6
/
caas.go
48 lines (43 loc) · 1.51 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
46
47
48
package ovh
import (
"fmt"
"net/url"
)
// 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", url.QueryEscape(containerservid))
e := c.OVHClient.Get(path, &containersservice)
return containersservice, e
}