lib

package
v0.0.0-...-acabab9 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// Version of this libary
	Version = "v1.8"

	// APIVersion of Vultr
	APIVersion = "v1"

	// DefaultEndpoint to be used
	DefaultEndpoint = "https://api.vultr.com/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Balance           float64 `json:"balance"`
	PendingCharges    float64 `json:"pending_charges"`
	LastPaymentDate   string  `json:"last_payment_date"`
	LastPaymentAmount float64 `json:"last_payment_amount"`
}

AccountInfo of Vultr account

func (*AccountInfo) UnmarshalJSON

func (a *AccountInfo) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaller on AccountInfo. This is needed because the Vultr API is inconsistent in it's JSON responses for account info. Some fields can change type, from JSON number to JSON string and vice-versa.

type Application

type Application struct {
	ID         int    `json:"APPID,string"`
	Name       string `json:"name"`
	ShortName  string `json:"short_name"`
	DeployName string `json:"deploy_name"`
	Surcharge  int    `json:"surcharge"`
}

application image on Vultr

type Client

type Client struct {

	// User agent for HTTP client
	UserAgent string

	// Endpoint URL for API requests
	Endpoint *url.URL

	// API key for accessing the Vultr API
	APIKey string

	// Max. number of request attempts
	MaxAttempts int
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string, options *Options) *Client

NewClient creates new Vultr API client. Options are optional and can be nil.

func (*Client) BandwidthOfServer

func (c *Client) BandwidthOfServer(id string) (bandwidth []map[string]string, err error)

func (*Client) ChangeOSofServer

func (c *Client) ChangeOSofServer(id string, osID int) error

func (*Client) CreateDnsDomain

func (c *Client) CreateDnsDomain(domain, serverip string) error

func (*Client) CreateDnsRecord

func (c *Client) CreateDnsRecord(domain, name, rtype, data string, priority, ttl int) error

func (*Client) CreateSSHKey

func (c *Client) CreateSSHKey(name, key string) (SSHKey, error)

func (*Client) CreateServer

func (c *Client) CreateServer(name string, regionID, planID int, options *ServerOptions) (Server, error)

func (*Client) CreateSnapshot

func (c *Client) CreateSnapshot(id, description string) (Snapshot, error)

func (*Client) CreateStartupScript

func (c *Client) CreateStartupScript(name, content, scriptType string) (StartupScript, error)

func (*Client) DefaultIPv4ReverseDNS

func (c *Client) DefaultIPv4ReverseDNS(id, ip string) error

func (*Client) DeleteDnsDomain

func (c *Client) DeleteDnsDomain(domain string) error

func (*Client) DeleteDnsRecord

func (c *Client) DeleteDnsRecord(domain string, recordID int) error

func (*Client) DeleteIPv6ReverseDNS

func (c *Client) DeleteIPv6ReverseDNS(id string, ip string) error

func (*Client) DeleteSSHKey

func (c *Client) DeleteSSHKey(id string) error

func (*Client) DeleteServer

func (c *Client) DeleteServer(id string) error

func (*Client) DeleteSnapshot

func (c *Client) DeleteSnapshot(id string) error

func (*Client) DeleteStartupScript

func (c *Client) DeleteStartupScript(id string) error

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo() (info AccountInfo, err error)

GetAccountInfo retrieves the Vultr account information about current balance, pending charges, etc..

func (*Client) GetApplications

func (c *Client) GetApplications() ([]Application, error)

func (*Client) GetAvailablePlansForRegion

func (c *Client) GetAvailablePlansForRegion(id int) (planIDs []int, err error)

func (*Client) GetDnsDomains

func (c *Client) GetDnsDomains() (dnsdomains []DnsDomain, err error)

func (*Client) GetDnsRecords

func (c *Client) GetDnsRecords(domain string) (dnsrecords []DnsRecord, err error)

func (*Client) GetISO

func (c *Client) GetISO() ([]ISO, error)

func (*Client) GetOS

func (c *Client) GetOS() ([]OS, error)

func (*Client) GetPlans

func (c *Client) GetPlans() ([]Plan, error)

func (*Client) GetRegions

func (c *Client) GetRegions() ([]Region, error)

func (*Client) GetSSHKeys

func (c *Client) GetSSHKeys() (keys []SSHKey, err error)

func (*Client) GetServer

func (c *Client) GetServer(id string) (server Server, err error)

func (*Client) GetServers

func (c *Client) GetServers() (servers []Server, err error)

func (*Client) GetServersByTag

func (c *Client) GetServersByTag(tag string) (servers []Server, err error)

func (*Client) GetSnapshots

func (c *Client) GetSnapshots() (snapshots []Snapshot, err error)

func (*Client) GetStartupScript

func (c *Client) GetStartupScript(id string) (StartupScript, error)

func (*Client) GetStartupScripts

func (c *Client) GetStartupScripts() (scripts []StartupScript, err error)

func (*Client) HaltServer

func (c *Client) HaltServer(id string) error

func (*Client) ListIPv4

func (c *Client) ListIPv4(id string) (list []IPv4, err error)

func (*Client) ListIPv6

func (c *Client) ListIPv6(id string) (list []IPv6, err error)

func (*Client) ListIPv6ReverseDNS

func (c *Client) ListIPv6ReverseDNS(id string) (list []ReverseDNSIPv6, err error)

func (*Client) ListOSforServer

func (c *Client) ListOSforServer(id string) (os []OS, err error)

func (*Client) RebootServer

func (c *Client) RebootServer(id string) error

func (*Client) ReinstallServer

func (c *Client) ReinstallServer(id string) error

func (*Client) RenameServer

func (c *Client) RenameServer(id, name string) error

func (*Client) SetIPv4ReverseDNS

func (c *Client) SetIPv4ReverseDNS(id, ip, entry string) error

func (*Client) SetIPv6ReverseDNS

func (c *Client) SetIPv6ReverseDNS(id, ip, entry string) error

func (*Client) StartServer

func (c *Client) StartServer(id string) error

func (*Client) UpdateDnsRecord

func (c *Client) UpdateDnsRecord(domain string, dnsrecord DnsRecord) error

func (*Client) UpdateSSHKey

func (c *Client) UpdateSSHKey(key SSHKey) error

func (*Client) UpdateStartupScript

func (c *Client) UpdateStartupScript(script StartupScript) error

type DnsDomain

type DnsDomain struct {
	Domain  string `json:"domain"`
	Created string `json:"date_created"`
}

DNS Domain

type DnsRecord

type DnsRecord struct {
	RecordID int    `json:"RECORDID"`
	Type     string `json:"type"`
	Name     string `json:"name"`
	Data     string `json:"data"`
	Priority int    `json:"priority"`
	TTL      int    `json:"ttl"`
}

DNS Record

type IPv4

type IPv4 struct {
	IP         string `json:"ip"`
	Netmask    string `json:"netmask"`
	Gateway    string `json:"gateway"`
	Type       string `json:"type"`
	ReverseDNS string `json:"reverse"`
}

IPv4 information of a virtual machine

type IPv6

type IPv6 struct {
	IP          string `json:"ip"`
	Network     string `json:"network"`
	NetworkSize string `json:"network_size"`
	Type        string `json:"type"`
}

IPv6 information of a virtual machine

type ISO

type ISO struct {
	ID       int    `json:"ISOID"`
	Created  string `json:"date_created"`
	Filename string `json:"filename"`
	Size     int    `json:"size"`
	MD5sum   string `json:"md5sum"`
}

ISO image on Vultr

type OS

type OS struct {
	ID        int    `json:"OSID"`
	Name      string `json:"name"`
	Arch      string `json:"arch"`
	Family    string `json:"family"`
	Windows   bool   `json:"windows"`
	Surcharge string `json:"surcharge"`
}

OS image on Vultr

type Options

type Options struct {
	// HTTP client for communication with the Vultr API
	HTTPClient *http.Client

	// User agent for HTTP client
	UserAgent string

	// Endpoint URL for API requests
	Endpoint string

	// API rate limitation, calls per duration
	RateLimitation time.Duration

	// Max. number of times to retry API calls
	MaxRetries int
}

type Plan

