godo

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2014 License: BSD-3-Clause, MIT Imports: 12 Imported by: 36

README

Godo

Godo is a Go client library for accessing the DigitalOcean V2 API.

You can view the client API docs here: http://godoc.org/github.com/digitalocean/godo

You can view Digital Ocean API docs here: https://developers.digitalocean.com/v2/

Usage

import "github.com/digitalocean/godo"

Create a new DigitalOcean client, then use the exposed services to access different parts of the DigitalOcean API.

Authentication

Currently, Personal Access Token (PAT) is the only method of authenticating with the API. You can manage your tokens at the Digital Ocean Control Panel Applications Page.

You can then use your token to create a new client:

import "code.google.com/p/goauth2/oauth"

pat := "mytoken"
t := &oauth.Transport{
	Token: &oauth.Token{AccessToken: pat},
}

client := godo.NewClient(t.Client())

Examples

To create a new Droplet:

dropletName := "super-cool-droplet"

createRequest := &godo.DropletCreateRequest{
    Name:   dropletName,
    Region: "nyc3",
    Size:   "512mb",
    Image:  "ubuntu-14-04-x64",
}

newDroplet, _, err := client.Droplets.Create(createRequest)

if err != nil {
    fmt.Printf("Something bad happened: %s\n\n", err)
    return err
}
Pagination

If a list of items is paginated by the API, you must request pages individually. For example, to fetch all Droplets:

func DropletList(client *godo.Client) ([]godo.Droplet, error) {
    // create a list to hold our droplets
    list := []godo.Droplet{}

    // create options. initially, these will be blank
    opt := &godo.ListOptions{}
    for {
        droplets, resp, err := client.Droplets.List(opt)
        if err != nil {
            return err
        }
        
        // append the current page's droplets to our list
        for _, d := range droplets {
            list = append(list, d)
        }

       // if we are at the last page, break out the for loop
       if resp.Links.IsLastPage() {
           break
       }

       page, err := resp.Links.CurrentPage()
       if err != nil {
           return err
        }

       // set the page we want for the next request
       opt.Page = page + 1
    }

    return nil
}

Documentation

Overview

Package godo is the DigtalOcean API v2 client for Go

Index

Constants

View Source
const (

	// ActionInProgress is an in progress action status
	ActionInProgress = "in-progress"

	//ActionCompleted is a completed action status
	ActionCompleted = "completed"
)

Variables

This section is empty.

Functions

func Bool added in v0.3.1

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func CheckResponse added in v0.3.1

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.

func Int added in v0.3.1

func Int(v int) *int

Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.

func StreamToString added in v0.3.1

func StreamToString(stream io.Reader) string

StreamToString converts a reader to a string

func String added in v0.3.1

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Stringify added in v0.3.1

func Stringify(message interface{}) string

Stringify attempts to create a string representation of Digital Ocean types

Types

type Action added in v0.3.1

type Action struct {
	ID           int        `json:"id"`
	Status       string     `json:"status"`
	Type         string     `json:"type"`
	StartedAt    *Timestamp `json:"started_at"`
	CompletedAt  *Timestamp `json:"completed_at"`
	ResourceID   int        `json:"resource_id"`
	ResourceType string     `json:"resource_type"`
}

Action represents a DigitalOcean Action

func (Action) String added in v0.3.1

func (a Action) String() string

type ActionRequest added in v0.3.1

type ActionRequest struct {
	Type   string                 `json:"type"`
	Params map[string]interface{} `json:"params,omitempty"`
}

ActionRequest reprents DigitalOcean Action Request

func (ActionRequest) String added in v0.3.1

func (d ActionRequest) String() string

Converts an ActionRequest to a string.

type ActionsService added in v0.3.1

type ActionsService interface {
	List(*ListOptions) ([]Action, *Response, error)
	Get(int) (*Action, *Response, error)
}

ActionsService handles communction with action related methods of the DigitalOcean API: https://developers.digitalocean.com/#actions

type ActionsServiceOp added in v0.3.1

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

