Documentation ¶
Index ¶
- Constants
- Variables
- func BuildRequest(token, method, url string, body io.Reader) (*http.Request, error)
- func PrintDroplet(droplet *Droplet)
- type Config
- type Droplet
- type DropletResponse
- type DropletsResponse
- type Image
- type Kernel
- type Meta
- type Networks
- type Region
- type Size
- type V4Network
- type V6Network
- type VM
- func (vm *VM) Destroy() error
- func (vm *VM) GetIPs() ([]net.IP, error)
- func (vm *VM) GetName() string
- func (vm *VM) GetSSH(options libssh.Options) (libssh.Client, error)
- func (vm *VM) GetState() (string, error)
- func (vm *VM) Halt() error
- func (vm *VM) Provision() error
- func (vm *VM) Resume() error
- func (vm *VM) Start() error
- func (vm *VM) Suspend() error
- func (vm *VM) Update() error
Constants ¶
const ( // StatusOk is the first number of a successful HTTP return code StatusOk = '2' // StatusNotFound is the status code for a 404 StatusNotFound = 404 )
Variables ¶
var ( // ErrNoInstanceID is returned when attempting to perform an operation on an instance, but the ID is missing. ErrNoInstanceID = errors.New("Missing droplet ID") )
Functions ¶
func BuildRequest ¶
BuildRequest builds an http request for this provider.
func PrintDroplet ¶
func PrintDroplet(droplet *Droplet)
PrintDroplet prints the basic droplet values
Types ¶
type Config ¶
type Config struct { Name string `json:"name,omitempty"` // required Region string `json:"region,omitempty"` // required Size string `json:"size,omitempty"` // required Image string `json:"image,omitempty"` // required SSHKeys []string `json:"ssh_keys,omitempty"` Backups bool `json:"backups,omitempty"` IPv6 bool `json:"ipv6,omitempty"` PrivateNetworking bool `json:"private_networking,omitempty"` UserData string `json:"user_data,omitempty"` }
Config is the new droplet payload
type Droplet ¶
type Droplet struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Region *Region `json:"region,omitempty"` Image *Image `json:"image,omitempty"` Size *Size `json:"size,omitempty"` SizeSlug string `json:"size_slug,omitempty"` Locked bool `json:"locked,omitempty"` Status string `json:"status,omitempty"` Networks *Networks `json:"networks,omitempty"` Kernel *Kernel `json:"kernel,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` BackupIds []int64 `json:"backup_ids,omitempty"` SnapshotIds []int64 `json:"snapshot_ids,omitempty"` ActionIds []int64 `json:"action_ids,omitempty"` }
Droplet is the base VM type in DigitalOcean
func GetDroplet ¶
GetDroplet returns a single droplet
type DropletResponse ¶
type DropletResponse struct {
Droplet *Droplet `json:"droplet,omitempty"`
}
DropletResponse is the API response containing one droplet
type DropletsResponse ¶
type DropletsResponse struct { Droplets []*Droplet `json:"droplets"` Meta *Meta `json:"meta,omitempty"` }
DropletsResponse is the API response containing multiple droplets
func GetDroplets ¶
func GetDroplets(token string) (*DropletsResponse, error)
GetDroplets returns and array of droplets
type Image ¶
type Image struct { ID int `json:"id,omitempty"` Name string `json:"name,omitempty"` Distribution string `json:"distribution,omitempty"` Slug string `json:"slug,omitempty"` Public bool `json:"public,omitempty"` Regions []string `json:"regions,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` }
Image contains droplet image information
type Kernel ¶
type Kernel struct { ID int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` }
Kernel contains droplet kernel information
type Meta ¶
type Meta struct {
Total int `json:"total,omitempty"`
}
Meta contains metadata from API responses
type Networks ¶
type Networks struct { V4 []*V4Network `json:"v4,omitempty"` V6 []*V6Network `json:"v6,omitempty"` }
Networks contains information on all droplet networks
type Region ¶
type Region struct { Slug string `json:"slug,omitempty"` Name string `json:"name,omitempty"` Sizes []string `json:"sizes,omitempty"` Available bool `json:"available,omitempty"` Features []string `json:"features,omitempty"` }
Region contains droplet region information
type Size ¶
type Size struct { Slug string `json:"slug,omitempty"` Memory int `json:"memory,omitempty"` VCpus int `json:"v_cpus,omitempty"` Disk int `json:"disk,omitempty"` Transfer interface{} `json:"transfer,omitempty"` PriceMonthley float64 `json:"price_monthley,omitempty"` PriceHourly float64 `json:"price_hourly,omitempty"` Regions []string `json:"regions,omitempty"` }
Size describes droplet sizing
type V4Network ¶
type V4Network struct { IPAddress string `json:"ip_address,omitempty"` Netmask string `json:"netmask,omitempty"` Gateway string `json:"gateway,omitempty"` Type string `json:"type,omitempty"` }
V4Network contains an IPV4 network's values
type V6Network ¶
type V6Network struct { IPAddress string `json:"ip_address,omitempty"` Netmask int64 `json:"netmask,omitempty"` Gateway string `json:"gateway,omitempty"` Type string `json:"type,omitempty"` }
V6Network contains an IPV6 network's values
type VM ¶
type VM struct { APIToken string // required Credentials libssh.Credentials Config Config Droplet *Droplet }
VM struct represents a full DigitalOcean VM in libretto. It contains the droplet itself, along with authentication and SSH credential information. It also contains the original creation config.
func (*VM) GetState ¶
GetState gets the running state of the VM through the DigitalOcean API Returns droplet state if available and 'not_found' if ID could not be located.