2013-06-13 10:03:10 -04:00
|
|
|
// All of the methods used to communicate with the digital_ocean API
|
|
|
|
// are here. Their API is on a path to V2, so just plain JSON is used
|
|
|
|
// in place of a proper client library for now.
|
|
|
|
|
|
|
|
package digitalocean
|
|
|
|
|
2013-10-05 22:29:02 -04:00
|
|
|
type Region struct {
|
2015-01-26 15:45:01 -05:00
|
|
|
Slug string `json:"slug"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
|
|
// v1 only
|
|
|
|
Id uint `json:"id,omitempty"`
|
|
|
|
|
|
|
|
// v2 only
|
|
|
|
Sizes []string `json:"sizes,omitempty"`
|
|
|
|
Available bool `json:"available,omitempty"`
|
|
|
|
Features []string `json:"features,omitempty"`
|
2013-10-05 22:29:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type RegionsResp struct {
|
|
|
|
Regions []Region
|
|
|
|
}
|
|
|
|
|
2014-04-29 23:33:31 -04:00
|
|
|
type Size struct {
|
2015-01-26 15:45:01 -05:00
|
|
|
Slug string `json:"slug"`
|
|
|
|
|
|
|
|
// v1 only
|
|
|
|
Id uint `json:"id,omitempty"`
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
|
|
|
|
// v2 only
|
|
|
|
Memory uint `json:"memory,omitempty"`
|
|
|
|
VCPUS uint `json:"vcpus,omitempty"`
|
|
|
|
Disk uint `json:"disk,omitempty"`
|
|
|
|
Transfer float64 `json:"transfer,omitempty"`
|
|
|
|
PriceMonthly float64 `json:"price_monthly,omitempty"`
|
|
|
|
PriceHourly float64 `json:"price_hourly,omitempty"`
|
2014-04-29 23:33:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type SizesResp struct {
|
|
|
|
Sizes []Size
|
|
|
|
}
|
|
|
|
|
2014-09-03 17:37:33 -04:00
|
|
|
type Image struct {
|
2015-01-26 15:45:01 -05:00
|
|
|
Id uint `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Slug string `json:"slug"`
|
|
|
|
Distribution string `json:"distribution"`
|
|
|
|
|
|
|
|
// v2 only
|
|
|
|
Public bool `json:"public,omitempty"`
|
|
|
|
ActionIds []string `json:"action_ids,omitempty"`
|
|
|
|
CreatedAt string `json:"created_at,omitempty"`
|
2014-04-29 23:33:31 -04:00
|
|
|
}
|
|
|
|
|
2014-09-03 17:37:33 -04:00
|
|
|
type ImagesResp struct {
|
|
|
|
Images []Image
|
2014-04-29 23:33:31 -04:00
|
|
|
}
|
|
|
|
|
2014-09-03 17:37:33 -04:00
|
|
|
type DigitalOceanClient interface {
|
|
|
|
CreateKey(string, string) (uint, error)
|
|
|
|
DestroyKey(uint) error
|
|
|
|
CreateDroplet(string, string, string, string, uint, bool) (uint, error)
|
|
|
|
DestroyDroplet(uint) error
|
|
|
|
PowerOffDroplet(uint) error
|
|
|
|
ShutdownDroplet(uint) error
|
|
|
|
CreateSnapshot(uint, string) error
|
|
|
|
Images() ([]Image, error)
|
|
|
|
DestroyImage(uint) error
|
|
|
|
DropletStatus(uint) (string, string, error)
|
|
|
|
Image(string) (Image, error)
|
|
|
|
Regions() ([]Region, error)
|
|
|
|
Region(string) (Region, error)
|
|
|
|
Sizes() ([]Size, error)
|
|
|
|
Size(string) (Size, error)
|
2013-10-05 22:29:02 -04:00
|
|
|
}
|