ActionsServiceOp handles communition with the image action related methods of the DigitalOcean API.

func (*ActionsServiceOp) Get added in v0.3.1

func (s *ActionsServiceOp) Get(id int) (*Action, *Response, error)

Get an action by ID

func (*ActionsServiceOp) List added in v0.3.1

func (s *ActionsServiceOp) List(opt *ListOptions) ([]Action, *Response, error)

List all actions

type Client added in v0.3.1

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent for client
	UserAgent string

	// Rate contains the current rate limit for the client as determined by the most recent
	// API call.
	Rate Rate

	// Services used for communicating with the API
	Actions        ActionsService
	Domains        DomainsService
	Droplets       DropletsService
	DropletActions DropletActionsService
	Images         ImagesService
	ImageActions   ImageActionsService
	Keys           KeysService
	Regions        RegionsService
	Sizes          SizesService
	// contains filtered or unexported fields
}

Client manages communication with DigitalOcean V2 API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Digital Ocean API client.

func (*Client) Do added in v0.3.1

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

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) NewRequest added in v0.3.1

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

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.

type Domain added in v0.3.1

type Domain struct {
	Name     string `json:"name"`
	TTL      int    `json:"ttl"`
	ZoneFile string `json:"zone_file"`
}

Domain represents a Digital Ocean domain

func (Domain) String added in v0.3.1

func (d Domain) String() string

type DomainCreateRequest added in v0.3.1

type DomainCreateRequest struct {
	Name      string `json:"name"`
	IPAddress string `json:"ip_address"`
}

DomainCreateRequest respresents a request to create a domain.

type DomainRecord added in v0.3.1

type DomainRecord struct {
	ID       int    `json:"id,float64,omitempty"`
	Type     string `json:"type,omitempty"`
	Name     string `json:"name,omitempty"`
	Data     string `json:"data,omitempty"`
	Priority int    `json:"priority,omitempty"`
	Port     int    `json:"port,omitempty"`
	Weight   int    `json:"weight,omitempty"`
}

DomainRecord represents a DigitalOcean DomainRecord

func (DomainRecord) String added in v0.3.1

func (d DomainRecord) String() string

Converts a DomainRecord to a string.

type DomainRecordEditRequest added in v0.3.1

type DomainRecordEditRequest struct {
	Type     string `json:"type,omitempty"`
	Name     string `json:"name,omitempty"`
	Data     string `json:"data,omitempty"`
	Priority int    `json:"priority,omitempty"`
	Port     int    `json:"port,omitempty"`
	Weight   int    `json:"weight,omitempty"`
}

DomainRecordEditRequest represents a request to update a domain record.

func (DomainRecordEditRequest) String added in v0.3.1

func (d DomainRecordEditRequest) String() string

Converts a DomainRecordEditRequest to a string.

type DomainRecordRoot added in v0.3.1

type DomainRecordRoot struct {
	DomainRecord *DomainRecord `json:"domain_record"`
}

DomainRecordRoot is the root of an individual Domain Record response

type DomainRecordsRoot added in v0.3.1

type DomainRecordsRoot struct {
	DomainRecords []DomainRecord `json:"domain_records"`
	Links         *Links         `json:"links"`
}

DomainRecordsRoot is the root of a group of Domain Record responses

type DomainRoot added in v0.3.1

type DomainRoot struct {
	Domain *Domain `json:"domain"`
}

DomainRoot represents a response from the Digital Ocean API

type DomainsService added in v0.3.1

type DomainsService interface {
	List(*ListOptions) ([]Domain, *Response, error)
	Get(string) (*DomainRoot, *Response, error)
	Create(*DomainCreateRequest) (*DomainRoot, *Response, error)
	Delete(string) (*Response, error)

	Records(string, *ListOptions) ([]DomainRecord, *Response, error)
	Record(string, int) (*DomainRecord, *Response, error)
	DeleteRecord(string, int) (*Response, error)
	EditRecord(string, int, *DomainRecordEditRequest) (*DomainRecord, *Response, error)
	CreateRecord(string, *DomainRecordEditRequest) (*DomainRecord, *Response, error)
}

