Skip to content

Commit

Permalink
Merge pull request #1 from ack/terraform-deltas
Browse files Browse the repository at this point in the history
additional interfaces for the sdk
  • Loading branch information
mikebeyer committed Oct 9, 2015
2 parents 0103cc7 + bf89bb0 commit b9f3bf0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ type Link struct {
Rel string `json:"rel,omitempty"`
Href string `json:"href,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Verbs []string `json:"verbs,omitempty"`
}

type Links []Link

func (l Links) GetID(rel string) (bool, string) {
if ok, v := l.GetLink(rel); ok {
return true, (*v).ID
}
return false, ""
}

func (l Links) GetLink(rel string) (bool, *Link) {
for _, v := range l {
if v.Rel == rel {
return true, v.ID
return true, &v
}
}
return false, ""
return false, nil
}

type Customfields struct {
Expand Down
3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/CenturyLinkCloud/clc-sdk/aa"
"github.com/CenturyLinkCloud/clc-sdk/alert"
"github.com/CenturyLinkCloud/clc-sdk/api"
"github.com/CenturyLinkCloud/clc-sdk/dc"
"github.com/CenturyLinkCloud/clc-sdk/group"
"github.com/CenturyLinkCloud/clc-sdk/lb"
"github.com/CenturyLinkCloud/clc-sdk/server"
Expand All @@ -19,6 +20,7 @@ type Client struct {
Alert *alert.Service
LB *lb.Service
Group *group.Service
DC *dc.Service
}

func New(config api.Config) *Client {
Expand All @@ -32,6 +34,7 @@ func New(config api.Config) *Client {
c.Alert = alert.New(c.client)
c.LB = lb.New(c.client)
c.Group = group.New(c.client)
c.DC = dc.New(c.client)

return c
}
26 changes: 26 additions & 0 deletions dc/dc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,34 @@ func (s *Service) GetAll() ([]*Response, error) {
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
}

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 string `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`
}
7 changes: 7 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ func (s *Service) AddPublicIP(name string, ip PublicIP) (*status.Status, error)
return resp, err
}

func (s *Service) UpdatePublicIP(name string, public string, ip PublicIP) (*status.Status, error) {
url := fmt.Sprintf("%s/servers/%s/%s/publicIPAddresses/%s", s.config.BaseURL, s.config.Alias, name, public)
resp := &status.Status{}
err := s.client.Put(url, ip, resp)
return resp, err
}

func (s *Service) DeletePublicIP(name, ip string) (*status.Status, error) {
url := fmt.Sprintf("%s/servers/%s/%s/publicIPAddresses/%s", s.config.BaseURL, s.config.Alias, name, ip)
resp := &status.Status{}
Expand Down

0 comments on commit b9f3bf0

Please sign in to comment.