govultr

package module
Version: v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 13 Imported by: 82

README

GoVultr

Build Status GoDoc codecov Go Report Card

The official Vultr Go client - GoVultr allows you to interact with the Vultr V1 API.

Installation

go get -u github.com/vultr/govultr

Usage

Vultr uses a PAT (Personal Access token) to interact/authenticate with the APIs. An API Key can be generated and acquired from the API menu in settings.

To instantiate a govultr client you invoke NewClient().

This takes in two parameters:

  • *http.Client
  • API Key

You can define your own http.Client however if you pass in nil then you will be defaulted to use http.DefaultClient. For the API key, we recommend you store this as a environment variable and not hard code it.

There are also three optional parameters you may change regarding the client:

  • BaseUrl: allows you to override the base URL that Vultr defaults to
  • UserAgent: allows you to override the UserAgent that Vultr defaults to
  • RateLimit: Vultr currently rate limits how fast you can make calls back to back. This lets you configure if you want a delay in between calls
Example Client Setup
package main

import (
	"github.com/vultr/govultr"
	"os"
)

func main() {
	apiKey := os.Getenv("VultrAPIKey")

	vultrClient := govultr.NewClient(nil, apiKey)

	// Optional changes
	_ = vultrClient.SetBaseURL("https://api.vultr.com")
	vultrClient.SetUserAgent("mycool-app")
	vultrClient.SetRateLimit(500)
}
Example Usage

Create a VPS

vpsOptions := &govultr.ServerOptions{
	Label:                "awesome-go-app",
	Hostname:             "awesome-go.com",
	EnablePrivateNetwork: true,
	AutoBackups:          true,
	EnableIPV6:           true,
}

// RegionId, VpsPlanID, OsID can be grabbed from their respective API calls
res, err := vultrClient.Server.Create(context.Background(), 1, 201, 1, vpsOptions)

if err != nil {
	fmt.Println(err)
}

Versioning

This project follows SemVer for versioning. For the versions available, see the tags on this repository.

Documentation

For detailed information about our V1 API head over to our API documentation.

If you want more details about this client's functionality then check out our GoDoc documentation.

Contributing

Feel free to send pull requests our way! Please see the contributing guidelines.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	ACL   []string `json:"acls"`
	Email string   `json:"email"`
	Name  string   `json:"name"`
}

API represents Vultr API information

type APIKey

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

APIKey contains a users API Key for interacting with the API

type APIService

type APIService interface {
	GetInfo(ctx context.Context) (*API, error)
}

APIService is the interface to interact with the API endpoint on the Vultr API Link: https://www.vultr.com/api/#auth

type APIServiceHandler

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

APIServiceHandler handles interaction with the API methods for the Vultr API

func (*APIServiceHandler) GetInfo

func (a *APIServiceHandler) GetInfo(ctx context.Context) (*API, error)

GetInfo Vultr API auth information

type Account

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

Account represents a Vultr account

type AccountService

type AccountService interface {
	GetInfo(ctx context.Context) (*Account, error)
}

AccountService is the interface to interact with Accounts endpoint on the Vultr API Link: https://www.vultr.com/api/#account

type AccountServiceHandler

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

AccountServiceHandler handles interaction with the account methods for the Vultr API

func (*AccountServiceHandler) GetInfo

func (a *AccountServiceHandler) GetInfo(ctx context.Context) (*Account, error)

GetInfo Vultr account info

type AppInfo

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

AppInfo represents information about the application on your VPS

type Application

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

Application represents a Vultr application

type ApplicationService

type ApplicationService interface {
	List(ctx context.Context) ([]Application, error)
}

ApplicationService is the interface to interact with the Application endpoint on the Vultr API Link: https://www.vultr.com/api/#app

type ApplicationServiceHandler

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

ApplicationServiceHandler handles interaction with the application methods for the Vultr API

func (*ApplicationServiceHandler) List added in v0.1.2

List retrieves a list of available applications that can be launched when creating a Vultr VPS

type Backup

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

Backup represents a Vultr backup

type BackupSchedule

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

BackupSchedule represents a schedule of a backup that runs on a VPS

type BackupService

type BackupService interface {
	List(ctx context.Context) ([]Backup, error)
	Get(ctx context.Context, backupID string) (*Backup, error)
	ListBySub(ctx context.Context, subID string) ([]Backup, error)
}

BackupService is the interface to interact with the backup endpoint on the Vultr API Link: https://www.vultr.com/api/#backup

type BackupServiceHandler

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

BackupServiceHandler handles interaction with the backup methods for the Vultr API

func (*BackupServiceHandler) Get

func (b *BackupServiceHandler) Get(ctx context.Context, backupID string) (*Backup, error)

Get retrieves a backup that matches the given backupID

func (*BackupServiceHandler) List added in v0.1.2

func (b *BackupServiceHandler) List(ctx context.Context) ([]Backup, error)

List retrieves a list of all backups on the current account

func (*BackupServiceHandler) ListBySub added in v0.1.2

func (b *BackupServiceHandler) ListBySub(ctx context.Context, subID string) ([]Backup, error)

ListBySub retrieves a list of all backups on the current account that match the given subID

type BareMetalPlan

type BareMetalPlan struct {
	PlanID      string `json:"METALPLANID"`
	Name        string `json:"name"`
	CPUs        int    `json:"cpu_count"`
	CPUModel    string `json:"cpu_model"`
	RAM         int    `json:"ram"`
	Disk        string `json:"disk"`
	BandwidthTB int    `json:"bandwidth_tb"`
	Price       int    `json:"price_per_month"`
	PlanType    string `json:"plan_type"`
	Deprecated  bool   `json:"deprecated"`
	Regions     []int  `json:"available_locations"`
}

BareMetalPlan represents bare metal plans

type BareMetalServer