DomainsService is an interface for managing DNS with the Digital Ocean API. See: https://developers.digitalocean.com/#domains and https://developers.digitalocean.com/#domain-records

type DomainsServiceOp added in v0.3.1

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

DomainsServiceOp handles communication with the domain related methods of the DigitalOcean API.

func (*DomainsServiceOp) Create added in v0.3.1

func (s *DomainsServiceOp) Create(createRequest *DomainCreateRequest) (*DomainRoot, *Response, error)

Create a new domain

func (*DomainsServiceOp) CreateRecord added in v0.3.1

func (s *DomainsServiceOp) CreateRecord(
	domain string,
	createRequest *DomainRecordEditRequest) (*DomainRecord, *Response, error)

CreateRecord creates a record using a DomainRecordEditRequest

func (*DomainsServiceOp) Delete added in v0.3.1

func (s *DomainsServiceOp) Delete(name string) (*Response, error)

Delete droplet

func (*DomainsServiceOp) DeleteRecord added in v0.3.1

func (s *DomainsServiceOp) DeleteRecord(domain string, id int) (*Response, error)

DeleteRecord deletes a record from a domain identified by id

func (*DomainsServiceOp) EditRecord added in v0.3.1

func (s *DomainsServiceOp) EditRecord(
	domain string,
	id int,
	editRequest *DomainRecordEditRequest) (*DomainRecord, *Response, error)

EditRecord edits a record using a DomainRecordEditRequest

func (*DomainsServiceOp) Get added in v0.3.1

func (s *DomainsServiceOp) Get(name string) (*DomainRoot, *Response, error)

Get individual domain

func (DomainsServiceOp) List added in v0.3.1

func (s DomainsServiceOp) List(opt *ListOptions) ([]Domain, *Response, error)

List all domains

func (*DomainsServiceOp) Record added in v0.3.1

func (s *DomainsServiceOp) Record(domain string, id int) (*DomainRecord, *Response, error)

Record returns the record id from a domain

func (*DomainsServiceOp) Records added in v0.3.1

func (s *DomainsServiceOp) Records(domain string, opt *ListOptions) ([]DomainRecord, *Response, error)

Records returns a slice of DomainRecords for a domain

type Droplet added in v0.3.1

type Droplet struct {
	ID          int       `json:"id,float64,omitempty"`
	Name        string    `json:"name,omitempty"`
	Memory      int       `json:"memory,omitempty"`
	Vcpus       int       `json:"vcpus,omitempty"`
	Disk        int       `json:"disk,omitempty"`
	Region      *Region   `json:"region,omitempty"`
	Image       *Image    `json:"image,omitempty"`
	Size        *Size     `json:"size,omitempty"`
	BackupIDs   []int     `json:"backup_ids,omitempty"`
	SnapshotIDs []int     `json:"snapshot_ids,omitempty"`
	Locked      bool      `json:"locked,bool,omitempty"`
	Status      string    `json:"status,omitempty"`
	Networks    *Networks `json:"networks,omitempty"`
	ActionIDs   []int     `json:"action_ids,omitempty"`
}

Droplet represents a DigitalOcean Droplet

func (Droplet) String added in v0.3.1

func (d Droplet) String() string

Convert Droplet to a string

type DropletActionsService added in v0.3.1

type DropletActionsService interface {
	Shutdown(int) (*Action, *Response, error)
	PowerOff(int) (*Action, *Response, error)
	PowerOn(int) (*Action, *Response, error)
	PowerCycle(int) (*Action, *Response, error)
	Reboot(int) (*Action, *Response, error)
	Restore(int, int) (*Action, *Response, error)
	Resize(int, string) (*Action, *Response, error)
	Rename(int, string) (*Action, *Response, error)

	Get(int, int) (*Action, *Response, error)
	GetByURI(string) (*Action, *Response, error)
	// contains filtered or unexported methods
}

