digitalocean

package
v0.0.0-...-87c85ce Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2015 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LibraryVersion = "0.1"
)

const

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

Types

type Account

type Account struct {
	DropletLimit  int    `json:"droplet_limit,omitempty"`
	Email         string `json:"email,omitempty"`
	UUID          string `json:"uuid,omitempty"`
	EmailVerified bool   `json:"email_verified,omitempty"`
}

Account represents a Digital Ocean acount.

type AccountResponse

type AccountResponse struct {
	Account Account `json:"account"`
}

AccountResponse https://developers.digitalocean.com/#account

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService Digital Ocean API docs: https://developers.digitalocean.com/#account

func (*AccountService) GetUserInformation

func (s *AccountService) GetUserInformation() (*Account, *http.Response, error)

GetUserInformation https://developers.digitalocean.com/#account

type Client

type Client struct {
	Option *Option

	BaseURL         *url.URL
	UserAgent       string
	SizesService    *SizesService
	RegionsService  *RegionsService
	DropletsService *DropletsService
	ImagesService   *ImagesService
	SSHKeysService  *SSHKeysService
	AccountService  *AccountService
	// contains filtered or unexported fields
}

A Client manages communication with the Digital Ocean API.

func NewClient

func NewClient(option *Option) (*Client, error)

NewClient returns a new Digital Ocean API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request.

type CreateDropletRequest

type CreateDropletRequest struct {
	Name              string   `json:"name,omitempty"`
	Region            string   `json:"region,omitempty"`
	Size              string   `json:"size,omitempty"`
	Image             string   `json:"image,omitempty"`
	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"`
}

CreateDropletsReque https://developers.digitalocean.com/#create-a-new-droplet

type Droplet

