govultr

package module
v2.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: MIT Imports: 12 Imported by: 0

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.InstanceReq{
	Label:                "awesome-go-app",
	Hostname:             "awesome-go.com",
	Backups:              true,
	EnableIPv6:           true,
	OsID:                 362,
	Plan:                 "vc2-1c-2gb",	
	Region:               "ewr",
}

res, err := vultrClient.Instance.Create(context.Background(), 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 APIKey

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

APIKey contains a users API Key for interacting with the API

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"`
	Name              string   `json:"name"`
	Email             string   `json:"email"`
	ACL               []string `json:"acls"`
}

Account represents a Vultr account

type AccountService

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

AccountService is the interface to interact with Accounts endpoint on the Vultr API

type AccountServiceHandler

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

AccountServiceHandler handles interaction with the account methods for the Vultr API

func (*AccountServiceHandler) Get

Get Vultr account info

type Application

type Application struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	ShortName  string `json:"short_name"`
	DeployName string `json:"deploy_name"`
}

Application represents all available apps that can be used to deployed with vultr Instances.

type ApplicationService

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

ApplicationService is the interface to interact with the Application endpoint on the Vultr API.

type ApplicationServiceHandler

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

ApplicationServiceHandler handles interaction with the application methods for the Vultr API.

func (*ApplicationServiceHandler) List

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

type BMBareMetalBase

type BMBareMetalBase struct {
	BareMetalBandwidth map[string]BareMetalServerBandwidth `json:"bandwidth"`
}

type Backup

type Backup struct {
	ID          string `json:"id"`
	DateCreated string `json:"date_created"`
	Description string `json:"description"`
	Size        int    `json:"size"`
	Status      string `json:"status"`
}

Backup represents a Vultr backup

type BackupSchedule

type BackupSchedule struct {
	Enabled             bool   `json:"enabled,omitempty"`
	Type                string `json:"type,omitempty"`
	NextScheduleTimeUTC string `json:"next_run_utc,omitempty"`
	Hour                int    `json:"hour,omitempty"`
	Dow                 int    `json:"dow,omitempty"`
	Dom                 int    `json:"dom,omitempty"`
}

type BackupScheduleReq

type BackupScheduleReq struct {
	Type string `json:"type"`
	Hour int    `json:"hour,omitempty"`
	Dow  int    `json:"dow,omitempty"`
	Dom  int    `json:"dom,omitempty"`
}

type BackupService

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

BackupService is the interface to interact with the backup endpoint on the Vultr API

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

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

List retrieves a list of all backups on the current account

type Bandwidth

type Bandwidth struct {
	Bandwidth map[string]struct {
		IncomingBytes int `json:"incoming_bytes"`
		OutgoingBytes int `json:"outgoing_bytes"`
	} `json:"bandwidth"`
}

type BareMetalPlan

type BareMetalPlan struct {
	ID          string   `json:"id"`
	CPUCount    int      `json:"cpu_count"`
	CPUModel    string   `json:"cpu_model"`
	CPUThreads  int      `json:"cpu_threads"`
	Ram         int      `json:"ram"`
	Disk        int      `json:"disk"`
	Bandwidth   int      `json:"bandwidth"`
	MonthlyCost int      `json:"monthly_cost"`
	Type        string   `json:"type"`
	Locations   []Region `json:"locations"`
}

BareMetalPlan represents bare metal plans

type BareMetalReq

type BareMetalReq struct {
	Region          string   `json:"region,omitempty"`
	Plan            string   `json:"plan,omitempty"`
	OsID            int      `json:"os_id,omitempty"`
	StartupScriptID string   `json:"script_id,omitempty"`
	SnapshotID      string   `json:"snapshot_id,omitempty"`
	EnableIPv6      string   `json:"enable_ipv6,omitempty"`
	Label           string   `json:"label,omitempty"`
	SSHKeyIDs       []string `json:"sshkey_id,omitempty"`
	AppID           int      `json:"app_id,omitempty"`
	UserData        string   `json:"user_data,omitempty"`
	NotifyActivate  string   `json:"notify_activate,omitempty"`
	Hostname        string   `json:"hostname,omitempty"`
	Tag             string   `json:"tag,omitempty"`
	ReservedIPv4    string   `json:"reserved_ipv4,omitempty"`
}

BareMetalReq represents the optional parameters that can be set when creating or updating a bare metal server

type BareMetalServer

type BareMetalServer struct {
	ID              string   `json:"id"`
	Os              string   `json:"os"`
	RAM             string   `json:"ram"`
	Disk            string   `json:"disk"`
	MainIP          string   `json:"main_ip"`
	CPUCount        int      `json:"cpu_count"`
	Region          string   `json:"region"`
	DefaultPassword string   `json:"default_password"`
	DateCreated     string   `json:"date_created"`
	Status          string   `json:"status"`
	NetmaskV4       string   `json:"netmask_v4"`
	GatewayV4       string   `json:"gateway_v4"`
	Plan            string   `json:"plan"`
	V6Network       string   `json:"v6_network"`
	V6MainIP        string   `json:"v6_main_ip"`
	V6Subnet        int      `json:"v6_subnet"`
	Label           string   `json:"label"`
	Tag             string   `json:"tag"`
	OsID            int      `json:"os_id"`
	AppID           int      `json:"app_id"`
	Features        []string `json:"features"`
}

BareMetalServer represents a bare metal server on Vultr

type BareMetalServerBandwidth

type BareMetalServerBandwidth struct {
	IncomingBytes int `json:"incoming_bytes"`
	OutgoingBytes int `json:"outgoing_bytes"`
}

BareMetalServerBandwidth represents bandwidth information for a bare metal server

type BareMetalServerService

type BareMetalServerService interface {
	Create(ctx context.Context, bmCreate *BareMetalReq) (*BareMetalServer, error)
	Get(ctx context.Context, serverID string) (*BareMetalServer, error)
	Update(ctx context.Context, serverID string, bmReq *BareMetalReq) error
	Delete(ctx context.Context, serverID string) error
	List(ctx context.Context, options *ListOptions) ([]BareMetalServer, *Meta, error)

	GetBandwidth(ctx context.Context, serverID string) (*Bandwidth, error)

	ListIPv4s(ctx context.Context, serverID string, options *ListOptions) ([]IPv4, *Meta, error)
	ListIPv6s(ctx context.Context, serverID string, options *ListOptions) ([]IPv6, *Meta, error)

	Halt(ctx context.Context, serverID string) error
	Reboot(ctx context.Context, serverID string) error
	Reinstall(ctx context.Context, serverID string) error

	MassStart(ctx context.Context, serverList []string) error
	MassHalt(ctx context.Context, serverList []string) error
	MassReboot(ctx context.Context, serverList []string) error
}