DropletActionsService is an interface for interfacing with the droplet actions endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#droplet-actions

type DropletActionsServiceOp added in v0.3.1

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

DropletActionsServiceOp handles communication with the droplet action related methods of the DigitalOcean API.

func (*DropletActionsServiceOp) Get added in v0.3.1

func (s *DropletActionsServiceOp) Get(dropletID, actionID int) (*Action, *Response, error)

Get an action for a particular droplet by id.

func (*DropletActionsServiceOp) GetByURI added in v0.3.1

func (s *DropletActionsServiceOp) GetByURI(rawurl string) (*Action, *Response, error)

GetByURI gets an action for a particular droplet by id.

func (*DropletActionsServiceOp) PowerCycle added in v0.3.1

func (s *DropletActionsServiceOp) PowerCycle(id int) (*Action, *Response, error)

PowerCycle a Droplet

func (*DropletActionsServiceOp) PowerOff added in v0.3.1

func (s *DropletActionsServiceOp) PowerOff(id int) (*Action, *Response, error)

PowerOff a Droplet

func (*DropletActionsServiceOp) PowerOn added in v0.4.0

func (s *DropletActionsServiceOp) PowerOn(id int) (*Action, *Response, error)

PowerOn a Droplet

func (*DropletActionsServiceOp) Reboot added in v0.3.1

func (s *DropletActionsServiceOp) Reboot(id int) (*Action, *Response, error)

Reboot a Droplet

func (*DropletActionsServiceOp) Rename added in v0.3.1

func (s *DropletActionsServiceOp) Rename(id int, name string) (*Action, *Response, error)

Rename a Droplet

func (*DropletActionsServiceOp) Resize added in v0.3.1

func (s *DropletActionsServiceOp) Resize(id int, sizeSlug string) (*Action, *Response, error)

Resize a Droplet

func (*DropletActionsServiceOp) Restore added in v0.3.1

func (s *DropletActionsServiceOp) Restore(id, imageID int) (*Action, *Response, error)

Restore an image to a Droplet

func (*DropletActionsServiceOp) Shutdown added in v0.3.1

func (s *DropletActionsServiceOp) Shutdown(id int) (*Action, *Response, error)

Shutdown a Droplet

type DropletCreateRequest added in v0.3.1

type DropletCreateRequest struct {
	Name    string        `json:"name"`
	Region  string        `json:"region"`
	Size    string        `json:"size"`
	Image   string        `json:"image"`
	SSHKeys []interface{} `json:"ssh_keys"`
}

DropletCreateRequest represents a request to create a droplet.

func (DropletCreateRequest) String added in v0.3.1

func (d DropletCreateRequest) String() string

type DropletRoot added in v0.3.1

type DropletRoot struct {
	Droplet *Droplet `json:"droplet"`
	Links   *Links   `json:"links,omitempty"`
}

DropletRoot represents a Droplet root

type DropletsService added in v0.3.1

type DropletsService interface {
	List(*ListOptions) ([]Droplet, *Response, error)
	Get(int) (*DropletRoot, *Response, error)
	Create(*DropletCreateRequest) (*DropletRoot, *Response, error)
	Delete(int) (*Response, error)
	// contains filtered or unexported methods
}

DropletsService is an interface for interfacing with the droplet endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#droplets

type DropletsServiceOp added in v0.3.1

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

DropletsServiceOp handles communication with the droplet related methods of the DigitalOcean API.

func (*DropletsServiceOp) Create added in v0.3.1

func (s *DropletsServiceOp) Create(createRequest *DropletCreateRequest) (*DropletRoot, *Response, error)

Create droplet

func (*DropletsServiceOp) Delete added in v0.3.1

func (s *DropletsServiceOp) Delete(dropletID int) (*Response, error)

Delete droplet

func (*DropletsServiceOp) Get added in v0.3.1

func (s *DropletsServiceOp) Get(dropletID int) (*DropletRoot, *Response, error)

Get individual droplet

func (*DropletsServiceOp) List added in v0.3.1

