github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/builder/digitalocean/api.go (about) 1 // All of the methods used to communicate with the digital_ocean API 2 // are here. Their API is on a path to V2, so just plain JSON is used 3 // in place of a proper client library for now. 4 5 package digitalocean 6 7 type Region struct { 8 Id uint `json:"id,omitempty"` //only in v1 api 9 Slug string `json:"slug"` //presen in both api 10 Name string `json:"name"` //presen in both api 11 Sizes []string `json:"sizes,omitempty"` //only in v2 api 12 Available bool `json:"available,omitempty"` //only in v2 api 13 Features []string `json:"features,omitempty"` //only in v2 api 14 } 15 16 type RegionsResp struct { 17 Regions []Region 18 } 19 20 type Size struct { 21 Id uint `json:"id,omitempty"` //only in v1 api 22 Name string `json:"name,omitempty"` //only in v1 api 23 Slug string `json:"slug"` //presen in both api 24 Memory uint `json:"memory,omitempty"` //only in v2 api 25 VCPUS uint `json:"vcpus,omitempty"` //only in v2 api 26 Disk uint `json:"disk,omitempty"` //only in v2 api 27 Transfer float64 `json:"transfer,omitempty"` //only in v2 api 28 PriceMonthly float64 `json:"price_monthly,omitempty"` //only in v2 api 29 PriceHourly float64 `json:"price_hourly,omitempty"` //only in v2 api 30 Regions []string `json:"regions,omitempty"` //only in v2 api 31 } 32 33 type SizesResp struct { 34 Sizes []Size 35 } 36 37 type Image struct { 38 Id uint `json:"id"` //presen in both api 39 Name string `json:"name"` //presen in both api 40 Slug string `json:"slug"` //presen in both api 41 Distribution string `json:"distribution"` //presen in both api 42 Public bool `json:"public,omitempty"` //only in v2 api 43 Regions []string `json:"regions,omitempty"` //only in v2 api 44 ActionIds []string `json:"action_ids,omitempty"` //only in v2 api 45 CreatedAt string `json:"created_at,omitempty"` //only in v2 api 46 } 47 48 type ImagesResp struct { 49 Images []Image 50 } 51 52 type DigitalOceanClient interface { 53 CreateKey(string, string) (uint, error) 54 DestroyKey(uint) error 55 CreateDroplet(string, string, string, string, uint, bool) (uint, error) 56 DestroyDroplet(uint) error 57 PowerOffDroplet(uint) error 58 ShutdownDroplet(uint) error 59 CreateSnapshot(uint, string) error 60 Images() ([]Image, error) 61 DestroyImage(uint) error 62 DropletStatus(uint) (string, string, error) 63 Image(string) (Image, error) 64 Regions() ([]Region, error) 65 Region(string) (Region, error) 66 Sizes() ([]Size, error) 67 Size(string) (Size, error) 68 }