type Droplet struct {
	ID        int    `json:"id,omitempty"`
	Name      string `json:"name,omitempty"`
	Memory    int    `json:"memory,omitempty"`
	Vcpus     int    `json:"vcpus,omitempty"`
	Disk      int    `json:"disk,omitempty"`
	Locked    bool   `json:"locked,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
	Status    string `json:"status,omitempty"`

	BackupIds   []int    `json:"backup_ids,omitempty"`
	SnapshotIds []int    `json:"snapshot_ids,omitempty"`
	ActionIds   []string `json:"action_ids,omitempty"`
	Features    []string `json:"features,omitempty"`
	Region      Region   `json:"region,omitempty"`
	Size        string   `json:"size_slug,omitempty"`

	Networks Networks `json:"networks,omitempty"`
	Image    Image    `json:"image,omitempty"`
	Kernel   Kernel   `json:"kernel,omitempty"`
}

Droplet https://developers.digitalocean.com/#create-a-new-droplet

type DropletResponse

type DropletResponse struct {
	Droplet Droplet `json:"droplet,omitempty"`
}

DropletResponse https://developers.digitalocean.com/#create-a-new-droplet

type DropletsListResponse

type DropletsListResponse struct {
	Droplets []Droplet `json:"droplets,omitempty"`
}

DropletsListResponse https://developers.digitalocean.com/#list-all-droplets

type DropletsService

type DropletsService struct {
	// contains filtered or unexported fields
}

DropletsService Digital Ocean API docs: https://developers.digitalocean.com/#droplets

func (*DropletsService) Create

func (s *DropletsService) Create(droplet *CreateDropletRequest) (*Droplet, *http.Response, error)

Create a new droplet

func (*DropletsService) Destroy

func (s *DropletsService) Destroy(id int) (*http.Response, error)

Destroy a droplet

func (*DropletsService) Get

func (s *DropletsService) Get(id int) (*Droplet, *http.Response, error)

Retrieve an existing Droplet by id

func (*DropletsService) List

func (s *DropletsService) List() ([]Droplet, *http.Response, error)

List List all droplets

type ErrorResponse

type ErrorResponse struct {
	Response    *http.Response
	ErrorStatus ErrorStatus
}

An ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type ErrorStatus

type ErrorStatus struct {
	ID      string `json:"id,omitempty"`
	Message string `json:"message,omitempty"`
}

ErrorStatus https://developers.digitalocean.com/#statuses

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    string   `json:"created_at,omitempty"`
	MinDiskSize  int      `json:"min_disk_size,omitempty"`
}

Image https://developers.digitalocean.com/#list-all-images

type ImagesResponse

type ImagesResponse struct {
	Images []Image `json:"images,omitempty"`
	Meta   Meta    `json:"meta,omitempty"`
}

ImagesResponse https://developers.digitalocean.com/#images

type ImagesService

type ImagesService struct {
	Page    int
	PerPage int
	// contains filtered or unexported fields
}

ImagesService Digital Ocean API docs: https://developers.digitalocean.com/#images

func (*ImagesService) ListAll

func (s *ImagesService) ListAll() ([]Image, *http.Response, error)

ListAll https://developers.digitalocean.com/#list-all-images

func (*ImagesService) ListApplication

func (s *ImagesService) ListApplication() ([]Image, *http.Response, error)

ListApplication https://developers.digitalocean.com/#list-all-application-images

func (*ImagesService) ListDistribution

func (s *ImagesService) ListDistribution() ([]Image, *http.Response, error)

ListDistribution https://developers.digitalocean.com/#list-all-distribution-images

type Kernel

type Kernel struct {
	ID      int    `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

Kernel The current kernel.

type Meta

type Meta struct {
	Total int `json:"total,omitempty"`
}

Meta https://developers.digitalocean.com/#meta

type MockClient

type MockClient struct {
	Mux         *http.ServeMux
	Client      *Client
	Server      *httptest.Server
	FixturesDir string
}

A MockClient manages communication with the Digital Ocean API mock.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient returns a new Digital Ocean API client mock.

func (*MockClient) Close

func (r *MockClient) Close()

Close Close Mocl

func (*MockClient) ReadJSON

func (r *MockClient) ReadJSON(filename string) string

ReadJSON Read json from file

type NetworkV4

type NetworkV4 struct {
	IPAddress string `json:"ip_address,omitempty"`
	Netmask   string `json:"netmask,omitempty"`
	Gateway   string `json:"gateway,omitempty"`
	Type      string `json:"type,omitempty"`
}

NetworkV4 The details of the network that are configured for the Droplet instance.

type NetworkV6

type NetworkV6 struct {
	IPAddress string `json:"ip_address,omitempty"`
	Netmask   int    `json:"netmask,omitempty"`
	Gateway   string `json:"gateway,omitempty"`
	Type      string `json:"type,omitempty"`
}

NetworkV6 The details of the network that are configured for the Droplet instance.

type Networks

type Networks struct {
	V4s []NetworkV4 `json:"v4,omitempty"`
	V6s []NetworkV6 `json:"v6,omitempty"`
}

Networks The details of the network that are configured for the Droplet instance.

type Option

type Option struct {
	APIKey string
}

Option Optional parameters

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 https://developers.digitalocean.com/#regions

type RegionsResponse

type RegionsResponse struct {
	Regions []Region `json:"regions,omitempty"`
	Meta    Meta     `json:"meta,omitempty"`
}

RegionsResponse https://developers.digitalocean.com/#list-all-regions

type RegionsService

type RegionsService struct {
	// contains filtered or unexported fields
}

RegionsService Digital Ocean API docs: https://developers.digitalocean.com/#regions

type SSHKey

type SSHKey struct {
	ID          int    `json:"id,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	PublicKey   string `json:"public_key,omitempty"`
	Name        string `json:"name,omitempty"`
}

SSHKey https://developers.digitalocean.com/#list-all-keys

type SSHKeyListResponse

type SSHKeyListResponse struct {
	SSHKeys []SSHKey `json:"ssh_keys,omitempty"`
	Meta    Meta     `json:"meta,omitempty"`
}

SSHKey https://developers.digitalocean.com/#list-all-keys

type SSHKeysService

type SSHKeysService struct {
	// contains filtered or unexported fields
}

SSHKeyService Digital Ocean API docs: https://developers.digitalocean.com/#ssh-keys

func (*SSHKeysService) List

func (s *SSHKeysService) List() ([]SSHKey, *http.Response, error)

List List all SSHKeys

type Size

type Size struct {
	Slug         string   `json:"slug,omitempty"`
	Memory       int      `json:"memory,omitempty"`
	Vcpus        int      `json:"vcpus,omitempty"`
	Disk         int      `json:"disk,omitempty"`
	Transfer     float32  `json:"transfer,omitempty"`
	PriceMonthly float32  `json:"price_monthly,omitempty"`
	PriceHourly  float32  `json:"price_hourly,omitempty"`
	Regions      []string `json:"regions,omitempty"`
}

Size https://developers.digitalocean.com/#sizes

type SizesResponse

type SizesResponse struct {
	Sizes []Size `json:"sizes,omitempty"`
	Meta  Meta   `json:"meta,omitempty"`
}

SizesResponse https://developers.digitalocean.com/#list-all-sizes

type SizesService

type SizesService struct {
	// contains filtered or unexported fields
}

SizesService Digital Ocean API docs: https://developers.digitalocean.com/#sizes

func (*SizesService) List

func (s *SizesService) List() ([]Size, *http.Response, error)

List all Images

Jump to

Keyboard shortcuts

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