type BareMetalServer struct {
	BareMetalServerID string      `json:"SUBID"`
	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"`
	DefaultPassword   string      `json:"default_password"`
	DateCreated       string      `json:"date_created"`
	Status            string      `json:"status"`
	NetmaskV4         string      `json:"netmask_v4"`
	GatewayV4         string      `json:"gateway_v4"`
	BareMetalPlanID   int         `json:"METALPLANID"`
	V6Networks        []V6Network `json:"v6_networks"`
	Label             string      `json:"label"`
	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 a custom unmarshaler on BareMetalServer This is done to help reduce data inconsistency with V1 of the Vultr API

type BareMetalServerIPV4

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

BareMetalServerIPV4 represents IPV4 information for a bare metal server

type BareMetalServerIPV6

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

BareMetalServerIPV6 represents IPV6 information for a bare metal server

type BareMetalServerOptions

type BareMetalServerOptions struct {
	StartupScriptID string
	SnapshotID      string
	EnableIPV6      string
	Label           string
	SSHKeyIDs       []string
	AppID           string
	UserData        string
	NotifyActivate  string
	Hostname        string
	Tag             string
	ReservedIPV4    string
}

BareMetalServerOptions represents the optional parameters that can be set when creating a bare metal server

type BareMetalServerService

type BareMetalServerService interface {
	AppInfo(ctx context.Context, serverID string) (*AppInfo, error)
	Bandwidth(ctx context.Context, serverID string) ([]map[string]string, error)
	ChangeApp(ctx context.Context, serverID, appID string) error
	ChangeOS(ctx context.Context, serverID, osID string) error
	Create(ctx context.Context, regionID, planID, osID string, options *BareMetalServerOptions) (*BareMetalServer, error)
	Delete(ctx context.Context, serverID string) error
	EnableIPV6(ctx context.Context, serverID string) error
	List(ctx context.Context) ([]BareMetalServer, error)
	ListByLabel(ctx context.Context, label string) ([]BareMetalServer, error)
	ListByMainIP(ctx context.Context, mainIP string) ([]BareMetalServer, error)
	ListByTag(ctx context.Context, tag string) ([]BareMetalServer, error)
	GetServer(ctx context.Context, serverID string) (*BareMetalServer, error)
	GetUserData(ctx context.Context, serverID string) (*UserData, error)
	Halt(ctx context.Context, serverID string) error
	IPV4Info(ctx context.Context, serverID string) ([]BareMetalServerIPV4, error)
	IPV6Info(ctx context.Context, serverID string) ([]BareMetalServerIPV6, error)
	ListApps(ctx context.Context, serverID string) ([]Application, error)
	ListOS(ctx context.Context, serverID string) ([]OS, error)
	Reboot(ctx context.Context, serverID string) error
	Reinstall(ctx context.Context, serverID string) error
	SetLabel(ctx context.Context, serverID, label string) error
	SetTag(ctx context.Context, serverID, tag string) error
	SetUserData(ctx context.Context, serverID, userData string) error
}

BareMetalServerService is the interface to interact with the bare metal endpoints on the Vultr API Link: https://www.vultr.com/api/#baremetal

type BareMetalServerServiceHandler

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

BareMetalServerServiceHandler handles interaction with the bare metal methods for the Vultr API

func (*BareMetalServerServiceHandler) AppInfo

func (b *BareMetalServerServiceHandler) AppInfo(ctx context.Context, serverID string) (*AppInfo, error)

AppInfo retrieves the application information for a given server ID

func (*BareMetalServerServiceHandler) Bandwidth

func (b *BareMetalServerServiceHandler) Bandwidth(ctx context.Context, serverID string) ([]map[string]string, error)

Bandwidth will get the bandwidth used by a bare metal server

func (*BareMetalServerServiceHandler) ChangeApp

func (b *BareMetalServerServiceHandler) ChangeApp(ctx context.Context, serverID, appID string) error

ChangeApp changes the bare metal server to a different application.

func (*BareMetalServerServiceHandler) ChangeOS

func (b *BareMetalServerServiceHandler) ChangeOS(ctx context.Context, serverID, osID string) error

ChangeOS changes the bare metal server to a different operating system. All data will be permanently lost.

func (*BareMetalServerServiceHandler) Create

func (b *BareMetalServerServiceHandler) Create(ctx context.Context, regionID, planID, osID string, options *BareMetalServerOptions) (*BareMetalServer, error)

Create a new bare metal server.

func (*BareMetalServerServiceHandler) Delete added in v0.1.2

func (b *BareMetalServerServiceHandler) Delete(ctx context.Context, serverID string) error

Delete a bare metal server. All data will be permanently lost, and the IP address will be released. There is no going back from this call.

func (*BareMetalServerServiceHandler) EnableIPV6

func (b *BareMetalServerServiceHandler) EnableIPV6(ctx context.Context, serverID string) error

EnableIPV6 enables IPv6 networking on a bare metal server by assigning an IPv6 subnet to it. The server will not be rebooted when the subnet is assigned.

func (*BareMetalServerServiceHandler) GetServer

func (b *BareMetalServerServiceHandler) GetServer(ctx context.Context, serverID string) (*BareMetalServer, error)

GetServer gets the server with the given ID

func (*BareMetalServerServiceHandler) GetUserData

func (b *BareMetalServerServiceHandler) GetUserData(ctx context.Context, serverID string) (*UserData, error)

GetUserData retrieves the (base64 encoded) user-data for this bare metal server

func (*BareMetalServerServiceHandler) Halt

func (b *BareMetalServerServiceHandler) Halt(ctx context.Context, serverID string) error

Halt a bare metal server. This is a hard power off, meaning that the power to the machine is severed. The data on the machine will not be modified, and you will still be billed for the machine.

func (*BareMetalServerServiceHandler) IPV4Info

IPV4Info will List the IPv4 information of a bare metal server. IP information is only available for bare metal servers in the "active" state.

func (*BareMetalServerServiceHandler) IPV6Info

IPV6Info ists the IPv6 information of a bare metal server. IP information is only available for bare metal servers in the "active" state. If the bare metal server does not have IPv6 enabled, then an empty array is returned.

func (*BareMetalServerServiceHandler) List added in v0.1.2

List lists all bare metal servers on the current account. This includes both pending and active servers.

func (*BareMetalServerServiceHandler) ListApps

func (b *BareMetalServerServiceHandler) ListApps(ctx context.Context, serverID string) ([]Application, error)

ListApps retrieves a list of Vultr one-click applications to which a bare metal server can be changed. Always check against this list before trying to switch applications because it is not possible to switch between every application combination.

func (*BareMetalServerServiceHandler) ListByLabel added in v0.1.2

func (b *BareMetalServerServiceHandler) ListByLabel(ctx context.Context, label string) ([]BareMetalServer, error)

ListByLabel lists all bare metal servers that match the given label on the current account. This includes both pending and active servers.

func (*BareMetalServerServiceHandler) ListByMainIP added in v0.1.2

func (b *BareMetalServerServiceHandler) ListByMainIP(ctx context.Context, mainIP string) ([]BareMetalServer, error)

ListByMainIP lists all bare metal servers that match the given IP address on the current account. This includes both pending and active servers.

func (*BareMetalServerServiceHandler) ListByTag added in v0.1.2

ListByTag lists all bare metal servers that match the given tag on the current account. This includes both pending and active servers.

func (*BareMetalServerServiceHandler) ListOS

func (b *BareMetalServerServiceHandler) ListOS(ctx context.Context, serverID string) ([]OS, error)

ListOS retrieves a list of operating systems to which a bare metal server can be changed. Always check against this list before trying to switch operating systems because it is not possible to switch between every operating system combination.

func (*BareMetalServerServiceHandler) Reboot

func (b *BareMetalServerServiceHandler) Reboot(ctx context.Context, serverID string) error

Reboot a bare metal server. This is a hard reboot, which means that the server is powered off, then back on.

func (*BareMetalServerServiceHandler) Reinstall

func (b *BareMetalServerServiceHandler) Reinstall(ctx context.Context, serverID string) error

Reinstall the operating system on a bare metal server. All data will be permanently lost, but the IP address will remain the same. There is no going back from this call.

func (*BareMetalServerServiceHandler) SetLabel

func (b *BareMetalServerServiceHandler) SetLabel(ctx context.Context, serverID, label string) error

SetLabel sets the label of a bare metal server.

func (*BareMetalServerServiceHandler) SetTag

func (b *BareMetalServerServiceHandler) SetTag(ctx context.Context, serverID, tag string) error

SetTag sets the tag of a bare metal server.

func (*BareMetalServerServiceHandler) SetUserData

func (b *BareMetalServerServiceHandler) SetUserData(ctx context.Context, serverID, userData string) error

SetUserData sets the user-data for this server. User-data is a generic data store, which some provisioning tools and cloud operating systems use as a configuration file. It is generally consumed only once after an instance has been launched, but individual needs may vary.

type BlockStorage

type BlockStorage struct {
	BlockStorageID string `json:"SUBID"`
	DateCreated    string `json:"date_created"`
	CostPerMonth   string `json:"cost_per_month"`
	Status         string `json:"status"`
	SizeGB         int    `json:"size_gb"`
	RegionID       int    `json:"DCID"`
	InstanceID     string `json:"attached_to_SUBID"`
	Label          string `json:"label"`
}

BlockStorage represents Vultr Block-Storage

func (*BlockStorage) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaller on BlockStorage to handle the inconsistent types returned from the Vultr v1 API.

type BlockStorageService

type BlockStorageService interface {
	Attach(ctx context.Context, blockID, InstanceID, liveAttach string) error
	Create(ctx context.Context, regionID, size int, label string) (*BlockStorage, error)
	Delete(ctx context.Context, blockID string) error
	Detach(ctx context.Context, blockID, liveDetach string) error
	SetLabel(ctx context.Context, blockID, label string) error
	List(ctx context.Context) ([]BlockStorage, error)
	Get(ctx context.Context, blockID string) (*BlockStorage, error)
	Resize(ctx context.Context, blockID string, size int) error
}

BlockStorageService is the interface to interact with Block-Storage endpoint on the Vultr API Link: https://www.vultr.com/api/#block

type BlockStorageServiceHandler

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

BlockStorageServiceHandler handles interaction with the block-storage methods for the Vultr API

func (*BlockStorageServiceHandler) Attach

func (b *BlockStorageServiceHandler) Attach(ctx context.Context, blockID, InstanceID, liveAttach string) error

Attach will link a given block storage to a given Vultr vps If liveAttach is set to "yes" the block storage will be attached without reloading the instance

func (*BlockStorageServiceHandler) Create

func (b *BlockStorageServiceHandler) Create(ctx context.Context, regionID, sizeGB int, label string) (*BlockStorage, error)

Create builds out a block storage

func (*BlockStorageServiceHandler) Delete

func (b *BlockStorageServiceHandler) Delete(ctx context.Context, blockID string) error

Delete will remove block storage instance from your Vultr account

func (*BlockStorageServiceHandler) Detach

func (b *BlockStorageServiceHandler) Detach(ctx context.Context, blockID, liveDetach string) error

Detach will de-link a given block storage to the Vultr vps it is attached to If liveDetach is set to "yes" the block storage will be detached without reloading the instance

func (*BlockStorageServiceHandler) Get

Get returns a single block storage instance based ony our blockID you provide from your Vultr Account

func (*BlockStorageServiceHandler) List added in v0.1.2

List returns a list of all block storage instances on your Vultr Account

func (*BlockStorageServiceHandler) Resize

func (b *BlockStorageServiceHandler) Resize(ctx context.Context, blockID string, sizeGB int) error

Resize allows you to resize your Vultr block storage instance

func (*BlockStorageServiceHandler) SetLabel

func (b *BlockStorageServiceHandler) SetLabel(ctx context.Context, blockID, label string) error

SetLabel allows you to set/update the label on your Vultr Block storage

type Client

type Client struct {

	// BASE URL for APIs
	BaseURL *url.URL

	// User Agent for the client
	UserAgent string

	// API Key
	APIKey APIKey

	// Services used to interact with the API
	Account         AccountService
	API             APIService
	Application     ApplicationService
	Backup          BackupService
	BareMetalServer BareMetalServerService
	BlockStorage    BlockStorageService
	DNSDomain       DNSDomainService
	DNSRecord       DNSRecordService
	FirewallGroup   FirewallGroupService
	FirewallRule    FireWallRuleService
	ISO             ISOService
	LoadBalancer    LoadBalancerService
	Network         NetworkService
	ObjectStorage   ObjectStorageService
	OS              OSService
	Plan            PlanService
	Region          RegionService
	ReservedIP      ReservedIPService
	Server          ServerService
	Snapshot        SnapshotService
	SSHKey          SSHKeyService
	StartupScript   StartupScriptService
	User            UserService
	// contains filtered or unexported fields
}

Client manages interaction with the Vultr V1 API

func NewClient

func NewClient(httpClient *http.Client, key string) *Client

NewClient returns a Vultr API Client

func (*Client) DoWithContext

func (c *Client) DoWithContext(ctx context.Context, r *http.Request, data interface{}) error

DoWithContext sends an API Request and returns back the response. The API response is checked to see if it was a successful call. A successful call is then checked to see if we need to unmarshal since some resources have their own implements of unmarshal.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, uri string, body url.Values) (*http.Request, error)

