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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
package dc
import (
"fmt"
"github.com/CenturyLinkCloud/clc-sdk/api"
)
func New(client api.HTTP) *Service {
return &Service{
client: client,
config: client.Config(),
}
}
type Service struct {
client api.HTTP
config *api.Config
}
func (s *Service) Get(id string) (*Response, error) {
url := fmt.Sprintf("%s/datacenters/%s/%s?groupLinks=true", s.config.BaseURL, s.config.Alias, id)
dc := &Response{}
err := s.client.Get(url, dc)
return dc, err
}
func (s *Service) GetAll() ([]*Response, error) {
url := fmt.Sprintf("%s/datacenters/%s", s.config.BaseURL, s.config.Alias)
dcs := make([]*Response, 0)
err := s.client.Get(url, &dcs)
return dcs, err
}
func (s *Service) GetCapabilities(id string) (*CapabilitiesResponse, error) {
url := fmt.Sprintf("%s/datacenters/%s/%s/deploymentCapabilities", s.config.BaseURL, s.config.Alias, id)
c := &CapabilitiesResponse{}
err := s.client.Get(url, c)
return c, err
}
func (s *Service) GetBareMetalCapabilities(dataCenterId string) (*BareMetalCapabilitiesResponse, error) {
url := fmt.Sprintf("%s/datacenters/%s/%s/bareMetalCapabilities", s.config.BaseURL, s.config.Alias, dataCenterId)
bm := &BareMetalCapabilitiesResponse{}
err := s.client.Get(url, bm)
return bm, err
}
type Response struct {
ID string `json:"id"`
Name string `json:"name"`
Links api.Links `json:"links"`
}
type CapabilitiesResponse struct {
SupportsPremiumStorage bool `json:"supportsPremiumStorage"`
SupportsBareMetalServers bool `json:"supportsBareMetalServers"`
SupportsSharedLoadBalancer bool `json:"supportsSharedLoadBalancer"`
Templates []struct {
Name string `json:"name"`
Description string `json:"description"`
StorageSizeGB int `json:"storageSizeGB"`
Capabilities []string `json:"capabilities"`
ReservedDrivePaths []string `json:"reservedDrivePaths"`
} `json:"templates"`
DeployableNetworks []struct {
Name string `json:"name"`
NetworkId string `json:"networkId"`
Type string `json:"type"`
AccountID string `json:"accountID"`
} `json:"deployableNetworks"`
}
type BareMetalCapabilitiesResponse struct {
SKUs []struct {
ID string `json:"id"`
HourlyRate float32 `json:"hourlyRate"`
Availability string `json:"availability"`
Memory []struct {
CapacityInGB int `json:"capacityGB"`
} `json:"memory"`
Processor struct {
Sockets int `json:"sockets"`
CoresPerSocket int `json:"coresPerSocket"`
Description string `json:"description"`
} `json:"processor"`
Storage []struct {
Type string `json:"type"`
CapacityInGB int `json:"capacityGB"`
SpeedInRPM int `json:"speedRpm"`
} `json:"storage"`
} `json:"skus"`
OperatingSystems []struct {
Type string `json:"type"`
Description string `json:"description"`
HourlyRatePerSocket float32 `json:"hourlyRatePerSocket"`
} `json:"operatingSystems"`
}
|