func (s *DropletsServiceOp) List(opt *ListOptions) ([]Droplet, *Response, error)

List all droplets

type ErrorResponse added in v0.3.1

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message
	Message string
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error added in v0.3.1

func (r *ErrorResponse) Error() string

type Image added in v0.3.1

type Image struct {
	ID           int      `json:"id,float64,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"`
}

Image represents a DigitalOcean Image

func (Image) String added in v0.3.1

func (i Image) String() string

type ImageActionsService added in v0.3.1

type ImageActionsService interface {
	Get(int, int) (*Action, *Response, error)
	Transfer(int, *ActionRequest) (*Action, *Response, error)
}

ImageActionsService is an interface for interfacing with the image actions endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#image-actions

type ImageActionsServiceOp added in v0.3.1

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

ImageActionsServiceOp handles communition with the image action related methods of the DigitalOcean API.

func (*ImageActionsServiceOp) Get added in v0.3.1

func (i *ImageActionsServiceOp) Get(imageID, actionID int) (*Action, *Response, error)

Get an action for a particular image by id.

func (*ImageActionsServiceOp) Transfer added in v0.3.1

func (i *ImageActionsServiceOp) Transfer(imageID int, transferRequest *ActionRequest) (*Action, *Response, error)

Transfer an image

type ImagesService added in v0.3.1

type ImagesService interface {
	List(*ListOptions) ([]Image, *Response, error)
}

ImagesService is an interface for interfacing with the images endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#images

type ImagesServiceOp added in v0.3.1

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

ImagesServiceOp handles communication with the image related methods of the DigitalOcean API.

func (*ImagesServiceOp) List added in v0.3.1

func (s *ImagesServiceOp) List(opt *ListOptions) ([]Image, *Response, error)

List all sizes

type Key added in v0.3.1

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

Key represents a DigitalOcean Key.

func (Key) String added in v0.3.1

func (s Key) String() string

type KeyCreateRequest added in v0.3.1

type KeyCreateRequest struct {
	Name      string `json:"name"`
	PublicKey string `json:"public_key"`
}

KeyCreateRequest represents a request to create a new key.

type KeysService added in v0.3.1

type KeysService interface {
	List(*ListOptions) ([]Key, *Response, error)
	GetByID(int) (*Key, *Response, error)
	GetByFingerprint(string) (*Key, *Response, error)
	Create(*KeyCreateRequest) (*Key, *Response, error)
	DeleteByID(int) (*Response, error)
	DeleteByFingerprint(string) (*Response, error)
}

KeysService is an interface for interfacing with the keys endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#keys

type KeysServiceOp added in v0.3.1

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

KeysServiceOp handles communication with key related method of the DigitalOcean API.

func (*KeysServiceOp) Create added in v0.3.1

func (s *KeysServiceOp) Create(createRequest *KeyCreateRequest) (*Key, *Response, error)

Create a key using a KeyCreateRequest

func (*KeysServiceOp) DeleteByFingerprint added in v0.3.1

func (s *KeysServiceOp) DeleteByFingerprint(fingerprint string) (*Response, error)

DeleteByFingerprint deletes a key by its fingerprint

func (*KeysServiceOp) DeleteByID added in v0.3.1

func (s *KeysServiceOp) DeleteByID(keyID int) (*Response, error)

DeleteByID deletes a key by its id

func (*KeysServiceOp) GetByFingerprint added in v0.3.1

func (s *KeysServiceOp) GetByFingerprint(fingerprint string) (*Key, *Response, error)

GetByFingerprint gets a Key by by fingerprint

func (*KeysServiceOp) GetByID added in v0.3.1

func (s *KeysServiceOp) GetByID(keyID int) (*Key, *Response, error)

GetByID gets a Key by id

func (*KeysServiceOp) List added in v0.3.1

func (s *KeysServiceOp) List(opt *ListOptions) ([]Key, *Response, error)

List all keys

type LinkAction added in v0.3.1