NewRequest creates an API Request

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the API request completion callback

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string) error

SetBaseURL Overrides the default BaseUrl

func (*Client) SetRateLimit

func (c *Client) SetRateLimit(time time.Duration)

SetRateLimit Overrides the default rateLimit. For performance, exponential backoff is used with the minimum wait being 2/3rds the time provided.

func (*Client) SetRetryLimit added in v0.1.6

func (c *Client) SetRetryLimit(n int)

SetRetryLimit overrides the default RetryLimit

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(ua string)

SetUserAgent Overrides the default UserAgent

type DNSDomain

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

DNSDomain represents a DNS Domain entry on Vultr

type DNSDomainService

type DNSDomainService interface {
	Create(ctx context.Context, domain, InstanceIP string) error
	Delete(ctx context.Context, domain string) error
	ToggleDNSSec(ctx context.Context, domain string, enabled bool) error
	DNSSecInfo(ctx context.Context, domain string) ([]string, error)
	List(ctx context.Context) ([]DNSDomain, error)
	GetSoa(ctx context.Context, domain string) (*Soa, error)
	UpdateSoa(ctx context.Context, domain, nsPrimary, email string) error
}

DNSDomainService is the interface to interact with the DNS endpoints on the Vultr API Link: https://www.vultr.com/api/#dns

type DNSDomainServiceHandler

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

DNSDomainServiceHandler handles interaction with the DNS methods for the Vultr API

func (*DNSDomainServiceHandler) Create

func (d *DNSDomainServiceHandler) Create(ctx context.Context, domain, InstanceIP string) error

Create will create a DNS Domain entry on Vultr

func (*DNSDomainServiceHandler) DNSSecInfo

func (d *DNSDomainServiceHandler) DNSSecInfo(ctx context.Context, domain string) ([]string, error)

DNSSecInfo gets the DNSSec keys for a domain (if enabled)

func (*DNSDomainServiceHandler) Delete

func (d *DNSDomainServiceHandler) Delete(ctx context.Context, domain string) error

Delete will delete a domain name and all associated records

func (*DNSDomainServiceHandler) GetSoa

func (d *DNSDomainServiceHandler) GetSoa(ctx context.Context, domain string) (*Soa, error)

GetSoa gets the SOA record information for a domain

func (*DNSDomainServiceHandler) List added in v0.1.2

List gets all domains associated with the current Vultr account.

func (*DNSDomainServiceHandler) ToggleDNSSec

func (d *DNSDomainServiceHandler) ToggleDNSSec(ctx context.Context, domain string, enabled bool) error

ToggleDNSSec will enable or disable DNSSEC for a domain on Vultr

func (*DNSDomainServiceHandler) UpdateSoa

func (d *DNSDomainServiceHandler) UpdateSoa(ctx context.Context, domain, nsPrimary, email string) error

UpdateSoa will update the SOA record information for a 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"`
}

DNSRecord represents a DNS record on Vultr

type DNSRecordService

type DNSRecordService interface {
	Create(ctx context.Context, domain, recordType, name, data string, ttl, priority int) error
	Delete(ctx context.Context, domain, recordID string) error
	List(ctx context.Context, domain string) ([]DNSRecord, error)
	Update(ctx context.Context, domain string, dnsRecord *DNSRecord) error
}

DNSRecordService is the interface to interact with the DNS Records endpoints on the Vultr API Link: https://www.vultr.com/api/#dns

type DNSRecordsServiceHandler

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

DNSRecordsServiceHandler handles interaction with the DNS Records methods for the Vultr API

func (*DNSRecordsServiceHandler) Create

func (d *DNSRecordsServiceHandler) Create(ctx context.Context, domain, recordType, name, data string, ttl, priority int) error

Create will add a DNS record.

func (*DNSRecordsServiceHandler) Delete

func (d *DNSRecordsServiceHandler) Delete(ctx context.Context, domain, recordID string) error

Delete will delete a domain name and all associated records.

func (*DNSRecordsServiceHandler) List added in v0.1.2

func (d *DNSRecordsServiceHandler) List(ctx context.Context, domain string) ([]DNSRecord, error)

List will list all the records associated with a particular domain on Vultr

func (*DNSRecordsServiceHandler) Update

func (d *DNSRecordsServiceHandler) Update(ctx context.Context, domain string, dnsRecord *DNSRecord) error

Update will update a DNS record

type FireWallGroupServiceHandler

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

FireWallGroupServiceHandler handles interaction with the firewall group methods for the Vultr API

func (*FireWallGroupServiceHandler) ChangeDescription

func (f *FireWallGroupServiceHandler) ChangeDescription(ctx context.Context, groupID, description string) error

ChangeDescription will change the description of a firewall group

func (*FireWallGroupServiceHandler) Create

func (f *FireWallGroupServiceHandler) Create(ctx context.Context, description string) (*FirewallGroup, error)

Create will create a new firewall group on your Vultr account

func (*FireWallGroupServiceHandler) Delete

func (f *FireWallGroupServiceHandler) Delete(ctx context.Context, groupID string) error

Delete will delete a firewall group from your Vultr account

func (*FireWallGroupServiceHandler) Get

Get will return a firewall group based on provided groupID from your Vultr account

func (*FireWallGroupServiceHandler) List added in v0.1.2

List will return a list of all firewall groups on your Vultr account

type FireWallRuleService

type FireWallRuleService interface {
	Create(ctx context.Context, groupID, protocol, port, network, notes string) (*FirewallRule, error)
	Delete(ctx context.Context, groupID, ruleID string) error
	ListByIPType(ctx context.Context, groupID, ipType string) ([]FirewallRule, error)
	List(ctx context.Context, groupID string) ([]FirewallRule, error)
}

FireWallRuleService is the interface to interact with the firewall rule endpoints on the Vultr API Link: https://www.vultr.com/api/#firewall

type FireWallRuleServiceHandler

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

FireWallRuleServiceHandler handles interaction with the firewall rule methods for the Vultr API

func (*FireWallRuleServiceHandler) Create

func (f *FireWallRuleServiceHandler) Create(ctx context.Context, groupID, protocol, port, cdirBlock, notes string) (*FirewallRule, error)

Create will create a rule in a firewall group.

func (*FireWallRuleServiceHandler) Delete

func (f *FireWallRuleServiceHandler) Delete(ctx context.Context, groupID, ruleID string) error

Delete will delete a firewall rule on your Vultr account

func (*FireWallRuleServiceHandler) List added in v0.1.2

List will return both ipv4 an ipv6 firewall rules that are defined within a firewall group

func (*FireWallRuleServiceHandler) ListByIPType added in v0.1.3

func (f *FireWallRuleServiceHandler) ListByIPType(ctx context.Context, groupID, ipType string) ([]FirewallRule, error)

List will list the current firewall rules in a firewall group. ipType values that can be passed in are "v4", "v6"

type FirewallGroup

type FirewallGroup struct {
	FirewallGroupID string `json:"FIREWALLGROUPID"`
	Description     string `json:"description"`
	DateCreated     string `json:"date_created"`
	DateModified    string `json:"date_modified"`
	InstanceCount   int    `json:"instance_count"`
	RuleCount       int    `json:"rule_count"`
	MaxRuleCount    int    `json:"max_rule_count"`
}

FirewallGroup represents a Vultr firewall group

type FirewallGroupService

type FirewallGroupService interface {
	Create(ctx context.Context, description string) (*FirewallGroup, error)
	Delete(ctx context.Context, groupID string) error
	List(ctx context.Context) ([]FirewallGroup, error)
	Get(ctx context.Context, groupID string) (*FirewallGroup, error)
	ChangeDescription(ctx context.Context, groupID, description string) error
}

FirewallGroupService is the interface to interact with the firewall group endpoints on the Vultr API Link: https://www.vultr.com/api/#firewall

type FirewallRule

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

FirewallRule represents a Vultr firewall rule

func (*FirewallRule) UnmarshalJSON

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

UnmarshalJSON implements a custom unmarshaler on FirewallRule This is done to help reduce data inconsistency with V1 of the Vultr API It also merges the subnet & subnet_mask into a single type of *net.IPNet

type ForwardingRule added in v0.3.0

type ForwardingRule struct {
	RuleID           string `json:"RULEID,omitempty"`
	FrontendProtocol string `json:"frontend_protocol,omitempty"`
	FrontendPort     int    `json:"frontend_port,omitempty"`
	BackendProtocol  string `json:"backend_protocol,omitempty"`
	BackendPort      int    `json:"backend_port,omitempty"`
}

ForwardingRule represent a single forwarding rule

type ForwardingRules added in v0.3.0

type ForwardingRules struct {
	ForwardRuleList []ForwardingRule `json:"forward_rule_list"`
}

ForwardingRules represent a list of forwarding rules

type GenericInfo added in v0.3.0

type GenericInfo struct {
	BalancingAlgorithm string          `json:"balancing_algorithm"`
	SSLRedirect        *bool           `json:"ssl_redirect,omitempty"`
	StickySessions     *StickySessions `json:"sticky_sessions"`
	ProxyProtocol      *bool           `json:"proxy_protocol"`
}

GenericInfo represents generic configuration of your load balancer

type HealthCheck added in v0.3.0

type HealthCheck struct {
	Protocol           string `json:"protocol,omitempty"`
	Port               int    `json:"port,omitempty"`
	Path               string `json:"path,omitempty"`
	CheckInterval      int    `json:"check_interval,omitempty"`
	ResponseTimeout    int    `json:"response_timeout,omitempty"`
	UnhealthyThreshold int    `json:"unhealthy_threshold,omitempty"`
	HealthyThreshold   int    `json:"healthy_threshold,omitempty"`
}

