digo

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2013 License: Apache-2.0 Imports: 10 Imported by: 2

README

digo

Build Status

DigitalOcean API cli tool and library for golang

Requirements

Set the following env variables:

export DIGITAL_OCEAN_CLIENT_ID=<secret>
export DIGITAL_OCEAN_API_KEY=<secret>

These env settings can be set optionally:

export DIGITAL_OCEAN_DEFAULT_REGION_ID=2
export DIGITAL_OCEAN_DEFAULT_SIZE_ID=66
export DIGITAL_OCEAN_DEFAULT_IMAGE_ID=350076
export DIGITAL_OCEAN_DEFULT_SSH_KEY=<secret_id>

Installation

Download and extract the appropriate binaries from github.com/dynport/digo/releases to e.g. /usr/local/bin/.

Usage

$ digo --help
USAGE
droplet	create 	<name>                 	Create new droplet                            
                                        -i DEFAULT: "350076" Image id for new droplet 
                                        -r DEFAULT: "2"      Region id for new droplet
                                        -s DEFAULT: "66"     Size id for new droplet  
                                        -k DEFAULT: "22197"  Ssh key to be used       
droplet	destroy	<droplet_id>           	Destroy droplet                               
droplet	info   	                       	Describe Droplet                              
droplet	list   	                       	List active droplets                          
droplet	rebuild	<droplet_id>           	Rebuild droplet                               
                                        -i DEFAULT: "0" Rebuild droplet               
droplet	rename 	<droplet_id> <new_name>	Describe Droplet                              
image  	list   	                       	List available droplet images                 
key    	list   	                       	List available ssh keys                       
region 	list   	                       	List available droplet regions                
size   	list   	                       	List available droplet sizes                  
version	       	                       	Print version and revision                    

Todos (not implemented yet)

Most of the missing functionality should be straight to implement (best with some refactorings to DRY things up).

Droplets
  • reboot
  • power_cycle
  • shutdown
  • power_on
  • power_off
  • password_reset
  • resize
  • snapshot
  • restore
  • enable_backups
  • disable_backups
Images
  • show
  • destroy
  • transfer
SSH Keys
  • new
  • show
  • edit
  • destroy
Domains
  • index
  • new
  • show
  • destroy
  • records
  • records/new
  • records/show
  • records/edit
  • records/destroy

Documentation

Index

Constants

View Source
const (
	VERSION                  = "0.1.3"
	IMAGE_UBUNTU_13_04_64BIT = 350076
	REGION_SF1               = 3
	SIZE_512M                = 66
)
View Source
const API_ROOT = "https://api.digitalocean.com"

Variables

View Source
var (
	GITCOMMIT string
)

Functions

func WaitForDroplet

func WaitForDroplet(droplet *Droplet) error

Types

type Account

type Account struct {
	Name     string
	ApiKey   string
	SshKey   int
	ClientId string

	RegionId int
	SizeId   int
	ImageId  int
	// contains filtered or unexported fields
}

func LoadAccount

func LoadAccount(name string) (account *Account, e error)

func NewAccount

func NewAccount(clientId, apiKey string) *Account

func (*Account) CachedImages

func (account *Account) CachedImages() (hash map[int]string, e error)

func (*Account) CachedRegions

func (account *Account) CachedRegions() (hash map[int]string, e error)

func (*Account) CachedSizes

func (account *Account) CachedSizes() (hash map[int]string, e error)

func (*Account) CreateDroplet

func (account *Account) CreateDroplet(droplet *Droplet) (out *Droplet, e error)

func (*Account) DefaultDroplet

func (account *Account) DefaultDroplet() (droplet *Droplet)

func (*Account) DestroyDroplet

func (account *Account) DestroyDroplet(id int) (*EventResponse, error)

func (*Account) Droplets

func (self *Account) Droplets() (droplets []*Droplet, e error)

func (*Account) GetDroplet

func (a *Account) GetDroplet(id int) (*Droplet, error)

func (*Account) GetImage

func (self *Account) GetImage(id int) (image *Image, e error)

func (*Account) ImageName

func (account *Account) ImageName(i int) string

func (*Account) Images

func (self *Account) Images() (images []*Image, e error)

func (*Account) RebuildDroplet

func (a *Account) RebuildDroplet(id int, imageId int) (*EventResponse, error)

func (*Account) RegionName

func (account *Account) RegionName(i int) string

func (*Account) Regions

func (self *Account) Regions() (regions []*Region, e error)

func (*Account) RenameDroplet added in v0.1.1

func (a *Account) RenameDroplet(id int, name string) (*EventResponse, error)

func (*Account) SizeName

func (account *Account) SizeName(i int) string

func (*Account) Sizes

func (account *Account) Sizes() (sizes []*Size, e error)

func (*Account) SshKeys

func (account *Account) SshKeys() (keys []*SshKey, e error)

type Config

type Config struct {
	Accounts []*Account
}

func LoadConfig

func LoadConfig() (config *Config, e error)

func (*Config) Account

func (c *Config) Account(name string) (account *Account, e error)

type Droplet

type Droplet struct {
	Id        int       `json:"id"`
	ImageId   int       `json:"image_id"`
	SizeId    int       `json:"size_id"`
	RegionId  int       `json:"region_id"`
	Name      string    `json:"name"`
	IpAddress string    `json:"ip_address"`
	Locked    bool      `json:"locked"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"created_at"`
	SshKey    int
	*Account
}

func (*Droplet) Reload

func (droplet *Droplet) Reload() error

type DropletResponse

type DropletResponse struct {
	Status   string `json:"status"`
	*Droplet `json:"droplet"`
}

type DropletsResponse

type DropletsResponse struct {
	Status   string     `json:"status"`
	Droplets []*Droplet `json:"droplets"`
}

type ErrorResponse

type ErrorResponse struct {
	Status string `json:"status"`
	Error  string `json:"error_message"`
}

type EventResponse

type EventResponse struct {
	Status       string `json:"status"`
	EventId      int    `json:"event_id"`
	ErrorMessage string `json:"error_message"`
}

type Image

type Image struct {
	Id           int    `json:"id"`
	Name         string `json:"name"`
	Distribution string `json:"distribution"`
}

type ImageResponse

type ImageResponse struct {
	Status string `json:"status"`
	Image  *Image `json:"image"`
}

type ImagesReponse

type ImagesReponse struct {
	Status string   `json:"status"`
	Images []*Image `json:"images"`
}

type Region

type Region struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type RegionResponse

type RegionResponse struct {
	Status  string    `json:"status"`
	Regions []*Region `json:"regions"`
}

type Size

type Size struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type SizeResponse

type SizeResponse struct {
	Status string  `json:"status"`
	Sizes  []*Size `json:"sizes"`
}

type SshKey

type SshKey struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type SshKeysResponse

type SshKeysResponse struct {
	Status string    `json:"status"`
	Keys   []*SshKey `json:"ssh_keys"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL