lib

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 19 Imported by: 102

Documentation

Index

Constants

View Source
const (
	// Version of this library
	Version = "2.0.2"

	// 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 AppInfo

type AppInfo struct {
	Info string `json:"app_info"`
}

AppInfo represents the application information of a Vultr server

type Application

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

Application on Vultr

type Backup

type Backup struct {
	ID          string `json:"BACKUPID"`
	Created     string `json:"date_created"`
	Description string `json:"description"`
	Size        string `json:"size"`
	Status      string `json:"status"`
}

Backup of a virtual machine

type BackupSchedule

type BackupSchedule struct {
	CronType             string `json:"cron_type"`
	NextScheduledTimeUtc string `json:"next_scheduled_time_utc"`
	Hour                 int    `json:"hour"`
	Dow                  int    `json:"dow"`
	Dom                  int    `json:"dom"`
}

BackupSchedule represents a scheduled backup on a server see: server/backup_set_schedule, server/backup_get_schedule

type BackupScheduleResponse

type BackupScheduleResponse struct {
	Enabled bool `json:"enabled"`
	BackupSchedule
}

BackupScheduleResponse details about a virtual machines backup schedule

type BareMetalPlan

type BareMetalPlan struct {
	Deprecated bool   `json:"deprecated"`
	ID         int    `json:"METALPLANID,string"`
	Name       string `json:"name"`
	CPUs       int    `json:"cpu_count"`
	RAM        int    `json:"ram"`
	Disk       string `json:"disk"`
	Bandwidth  int    `json:"bandwidth_tb"`
	Price      int    `json:"price_per_month"`
	Regions    []int  `json:"available_locations"`
	Type       string `json:"type"`
}

BareMetalPlan is a bare metal-compatible plan on Vultr.

type BareMetalServer

type BareMetalServer 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"`
	CPUs            int         `json:"cpu_count"`
	Location        string      `json:"location"`
	RegionID        int         `json:"DCID,string"`
	DefaultPassword string      `json:"default_password"`
	Created         string      `json:"date_created"`
	Status          string      `json:"status"`
	NetmaskV4       string      `json:"netmask_v4"`
	GatewayV4       string      `json:"gateway_v4"`
	PlanID          int         `json:"METALPLANID"`
	V6Networks      []V6Network `json:"v6_networks"`
	Tag             string      `json:"tag"`
	OSID            string      `json:"OSID"`
	AppID           string      `json:"APPID"`
}

BareMetalServer represents a bare metal server on Vultr.

func (*BareMetalServer) UnmarshalJSON

func (b *BareMetalServer) UnmarshalJSON(data []byte) error

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

type BareMetalServerOptions

type BareMetalServerOptions struct {
	Script               int
	UserData             string
	Snapshot             string
	SSHKey               string
	ReservedIP           string
	IPV6                 bool
	DontNotifyOnActivate bool
	Hostname             string
	Tag                  string
	AppID                string
}

BareMetalServerOptions are optional parameters to be used during bare metal server creation.

type BlockStorage

type BlockStorage struct {
	ID         string `json:"SUBID,string"`
	Name       string `json:"label"`
	RegionID   int    `json:"DCID,string"`
	SizeGB     int    `json:"size_gb,string"`
	Created    string `json:"date_created"`
	Cost       string `json:"cost_per_month"`
	Status     string `json:"status"`
	AttachedTo string `json:"attached_to_SUBID"`
}

BlockStorage on Vultr account

func (*BlockStorage) UnmarshalJSON

func (b *BlockStorage) UnmarshalJSON(data []byte) (err error)

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

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
}

Client represents the Vultr API client

func NewClient

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

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

func (*Client) AttachBlockStorage

func (c *Client) AttachBlockStorage(id, serverID string) error

AttachBlockStorage attaches block storage to an existing virtual machine

func (*Client) AttachISOtoServer

func (c *Client) AttachISOtoServer(id string, isoID int) error

AttachISOtoServer attaches an ISO image to an existing virtual machine and reboots it

func (*Client) AttachReservedIP

func (c *Client) AttachReservedIP(ip string, serverID string) error

AttachReservedIP attaches a reserved IP to a virtual machine

func (*Client) BackupGetSchedule

func (c *Client) BackupGetSchedule(id string) (*BackupScheduleResponse, error)

BackupGetSchedule returns a virtual machines backup schedule

func (*Client) BackupSetSchedule

func (c *Client) BackupSetSchedule(id string, bs BackupSchedule) error

BackupSetSchedule sets the backup schedule given a BackupSchedule struct

func (*Client) BandwidthOfBareMetalServer

func (c *Client) BandwidthOfBareMetalServer(id string) ([]map[string]string, error)

BandwidthOfBareMetalServer retrieves the bandwidth used by a bare metal server.

func (*Client) BandwidthOfServer

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

BandwidthOfServer retrieves the bandwidth used by a virtual machine

func (*Client) ChangeApplicationofBareMetalServer

func (c *Client) ChangeApplicationofBareMetalServer(id string, appID string) error

ChangeApplicationofBareMetalServer changes the bare metal server to a different application.

func (*Client) ChangeApplicationofServer

func (c *Client) ChangeApplicationofServer(id string, appID string) error

ChangeApplicationofServer changes the virtual machine to a different application

func (*Client) ChangeOSofBareMetalServer

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

ChangeOSofBareMetalServer changes the bare metal server to a different operating system.

func (*Client) ChangeOSofServer

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

ChangeOSofServer changes the virtual machine to a different operating system

func (*Client) ChangePlanOfServer

func (c *Client) ChangePlanOfServer(id string, planID int) error

ChangePlanOfServer changes the virtual machine to a different plan

func (*Client) ConvertReservedIP

func (c *Client) ConvertReservedIP(serverID string, ip string) (string, error)

ConvertReservedIP converts an existing virtual machines IP to a reserved IP

func (*Client) CreateBareMetalServer

func (c *Client) CreateBareMetalServer(name string, regionID, planID, osID int, options *BareMetalServerOptions) (BareMetalServer, error)

CreateBareMetalServer creates a new bare metal server on Vultr. BareMetalServerOptions are optional settings.

func (*Client) CreateBlockStorage

func (c *Client) CreateBlockStorage(name string, regionID, size int) (BlockStorage, error)

CreateBlockStorage creates a new block storage on Vultr account

func (*Client) CreateDNSDomain

func (c *Client) CreateDNSDomain(domain, serverIP string) error

CreateDNSDomain creates a new DNS domain name on Vultr

func (*Client) CreateDNSRecord

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

CreateDNSRecord creates a new DNS record

func (*Client) CreateFirewallGroup

func (c *Client) CreateFirewallGroup(description string) (string, error)

CreateFirewallGroup creates a new firewall group in Vultr account

func (*Client) CreateFirewallRule

func (c *Client) CreateFirewallRule(groupID, protocol, port string,
	network *net.IPNet, notes string) (int, error)

CreateFirewallRule creates a new firewall rule in Vultr account. groupID is the ID of the firewall group to create the rule in protocol must be one of: "icmp", "tcp", "udp", "gre" port can be a port number or colon separated port range (TCP/UDP only)

func (*Client) CreateIPv4

func (c *Client) CreateIPv4(id string, reboot bool) error

CreateIPv4 creates an IPv4 address and attaches it to a virtual machine

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(regionID int, description string, subnet *net.IPNet) (Network, error)

CreateNetwork creates new Network on Vultr

func (*Client) CreateReservedIP

func (c *Client) CreateReservedIP(regionID int, ipType string, label string) (string, error)

CreateReservedIP creates a new reserved IP on Vultr account

func (*Client) CreateSSHKey

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

CreateSSHKey creates new SSHKey on Vultr

func (*Client) CreateServer

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

CreateServer creates a new virtual machine on Vultr. ServerOptions are optional settings.

func (*Client) CreateSnapshot

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

CreateSnapshot creates a new virtual machine snapshot

func (*Client) CreateStartupScript

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

CreateStartupScript creates a new startup script

func (*Client) DefaultIPv4ReverseDNS

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

DefaultIPv4ReverseDNS sets a reverse DNS entry for an IPv4 address of a virtual machine to the original setting

func (*Client) DeleteBareMetalServer

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

DeleteBareMetalServer deletes an existing bare metal server.

func (*Client) DeleteBlockStorage

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

DeleteBlockStorage deletes an existing block storage

func (*Client) DeleteDNSDomain

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

DeleteDNSDomain deletes an existing DNS domain name

func (*Client) DeleteDNSRecord

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

DeleteDNSRecord deletes an existing DNS record

func (*Client) DeleteFirewallGroup

func (c *Client) DeleteFirewallGroup(groupID string) error

DeleteFirewallGroup deletes an existing firewall group

func (*Client) DeleteFirewallRule

func (c *Client) DeleteFirewallRule(ruleNumber int, groupID string) error

DeleteFirewallRule deletes an existing firewall rule

func (*Client) DeleteIPv4

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

DeleteIPv4 deletes an IPv4 address and detaches it from a virtual machine

func (*Client) DeleteIPv6ReverseDNS

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

DeleteIPv6ReverseDNS removes a reverse DNS entry for an IPv6 address of a virtual machine

func (*Client) DeleteNetwork

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

DeleteNetwork deletes an existing Network from Vultr account

func (*Client) DeleteSSHKey

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

DeleteSSHKey deletes an existing SSHKey from Vultr account

func (*Client) DeleteServer

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

DeleteServer deletes an existing virtual machine

func (*Client) DeleteSnapshot

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

DeleteSnapshot deletes an existing virtual machine snapshot

func (*Client) DeleteStartupScript

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

DeleteStartupScript deletes an existing startup script from Vultr account

func (*Client) DestroyReservedIP

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

DestroyReservedIP deletes an existing reserved IP

func (*Client) DetachBlockStorage

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

DetachBlockStorage detaches block storage from virtual machine

func (*Client) DetachISOfromServer

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

DetachISOfromServer detaches the currently mounted ISO image from the virtual machine and reboots it

func (*Client) DetachReservedIP

func (c *Client) DetachReservedIP(serverID string, ip string) error

DetachReservedIP detaches a reserved IP from an existing virtual machine

func (*Client) DisablePrivateNetworkForServer

func (c *Client) DisablePrivateNetworkForServer(id, networkID string) error

DisablePrivateNetworkForServer removes the given virtual machine from the given private network

func (*Client) EnablePrivateNetworkForServer

func (c *Client) EnablePrivateNetworkForServer(id, networkID string) error

EnablePrivateNetworkForServer enables private networking for the given virtual machine. If private networking is already enabled, then nothing occurs. If multiple private networks exist in the virtual machine's region, then the network ID must be specified.

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) GetApplicationInfo

func (c *Client) GetApplicationInfo(id string) (appInfo AppInfo, err error)

GetApplicationInfo retrieves the application information for the existing virtual machine

func (*Client) GetApplications

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

GetApplications returns a list of all available applications on Vultr

func (*Client) GetAvailableBareMetalPlansForRegion

func (c *Client) GetAvailableBareMetalPlansForRegion(id int) ([]int, error)

GetAvailableBareMetalPlansForRegion returns available bare metal plans for specified region.

func (*Client) GetAvailablePlansForRegion

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

GetAvailablePlansForRegion returns available plans for specified region

func (*Client) GetBackups

func (c *Client) GetBackups(id string, backupid string) ([]Backup, error)

GetBackups retrieves a list of all backups on Vultr account

func (*Client) GetBareMetalPlans

func (c *Client) GetBareMetalPlans() ([]BareMetalPlan, error)

GetBareMetalPlans returns a list of all available bare metal plans on Vultr account.

func (*Client) GetBareMetalServer

func (c *Client) GetBareMetalServer(id string) (BareMetalServer, error)

GetBareMetalServer returns the bare metal server with the given ID.

func (*Client) GetBareMetalServers

func (c *Client) GetBareMetalServers() ([]BareMetalServer, error)

GetBareMetalServers returns a list of current bare metal servers on the Vultr account.

func (*Client) GetBareMetalServersByTag

func (c *Client) GetBareMetalServersByTag(tag string) ([]BareMetalServer, error)

GetBareMetalServersByTag returns a list of all bare metal servers matching by tag.

func (*Client) GetBlockStorage

func (c *Client) GetBlockStorage(id string) (BlockStorage, error)

GetBlockStorage returns block storage with given ID

func (*Client) GetBlockStorages

func (c *Client) GetBlockStorages() (storages []BlockStorage, err error)

GetBlockStorages returns a list of all active block storages on Vultr account

func (*Client) GetDNSDomains

func (c *Client) GetDNSDomains() (domains []DNSDomain, err error)

GetDNSDomains returns a list of available domains on Vultr account

func (*Client) GetDNSRecords

func (c *Client) GetDNSRecords(domain string) (records []DNSRecord, err error)

GetDNSRecords returns a list of all DNS records of a particular domain

func (*Client) GetFirewallGroup

func (c *Client) GetFirewallGroup(id string) (FirewallGroup, error)

GetFirewallGroup returns the firewall group with given ID

func (*Client) GetFirewallGroups

func (c *Client) GetFirewallGroups() ([]FirewallGroup, error)

GetFirewallGroups returns a list of all available firewall groups on Vultr

func (*Client) GetFirewallRules

func (c *Client) GetFirewallRules(groupID string) ([]FirewallRule, error)

GetFirewallRules returns a list of rules for the given firewall group

func (*Client) GetISO

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

GetISO returns a list of all ISO images on Vultr account

func (*Client) GetISOStatusofServer

func (c *Client) GetISOStatusofServer(id string) (isoStatus ISOStatus, err error)

GetISOStatusofServer retrieves the current ISO image state of an existing virtual machine

func (*Client) GetNetworks

func (c *Client) GetNetworks() (nets []Network, err error)

GetNetworks returns a list of Networks from Vultr account

func (*Client) GetOS

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

GetOS returns a list of all available operating systems on Vultr

func (*Client) GetPlans

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

GetPlans returns a list of all available plans on Vultr account

func (*Client) GetRegions

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

GetRegions returns a list of all available Vultr regions

func (*Client) GetReservedIP

func (c *Client) GetReservedIP(id string) (IP, error)

GetReservedIP returns reserved IP with given ID

func (*Client) GetSSHKeys

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

GetSSHKeys returns a list of SSHKeys from Vultr account

func (*Client) GetServer

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

GetServer returns the virtual machine with the given ID

func (*Client) GetServers

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

GetServers returns a list of current virtual machines on Vultr account

func (*Client) GetServersByTag

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

GetServersByTag returns a list of all virtual machines matching by tag

func (*Client) GetSnapshots

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

GetSnapshots retrieves a list of all snapshots on Vultr account

func (*Client) GetStartupScript

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

GetStartupScript returns the startup script with the given ID

func (*Client) GetStartupScripts

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

GetStartupScripts returns a list of all startup scripts on the current Vultr account

func (*Client) HaltBareMetalServer

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

HaltBareMetalServer stops an existing bare metal server.

func (*Client) HaltServer

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

HaltServer stops an existing virtual machine

func (*Client) LabelBlockStorage

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

LabelBlockStorage changes the label on an existing block storage

func (*Client) ListApplicationsforBareMetalServer

func (c *Client) ListApplicationsforBareMetalServer(id string) ([]Application, error)

ListApplicationsforBareMetalServer lists all available operating systems to which an existing bare metal server can be changed.

func (*Client) ListApplicationsforServer

func (c *Client) ListApplicationsforServer(id string) (apps []Application, err error)

ListApplicationsforServer lists all available operating systems to which an existing virtual machine can be changed

func (*Client) ListIPv4

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

ListIPv4 lists the IPv4 information of a virtual machine

func (*Client) ListIPv6

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

ListIPv6 lists the IPv4 information of a virtual machine

func (*Client) ListIPv6ReverseDNS

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

ListIPv6ReverseDNS lists the IPv6 reverse DNS entries of a virtual machine

func (*Client) ListOSforBareMetalServer

func (c *Client) ListOSforBareMetalServer(id string) ([]OS, error)

ListOSforBareMetalServer lists all available operating systems to which an existing bare metal server can be changed.

func (*Client) ListOSforServer

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

ListOSforServer lists all available operating systems to which an existing virtual machine can be changed

func (*Client) ListPrivateNetworksForServer

func (c *Client) ListPrivateNetworksForServer(id string) (nets []PrivateNetwork, err error)

ListPrivateNetworksForServer lists all the private networks to which an existing virtual machine is attached

func (*Client) ListReservedIP

func (c *Client) ListReservedIP() ([]IP, error)

ListReservedIP returns a list of all available reserved IPs on Vultr account

func (*Client) ListUpgradePlansForServer

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

ListUpgradePlansForServer retrieves a list of the VPSPLANIDs for which a virtual machine can be upgraded. An empty response means that there are currently no upgrades available

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the API request completion callback

func (*Client) RebootBareMetalServer

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

RebootBareMetalServer reboots an existing bare metal server.

func (*Client) RebootServer

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

RebootServer reboots an existing virtual machine

func (*Client) ReinstallBareMetalServer

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

ReinstallBareMetalServer reinstalls the operating system on an existing bare metal server.

func (*Client) ReinstallServer

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

ReinstallServer reinstalls the operating system on an existing virtual machine

func (*Client) RenameBareMetalServer

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

RenameBareMetalServer renames an existing bare metal server.

func (*Client) RenameServer

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

RenameServer renames an existing virtual machine

func (*Client) ResizeBlockStorage

func (c *Client) ResizeBlockStorage(id string, size int) error

ResizeBlockStorage resizes an existing block storage

func (*Client) RestoreBackup

func (c *Client) RestoreBackup(id, backupID string) error

RestoreBackup restore the specified backup to the virtual machine

func (*Client) RestoreSnapshot

func (c *Client) RestoreSnapshot(id, snapshotID string) error

RestoreSnapshot restore the specified snapshot to the virtual machine

func (*Client) SetFirewallGroup

func (c *Client) SetFirewallGroup(id, firewallgroup string) error

SetFirewallGroup adds a virtual machine to a firewall group

func (*Client) SetFirewallGroupDescription

func (c *Client) SetFirewallGroupDescription(groupID, description string) error

SetFirewallGroupDescription sets the description of an existing firewall group

func (*Client) SetIPv4ReverseDNS

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

SetIPv4ReverseDNS sets a reverse DNS entry for an IPv4 address of a virtual machine

func (*Client) SetIPv6ReverseDNS

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

SetIPv6ReverseDNS sets a reverse DNS entry for an IPv6 address of a virtual machine

func (*Client) StartServer

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

StartServer starts an existing virtual machine

func (*Client) TagBareMetalServer

func (c *Client) TagBareMetalServer(id, tag string) error

TagBareMetalServer replaces the tag on an existing bare metal server.

func (*Client) TagServer

func (c *Client) TagServer(id, tag string) error

TagServer replaces the tag on an existing virtual machine

func (*Client) UnsetFirewallGroup

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

UnsetFirewallGroup removes a virtual machine from a firewall group

func (*Client) UpdateDNSRecord

func (c *Client) UpdateDNSRecord(domain string, dnsrecord DNSRecord) error

UpdateDNSRecord updates an existing DNS record

func (*Client) UpdateSSHKey

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

UpdateSSHKey updates an existing SSHKey entry

func (*Client) UpdateStartupScript

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

UpdateStartupScript updates an existing startup script

type DNSDomain

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

DNSDomain represents a DNS domain on Vultr

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"`
}

DNSRecord represents a DNS record on Vultr

type FirewallGroup

type FirewallGroup struct {
	ID            string `json:"FIREWALLGROUPID"`
	Description   string `json:"description"`
	Created       string `json:"date_created"`
	Modified      string `json:"date_modified"`
	InstanceCount int    `json:"instance_count"`
	RuleCount     int    `json:"rule_count"`
	MaxRuleCount  int    `json:"max_rule_count"`
}

FirewallGroup represents a firewall group on Vultr

type FirewallRule

type FirewallRule struct {
	RuleNumber int    `json:"rulenumber"`
	Action     string `json:"action"`
	Protocol   string `json:"protocol"`
	Port       string `json:"port"`
	Network    *net.IPNet
	Notes      string `json:"notes"`
}

FirewallRule represents a firewall rule on Vultr

func (*FirewallRule) UnmarshalJSON

func (r *FirewallRule) UnmarshalJSON(data []byte) (err error)

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

type IP

type IP struct {
	ID         string `json:"SUBID,string"`
	RegionID   int    `json:"DCID,string"`
	IPType     string `json:"ip_type"`
	Subnet     string `json:"subnet"`
	SubnetSize int    `json:"subnet_size"`
	Label      string `json:"label"`
	AttachedTo string `json:"attached_SUBID,string"`
}

IP on Vultr

func (*IP) UnmarshalJSON

func (i *IP) UnmarshalJSON(data []byte) (err error)

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

type IPv4

type IPv4 struct {
	IP         string `json:"ip"`
	Netmask    string `json:"netmask"`
	Gateway    string `json:"gateway"`
	MAC        string `json:"mac_address"`
	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 ISOStatus

type ISOStatus struct {
	State string `json:"state"`
	ISOID string `json:"ISOID"`
}

ISOStatus represents an ISO image attached to a Vultr server

type Network

type Network struct {
	ID           string `json:"NETWORKID"`
	RegionID     int    `json:"DCID,string"`
	Description  string `json:"description"`
	V4Subnet     string `json:"v4_subnet"`
	V4SubnetMask int    `json:"v4_subnet_mask"`
	Created      string `json:"date_created"`
}

Network on Vultr account

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
}

Options represents optional settings and flags that can be passed to NewClient

type Plan

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

Plan on Vultr

type PrivateNetwork

type PrivateNetwork struct {
	ID         string `json:"NETWORKID"`
	MACAddress string `json:"mac_address"`
	IPAddress  string `json:"ip_address"`
}

PrivateNetwork 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"`
	BlockStorage bool   `json:"block_storage"`
	Code         string `json:"regioncode"`
}

Region on Vultr

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

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"`
	OSID             string      `json:"OSID"`
	AppID            string      `json:"APPID"`
	FirewallGroupID  string      `json:"FIREWALLGROUPID"`
}

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
	ISO                  int
	Script               int
	UserData             string
	Snapshot             string
	SSHKey               string
	ReservedIP           string
	IPV6                 bool
	Networks             []string
	PrivateNetworking    bool
	AutoBackups          bool
	DontNotifyOnActivate bool
	Hostname             string
	Tag                  string
	AppID                string
	FirewallGroupID      string
}

ServerOptions are optional parameters to be used during server creation

type Snapshot

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

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)

UnmarshalJSON implements json.Unmarshaller on StartupScript. Necessary because the SCRIPTID 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