HealthCheck represents your health check configuration for your load balancer.

type IP added in v0.5.0

type IP struct {
	IPv4 string `json:"ipv4"`
}

type IPV4

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

IPV4 represents IPV4 information for a VPS

type IPV6

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

IPV6 represents IPV6 information for a VPS

type ISO added in v0.1.1

type ISO struct {
	ISOID       int    `json:"ISOID"`
	DateCreated string `json:"date_created"`
	FileName    string `json:"filename"`
	Size        int    `json:"size"`
	MD5Sum      string `json:"md5sum"`
	SHA512Sum   string `json:"sha512sum"`
	Status      string `json:"status"`
}

ISO represents ISOs currently available on this account.

type ISOService added in v0.1.1

type ISOService interface {
	CreateFromURL(ctx context.Context, ISOURL string) (*ISO, error)
	Delete(ctx context.Context, ISOID int) error
	List(ctx context.Context) ([]ISO, error)
	GetPublicList(ctx context.Context) ([]PublicISO, error)
}

ISOService is the interface to interact with the ISO endpoints on the Vultr API Link: https://www.vultr.com/api/#ISO

type ISOServiceHandler added in v0.1.1

type ISOServiceHandler struct {
	Client *Client
}

ISOServiceHandler handles interaction with the ISO methods for the Vultr API

func (*ISOServiceHandler) CreateFromURL added in v0.1.1

func (i *ISOServiceHandler) CreateFromURL(ctx context.Context, ISOURL string) (*ISO, error)

CreateFromURL will create a new ISO image on your account

func (*ISOServiceHandler) Delete added in v0.1.1

func (i *ISOServiceHandler) Delete(ctx context.Context, isoID int) error

Delete will delete an ISO image from your account

func (*ISOServiceHandler) GetPublicList added in v0.1.1

func (i *ISOServiceHandler) GetPublicList(ctx context.Context) ([]PublicISO, error)

GetPublicList will list public ISOs offered in the Vultr ISO library.

func (*ISOServiceHandler) List added in v0.1.2

func (i *ISOServiceHandler) List(ctx context.Context) ([]ISO, error)

List will list all ISOs currently available on your account

type InstanceList added in v0.3.0

type InstanceList struct {
	InstanceList []int `json:"instance_list"`
}

InstanceList represents instances that attached to your load balancer

type LBConfig added in v0.3.0

type LBConfig struct {
	GenericInfo `json:"generic_info"`
	HealthCheck `json:"health_checks_info"`
	SSLInfo     bool `json:"has_ssl"`
	ForwardingRules
	InstanceList
}

LBConfig represents the full config with all components of a load balancer

type LoadBalancerHandler added in v0.3.0

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

LoadBalancerHandler handles interaction with the server methods for the Vultr API

func (*LoadBalancerHandler) AddSSL added in v0.3.1

func (l *LoadBalancerHandler) AddSSL(ctx context.Context, ID int, ssl *SSL) error

AddSSL will attach an SSL certificate to a given load balancer

func (*LoadBalancerHandler) AttachInstance added in v0.3.0

func (l *LoadBalancerHandler) AttachInstance(ctx context.Context, ID, backendNode int) error

AttachInstance attaches a backend node to your load balancer subscription

func (*LoadBalancerHandler) AttachedInstances added in v0.3.0

func (l *LoadBalancerHandler) AttachedInstances(ctx context.Context, ID int) (*InstanceList, error)

AttachedInstances lists the instances that are currently attached to a load balancer subscription.

func (*LoadBalancerHandler) Create added in v0.3.0

func (l *LoadBalancerHandler) Create(ctx context.Context, region int, label string, genericInfo *GenericInfo, healthCheck *HealthCheck, rules []ForwardingRule, ssl *SSL, instances *InstanceList) (*LoadBalancers, error)

Create a load balancer

func (*LoadBalancerHandler) CreateForwardingRule added in v0.3.0

func (l *LoadBalancerHandler) CreateForwardingRule(ctx context.Context, ID int, rule *ForwardingRule) (*ForwardingRule, error)

CreateForwardingRule will create a new forwarding rule for your load balancer subscription. Note the RuleID will be returned in the ForwardingRule struct

func (*LoadBalancerHandler) Delete added in v0.3.0

func (l *LoadBalancerHandler) Delete(ctx context.Context, ID int) error

Delete a load balancer subscription.

func (*LoadBalancerHandler) DeleteForwardingRule added in v0.3.0

func (l *LoadBalancerHandler) DeleteForwardingRule(ctx context.Context, ID int, RuleID string) error

DeleteForwardingRule removes a forwarding rule from a load balancer subscription

func (*LoadBalancerHandler) DetachInstance added in v0.3.0

func (l *LoadBalancerHandler) DetachInstance(ctx context.Context, ID, backendNode int) error

DetachInstance detaches a backend node to your load balancer subscription

func (*LoadBalancerHandler) GetFullConfig added in v0.3.0

func (l *LoadBalancerHandler) GetFullConfig(ctx context.Context, ID int) (*LBConfig, error)

GetFullConfig retrieves the entire configuration of a load balancer subscription.

func (*LoadBalancerHandler) GetGenericInfo added in v0.3.0

func (l *LoadBalancerHandler) GetGenericInfo(ctx context.Context, ID int) (*GenericInfo, error)

GetGenericInfo is the generic configuration of a load balancer subscription

func (*LoadBalancerHandler) GetHealthCheck added in v0.3.0

func (l *LoadBalancerHandler) GetHealthCheck(ctx context.Context, ID int) (*HealthCheck, error)

GetHealthCheck retrieves the health check configuration for your load balancer subscription.

func (*LoadBalancerHandler) HasSSL added in v0.3.0

func (l *LoadBalancerHandler) HasSSL(ctx context.Context, ID int) (*struct {
	SSLInfo bool `json:"has_ssl"`
}, error)

HasSSL retrieves whether or not your load balancer subscription has an SSL cert attached.

func (*LoadBalancerHandler) List added in v0.3.0

List all load balancer subscriptions on the current account.

func (*LoadBalancerHandler) ListForwardingRules added in v0.3.0

func (l *LoadBalancerHandler) ListForwardingRules(ctx context.Context, ID int) (*ForwardingRules, error)

ListForwardingRules lists all forwarding rules for a load balancer subscription

func (*LoadBalancerHandler) RemoveSSL added in v0.3.1

func (l *LoadBalancerHandler) RemoveSSL(ctx context.Context, ID int) error

RemoveSSL will remove an SSL certificate from a load balancer

func (*LoadBalancerHandler) SetHealthCheck added in v0.3.0

func (l *LoadBalancerHandler) SetHealthCheck(ctx context.Context, ID int, healthConfig *HealthCheck) error

SetHealthCheck sets your health check configuration for your load balancer

func (*LoadBalancerHandler) SetLabel added in v0.3.0

func (l *LoadBalancerHandler) SetLabel(ctx context.Context, ID int, label string) error

SetLabel sets the label for your load balancer subscription.

func (*LoadBalancerHandler) UpdateGenericInfo added in v0.3.0

func (l *LoadBalancerHandler) UpdateGenericInfo(ctx context.Context, ID int, label string, genericInfo *GenericInfo) error

UpdateGenericInfo will update portions of your generic info section

type LoadBalancerService added in v0.3.0

type LoadBalancerService interface {
	List(ctx context.Context) ([]LoadBalancers, error)
	Delete(ctx context.Context, ID int) error
	SetLabel(ctx context.Context, ID int, label string) error
	AttachedInstances(ctx context.Context, ID int) (*InstanceList, error)
	AttachInstance(ctx context.Context, ID, backendNode int) error
	DetachInstance(ctx context.Context, ID, backendNode int) error
	GetHealthCheck(ctx context.Context, ID int) (*HealthCheck, error)
	SetHealthCheck(ctx context.Context, ID int, healthConfig *HealthCheck) error
	GetGenericInfo(ctx context.Context, ID int) (*GenericInfo, error)
	ListForwardingRules(ctx context.Context, ID int) (*ForwardingRules, error)
	DeleteForwardingRule(ctx context.Context, ID int, RuleID string) error
	CreateForwardingRule(ctx context.Context, ID int, rule *ForwardingRule) (*ForwardingRule, error)
	GetFullConfig(ctx context.Context, ID int) (*LBConfig, error)
	HasSSL(ctx context.Context, ID int) (*struct {
		SSLInfo bool `json:"has_ssl"`
	}, error)
	Create(ctx context.Context, region int, label string, genericInfo *GenericInfo, healthCheck *HealthCheck, rules []ForwardingRule, ssl *SSL, instances *InstanceList) (*LoadBalancers, error)
	UpdateGenericInfo(ctx context.Context, ID int, label string, genericInfo *GenericInfo) error
	AddSSL(ctx context.Context, ID int, ssl *SSL) error
	RemoveSSL(ctx context.Context, ID int) error
}

LoadBalancerService is the interface to interact with the server endpoints on the Vultr API Link: https://www.vultr.com/api/#loadbalancer

type LoadBalancers added in v0.3.0

type LoadBalancers struct {
	ID          int    `json:"SUBID,omitempty"`
	DateCreated string `json:"date_created,omitempty"`
	RegionID    int    `json:"DCID,omitempty"`
	Location    string `json:"location,omitempty"`
	Label       string `json:"label,omitempty"`
	Status      string `json:"status,omitempty"`
	IPV4        string `json:"ipv4,omitempty"`
	IPV6        string `json:"ipv6,omitempty"`
}

LoadBalancers represent a basic structure of a load balancer

type Network

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

Network represents a Vultr private network

type NetworkService

type NetworkService interface {
	Create(ctx context.Context, regionID, description, cidrBlock string) (*Network, error)
	Delete(ctx context.Context, networkID string) error
	List(ctx context.Context) ([]Network, error)
}

NetworkService is the interface to interact with the network endpoints on the Vultr API Link: https://www.vultr.com/api/#network

type NetworkServiceHandler

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

NetworkServiceHandler handles interaction with the network methods for the Vultr API

func (*NetworkServiceHandler) Create

func (n *NetworkServiceHandler) Create(ctx context.Context, regionID, description, cidrBlock string) (*Network, error)

Create a new private network. A private network can only be used at the location for which it was created.

func (*NetworkServiceHandler) Delete added in v0.1.2

func (n *NetworkServiceHandler) Delete(ctx context.Context, networkID string) error

Delete a private network. Before deleting, a network must be disabled from all instances. See https://www.vultr.com/api/#server_private_network_disable

func (*NetworkServiceHandler) List added in v0.1.2

List lists all private networks on the current account

type OS

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

OS represents a Vultr operating system

func (*OS) UnmarshalJSON

func (o *OS) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaller on OS to handle the inconsistent types returned from the Vultr API.

type OSService

type OSService interface {
	List(ctx context.Context) ([]OS, error)
}

OSService is the interface to interact with the operating system endpoint on the Vultr API Link: https://www.vultr.com/api/#os

type OSServiceHandler

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

OSServiceHandler handles interaction with the operating system methods for the Vultr API

func (*OSServiceHandler) List added in v0.1.2

func (o *OSServiceHandler) List(ctx context.Context) ([]OS, error)

List retrieves a list of available operating systems. If the Windows flag is true, a Windows license will be included with the instance, which will increase the cost.

type ObjectListOptions added in v0.2.0

type ObjectListOptions struct {
	IncludeS3 bool
	Label     string
}

ObjectListOptions are your optional params you have available to list data.

type ObjectStorage added in v0.2.0

type ObjectStorage struct {
	ID                   int    `json:"SUBID"`
	DateCreated          string `json:"date_created"`
	ObjectStoreClusterID int    `json:"OBJSTORECLUSTERID"`
	RegionID             int    `json:"DCID"`
	Location             string
	Label                string
	Status               string
	S3Keys
}

ObjectStorage represents a Vultr Object Storage subscription.

type ObjectStorageCluster added in v0.2.0

type ObjectStorageCluster struct {
	ObjectStoreClusterID int `json:"OBJSTORECLUSTERID"`
	RegionID             int `json:"DCID"`
	Location             string
	Hostname             string
	Deploy               string
}

ObjectStorageCluster represents a Vultr Object Storage cluster.

type ObjectStorageService added in v0.2.0

type ObjectStorageService interface {
	Create(ctx context.Context, objectStoreClusterID int, Label string) (*struct {
		ID int `json:"SUBID"`
	}, error)
	Delete(ctx context.Context, id int) error
	SetLabel(ctx context.Context, id int, label string) error
	List(ctx context.Context, options *ObjectListOptions) ([]ObjectStorage, error)
	Get(ctx context.Context, id int) (*ObjectStorage, error)
	ListCluster(ctx context.Context) ([]ObjectStorageCluster, error)
	RegenerateKeys(ctx context.Context, id int, s3AccessKey string) (*S3Keys, error)
}

ObjectStorageService is the interface to interact with the object storage endpoints on the Vultr API. Link: https://www.vultr.com/api/#objectstorage

type ObjectStorageServiceHandler added in v0.2.0

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

ObjectStorageServiceHandler handles interaction with the firewall rule methods for the Vultr API.

func (*ObjectStorageServiceHandler) Create added in v0.2.0

func (o *ObjectStorageServiceHandler) Create(ctx context.Context, objectStoreClusterID int, Label string) (*struct {
	ID int `json:"SUBID"`
}, error)

Create an object storage subscription

func (*ObjectStorageServiceHandler) Delete added in v0.2.0

Delete an object storage subscription.

func (*ObjectStorageServiceHandler) Get added in v0.2.0

Get returns a specified object storage by the provided ID

func (*ObjectStorageServiceHandler) List added in v0.2.0

List returns all object storage subscriptions on the current account. This includes both pending and active subscriptions.

func (*ObjectStorageServiceHandler) ListCluster added in v0.2.0

ListCluster returns back your object storage clusters. Clusters may be removed over time. The "deploy" field can be used to determine whether or not new deployments are allowed in the cluster.

func (*ObjectStorageServiceHandler) RegenerateKeys added in v0.2.0

func (o *ObjectStorageServiceHandler) RegenerateKeys(ctx context.Context, id int, s3AccessKey string) (*S3Keys, error)

RegenerateKeys of the S3 API Keys for an object storage subscription

func (*ObjectStorageServiceHandler) SetLabel added in v0.2.0

func (o *ObjectStorageServiceHandler) SetLabel(ctx context.Context, id int, label string) error

SetLabel of an object storage subscription.

type Plan

type Plan struct {
	PlanID      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"`
	BandwidthGB string `json:"bandwidth_gb"`
	Price       string `json:"price_per_month"`
	Windows     bool   `json:"windows"`
	PlanType    string `json:"plan_type"`
	Regions     []int  `json:"available_locations"`
	Deprecated  bool   `json:"deprecated"`
}

Plan represents available Plans that Vultr offers

type PlanService

type PlanService interface {
	List(ctx context.Context, planType string) ([]Plan, error)
	GetBareMetalList(ctx context.Context) ([]BareMetalPlan, error)
	GetVc2List(ctx context.Context) ([]VCPlan, error)
	GetVdc2List(ctx context.Context) ([]VCPlan, error)
	GetVc2zList(ctx context.Context) ([]VCPlan, error)
}

PlanService is the interface to interact with the Plans endpoints on the Vultr API Link: https://www.vultr.com/api/#plans

type PlanServiceHandler

type PlanServiceHandler struct {
	Client *Client
}

PlanServiceHandler handles interaction with the Plans methods for the Vultr API

func (*PlanServiceHandler) GetBareMetalList

func (p *PlanServiceHandler) GetBareMetalList(ctx context.Context) ([]BareMetalPlan, error)

GetBareMetalList retrieves a list of all active bare metal plans.

func (*PlanServiceHandler) GetVc2List

func (p *PlanServiceHandler) GetVc2List(ctx context.Context) ([]VCPlan, error)

GetVc2List retrieve a list of all active vc2 plans.

func (*PlanServiceHandler) GetVc2zList added in v0.1.3

func (p *PlanServiceHandler) GetVc2zList(ctx context.Context) ([]VCPlan, error)

GetVc2zList Retrieve a list of all active vc2z plans (high frequency)

func (*PlanServiceHandler) GetVdc2List

func (p *PlanServiceHandler) GetVdc2List(ctx context.Context) ([]VCPlan, error)

GetVdc2List Retrieve a list of all active vdc2 plans

func (*PlanServiceHandler) List added in v0.1.2

func (p *PlanServiceHandler) List(ctx context.Context, planType string) ([]Plan, error)

List retrieves a list of all active plans. planType is optional - pass an empty string to get all plans

type PrivateNetwork

type PrivateNetwork struct {
	NetworkID  string `json:"NETWORKID"`
	MacAddress string `json:"mac_address"`
	IPAddress  string `json:"ip_address"`
}

PrivateNetwork represents a private network attached to a VPS

type PublicISO added in v0.1.1

type PublicISO struct {
	ISOID       int    `json:"ISOID"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

PublicISO represents public ISOs offered in the Vultr ISO library.

type Region

type Region struct {
	RegionID     string `json:"DCID"`
	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"`
	RegionCode   string `json:"regioncode"`
}

Region represents a Vultr region

type RegionService

type RegionService interface {
	Availability(ctx context.Context, regionID int, planType string) ([]int, error)
	BareMetalAvailability(ctx context.Context, regionID int) ([]int, error)
	Vc2Availability(ctx context.Context, regionID int) ([]int, error)
	Vdc2Availability(ctx context.Context, regionID int) ([]int, error)
	List(ctx context.Context) ([]Region, error)
}

RegionService is the interface to interact with Region endpoints on the Vultr API Link: https://www.vultr.com/api/#regions

type RegionServiceHandler

type RegionServiceHandler struct {
	Client *Client
}

RegionServiceHandler handles interaction with the region methods for the Vultr API

func (*RegionServiceHandler) Availability

func (r *RegionServiceHandler) Availability(ctx context.Context, regionID int, planType string) ([]int, error)

Availability retrieves a list of the VPSPLANIDs currently available for a given location.

func (*RegionServiceHandler) BareMetalAvailability

func (r *RegionServiceHandler) BareMetalAvailability(ctx context.Context, regionID int) ([]int, error)

BareMetalAvailability retrieve a list of the METALPLANIDs currently available for a given location.

func (*RegionServiceHandler) List added in v0.1.2

func (r *RegionServiceHandler) List(ctx context.Context) ([]Region, error)

List retrieves a list of all active regions

func (*RegionServiceHandler) Vc2Availability

func (r *RegionServiceHandler) Vc2Availability(ctx context.Context, regionID int) ([]int, error)

Vc2Availability retrieve a list of the vc2 VPSPLANIDs currently available for a given location.

func (*RegionServiceHandler) Vdc2Availability

func (r *RegionServiceHandler) Vdc2Availability(ctx context.Context, regionID int) ([]int, error)

Vdc2Availability retrieves a list of the vdc2 VPSPLANIDs currently available for a given location.

type RequestCompletionCallback

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

RequestCompletionCallback defines the type of the request callback function

type ReservedIP

type ReservedIP struct {
	ReservedIPID string `json:"SUBID"`
	RegionID     int    `json:"DCID"`
	IPType       string `json:"ip_type"`
	Subnet       string `json:"subnet"`
	SubnetSize   int    `json:"subnet_size"`
	Label        string `json:"label"`
	AttachedID   string `json:"attached_SUBID"`
}

ReservedIP represents an reserved IP on Vultr

func (*ReservedIP) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaller on ReservedIP to handle the inconsistent types returned from the Vultr API.

type ReservedIPService

type ReservedIPService interface {
	Attach(ctx context.Context, ip, InstanceID string) error
	Convert(ctx context.Context, ip, InstanceID, label string) (*ReservedIP, error)
	Create(ctx context.Context, regionID int, ipType, label string) (*ReservedIP, error)
	Delete(ctx context.Context, ip string) error
	Detach(ctx context.Context, ip, InstanceID string) error
	List(ctx context.Context) ([]ReservedIP, error)
}

ReservedIPService is the interface to interact with the reserved IP endpoints on the Vultr API Link: https://www.vultr.com/api/#reservedip

type ReservedIPServiceHandler

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

ReservedIPServiceHandler handles interaction with the reserved IP methods for the Vultr API

func (*ReservedIPServiceHandler) Attach

func (r *ReservedIPServiceHandler) Attach(ctx context.Context, ip, InstanceID string) error

Attach a reserved IP to an existing subscription

func (*ReservedIPServiceHandler) Convert

func (r *ReservedIPServiceHandler) Convert(ctx context.Context, ip, InstanceID, label string) (*ReservedIP, error)

Convert an existing IP on a subscription to a reserved IP.

func (*ReservedIPServiceHandler) Create

func (r *ReservedIPServiceHandler) Create(ctx context.Context, regionID int, ipType, label string) (*ReservedIP, error)

Create adds the specified reserved IP to your Vultr account

func (*ReservedIPServiceHandler) Delete added in v0.1.2

Delete removes the specified reserved IP from your Vultr account

func (*ReservedIPServiceHandler) Detach

func (r *ReservedIPServiceHandler) Detach(ctx context.Context, ip, InstanceID string) error

Detach a reserved IP from an existing subscription.

func (*ReservedIPServiceHandler) List added in v0.1.2

List lists all the reserved IPs associated with your Vultr account

type ReverseIPV6

type ReverseIPV6 struct {
	IP      string `json:"ip"`
	Reverse string `json:"reverse"`
}

ReverseIPV6 represents IPV6 reverse DNS entries

type S3Keys added in v0.2.0

type S3Keys struct {
	S3Hostname  string `json:"s3_hostname"`
	S3AccessKey string `json:"s3_access_key"`
	S3SecretKey string `json:"s3_secret_key"`
}

S3Keys define your api access to your cluster

type SSHKey

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

SSHKey represents an SSH Key on Vultr

type SSHKeyService

type SSHKeyService interface {
	Create(ctx context.Context, name, sshKey string) (*SSHKey, error)
	Delete(ctx context.Context, sshKeyID string) error
	List(ctx context.Context) ([]SSHKey, error)
	Update(ctx context.Context, sshKey *SSHKey) error
}

SSHKeyService is the interface to interact with the SSH Key endpoints on the Vultr API Link: https://www.vultr.com/api/#sshkey

type SSHKeyServiceHandler

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

SSHKeyServiceHandler handles interaction with the SSH Key methods for the Vultr API

func (*SSHKeyServiceHandler) Create

func (s *SSHKeyServiceHandler) Create(ctx context.Context, name, sshKey string) (*SSHKey, error)

Create will add the specified SSH Key to your Vultr account

func (*SSHKeyServiceHandler) Delete added in v0.1.2

func (s *SSHKeyServiceHandler) Delete(ctx context.Context, sshKeyID string) error

Delete will delete the specified SHH Key from your Vultr account

func (*SSHKeyServiceHandler) List added in v0.1.2

func (s *SSHKeyServiceHandler) List(ctx context.Context) ([]SSHKey, error)

List will list all the SSH Keys associated with your Vultr account

func (*SSHKeyServiceHandler) Update

func (s *SSHKeyServiceHandler) Update(ctx context.Context, sshKey *SSHKey) error

Update will update the given SSH Key. Empty strings will be ignored.

type SSL added in v0.3.1

type SSL struct {
	PrivateKey  string `json:"ssl_private_key"`
	Certificate string `json:"ssl_certificate"`
	Chain       string `json:"chain,omitempty"`
}

SSL represents valid SSL config

type Server

