-
Notifications
You must be signed in to change notification settings - Fork 16
/
contractresources.go
66 lines (59 loc) · 2.46 KB
/
contractresources.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package profitbricks
import (
"net/http"
)
//ContractResources object
type ContractResources struct {
ID string `json:"id,omitempty"`
PBType string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Properties ContractResourcesProperties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"statuscode,omitempty"`
}
//ContractResourcesProperties object
type ContractResourcesProperties struct {
PBContractNumber int64 `json:"contractNumber,omitempty"`
Owner string `json:"owner,omitempty"`
Status string `json:"status,omitempty"`
ResourceLimits *ResourcesLimits `json:"resourceLimits,omitempty"`
}
//ResourcesLimits object
type ResourcesLimits struct {
CoresPerServer int32 `json:"coresPerServer,omitempty"`
CoresPerContract int32 `json:"coresPerContract,omitempty"`
CoresProvisioned int32 `json:"coresProvisioned,omitempty"`
RAMPerServer int32 `json:"ramPerServer,omitempty"`
RAMPerContract int32 `json:"ramPerContract,omitempty"`
RAMProvisioned int32 `json:"ramProvisioned,omitempty"`
HddLimitPerVolume int64 `json:"hddLimitPerVolume,omitempty"`
HddLimitPerContract int64 `json:"hddLimitPerContract,omitempty"`
HddVolumeProvisioned int64 `json:"hddVolumeProvisioned,omitempty"`
SsdLimitPerVolume int64 `json:"ssdLimitPerVolume,omitempty"`
SsdLimitPerContract int64 `json:"ssdLimitPerContract,omitempty"`
SsdVolumeProvisioned int64 `json:"ssdVolumeProvisioned,omitempty"`
ReservableIps int32 `json:"reservableIps,omitempty"`
ReservedIpsOnContract int32 `json:"reservedIpsOnContract,omitempty"`
ReservedIpsInUse int32 `json:"reservedIpsInUse,omitempty"`
}
// GetContractResources returns list of contract resources
func (c *Client) GetContractResources() (*ContractResources, error) {
ctx, cancel := c.GetContext()
if cancel != nil {
defer cancel()
}
rsp, apiResponse, err := c.CoreSdk.ContractApi.ContractsGet(ctx).Execute()
ret := ContractResources{}
if errConv := convertToCompat(&rsp, &ret); errConv != nil {
return nil, errConv
}
fillInResponse(&ret, apiResponse)
return &ret, err
/*
url := contractsPath()
ret := &ContractResources{}
err := c.Get(url, ret, http.StatusOK)
return ret, err
*/
}