BareMetalServerService is the interface to interact with the bare metal endpoints on the Vultr API

type BareMetalServerServiceHandler

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

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

func (*BareMetalServerServiceHandler) Create

Create a new bare metal server.

func (*BareMetalServerServiceHandler) Delete

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

Get gets the server with the given ID

func (*BareMetalServerServiceHandler) GetBandwidth

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

Bandwidth will get the bandwidth used by a 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) List

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

func (*BareMetalServerServiceHandler) ListIPv4s

func (b *BareMetalServerServiceHandler) ListIPv4s(ctx context.Context, serverID string, options *ListOptions) ([]IPv4, *Meta, error)

ListIPv4s 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) ListIPv6s

func (b *BareMetalServerServiceHandler) ListIPv6s(ctx context.Context, serverID string, options *ListOptions) ([]IPv6, *Meta, error)

ListIPv6s lists 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) MassHalt

func (b *BareMetalServerServiceHandler) MassHalt(ctx context.Context, serverList []string) error

Halt will pause a list of bare metals.

func (*BareMetalServerServiceHandler) MassReboot

func (b *BareMetalServerServiceHandler) MassReboot(ctx context.Context, serverList []string) error

MassReboot reboots a list of instances.

func (*BareMetalServerServiceHandler) MassStart

func (b *BareMetalServerServiceHandler) MassStart(ctx context.Context, serverList []string) error

Start will start a list of bare metal servers the machine is already running, it will be restarted.

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

func (b *BareMetalServerServiceHandler) Update(ctx context.Context, serverID string, bmReq *BareMetalReq) error

Update will update the given bare metal. Empty values are ignored

type BlockStorage

type BlockStorage struct {
	ID                 string `json:"id"`
	Cost               int    `json:"cost"`
	Status             string `json:"status"`
	SizeGB             int    `json:"size_gb"`
	Region             string `json:"region"`
	DateCreated        string `json:"date_created"`
	AttachedToInstance string `json:"attached_to_instance"`
	Label              string `json:"label"`
}

BlockStorage represents Vultr Block-Storage

type BlockStorageReq

type BlockStorageReq struct {
	Region string `json:"region"`
	SizeGB int    `json:"size_gb"`
	Label  string `json:"label,omitempty"`
}

BlockStorageReq

type BlockStorageService

type BlockStorageService interface {
	Create(ctx context.Context, blockReq *BlockStorageReq) (*BlockStorage, error)
	Get(ctx context.Context, blockID string) (*BlockStorage, error)
	Update(ctx context.Context, blockID string, label string) error
	Delete(ctx context.Context, blockID string) error
	List(ctx context.Context, options *ListOptions) ([]BlockStorage, *Meta, error)

	Attach(ctx context.Context, blockID, instanceID string, liveAttach string) error
	Detach(ctx context.Context, blockID string, liveDetach string) error
	Resize(ctx context.Context, blockID string, sizeGB int) error
}

BlockStorageService is the interface to interact with Block-Storage endpoint on the Vultr API

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 string, 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

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 string, liveDetach string) error

Detach will de-link a given block storage to the Vultr instance 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

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

func (*BlockStorageServiceHandler) Update