type LinkAction struct {
	ID   int    `json:"id,omitempty"`
	Rel  string `json:"rel,omitempty"`
	HREF string `json:"href,omitempty"`
}

LinkAction is a pointer to an action

func (*LinkAction) Get added in v0.3.1

func (la *LinkAction) Get(client *Client) (*Action, *Response, error)
type Links struct {
	Pages   *Pages       `json:"pages,omitempty"`
	Actions []LinkAction `json:"actions,omitempty"`
}

Links manages links that are returned along with a List

func (*Links) CurrentPage added in v0.3.1

func (l *Links) CurrentPage() (int, error)

CurrentPage is current page of the list

func (*Links) IsLastPage added in v0.3.1

func (l *Links) IsLastPage() bool

IsLastPage returns true if the current page is the last

type ListOptions added in v0.3.1

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Page int `url:"page,omitempty"`

	// For paginated result sets, the number of results to include per page.
	PerPage int `url:"per_page,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type Network added in v0.3.1

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

Network represents a DigitalOcean Network

func (Network) String added in v0.3.1

func (n Network) String() string

type Networks added in v0.3.1

type Networks struct {
	V4 []Network `json:"v4,omitempty"`
	V6 []Network `json:"v6,omitempty"`
}

Networks represents the droplet's networks

type Pages added in v0.3.1

type Pages struct {
	First string `json:"first,omitempty"`
	Prev  string `json:"prev,omitempty"`
	Last  string `json:"last,omitempty"`
	Next  string `json:"next,omitempty"`
}

Pages are pages specified in Links

type Rate added in v0.3.1

type Rate struct {
	// The number of request per hour the client is currently limited to.
	Limit int `json:"limit"`

	// The number of remaining requests the client can make this hour.
	Remaining int `json:"remaining"`

	// The time at w\hic the current rate limit will reset.
	Reset Timestamp `json:"reset"`
}

Rate contains the rate limit for the current client.

func (Rate) String added in v0.3.1

func (r Rate) String() string

type Region added in v0.3.1

type Region struct {
	Slug      string   `json:"slug,omitempty"`
	Name      string   `json:"name,omitempty"`
	Sizes     []string `json:"sizes,omitempty"`
	Available bool     `json:"available,omitempty`
}

Region represents a DigitalOcean Region

func (Region) String added in v0.3.1

func (r Region) String() string

type RegionsService added in v0.3.1

type RegionsService interface {
	List(*ListOptions) ([]Region, *Response, error)
}

RegionsService is an interface for interfacing with the regions endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#regions

type RegionsServiceOp added in v0.3.1

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

RegionsServiceOp handles communication with the region related methods of the DigitalOcean API.

func (*RegionsServiceOp) List added in v0.3.1

func (s *RegionsServiceOp) List(opt *ListOptions) ([]Region, *Response, error)

List all regions

type Response added in v0.3.1

type Response struct {
	*http.Response

	// Links that were returned with the response. These are parsed from
	// request body and not the header.
	Links *Links

	// Monitoring URI
	Monitor string

	Rate
}

Response is a Digital Ocean response. This wraps the standard http.Response returned from DigitalOcean.

type Size added in v0.3.1

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

Size represents a DigitalOcean Size

func (Size) String added in v0.3.1

func (s Size) String() string

type SizesService added in v0.3.1

type SizesService interface {
	List(*ListOptions) ([]Size, *Response, error)
}

SizesService is an interface for interfacing with the size endpoints of the Digital Ocean API See: https://developers.digitalocean.com/#sizes

type SizesServiceOp added in v0.3.1

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

SizesServiceOp handles communication with the size related methods of the DigitalOcean API.

func (*SizesServiceOp) List added in v0.3.1

func (s *SizesServiceOp) List(opt *ListOptions) ([]Size, *Response, error)

List all images

type Timestamp added in v0.3.1

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. All exported methods of time.Time can be called on Timestamp.

func (Timestamp) Equal added in v0.3.1

func (t Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) String added in v0.3.1

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON added in v0.3.1

func (t *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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