Documentation ¶
Index ¶
- type Client
- func (c *Client) Action(id string, action map[string]interface{}) error
- func (c *Client) CreateDomain(opts *CreateDomain) (string, error)
- func (c *Client) CreateDroplet(opts *CreateDroplet) (string, error)
- func (c *Client) CreateRecord(domain string, opts *CreateRecord) (string, error)
- func (c *Client) CreateSSHKey(opts *CreateSSHKey) (string, error)
- func (c *Client) DestroyDomain(name string) error
- func (c *Client) DestroyDroplet(id string) error
- func (c *Client) DestroyRecord(domain string, id string) error
- func (c *Client) DestroySSHKey(id string) error
- func (c *Client) EnableIPV6s(id string) error
- func (c *Client) EnablePrivateNetworking(id string) error
- func (c *Client) NewRequest(body interface{}, method string, endpoint string) (*http.Request, error)
- func (c *Client) PowerOff(id string) error
- func (c *Client) PowerOn(id string) error
- func (c *Client) Rename(id string, name string) error
- func (c *Client) RenameSSHKey(id string, name string) error
- func (c *Client) Resize(id string, size string) error
- func (c *Client) RetrieveDomain(name string) (Domain, error)
- func (c *Client) RetrieveDroplet(id string) (Droplet, error)
- func (c *Client) RetrieveDroplets() ([]Droplet, error)
- func (c *Client) RetrieveRecord(domain string, id string) (Record, error)
- func (c *Client) RetrieveSSHKey(id string) (SSHKey, error)
- func (c *Client) UpdateRecord(domain string, id string, opts *UpdateRecord) error
- func (c *Client) VerifyAuthentication() error
- type CreateDomain
- type CreateDroplet
- type CreateRecord
- type CreateSSHKey
- type DoError
- type Domain
- type DomainResponse
- type Droplet
- func (d *Droplet) IPV4Address(addressType string) string
- func (d *Droplet) IPV6Address(addressType string) string
- func (d *Droplet) ImageId() string
- func (d *Droplet) ImageSlug() string
- func (d *Droplet) IsLocked() string
- func (d *Droplet) NetworkingType() string
- func (d *Droplet) RegionSlug() string
- func (d *Droplet) StringId() string
- type DropletResponse
- type DropletsResponse
- type Record
- type RecordResponse
- type SSHKey
- type UpdateRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Access Token Token string // URL to the DO API to use URL string // HttpClient is the client to use. Default will be // used if not provided. Http *http.Client }
Client provides a client to the DigitalOcean API
func NewClient ¶
NewClient returns a new digitalocean client, requires an authorization token. You can generate an OAuth token by visiting the Apps & API section of the DigitalOcean control panel for your account.
func (*Client) Action ¶
Action sends the specified action to the droplet. An error is retunred, and is nil if successful
func (*Client) CreateDomain ¶
func (c *Client) CreateDomain(opts *CreateDomain) (string, error)
CreateDomain creates a domain from the parameters specified and returns an error if it fails. If no error and the name is returned, the Domain was succesfully created.
func (*Client) CreateDroplet ¶
func (c *Client) CreateDroplet(opts *CreateDroplet) (string, error)
CreateDroplet creates a droplet from the parameters specified and returns an error if it fails. If no error and an ID is returned, the Droplet was succesfully created.
func (*Client) CreateRecord ¶
func (c *Client) CreateRecord(domain string, opts *CreateRecord) (string, error)
CreateRecord creates a record from the parameters specified and returns an error if it fails. If no error and the name is returned, the Record was succesfully created.
func (*Client) CreateSSHKey ¶
func (c *Client) CreateSSHKey(opts *CreateSSHKey) (string, error)
CreateSSHKey creates an SSH key from the parameters specified and returns an error if it fails. If no error and the SSH key is returned, it was succesfully created.
func (*Client) DestroyDomain ¶
DestroyDomain destroys a domain by the ID specified and returns an error if it fails. If no error is returned, the Domain was succesfully destroyed.
func (*Client) DestroyDroplet ¶
DestroyDroplet destroys a droplet by the ID specified and returns an error if it fails. If no error is returned, the Droplet was succesfully destroyed.
func (*Client) DestroyRecord ¶
DestroyRecord destroys a record by the ID specified and returns an error if it fails. If no error is returned, the Record was succesfully destroyed.
func (*Client) DestroySSHKey ¶
DestroySSHKey destroys an SSH key by the ID specified and returns an error if it fails. If no error is returned, the key was succesfully destroyed.
func (*Client) EnableIPV6s ¶
Enables IPV6 on the droplet
func (*Client) EnablePrivateNetworking ¶
Enables private networking on the droplet
func (*Client) NewRequest ¶
func (c *Client) NewRequest(body interface{}, method string, endpoint string) (*http.Request, error)
Creates a new request with the params
func (*Client) RenameSSHKey ¶
RenameSSHKey renames an SSH key to the name specified
func (*Client) RetrieveDomain ¶
RetrieveDomain gets a domain by the ID specified and returns a Domain and an error. An error will be returned for failed requests with a nil Domain.
func (*Client) RetrieveDroplet ¶
RetrieveDroplet gets a droplet by the ID specified and returns a Droplet and an error. An error will be returned for failed requests with a nil Droplet.
func (*Client) RetrieveDroplets ¶
RetrieveDroplets gets the list of Droplets and an error. An error will be returned for failed requests with a nil slice.
func (*Client) RetrieveRecord ¶
RetrieveRecord gets a record by the ID specified and returns a Record and an error. An error will be returned for failed requests with a nil Record.
func (*Client) RetrieveSSHKey ¶
RetrieveSSHKey gets an SSH key by the ID specified and returns a SSHKey and an error. An error will be returned for failed requests with a nil SSHKey.
func (*Client) UpdateRecord ¶
func (c *Client) UpdateRecord(domain string, id string, opts *UpdateRecord) error
UpdateRecord destroys a record by the ID specified and returns an error if it fails. If no error is returned, the Record was succesfully updated.
func (*Client) VerifyAuthentication ¶
VerifyAuthentication makes a simple request to verify the provided authentication is working and returns an error if it is not.
type CreateDomain ¶
type CreateDomain struct { Name string // Name of the domain IPAddress string // IPAddress of the domain }
CreateDomain contains the request parameters to create a new domain.
type CreateDroplet ¶
type CreateDroplet struct { Name string `json:"name,omitempty"` // Name of the droplet Region string `json:"region,omitempty"` // Slug of the region to create the droplet in Size string `json:"size,omitempty"` // Slug of the size to use for the droplet Image string `json:"image,omitempty"` // Slug of the image, if using a public image SSHKeys []string `json:"ssh_keys,omitempty"` // Array of SSH Key IDs that should be added Backups bool `json:"backups,omitempty"` // true or false if backups are enabled IPV6 bool `json:"ipv6,omitempty"` // true or false if IPV6 is enabled PrivateNetworking bool `json:"private_networking,omitempty"` // true or false if Private Networking is enabled UserData string `json:"user_data,omitempty"` // metadata for the droplet }
CreateDroplet contains the request parameters to create a new droplet.
type CreateRecord ¶
type CreateRecord struct { Type string Name string Data string Priority string Port string Weight string }
CreateRecord contains the request parameters to create a new record.
type CreateSSHKey ¶
type CreateSSHKey struct { Name string `json:"name,omitempty"` PublicKey string `json:"public_key,omitempty"` }
CreateSSHKey contains the request parameters to register a new SSH key.
type DomainResponse ¶
type DomainResponse struct {
Domain Domain `json:"domain"`
}
type Droplet ¶
type Droplet struct { Id int64 `json:"id"` Name string `json:"name"` Region map[string]interface{} `json:"region"` Image map[string]interface{} `json:"image"` SizeSlug string `json:"size_slug"` Locked bool `json:"locked"` Status string `json:"status"` Networks map[string][]map[string]interface{} `json:"networks"` }
Droplet is used to represent a retrieved Droplet. All properties are set as strings.
func (*Droplet) IPV4Address ¶
Returns the ipv4 address
func (*Droplet) IPV6Address ¶
Returns the ipv6 adddress
func (*Droplet) NetworkingType ¶
Currently DO only has a network type per droplet, so we just takes ipv4s
type DropletResponse ¶
type DropletResponse struct {
Droplet Droplet `json:"droplet"`
}
type DropletsResponse ¶
type DropletsResponse struct {
Droplets []Droplet `json:"droplets"`
}
type Record ¶
type Record struct { Id int `json:"id"` Type string `json:"type"` Name string `json:"name"` Data string `json:"data"` Priority int `json:"priority"` Port int `json:"port"` Weight int `json:"weight"` }
Record is used to represent a retrieved Record. All properties are set as strings.
func (*Record) StringPort ¶
func (*Record) StringPriority ¶
func (*Record) StringWeight ¶
type RecordResponse ¶
type RecordResponse struct {
Record Record `json:"domain_record"`
}
type SSHKey ¶
type SSHKey struct { Id int64 `json:"id"` Name string `json:"name"` Fingerprint string `json:"fingerprint"` PublicKey string `json:"public_key"` }
SSHKey is used to represent a retrieved SSH key.
type UpdateRecord ¶
type UpdateRecord struct {
Name string
}
UpdateRecord contains the request parameters to create a new record.