func (b *BlockStorageServiceHandler) Update(ctx context.Context, blockID string, 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
	Application ApplicationService
	Backup      BackupService
	//BareMetalServer BareMetalServerService
	BlockStorage  BlockStorageService
	Domain        DomainService
	DomainRecord  DomainRecordService
	FirewallGroup FirewallGroupService
	FirewallRule  FireWallRuleService
	Instance      InstanceService
	ISO           ISOService
	LoadBalancer  LoadBalancerService
	Network       NetworkService
	ObjectStorage ObjectStorageService
	OS            OSService
	Plan          PlanService
	Region        RegionService
	ReservedIP    ReservedIPService
	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) *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 interface{}) (*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

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 Domain

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

Domain represents a Domain entry on Vultr

type DomainRecord

type DomainRecord struct {
	ID       string `json:"id,omitempty"`
	Type     string `json:"type,omitempty"`
	Name     string `json:"name,omitempty"`
	Data     string `json:"data,omitempty"`
	Priority int    `json:"priority,omitempty"`
	TTL      int    `json:"ttl,omitempty"`
}

DomainRecord represents a DNS record on Vultr

type DomainRecordReq

type DomainRecordReq struct {
	Name     string `json:"name,omitempty"`
	Type     string `json:"type,omitempty"`
	Data     string `json:"data,omitempty"`
	TTL      int    `json:"ttl,omitempty"`
	Priority int    `json:"priority,omitempty"`
}

DomainRecordReq struct to use for create/update domain record calls.

type DomainRecordService

type DomainRecordService interface {
	Create(ctx context.Context, domain string, domainRecordReq *DomainRecordReq) (*DomainRecord, error)
	Get(ctx context.Context, domain, recordID string) (*DomainRecord, error)
	Update(ctx context.Context, domain, recordID string, domainRecordReq *DomainRecordReq) error
	Delete(ctx context.Context, domain, recordID string) error
	List(ctx context.Context, domain string, options *ListOptions) ([]DomainRecord, *Meta, error)
}

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

type DomainRecordsServiceHandler

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

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

func (*DomainRecordsServiceHandler) Create

func (d *DomainRecordsServiceHandler) Create(ctx context.Context, domain string, domainRecordReq *DomainRecordReq) (*DomainRecord, error)

Create will add a DNS record.

func (*DomainRecordsServiceHandler) Delete

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

Delete will delete a domain name and all associated records.

func (*DomainRecordsServiceHandler) Get

func (d *DomainRecordsServiceHandler) Get(ctx context.Context, domain, recordID string) (*DomainRecord, error)

Get record from a domain

func (*DomainRecordsServiceHandler) List

func (d *DomainRecordsServiceHandler) List(ctx context.Context, domain string, options *ListOptions) ([]DomainRecord, *Meta, error)

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

func (*DomainRecordsServiceHandler) Update

func (d *DomainRecordsServiceHandler) Update(ctx context.Context, domain, recordID string, domainRecordReq *DomainRecordReq) error

Update will update a Domain record

type DomainReq

type DomainReq struct {
	Domain string `json:"domain,omitempty"`
	IP     string `json:"ip,omitempty"`
	DNSSec string `json:"dns_sec,omitempty"`
}

DomainReq is the struct to create a domain If IP is omitted then an empty DNS entry will be created. If supplied the domain will be pre populated with entries

type DomainService

type DomainService interface {
	Create(ctx context.Context, domainReq *DomainReq) (*Domain, error)
	Get(ctx context.Context, domain string) (*Domain, error)
	Update(ctx context.Context, domain, dnsSec string) error
	Delete(ctx context.Context, domain string) error
	List(ctx context.Context, options *ListOptions) ([]Domain, *Meta, error)

	GetSoa(ctx context.Context, domain string) (*Soa, error)
	UpdateSoa(ctx context.Context, domain string, soaReq *Soa) error

	GetDnsSec(ctx context.Context, domain string) ([]string, error)
}

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

type DomainServiceHandler

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

DNSDomainServiceHandler handles interaction with the DNS methods for the Vultr API

func (*DomainServiceHandler) Create

func (d *DomainServiceHandler) Create(ctx context.Context, domainReq *DomainReq) (*Domain, error)

Create a domain entry

func (*DomainServiceHandler) Delete

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

Delete a domain with all associated records.

func (*DomainServiceHandler) Get

func (d *DomainServiceHandler) Get(ctx context.Context, domain string) (*Domain, error)

Get a domain from your Vultr account.

func (*DomainServiceHandler) GetDnsSec

func (d *DomainServiceHandler) GetDnsSec(ctx context.Context, domain string) ([]string, error)

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

func (*DomainServiceHandler) GetSoa

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

GetSoa gets the SOA record information for a domain

func (*DomainServiceHandler) List

func (d *DomainServiceHandler) List(ctx context.Context, options *ListOptions) ([]Domain, *Meta, error)

List gets all domains associated with the current Vultr account.

func (*DomainServiceHandler) Update

func (d *DomainServiceHandler) Update(ctx context.Context, domain, dnsSec string) error

Update allows you to enable or disable DNS Sec on the domain. The two valid options for dnsSec are "enabled" or "disabled"

func (*DomainServiceHandler) UpdateSoa

func (d *DomainServiceHandler) UpdateSoa(ctx context.Context, domain string, soaReq *Soa) error

UpdateSoa will update the SOA record information for a domain.

type FireWallGroupServiceHandler

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

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

func (*FireWallGroupServiceHandler) Create

Create will create a new firewall group on your Vultr account

func (*FireWallGroupServiceHandler) Delete

func (f *FireWallGroupServiceHandler) Delete(ctx context.Context, fwGroupID 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

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

func (*FireWallGroupServiceHandler) Update

func (f *FireWallGroupServiceHandler) Update(ctx context.Context, fwGroupID string, fwGroupReq *FirewallGroupReq) error

Update will change the description of a firewall group

type FireWallRuleService

type FireWallRuleService interface {
	Create(ctx context.Context, fwGroupID string, fwRuleReq *FirewallRuleReq) (*FirewallRule, error)
	Delete(ctx context.Context, fwGroupID string, fwRuleID int) error
	List(ctx context.Context, fwGroupID string, options *ListOptions) ([]FirewallRule, *Meta, error)
}

FireWallRuleService is the interface to interact with the firewall rule endpoints on the Vultr API

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, fwGroupID string, fwRuleReq *FirewallRuleReq) (*FirewallRule, error)

Create will create a rule in a firewall group.

func (*FireWallRuleServiceHandler) Delete

func (f *FireWallRuleServiceHandler) Delete(ctx context.Context, fwGroupID string, fwRuleID int) error

Delete will delete a firewall rule on your Vultr account

func (*FireWallRuleServiceHandler) List

func (f *FireWallRuleServiceHandler) List(ctx context.Context, fwGroupID string, options *ListOptions) ([]FirewallRule, *Meta, error)

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

type FirewallGroup

type FirewallGroup struct {
	ID            string `json:"id"`
	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 FirewallGroupReq

type FirewallGroupReq struct {
	Description string `json:"description"`
}

FirewallGroupReq

type FirewallGroupService

type FirewallGroupService interface {
	Create(ctx context.Context, fwGroupReq *FirewallGroupReq) (*FirewallGroup, error)
	Get(ctx context.Context, groupID string) (*FirewallGroup, error)
	Update(ctx context.Context, fwGroupID string, fwGroupReq *FirewallGroupReq) error
	Delete(ctx context.Context, fwGroupID string) error
	List(ctx context.Context, options *ListOptions) ([]FirewallGroup, *Meta, error)
}

FirewallGroupService is the interface to interact with the firewall group endpoints on the Vultr API

type FirewallRule

type FirewallRule struct {
	ID         int    `json:"id"`
	Action     string `json:"action"`
	Type       string `json:"type"`
	Protocol   string `json:"protocol"`
	Port       string `json:"port"`
	Subnet     string `json:"subnet"`
	SubnetSize int    `json:"subnet_size"`
	Source     string `json:"source"`
	Notes      string `json:"notes"`
}

FirewallRule represents a Vultr firewall rule

type FirewallRuleReq

type FirewallRuleReq struct {
	IPType     string `json:"ip_type"`
	Protocol   string `json:"protocol"`
	Subnet     string `json:"subnet"`
	SubnetSize int    `json:"subnet_size"`
	Port       string `json:"port,omitempty"`
	Source     string `json:"source,omitempty"`
	Notes      string `json:"notes,omitempty"`
}

FirewallRuleReq

type ForwardingRule

type ForwardingRule struct {
	RuleID           string `json:"id,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

type ForwardingRules struct {
	ForwardRuleList []ForwardingRule `json:"forwarding_rules,omitempty"`
}

ForwardingRules represent a list of forwarding rules

type GenericInfo

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

GenericInfo represents generic configuration of your load balancer

type HealthCheck

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 IPv4

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

type IPv6

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

type ISO

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

ISO represents ISOs currently available on this account.

type ISOReq

type ISOReq struct {
	Url string `json:"url"`
}

ISOReq

type ISOService

type ISOService interface {
	Create(ctx context.Context, isoReq *ISOReq) (*ISO, error)
	Get(ctx context.Context, isoID int) (*ISO, error)
	Delete(ctx context.Context, isoID int) error
	List(ctx context.Context, options *ListOptions) ([]ISO, *Meta, error)
	ListPublic(ctx context.Context, options *ListOptions) ([]PublicISO, *Meta, error)
}

ISOService is the interface to interact with the ISO endpoints on the Vultr API

type ISOServiceHandler

type ISOServiceHandler struct {
	Client *Client
}

ISOServiceHandler handles interaction with the ISO methods for the Vultr API

func (*ISOServiceHandler) Create

func (i *ISOServiceHandler) Create(ctx context.Context, isoReq *ISOReq) (*ISO, error)

CreateFromURL will create a new ISO image on your account

func (*ISOServiceHandler) Delete

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

Delete will delete an ISO image from your account

func (*ISOServiceHandler) Get

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

Get an ISO

func (*ISOServiceHandler) List

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

List will list all ISOs currently available on your account

func (*ISOServiceHandler) ListPublic

func (i *ISOServiceHandler) ListPublic(ctx context.Context, options *ListOptions) ([]PublicISO, *Meta, error)

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

type Instance

type Instance struct {
	ID               string   `json:"id"`
	Os               string   `json:"os"`
	Ram              int      `json:"ram"`
	Disk             int      `json:"disk"`
	Plan             string   `json:"plan"`
	MainIP           string   `json:"main_ip"`
	VCPUCount        int      `json:"vcpu_count"`
	Region           string   `json:"region"`
	DefaultPassword  string   `json:"default_password,omitempty"`
	DateCreated      string   `json:"date_created"`
	Status           string   `json:"status"`
	AllowedBandwidth int      `json:"allowed_bandwidth"`
	NetmaskV4        string   `json:"netmask_v4"`
	GatewayV4        string   `json:"gateway_v4"`
	PowerStatus      string   `json:"power_status"`
	ServerStatus     string   `json:"server_status"`
	V6Network        string   `json:"v6_network"`
	V6MainIP         string   `json:"v6_main_ip"`
	V6NetworkSize    int      `json:"v6_network_size"`
	Label            string   `json:"label"`
	InternalIP       string   `json:"internal_ip"`
	KVM              string   `json:"kvm"`
	Tag              string   `json:"tag"`
	OsID             int      `json:"os_id"`
	AppID            int      `json:"app_id"`
	FirewallGroupID  string   `json:"firewall_group_id"`
	Features         []string `json:"features"`
}

Instance represents a VPS

type InstanceList

type InstanceList struct {
	InstanceList []int
}

InstanceList represents instances that are attached to your load balancer

type InstanceReq

type InstanceReq struct {
	Region               string   `json:"region,omitempty"`
	Plan                 string   `json:"plan,omitempty"`
	UpgradePlan          string   `json:"upgrade_plan,omitempty"`
	Label                string   `json:"label,omitempty"`
	Tag                  string   `json:"tag,omitempty"`
	OsID                 int      `json:"os_id,omitempty"`
	ISOID                string   `json:"iso_id,omitempty"`
	AppID                int      `json:"app_id,omitempty"`
	FirewallGroupID      string   `json:"firewall_group_id,omitempty"`
	Hostname             string   `json:"hostname,omitempty"`
	IPXEChainURL         string   `json:"ipxe_chain_url,omitempty"`
	ScriptID             string   `json:"script_id,omitempty"`
	SnapshotID           string   `json:"snapshot_id,omitempty"`
	EnableIPv6           bool     `json:"enable_ipv6,omitempty"`
	AttachPrivateNetwork []string `json:"attach_private_network,omitempty"`
	DetachPrivateNetwork []string `json:"detach_private_network,omitempty"`
	SSHKey               []string `json:"sshkey_id,omitempty"`
	Backups              bool     `json:"backups,omitempty"`
	DDOSProtection       bool     `json:"ddos_protection,omitempty"`
	UserData             string   `json:"user_data,omitempty"`
	ReservedIPv4         string   `json:"reserved_ipv4,omitempty"`
	ActivationEmail      bool     `json:"activation_email,omitempty"`
}

InstanceReq

type InstanceService

type InstanceService interface {
	Create(ctx context.Context, instanceReq *InstanceReq) (*Instance, error)
	Get(ctx context.Context, instanceID string) (*Instance, error)
	Update(ctx context.Context, instanceID string, instanceReq *InstanceReq) error
	Delete(ctx context.Context, instanceID string) error
	List(ctx context.Context, options *ListOptions) ([]Instance, *Meta, 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

	MassStart(ctx context.Context, instanceList []string) error
	MassHalt(ctx context.Context, instanceList []string) error
	MassReboot(ctx context.Context, instanceList []string) error

	Restore(ctx context.Context, instanceID string, restoreReq *RestoreReq) error

	GetBandwidth(ctx context.Context, instanceID string) (*Bandwidth, error)
	GetNeighbors(ctx context.Context, instanceID string) (*Neighbors, error)

	ListPrivateNetworks(ctx context.Context, instanceID string) ([]PrivateNetwork, *Meta, error)
	AttachPrivateNetwork(ctx context.Context, instanceID, networkID string) error
	DetachPrivateNetwork(ctx context.Context, instanceID, networkID string) error

	ISOStatus(ctx context.Context, instanceID string) (*Iso, error)
	AttachISO(ctx context.Context, instanceID, isoID string) error
	DetachISO(ctx context.Context, instanceID string) error

	GetBackupSchedule(ctx context.Context, instanceID string) (*BackupSchedule, error)
	SetBackupSchedule(ctx context.Context, instanceID string, backup *BackupScheduleReq) error

	CreateIPv4(ctx context.Context, instanceID string, reboot bool) (*IPv4, error)
	ListIPv4(ctx context.Context, instanceID string, option *ListOptions) ([]IPv4, *Meta, error)
	DeleteIPv4(ctx context.Context, instanceID, ip string) error
	ListIPv6(ctx context.Context, instanceID string, option *ListOptions) ([]IPv6, *Meta, error)

	CreateReverseIPv6(ctx context.Context, instanceID string, reverseReq *ReverseIP) error
	ListReverseIPv6(ctx context.Context, instanceID string) ([]ReverseIP, error)
	DeleteReverseIPv6(ctx context.Context, instanceID, ip string) error

	CreateReverseIPv4(ctx context.Context, instanceID string, reverseReq *ReverseIP) error
	DefaultReverseIPv4(ctx context.Context, instanceID, ip string) error

	GetUserData(ctx context.Context, instanceID string) (*UserData, error)
}

InstanceService is the interface to interact with the instance endpoints on the Vultr API Link: https://www.vultr.com/api/v2/#tag/instances

type InstanceServiceHandler

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

ServerServiceHandler handles interaction with the server methods for the Vultr API

func (*InstanceServiceHandler) AttachISO

func (i *InstanceServiceHandler) AttachISO(ctx context.Context, instanceID, isoID string) error

AttachISO will attach an ISO to the given instance and reboot it

func (*InstanceServiceHandler) AttachPrivateNetwork

func (i *InstanceServiceHandler) AttachPrivateNetwork(ctx context.Context, instanceID, networkID string) error

AttachPrivateNetwork to an instance

func (*InstanceServiceHandler) Create

func (i *InstanceServiceHandler) Create(ctx context.Context, instanceReq *InstanceReq) (*Instance, error)

Create will create the server with the given parameters

func (*InstanceServiceHandler) CreateIPv4

func (i *InstanceServiceHandler) CreateIPv4(ctx context.Context, instanceID string, reboot bool) (*IPv4, error)

func (*InstanceServiceHandler) CreateReverseIPv4

func (i *InstanceServiceHandler) CreateReverseIPv4(ctx context.Context, instanceID string, reverseReq *ReverseIP) error

CreateReverseIPv4 for a given IP on a given instance.

func (*InstanceServiceHandler) CreateReverseIPv6

func (i *InstanceServiceHandler) CreateReverseIPv6(ctx context.Context, instanceID string, reverseReq *ReverseIP) error

func (*InstanceServiceHandler) DefaultReverseIPv4

func (i *InstanceServiceHandler) DefaultReverseIPv4(ctx context.Context, instanceID, ip string) error

DefaultReverseIPv4 will set the IPs reverse setting back to the original one supplied by Vultr.

func (*InstanceServiceHandler) Delete

func (i *InstanceServiceHandler) Delete(ctx context.Context, instanceID string) error

Delete an instance. All data will be permanently lost, and the IP address will be released

func (*InstanceServiceHandler) DeleteIPv4

func (i *InstanceServiceHandler) DeleteIPv4(ctx context.Context, instanceID, ip string) error

func (*InstanceServiceHandler) DeleteReverseIPv6

func (i *InstanceServiceHandler) DeleteReverseIPv6(ctx context.Context, instanceID, ip string) error

DeleteReverseIPv6 a given reverse IPv6.

func (*InstanceServiceHandler) DetachISO

func (i *InstanceServiceHandler) DetachISO(ctx context.Context, instanceID string) error

DetachISO will detach the currently mounted ISO and reboot the instance.

func (*InstanceServiceHandler) DetachPrivateNetwork

func (i *InstanceServiceHandler) DetachPrivateNetwork(ctx context.Context, instanceID, networkID string) error

DetachedPrivateNetwork from an instance.

func (*InstanceServiceHandler) Get

func (i *InstanceServiceHandler) Get(ctx context.Context, instanceID string) (*Instance, error)

Get will get the server with the given instanceID

func (*InstanceServiceHandler) GetBackupSchedule

func (i *InstanceServiceHandler) GetBackupSchedule(ctx context.Context, instanceID string) (*BackupSchedule, error)

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

func (*InstanceServiceHandler) GetBandwidth

func (i *InstanceServiceHandler) GetBandwidth(ctx context.Context, instanceID string) (*Bandwidth, error)

func (*InstanceServiceHandler) GetNeighbors

func (i *InstanceServiceHandler) GetNeighbors(ctx context.Context, instanceID string) (*Neighbors, error)

GetNeighbors gets a list of other instances in the same location as this Instance.

func (*InstanceServiceHandler) GetUserData

func (i *InstanceServiceHandler) GetUserData(ctx context.Context, instanceID string) (*UserData, error)

GetUserData from given instance. The userdata returned will be in base64 encoding.

func (*InstanceServiceHandler) Halt

func (i *InstanceServiceHandler) Halt(ctx context.Context, instanceID string) error

Halt will pause an instance.

func (*InstanceServiceHandler) ISOStatus

func (i *InstanceServiceHandler) ISOStatus(ctx context.Context, instanceID string) (*Iso, error)

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

func (*InstanceServiceHandler) List

func (i *InstanceServiceHandler) List(ctx context.Context, options *ListOptions) ([]Instance, *Meta, error)

List all instances on your account.

func (*InstanceServiceHandler) ListIPv4

func (i *InstanceServiceHandler) ListIPv4(ctx context.Context, instanceID string, options *ListOptions) ([]IPv4, *Meta, error)

func (*InstanceServiceHandler) ListIPv6

func (i *InstanceServiceHandler) ListIPv6(ctx context.Context, instanceID string, options *ListOptions) ([]IPv6, *Meta, error)

func (*InstanceServiceHandler) ListPrivateNetworks

func (i *InstanceServiceHandler) ListPrivateNetworks(ctx context.Context, instanceID string) ([]PrivateNetwork, *Meta, error)

func (*InstanceServiceHandler) ListReverseIPv6

func (i *InstanceServiceHandler) ListReverseIPv6(ctx context.Context, instanceID string) ([]ReverseIP, error)

func (*InstanceServiceHandler) MassHalt

func (i *InstanceServiceHandler) MassHalt(ctx context.Context, instanceList []string) error

Halt will pause a list of instances.

func (*InstanceServiceHandler) MassReboot

func (i *InstanceServiceHandler) MassReboot(ctx context.Context, instanceList []string) error

MassReboot reboots a list of instances.

func (*InstanceServiceHandler) MassStart

func (i *InstanceServiceHandler) MassStart(ctx context.Context, instanceList []string) error

Start will start a list of vps instances the machine is already running, it will be restarted.

func (*InstanceServiceHandler) Reboot

func (i *InstanceServiceHandler) Reboot(ctx context.Context, instanceID string) error

Reboot an instance.

func (*InstanceServiceHandler) Reinstall

func (i *InstanceServiceHandler) Reinstall(ctx context.Context, instanceID string) error

Reinstall an instance.

func (*InstanceServiceHandler) Restore

func (i *InstanceServiceHandler) Restore(ctx context.Context, instanceID string, restoreReq *RestoreReq) error

Restore an instance.

func (*InstanceServiceHandler) SetBackupSchedule

func (i *InstanceServiceHandler) SetBackupSchedule(ctx context.Context, instanceID string, backup *BackupScheduleReq) error

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

func (*InstanceServiceHandler) Start

func (i *InstanceServiceHandler) Start(ctx context.Context, instanceID string) error

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

func (*InstanceServiceHandler) Update

func (i *InstanceServiceHandler) Update(ctx context.Context, instanceID string, instanceReq *InstanceReq) error

Update will update the server with the given parameters

type Iso

type Iso struct {
	State string `json:"state"`
	IsoID string `json:"iso_id"`
}
type Links struct {
	Next string `json:"next"`
	Prev string `json:"prev"`
}

Links represent the next/previous cursor in your pagination calls

type ListOptions

type ListOptions struct {
	PerPage int    `url:"per_page,omitempty"`
	Cursor  string `url:"cursor,omitempty"`
}

ListOptions

type LoadBalancer

type LoadBalancer struct {
	ID              string           `json:"id,omitempty"`
	DateCreated     string           `json:"date_created,omitempty"`
	Region          string           `json:"region,omitempty"`
	Label           string           `json:"label,omitempty"`
	Status          string           `json:"status,omitempty"`
	IPV4            string           `json:"ipv4,omitempty"`
	IPV6            string           `json:"ipv6,omitempty"`
	Instances       []int            `json:"instances,omitempty"`
	HealthCheck     *HealthCheck     `json:"health_check,omitempty"`
	GenericInfo     *GenericInfo     `json:"generic_info,omitempty"`
	SSLInfo         bool             `json:"has_ssl,omitempty"`
	ForwardingRules []ForwardingRule `json:"forwarding_rules,omitempty"`
}

LoadBalancer represent the structure of a load balancer

type LoadBalancerHandler

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

LoadBalancerHandler handles interaction with the server methods for the Vultr API

func (*LoadBalancerHandler) Create

func (l *LoadBalancerHandler) Create(ctx context.Context, createReq *LoadBalancerReq) (*LoadBalancer, error)

Create a load balancer

func (*LoadBalancerHandler) CreateForwardingRule

func (l *LoadBalancerHandler) CreateForwardingRule(ctx context.Context, ID string, 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

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

Delete a load balancer subscription.

func (*LoadBalancerHandler) DeleteForwardingRule

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

DeleteForwardingRule removes a forwarding rule from a load balancer subscription

func (*LoadBalancerHandler) Get

Get a load balancer

func (*LoadBalancerHandler) GetForwardingRule

func (l *LoadBalancerHandler) GetForwardingRule(ctx context.Context, ID string, ruleID string) (*ForwardingRule, error)

GetForwardingRule will get a forwarding rule from your load balancer subscription.

func (*LoadBalancerHandler) List

func (l *LoadBalancerHandler) List(ctx context.Context, options *ListOptions) ([]LoadBalancer, *Meta, error)

List all load balancer subscriptions on the current account.

func (*LoadBalancerHandler) ListForwardingRules

func (l *LoadBalancerHandler) ListForwardingRules(ctx context.Context, ID string, options *ListOptions) ([]ForwardingRule, *Meta, error)

ListForwardingRules lists all forwarding rules for a load balancer subscription

func (*LoadBalancerHandler) Update

func (l *LoadBalancerHandler) Update(ctx context.Context, ID string, updateReq *LoadBalancerReq) error

Update updates your your load balancer

type LoadBalancerReq

type LoadBalancerReq struct {
	Region             string           `json:"region,omitempty"`
	Label              string           `json:"label,omitempty"`
	Instances          []int            `json:"instances,omitempty"`
	HealthCheck        *HealthCheck     `json:"health_check,omitempty"`
	StickySessions     *StickySessions  `json:"sticky_session,omitempty"`
	ForwardingRules    []ForwardingRule `json:"forwarding_rules,omitempty"`
	SSL                *SSL             `json:"ssl,omitempty"`
	SSLRedirect        bool             `json:"ssl_redirect,omitempty"`
	ProxyProtocol      string           `json:"proxy_protocol,omitempty"`
	BalancingAlgorithm string           `json:"balancing_algorithm,omitempty"`
}

LoadBalancerReq gives options for creating or updating a load balancer

type LoadBalancerService

type LoadBalancerService interface {
	Create(ctx context.Context, createReq *LoadBalancerReq) (*LoadBalancer, error)
	Get(ctx context.Context, ID string) (*LoadBalancer, error)
	Update(ctx context.Context, ID string, updateReq *LoadBalancerReq) error
	Delete(ctx context.Context, ID string) error
	List(ctx context.Context, options *ListOptions) ([]LoadBalancer, *Meta, error)
	CreateForwardingRule(ctx context.Context, ID string, rule *ForwardingRule) (*ForwardingRule, error)
	GetForwardingRule(ctx context.Context, ID string, ruleID string) (*ForwardingRule, error)
	DeleteForwardingRule(ctx context.Context, ID string, RuleID string) error
	ListForwardingRules(ctx context.Context, ID string, options *ListOptions) ([]ForwardingRule, *Meta, error)
}

LoadBalancerService is the interface to interact with the server endpoints on the Vultr API

type Meta

type Meta struct {
	Total int `json:"total"`
	Links *Links
}

Meta represents the available pagination information

type Neighbors

type Neighbors struct {
	Neighbors []string `json:"neighbors"`
}

type Network

type Network struct {
	NetworkID    string `json:"id"`
	Region       string `json:"region"`
	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 NetworkReq

type NetworkReq struct {
	Region       string `json:"region"`
	Description  string `json:"description"`
	V4Subnet     string `json:"v4_subnet"`
	V4SubnetMask int    `json:"v4_subnet_mask"`
}

NetworkReq represents parameters to create or update Network resource

type NetworkService

type NetworkService interface {
	Create(ctx context.Context, createReq *NetworkReq) (*Network, error)
	Get(ctx context.Context, networkID string) (*Network, error)
	Update(ctx context.Context, networkID string, updateReq *NetworkReq) error
	Delete(ctx context.Context, networkID string) error
	List(ctx context.Context, options *ListOptions) ([]Network, *Meta, error)
}

NetworkService is the interface to interact with the network endpoints on the Vultr API

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, createReq *NetworkReq) (*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

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

Delete a private network. Before deleting, a network must be disabled from all instances

func (*NetworkServiceHandler) Get

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

Get gets the private networks of the requested ID

func (*NetworkServiceHandler) List

func (n *NetworkServiceHandler) List(ctx context.Context, options *ListOptions) ([]Network, *Meta, error)

List lists all private networks on the current account

func (*NetworkServiceHandler) Update

func (n *NetworkServiceHandler) Update(ctx context.Context, networkID string, updateReq *NetworkReq) error

Update updates a private network

type OS

type OS struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Arch   string `json:"arch"`
	Family string `json:"family"`
}

OS represents a Vultr operating system

type OSService

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

OSService is the interface to interact with the operating system endpoint on the Vultr API

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

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

List retrieves a list of available operating systems.

type ObjectStorage

type ObjectStorage struct {
	ID                   int    `json:"id"`
	DateCreated          string `json:"date_created"`
	ObjectStoreClusterID int    `json:"cluster_id"`
	Region               string `json:"region"`
	Label                string `json:"label"`
	Status               string
	S3Keys
}

ObjectStorage represents a Vultr Object Storage subscription.

type ObjectStorageCluster

type ObjectStorageCluster struct {
	ID       int    `json:"id"`
	Region   string `json:"region"`
	Hostname string `json:"hostname"`
	Deploy   string `json:"deploy"`
}

ObjectStorageCluster represents a Vultr Object Storage cluster.

type ObjectStorageService

type ObjectStorageService interface {
	Create(ctx context.Context, clusterID int, label string) (*ObjectStorage, error)
	Get(ctx context.Context, id int) (*ObjectStorage, error)
	Update(ctx context.Context, id int, label string) error
	Delete(ctx context.Context, id int) error
	List(ctx context.Context, options *ListOptions) ([]ObjectStorage, *Meta, error)

	ListCluster(ctx context.Context, options *ListOptions) ([]ObjectStorageCluster, *Meta, error)
	RegenerateKeys(ctx context.Context, id int) (*S3Keys, error)
}

ObjectStorageService is the interface to interact with the object storage endpoints on the Vultr API.

type ObjectStorageServiceHandler

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

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

func (*ObjectStorageServiceHandler) Create

func (o *ObjectStorageServiceHandler) Create(ctx context.Context, clusterID int, label string) (*ObjectStorage, error)

Create an object storage subscription

func (*ObjectStorageServiceHandler) Delete

Delete an object storage subscription.

func (*ObjectStorageServiceHandler) Get

Get returns a specified object storage by the provided ID

func (*ObjectStorageServiceHandler) List

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

func (*ObjectStorageServiceHandler) ListCluster

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

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

RegenerateKeys of the S3 API Keys for an object storage subscription

func (*ObjectStorageServiceHandler) Update

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

SetLabel of an object storage subscription.

type Plan

type Plan struct {
	ID          string   `json:"id"`
	VCPUCount   int      `json:"vcpu_count"`
	Ram         int      `json:"ram"`
	Disk        int      `json:"disk"`
	Bandwidth   int      `json:"bandwidth"`
	MonthlyCost string   `json:"monthly_cost"`
	Type        string   `json:"type"`
	Locations   []Region `json:"locations"`
}

Plans represents vc2, vdc, or vhf

type PlanService

type PlanService interface {
	List(ctx context.Context, planType string, options *ListOptions) ([]Plan, *Meta, error)
	ListBareMetal(ctx context.Context, options *ListOptions) ([]BareMetalPlan, *Meta, error)
}

PlanService is the interface to interact with the Plans endpoints on the Vultr API

type PlanServiceHandler

type PlanServiceHandler struct {
	Client *Client
}

PlanServiceHandler handles interaction with the Plans methods for the Vultr API

func (*PlanServiceHandler) List

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

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

func (*PlanServiceHandler) ListBareMetal

func (p *PlanServiceHandler) ListBareMetal(ctx context.Context, options *ListOptions) ([]BareMetalPlan, *Meta, error)

GetBareMetalList retrieves a list of all active bare metal plans.

type PrivateNetwork

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

type PublicISO

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

PublicISO represents public ISOs offered in the Vultr ISO library.

type Region

type Region struct {
	ID        string   `json:"id"`
	City      string   `json:"city"`
	Country   string   `json:"country"`
	Continent string   `json:"continent,omitempty"`
	Options   []string `json:"options"`
}

Region represents a Vultr region

type RegionService

type RegionService interface {
	Availability(ctx context.Context, regionID string, planType string) (*planAvailability, error)
	List(ctx context.Context, options *ListOptions) ([]Region, *Meta, error)
}

RegionService is the interface to interact with Region endpoints on the Vultr API

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 string, planType string) (*planAvailability, error)

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

func (*RegionServiceHandler) List

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

List returns all available regions

type RequestBody

type RequestBody map[string]interface{}

type RequestCompletionCallback

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

RequestCompletionCallback defines the type of the request callback function

type ReservedIP

type ReservedIP struct {
	ID         string `json:"id"`
	Region     string `json:"region"`
	IPType     string `json:"ip_type"`
	Subnet     string `json:"subnet"`
	SubnetSize int    `json:"subnet_size"`
	Label      string `json:"label"`
	InstanceID string `json:"instance_id"`
}

ReservedIP represents an reserved IP on Vultr

type ReservedIPReq

type ReservedIPReq struct {
	Region     string `json:"region,omitempty"`
	IPType     string `json:"ip_type,omitempty"`
	IPAddress  string `json:"ip_address,omitempty"`
	Label      string `json:"label,omitempty"`
	InstanceID string `json:"instance_id,omitempty"`
}

ReservedIPReq represents the parameters for creating a new Reserved IP on Vultr

type ReservedIPService

type ReservedIPService interface {
	Create(ctx context.Context, ripCreate *ReservedIPReq) (*ReservedIP, error)
	Get(ctx context.Context, id string) (*ReservedIP, error)
	Delete(ctx context.Context, id string) error
	List(ctx context.Context, options *ListOptions) ([]ReservedIP, *Meta, error)

	Convert(ctx context.Context, ripConvert *ReservedIPReq) (*ReservedIP, error)
	Attach(ctx context.Context, id string, ripAttach *ReservedIPReq) error
	Detach(ctx context.Context, id string) error
}

ReservedIPService is the interface to interact with the reserved IP endpoints on the Vultr API

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, id string, ripAttach *ReservedIPReq) error

Attach a reserved IP to an existing subscription

func (*ReservedIPServiceHandler) Convert

func (r *ReservedIPServiceHandler) Convert(ctx context.Context, ripConvert *ReservedIPReq) (*ReservedIP, error)

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

func (*ReservedIPServiceHandler) Create

func (r *ReservedIPServiceHandler) Create(ctx context.Context, ripCreate *ReservedIPReq) (*ReservedIP, error)

Create adds the specified reserved IP to your Vultr account

func (*ReservedIPServiceHandler) Delete

Delete removes the specified reserved IP from your Vultr account

func (*ReservedIPServiceHandler) Detach

Detach a reserved IP from an existing subscription.

func (*ReservedIPServiceHandler) Get

Get gets the reserved IP associated with provided ID

func (*ReservedIPServiceHandler) List

List lists all the reserved IPs associated with your Vultr account

type RestoreReq

type RestoreReq struct {
	BackupId   string `json:"backup_id,omitempty"`
	SnapshotID string `json:"snapshot_id,omitempty"`
}

type ReverseIP

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

type S3Keys

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 {
	ID          string `json:"id"`
	Name        string `json:"name"`
	SSHKey      string `json:"ssh_key"`
	DateCreated string `json:"date_created"`
}

SSHKey represents an SSH Key on Vultr

type SSHKeyReq

type SSHKeyReq struct {
	Name   string `json:"name,omitempty"`
	SSHKey string `json:"ssh_key,omitempty"`
}

SSHKeyReq is the ssh key struct for create and update calls

type SSHKeyService

type SSHKeyService interface {
	Create(ctx context.Context, sshKeyReq *SSHKeyReq) (*SSHKey, error)
	Get(ctx context.Context, sshKeyID string) (*SSHKey, error)
	Update(ctx context.Context, sshKeyID string, sshKeyReq *SSHKeyReq) error
	Delete(ctx context.Context, sshKeyID string) error
	List(ctx context.Context, options *ListOptions) ([]SSHKey, *Meta, error)
}

SSHKeyService is the interface to interact with the SSH Key endpoints on the Vultr API

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, sshKeyReq *SSHKeyReq) (*SSHKey, error)

Create a ssh key

func (*SSHKeyServiceHandler) Delete

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

Delete a specific ssh-key.

func (*SSHKeyServiceHandler) Get

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

Get a specific ssh key.

func (*SSHKeyServiceHandler) List

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

List all available SSH Keys.

func (*SSHKeyServiceHandler) Update

func (s *SSHKeyServiceHandler) Update(ctx context.Context, sshKeyID string, sshKeyReq *SSHKeyReq) error

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

type SSL

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

SSL represents valid SSL config

type Snapshot

type Snapshot struct {
	ID          string `json:"id"`
	DateCreated string `json:"date_created"`
	Description string `json:"description"`
	Size        int    `json:"size"`
	Status      string `json:"status"`
	OsID        int    `json:"os_id"`
	AppID       int    `json:"app_id"`
}

Snapshot represents a Vultr snapshot

type SnapshotReq

type SnapshotReq struct {
	InstanceID  int    `json:"instance_id,omitempty"`
	Description string `json:"description,omitempty"`
}

SnapshotReq

type SnapshotService

type SnapshotService interface {
	Create(ctx context.Context, snapshotReq *SnapshotReq) (*Snapshot, error)
	CreateFromURL(ctx context.Context, snapshotURLReq SnapshotURLReq) (*Snapshot, error)
	Get(ctx context.Context, snapshotID string) (*Snapshot, error)
	Delete(ctx context.Context, snapshotID string) error
	List(ctx context.Context, options *ListOptions) ([]Snapshot, *Meta, error)
}

SnapshotService is the interface to interact with Snapshot endpoints on the Vultr API

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, snapshotReq *SnapshotReq) (*Snapshot, error)

Create makes a snapshot of a provided server

func (*SnapshotServiceHandler) CreateFromURL

func (s *SnapshotServiceHandler) CreateFromURL(ctx context.Context, snapshotURLReq SnapshotURLReq) (*Snapshot, error)

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

func (*SnapshotServiceHandler) Delete

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

Delete a snapshot.

func (*SnapshotServiceHandler) Get

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

Get a specific snapshot

func (*SnapshotServiceHandler) List

func (s *SnapshotServiceHandler) List(ctx context.Context, options *ListOptions) ([]Snapshot, *Meta, error)

List all available snapshots.

type SnapshotURLReq

type SnapshotURLReq struct {
	URL string `json:"url"`
}

SnapshotURLReq

type Soa

type Soa struct {
	NSPrimary string `json:"nsprimary,omitempty"`
	Email     string `json:"email,omitempty"`
}

Soa information for the Domain

type StartupScript

type StartupScript struct {
	ID           string `json:"id"`
	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

type StartupScriptReq

type StartupScriptReq struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Script string `json:"script"`
}

StartupScriptReq is the user struct for create and update calls

type StartupScriptService

type StartupScriptService interface {
	Create(ctx context.Context, req *StartupScriptReq) (*StartupScript, error)
	Get(ctx context.Context, scriptID string) (*StartupScript, error)
	Update(ctx context.Context, scriptID string, scriptReq *StartupScriptReq) error
	Delete(ctx context.Context, scriptID string) error
	List(ctx context.Context, options *ListOptions) ([]StartupScript, *Meta, error)
}

StartupScriptService is the interface to interact with the startup script endpoints on the Vultr API

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

Create a startup script

func (*StartupScriptServiceHandler) Delete

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

Delete the specified startup script from your account.

func (*StartupScriptServiceHandler) Get

Get a single startup script

func (*StartupScriptServiceHandler) List

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

func (*StartupScriptServiceHandler) Update

func (s *StartupScriptServiceHandler) Update(ctx context.Context, scriptID string, scriptReq *StartupScriptReq) error

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

type StickySessions

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

StickySessions represents cookie for your load balancer

type User

type User struct {
	ID         string   `json:"id"`
	Name       string   `json:"name"`
	Email      string   `json:"email"`
	APIEnabled string   `json:"api_enabled"`
	APIKey     string   `json:"api_key,omitempty"`
	ACL        []string `json:"acls,omitempty"`
}

User represents an user on Vultr

type UserData

type UserData struct {
	Data string `json:"data"`
}

type UserReq

type UserReq struct {
	Email      string   `json:"email,omitempty"`
	Name       string   `json:"name,omitempty"`
	APIEnabled string   `json:"api_enabled,omitempty"`
	ACL        []string `json:"acl,omitempty"`
	Password   string   `json:"password,omitempty"`
}

UserReq is the user struct for create and update calls

type UserService

type UserService interface {
	Create(ctx context.Context, userCreate *UserReq) (*User, error)
	Get(ctx context.Context, userID string) (*User, error)
	Update(ctx context.Context, userID string, userReq *UserReq) error
	Delete(ctx context.Context, userID string) error
	List(ctx context.Context, options *ListOptions) ([]User, *Meta, error)
}

UserService is the interface to interact with the user management endpoints on the Vultr API

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, userCreate *UserReq) (*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) Get

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

Get will retrieve a specific user account

func (*UserServiceHandler) List

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

List will list all the users associated with your Vultr account

func (*UserServiceHandler) Update

func (u *UserServiceHandler) Update(ctx context.Context, userID string, userReq *UserReq) error

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

Jump to

Keyboard shortcuts

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