type Plan struct {
	ID        int    `json:"VPSPLANID,string"`
	Name      string `json:"name"`
	VCpus     int    `json:"vcpu_count,string"`
	RAM       int    `json:"ram,string"`
	Disk      int    `json:"disk,string"`
	Bandwidth string `json:"bandwidth"`
	Price     string `json:"price_per_month"`
	Regions   []int  `json:"available_locations"`
}

Plan on Vultr

type Region

type Region struct {
	ID        int    `json:"DCID,string"`
	Name      string `json:"name"`
	Country   string `json:"country"`
	Continent string `json:"continent"`
	State     string `json:"state"`
	Ddos      bool   `json:"ddos_protection"`
}

Region on Vultr

type ReverseDNSIPv6

type ReverseDNSIPv6 struct {
	IP         string `json:"ip"`
	ReverseDNS string `json:"reverse"`
}

ReverseDNSIPv6 information of a virtual machine

type SSHKey

type SSHKey struct {
	ID      string `json:"SSHKEYID"`
	Name    string `json:"name"`
	Key     string `json:"ssh_key"`
	Created string `json:"date_created"`
}

SSHKey on Vultr account

type Server

type Server struct {
	ID               string      `json:"SUBID"`
	Name             string      `json:"label"`
	OS               string      `json:"os"`
	RAM              string      `json:"ram"`
	Disk             string      `json:"disk"`
	MainIP           string      `json:"main_ip"`
	VCpus            int         `json:"vcpu_count,string"`
	Location         string      `json:"location"`
	RegionID         int         `json:"DCID,string"`
	DefaultPassword  string      `json:"default_password"`
	Created          string      `json:"date_created"`
	PendingCharges   float64     `json:"pending_charges"`
	Status           string      `json:"status"`
	Cost             string      `json:"cost_per_month"`
	CurrentBandwidth float64     `json:"current_bandwidth_gb"`
	AllowedBandwidth float64     `json:"allowed_bandwidth_gb,string"`
	NetmaskV4        string      `json:"netmask_v4"`
	GatewayV4        string      `json:"gateway_v4"`
	PowerStatus      string      `json:"power_status"`
	ServerState      string      `json:"server_state"`
	PlanID           int         `json:"VPSPLANID,string"`
	V6Networks       []V6Network `json:"v6_networks"`
	InternalIP       string      `json:"internal_ip"`
	KVMUrl           string      `json:"kvm_url"`
	AutoBackups      string      `json:"auto_backups"`
	Tag              string      `json:"tag"`
}

Server (virtual machine) on Vultr account

func (*Server) UnmarshalJSON

func (s *Server) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaller on Server. This is needed because the Vultr API is inconsistent in it's JSON responses for servers. Some fields can change type, from JSON number to JSON string and vice-versa.

type ServerOptions

type ServerOptions struct {
	IPXEChainURL         string
	OS                   int
	ISO                  int
	Script               int
	Application          int
	UserData             string
	Snapshot             string
	SSHKey               string
	IPV6                 bool
	PrivateNetworking    bool
	AutoBackups          bool
	DontNotifyOnActivate bool
}

ServerOptions are optional parameters to be used during server creation

type Snapshot

type Snapshot struct {
	ID          string `json:"SNAPSHOTID"`
	Description string `json:"description"`
	Size        int64  `json:"size,string"`
	Status      string `json:"status"`
	Created     string `json:"date_created"`
}

Snapshot of a virtual machine on Vultr account

type StartupScript

type StartupScript struct {
	ID      string `json:"SCRIPTID"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Content string `json:"script"`
}

StartupScript on Vultr account

func (*StartupScript) UnmarshalJSON

func (s *StartupScript) UnmarshalJSON(data []byte) (err error)

Implements json.Unmarshaller on StartupScript. Necessary because the SRIPTID field has inconsistent types.

type V6Network

type V6Network struct {
	Network     string `json:"v6_network"`
	MainIP      string `json:"v6_main_ip"`
	NetworkSize string `json:"v6_network_size"`
}

V6Network represents a IPv6 network of a Vultr server

Jump to

Keyboard shortcuts

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