type Server struct {
	InstanceID       string      `json:"SUBID"`
	Os               string      `json:"os"`
	RAM              string      `json:"ram"`
	Disk             string      `json:"disk"`
	MainIP           string      `json:"main_ip"`
	VPSCpus          string      `json:"vcpu_count"`
	Location         string      `json:"location"`
	RegionID         string      `json:"DCID"`
	DefaultPassword  string      `json:"default_password"`
	Created          string      `json:"date_created"`
	PendingCharges   string      `json:"pending_charges"`
	Status           string      `json:"status"`
	Cost             string      `json:"cost_per_month"`
	CurrentBandwidth float64     `json:"current_bandwidth_gb"`
	AllowedBandwidth string      `json:"allowed_bandwidth_gb"`
	NetmaskV4        string      `json:"netmask_v4"`
	GatewayV4        string      `json:"gateway_v4"`
	PowerStatus      string      `json:"power_status"`
	ServerState      string      `json:"server_state"`
	PlanID           string      `json:"VPSPLANID"`
	V6Networks       []V6Network `json:"v6_networks"`
	Label            string      `json:"label"`
	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 represents a VPS

type ServerIso

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

ServerIso represents a iso attached to a VPS

type ServerOptions

type ServerOptions struct {
	IPXEChain            string
	IsoID                int
	SnapshotID           string
	ScriptID             string
	EnableIPV6           bool
	EnablePrivateNetwork bool
	NetworkID            []string
	Label                string
	SSHKeyIDs            []string
	AutoBackups          bool
	AppID                string
	UserData             string
	NotifyActivate       bool
	DDOSProtection       bool
	ReservedIPV4         string
	Hostname             string
	Tag                  string
	FirewallGroupID      string
}

ServerOptions are all optional fields that can be used during vps creation

type ServerService

type ServerService interface {
	ChangeApp(ctx context.Context, instanceID, appID string) error
	ListApps(ctx context.Context, instanceID string) ([]Application, error)
	AppInfo(ctx context.Context, instanceID string) (*AppInfo, error)
	EnableBackup(ctx context.Context, instanceID string) error
	DisableBackup(ctx context.Context, instanceID string) error
	GetBackupSchedule(ctx context.Context, instanceID string) (*BackupSchedule, error)
	SetBackupSchedule(ctx context.Context, instanceID string, backup *BackupSchedule) error
	RestoreBackup(ctx context.Context, instanceID, backupID string) error
	RestoreSnapshot(ctx context.Context, instanceID, snapshotID string) error
	SetLabel(ctx context.Context, instanceID, label string) error
	SetTag(ctx context.Context, instanceID, tag string) error
	Neighbors(ctx context.Context, instanceID string) ([]int, error)
	EnablePrivateNetwork(ctx context.Context, instanceID, networkID string) error
	DisablePrivateNetwork(ctx context.Context, instanceID, networkID string) error
	ListPrivateNetworks(ctx context.Context, instanceID string) ([]PrivateNetwork, error)
	ListUpgradePlan(ctx context.Context, instanceID string) ([]int, error)
	UpgradePlan(ctx context.Context, instanceID, vpsPlanID string) error
	ListOS(ctx context.Context, instanceID string) ([]OS, error)
	ChangeOS(ctx context.Context, instanceID, osID string) error
	IsoAttach(ctx context.Context, instanceID, isoID string) error
	IsoDetach(ctx context.Context, instanceID string) error
	IsoStatus(ctx context.Context, instanceID string) (*ServerIso, error)
	SetFirewallGroup(ctx context.Context, instanceID, firewallGroupID string) error
	GetUserData(ctx context.Context, instanceID string) (*UserData, error)
	SetUserData(ctx context.Context, instanceID, userData string) error
	IPV4Info(ctx context.Context, instanceID string, public bool) ([]IPV4, error)
	IPV6Info(ctx context.Context, instanceID string) ([]IPV6, error)
	AddIPV4(ctx context.Context, instanceID, reboot string) (*IP, error)
	DestroyIPV4(ctx context.Context, instanceID, ip string) error
	EnableIPV6(ctx context.Context, instanceID string) error
	Bandwidth(ctx context.Context, instanceID string) ([]map[string]string, error)
	ListReverseIPV6(ctx context.Context, instanceID string) ([]ReverseIPV6, error)
	SetDefaultReverseIPV4(ctx context.Context, instanceID, ip string) error
	DeleteReverseIPV6(ctx context.Context, instanceID, ip string) error
	SetReverseIPV4(ctx context.Context, instanceID, ipv4, entry string) error
	SetReverseIPV6(ctx context.Context, instanceID, ipv6, entry string) error
	Start(ctx context.Context, instanceID string) error
	Halt(ctx context.Context, instanceID string) error
	Reboot(ctx context.Context, instanceID string) error
	Reinstall(ctx context.Context, instanceID string) error
	Delete(ctx context.Context, instanceID string) error
	Create(ctx context.Context, regionID, vpsPlanID, osID int, options *ServerOptions) (*Server, error)
	List(ctx context.Context) ([]Server, error)
	ListByLabel(ctx context.Context, label string) ([]Server, error)
	ListByMainIP(ctx context.Context, mainIP string) ([]Server, error)
	ListByTag(ctx context.Context, tag string) ([]Server, error)
	GetServer(ctx context.Context, instanceID string) (*Server, error)
	EnableDDOS(ctx context.Context, instanceID string) error
	DisableDDOS(ctx context.Context, instanceID string) error
}

ServerService is the interface to interact with the server endpoints on the Vultr API Link: https://www.vultr.com/api/#server

type ServerServiceHandler

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

ServerServiceHandler handles interaction with the server methods for the Vultr API

func (*ServerServiceHandler) AddIPV4

func (s *ServerServiceHandler) AddIPV4(ctx context.Context, instanceID, reboot string) (*IP, error)

AddIPV4 will add a new IPv4 address to a server. The server will be rebooted unless you specify otherwise. You must reboot the server before the IPv4 address can be configured.

func (*ServerServiceHandler) AppInfo

func (s *ServerServiceHandler) AppInfo(ctx context.Context, instanceID string) (*AppInfo, error)

AppInfo retrieves the application information for a given VPS ID

func (*ServerServiceHandler) Bandwidth

func (s *ServerServiceHandler) Bandwidth(ctx context.Context, instanceID string) ([]map[string]string, error)

Bandwidth will get the bandwidth used by a VPS

func (*ServerServiceHandler) ChangeApp

func (s *ServerServiceHandler) ChangeApp(ctx context.Context, instanceID, appID string) error

ChangeApp changes the VPS to a different application.

func (*ServerServiceHandler) ChangeOS

func (s *ServerServiceHandler) ChangeOS(ctx context.Context, instanceID, osID string) error

ChangeOS changes the VPS to a different operating system. All data will be permanently lost.

func (*ServerServiceHandler) Create

func (s *ServerServiceHandler) Create(ctx context.Context, regionID, vpsPlanID, osID int, options *ServerOptions) (*Server, error)

Create will create a new VPS In order to create a server using a snapshot, use OSID 164 and specify a SNAPSHOTID. Similarly, to create a server using an ISO use OSID 159 and specify an ISOID.

func (*ServerServiceHandler) Delete added in v0.1.2

func (s *ServerServiceHandler) Delete(ctx context.Context, instanceID string) error

Delete a VPS. All data will be permanently lost, and the IP address will be released

func (*ServerServiceHandler) DeleteReverseIPV6

func (s *ServerServiceHandler) DeleteReverseIPV6(ctx context.Context, instanceID, ip string) error

DeleteReverseIPV6 Remove a reverse DNS entry for an IPv6 address of a VPS. Upon success, DNS changes may take 6-12 hours to become active.

func (*ServerServiceHandler) DestroyIPV4

func (s *ServerServiceHandler) DestroyIPV4(ctx context.Context, instanceID, ip string) error

DestroyIPV4 removes a secondary IPv4 address from a server. Your server will be hard-restarted. We suggest halting the machine gracefully before removing IPs.

func (*ServerServiceHandler) DisableBackup

func (s *ServerServiceHandler) DisableBackup(ctx context.Context, instanceID string) error

DisableBackup disable automatic backups on a given VPS

func (*ServerServiceHandler) DisableDDOS added in v0.5.0

func (s *ServerServiceHandler) DisableDDOS(ctx context.Context, instanceID string) error

DisableDDOS protection for a specific server.

func (*ServerServiceHandler) DisablePrivateNetwork

func (s *ServerServiceHandler) DisablePrivateNetwork(ctx context.Context, instanceID, networkID string) error

DisablePrivateNetwork removes a private network from a server. The server will be automatically rebooted to complete the request.

func (*ServerServiceHandler) EnableBackup

func (s *ServerServiceHandler) EnableBackup(ctx context.Context, instanceID string) error

EnableBackup enables automatic backups on a given VPS

func (*ServerServiceHandler) EnableDDOS added in v0.5.0

func (s *ServerServiceHandler) EnableDDOS(ctx context.Context, instanceID string) error

EnableDDOS for a specific server.

func (*ServerServiceHandler) EnableIPV6

func (s *ServerServiceHandler) EnableIPV6(ctx context.Context, instanceID string) error

EnableIPV6 enables IPv6 networking on a server by assigning an IPv6 subnet to it.

func (*ServerServiceHandler) EnablePrivateNetwork

func (s *ServerServiceHandler) EnablePrivateNetwork(ctx context.Context, instanceID, networkID string) error

EnablePrivateNetwork enables private networking on a server. The server will be automatically rebooted to complete the request. No action occurs if private networking was already enabled

func (*ServerServiceHandler) GetBackupSchedule

func (s *ServerServiceHandler) GetBackupSchedule(ctx context.Context, instanceID string) (*BackupSchedule, error)

GetBackupSchedule retrieves the backup schedule for a given vps - all time values are in UTC

func (*ServerServiceHandler) GetServer

func (s *ServerServiceHandler) GetServer(ctx context.Context, instanceID string) (*Server, error)

GetServer will get the server with the given instanceID

func (*ServerServiceHandler) GetUserData

func (s *ServerServiceHandler) GetUserData(ctx context.Context, instanceID string) (*UserData, error)

GetUserData retrieves the (base64 encoded) user-data for this VPS

func (*ServerServiceHandler) Halt

func (s *ServerServiceHandler) Halt(ctx context.Context, instanceID string) error

Halt will halt a virtual machine. This is a hard power off

func (*ServerServiceHandler) IPV4Info

func (s *ServerServiceHandler) IPV4Info(ctx context.Context, instanceID string, public bool) ([]IPV4, error)

IPV4Info will list the IPv4 information of a virtual machine. Public if set to 'true', includes information about the public network adapter (such as MAC address) with the "main_ip" entry.

func (*ServerServiceHandler) IPV6Info

func (s *ServerServiceHandler) IPV6Info(ctx context.Context, instanceID string) ([]IPV6, error)

IPV6Info will list the IPv6 information of a virtual machine. If the virtual machine does not have IPv6 enabled, then an empty array is returned.

func (*ServerServiceHandler) IsoAttach

func (s *ServerServiceHandler) IsoAttach(ctx context.Context, instanceID, isoID string) error

IsoAttach will attach an ISO to the given VPS and reboot it

func (*ServerServiceHandler) IsoDetach

func (s *ServerServiceHandler) IsoDetach(ctx context.Context, instanceID string) error

IsoDetach will detach the currently mounted ISO and reboot the server.

func (*ServerServiceHandler) IsoStatus

func (s *ServerServiceHandler) IsoStatus(ctx context.Context, instanceID string) (*ServerIso, error)

IsoStatus retrieves the current ISO state for a given VPS. The returned state may be one of: ready | isomounting | isomounted.

func (*ServerServiceHandler) List added in v0.1.2

func (s *ServerServiceHandler) List(ctx context.Context) ([]Server, error)

List lists all VPS on the current account. This includes both pending and active servers.

func (*ServerServiceHandler) ListApps

func (s *ServerServiceHandler) ListApps(ctx context.Context, instanceID string) ([]Application, error)

ListApps retrieves a list of applications to which a virtual machine can be changed.

func (*ServerServiceHandler) ListByLabel added in v0.1.2

func (s *ServerServiceHandler) ListByLabel(ctx context.Context, label string) ([]Server, error)

ListByLabel lists all VPS that match the given label on the current account. This includes both pending and active servers.

func (*ServerServiceHandler) ListByMainIP added in v0.1.2

func (s *ServerServiceHandler) ListByMainIP(ctx context.Context, mainIP string) ([]Server, error)

ListByMainIP lists all VPS that match the given IP address on the current account. This includes both pending and active servers.

func (*ServerServiceHandler) ListByTag added in v0.1.2

func (s *ServerServiceHandler) ListByTag(ctx context.Context, tag string) ([]Server, error)

ListByTag lists all VPS that match the given tag on the current account. This includes both pending and active servers.

func (*ServerServiceHandler) ListOS

func (s *ServerServiceHandler) ListOS(ctx context.Context, instanceID string) ([]OS, error)

ListOS retrieves a list of operating systems to which the VPS can be changed to.

func (*ServerServiceHandler) ListPrivateNetworks

func (s *ServerServiceHandler) ListPrivateNetworks(ctx context.Context, instanceID string) ([]PrivateNetwork, error)

ListPrivateNetworks will list private networks attached to a vps

func (*ServerServiceHandler) ListReverseIPV6

func (s *ServerServiceHandler) ListReverseIPV6(ctx context.Context, instanceID string) ([]ReverseIPV6, error)

ListReverseIPV6 List the IPv6 reverse DNS entries of a virtual machine. Reverse DNS entries are only available for virtual machines in the "active" state. If the virtual machine does not have IPv6 enabled, then an empty array is returned.

func (*ServerServiceHandler) ListUpgradePlan

func (s *ServerServiceHandler) ListUpgradePlan(ctx context.Context, instanceID string) ([]int, error)

ListUpgradePlan Retrieve a list of the planIDs for which the vps can be upgraded. An empty response array means that there are currently no upgrades available

func (*ServerServiceHandler) Neighbors

func (s *ServerServiceHandler) Neighbors(ctx context.Context, instanceID string) ([]int, error)

Neighbors will determine what other vps are hosted on the same physical host as a given vps.

func (*ServerServiceHandler) Reboot

func (s *ServerServiceHandler) Reboot(ctx context.Context, instanceID string) error

Reboot will reboot a VPS. This is a hard reboot

func (*ServerServiceHandler) Reinstall

func (s *ServerServiceHandler) Reinstall(ctx context.Context, instanceID string) error

Reinstall will reinstall the operating system on a VPS.

func (*ServerServiceHandler) RestoreBackup

func (s *ServerServiceHandler) RestoreBackup(ctx context.Context, instanceID, backupID string) error

RestoreBackup will restore the specified backup to the given VPS

func (*ServerServiceHandler) RestoreSnapshot

func (s *ServerServiceHandler) RestoreSnapshot(ctx context.Context, instanceID, snapshotID string) error

RestoreSnapshot will restore the specified snapshot to the given VPS

func (*ServerServiceHandler) SetBackupSchedule

func (s *ServerServiceHandler) SetBackupSchedule(ctx context.Context, instanceID string, backup *BackupSchedule) error

SetBackupSchedule sets the backup schedule for a given vps - all time values are in UTC

func (*ServerServiceHandler) SetDefaultReverseIPV4

func (s *ServerServiceHandler) SetDefaultReverseIPV4(ctx context.Context, instanceID, ip string) error

SetDefaultReverseIPV4 will set a reverse DNS entry for an IPv4 address of a virtual machine to the original setting. Upon success, DNS changes may take 6-12 hours to become active.

func (*ServerServiceHandler) SetFirewallGroup

func (s *ServerServiceHandler) SetFirewallGroup(ctx context.Context, instanceID, firewallGroupID string) error

SetFirewallGroup will set, change, or remove the firewall group currently applied to a vps.

A value of "0" means "no firewall group"

func (*ServerServiceHandler) SetLabel

func (s *ServerServiceHandler) SetLabel(ctx context.Context, instanceID, label string) error

SetLabel will set a label for a given VPS

func (*ServerServiceHandler) SetReverseIPV4

func (s *ServerServiceHandler) SetReverseIPV4(ctx context.Context, instanceID, ipv4, entry string) error

SetReverseIPV4 will set a reverse DNS entry for an IPv4 address of a virtual machine. Upon success, DNS changes may take 6-12 hours to become active.

func (*ServerServiceHandler) SetReverseIPV6

func (s *ServerServiceHandler) SetReverseIPV6(ctx context.Context, instanceID, ipv6, entry string) error

SetReverseIPV6 will set a reverse DNS entry for an IPv4 address of a virtual machine. Upon success, DNS changes may take 6-12 hours to become active.

func (*ServerServiceHandler) SetTag

func (s *ServerServiceHandler) SetTag(ctx context.Context, instanceID, tag string) error

SetTag will set a tag for a given VPS

func (*ServerServiceHandler) SetUserData

func (s *ServerServiceHandler) SetUserData(ctx context.Context, instanceID, userData string) error

SetUserData sets the user-data for this subscription. User-data is a generic data store, which some provisioning tools and cloud operating systems use as a configuration file. It is generally consumed only once after an instance has been launched, but individual needs may vary.

func (*ServerServiceHandler) Start

func (s *ServerServiceHandler) Start(ctx context.Context, instanceID string) error

Start will start a vps. If the machine is already running, it will be restarted.

func (*ServerServiceHandler) UpgradePlan

func (s *ServerServiceHandler) UpgradePlan(ctx context.Context, instanceID, vpsPlanID string) error

UpgradePlan will upgrade the plan of a virtual machine. The vps will be rebooted upon a successful upgrade.

type Snapshot

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

Snapshot represents a Vultr snapshot

type SnapshotService

type SnapshotService interface {
	Create(ctx context.Context, InstanceID, description string) (*Snapshot, error)
	CreateFromURL(ctx context.Context, snapshotURL string) (*Snapshot, error)
	Delete(ctx context.Context, snapshotID string) error
	List(ctx context.Context) ([]Snapshot, error)
	Get(ctx context.Context, snapshotID string) (*Snapshot, error)
}

SnapshotService is the interface to interact with Snapshot endpoints on the Vultr API Link: https://www.vultr.com/api/#snapshot

type SnapshotServiceHandler

type SnapshotServiceHandler struct {
	Client *Client
}

SnapshotServiceHandler handles interaction with the snapshot methods for the Vultr API

func (*SnapshotServiceHandler) Create

func (s *SnapshotServiceHandler) Create(ctx context.Context, InstanceID, description string) (*Snapshot, error)

Create makes a snapshot of a provided server

func (*SnapshotServiceHandler) CreateFromURL

func (s *SnapshotServiceHandler) CreateFromURL(ctx context.Context, snapshotURL string) (*Snapshot, error)

CreateFromURL will create a snapshot based on an image iso from a URL you provide

func (*SnapshotServiceHandler) Delete added in v0.1.2

func (s *SnapshotServiceHandler) Delete(ctx context.Context, snapshotID string) error

Delete a snapshot based on snapshotID

func (*SnapshotServiceHandler) Get

func (s *SnapshotServiceHandler) Get(ctx context.Context, snapshotID string) (*Snapshot, error)

Get individual details of a snapshot based on snapshotID

func (*SnapshotServiceHandler) List added in v0.1.2

List of snapshots details

type Snapshots

type Snapshots []Snapshot

Snapshots represent a collection of snapshots

type Soa

type Soa struct {
	NsPrimary string `json:"nsprimary"`
	Email     string `json:"email"`
}

Soa represents record information for a domain on Vultr

type StartupScript

type StartupScript struct {
	ScriptID     string `json:"SCRIPTID"`
	DateCreated  string `json:"date_created"`
	DateModified string `json:"date_modified"`
	Name         string `json:"name"`
	Type         string `json:"type"`
	Script       string `json:"script"`
}

StartupScript represents an startup script on Vultr

func (*StartupScript) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaller on StartupScript to handle the inconsistent types returned from the Vultr API.

type StartupScriptService

type StartupScriptService interface {
	Create(ctx context.Context, name, script, scriptType string) (*StartupScript, error)
	Delete(ctx context.Context, scriptID string) error
	List(ctx context.Context) ([]StartupScript, error)
	Update(ctx context.Context, script *StartupScript) error
}

StartupScriptService is the interface to interact with the startup script endpoints on the Vultr API Link: https://www.vultr.com/api/#startupscript

type StartupScriptServiceHandler

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

StartupScriptServiceHandler handles interaction with the startup script methods for the Vultr API

func (*StartupScriptServiceHandler) Create

func (s *StartupScriptServiceHandler) Create(ctx context.Context, name, script, scriptType string) (*StartupScript, error)

Create will add the specified startup script to your Vultr account

func (*StartupScriptServiceHandler) Delete added in v0.1.2

func (s *StartupScriptServiceHandler) Delete(ctx context.Context, scriptID string) error

Delete will delete the specified startup script from your Vultr account

func (*StartupScriptServiceHandler) List added in v0.1.2

List will list all the startup scripts associated with your Vultr account

func (*StartupScriptServiceHandler) Update

Update will update the given startup script. Empty strings will be ignored.

type StickySessions added in v0.3.0

type StickySessions struct {
	StickySessionsEnabled string `json:"sticky_sessions"`
	CookieName            string `json:"cookie_name"`
}

CookieName represents cookie for your load balancer

type User

type User struct {
	UserID     string   `json:"USERID"`
	Name       string   `json:"name"`
	Email      string   `json:"email"`
	Password   string   `json:"password"`
	APIEnabled string   `json:"api_enabled"`
	ACL        []string `json:"acls"`
	APIKey     string   `json:"api_key"`
}

User represents an user on Vultr

type UserData

type UserData struct {
	UserData string `json:"userdata"`
}

UserData represents the user data you can give a VPS

type UserService

type UserService interface {
	Create(ctx context.Context, email, name, password, apiEnabled string, acls []string) (*User, error)
	Delete(ctx context.Context, userID string) error
	List(ctx context.Context) ([]User, error)
	Update(ctx context.Context, user *User) error
}

UserService is the interface to interact with the user management endpoints on the Vultr API Link: https://www.vultr.com/api/#user

type UserServiceHandler

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

UserServiceHandler handles interaction with the user methods for the Vultr API

func (*UserServiceHandler) Create

func (u *UserServiceHandler) Create(ctx context.Context, email, name, password, apiEnabled string, acls []string) (*User, error)

Create will add the specified user to your Vultr account

func (*UserServiceHandler) Delete

func (u *UserServiceHandler) Delete(ctx context.Context, userID string) error

Delete will remove the specified user from your Vultr account

func (*UserServiceHandler) List added in v0.1.2

func (u *UserServiceHandler) List(ctx context.Context) ([]User, error)

List will list all the users associated with your Vultr account

func (*UserServiceHandler) Update

func (u *UserServiceHandler) Update(ctx context.Context, user *User) error

Update will update the given user. Empty strings will be ignored.

type V6Network

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

V6Network represents an IPV6 network on a VPS

type VCPlan

type VCPlan struct {
	PlanID      string `json:"VPSPLANID"`
	Name        string `json:"name"`
	VCPUs       string `json:"vcpu_count"`
	RAM         string `json:"ram"`
	Disk        string `json:"disk"`
	Bandwidth   string `json:"bandwidth"`
	BandwidthGB string `json:"bandwidth_gb"`
	Price       string `json:"price_per_month"`
	PlanType    string `json:"plan_type"`
}

VCPlan represents either a vdc2 or a vc2 plan

Jump to

Keyboard shortcuts

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