linodego

package module
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 15 Imported by: 0

README

linodego

Build Status GoDoc Go Report Card codecov

Go client for Linode REST v4 API

Installation

go get -u github.com/linode/linodego

API Support

Check API_SUPPORT.md for current support of the Linode v4 API endpoints.

** Note: This project will change and break until we release a v1.0.0 tagged version. Breaking changes in v0.x.x will be denoted with a minor version bump (v0.2.4 -> v0.3.0) **

Documentation

See godoc for a complete reference.

The API generally follows the naming patterns prescribed in the OpenAPIv3 document for Linode APIv4.

Deviations in naming have been made to avoid using "Linode" and "Instance" redundantly or inconsistently.

A brief summary of the features offered in this API client are shown here.

Examples

General Usage
package main

import (
	"context"
	"fmt"

	"github.com/linode/linodego"
	"golang.org/x/oauth2"

	"log"
	"net/http"
	"os"
)

func main() {
  apiKey, ok := os.LookupEnv("LINODE_TOKEN")
  if !ok {
    log.Fatal("Could not find LINODE_TOKEN, please assert it is set.")
  }
  tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey})

  oauth2Client := &http.Client{
    Transport: &oauth2.Transport{
      Source: tokenSource,
    },
  }

  linodeClient := linodego.NewClient(oauth2Client)
  linodeClient.SetDebug(true)
  
  res, err := linodeClient.GetInstance(context.Background(), 4090913)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Printf("%v", res)
}
Pagination
Auto-Pagination Requests
kernels, err := linodego.ListKernels(context.Background(), nil)
// len(kernels) == 218

Or, use a page value of "0":

opts := linodego.NewListOptions(0,"")
kernels, err := linodego.ListKernels(context.Background(), opts)
// len(kernels) == 218
Single Page
opts := linodego.NewListOptions(2,"")
// or opts := linodego.ListOptions{PageOptions: &PageOptions: {Page: 2 }}
kernels, err := linodego.ListKernels(context.Background(), opts)
// len(kernels) == 100

ListOptions are supplied as a pointer because the Pages and Results values are set in the supplied ListOptions.

// opts.Results == 218
Filtering
opts := linodego.ListOptions{Filter: "{\"mine\":true}"}
// or opts := linodego.NewListOptions(0, "{\"mine\":true}")
stackscripts, err := linodego.ListStackscripts(context.Background(), opts)
Error Handling
Getting Single Entities
linode, err := linodego.GetInstance(context.Background(), 555) // any Linode ID that does not exist or is not yours
// linode == nil: true
// err.Error() == "[404] Not Found"
// err.Code == "404"
// err.Message == "Not Found"
Lists

For lists, the list is still returned as [], but err works the same way as on the Get request.

linodes, err := linodego.ListInstances(context.Background(), linodego.NewListOptions(0, "{\"foo\":bar}"))
// linodes == []
// err.Error() == "[400] [X-Filter] Cannot filter on foo"

Otherwise sane requests beyond the last page do not trigger an error, just an empty result:

linodes, err := linodego.ListInstances(context.Background(), linodego.NewListOptions(9999, ""))
// linodes == []
// err = nil
Writes

When performing a POST or PUT request, multiple field related errors will be returned as a single error, currently like:

// err.Error() == "[400] [field1] foo problem; [field2] bar problem; [field3] baz problem"

Tests

Run make test to run the unit tests. This is the same as running go test except that make test will execute the tests while playing back API response fixtures that were recorded during a previous development build.

go test can be used without the fixtures. Copy env.sample to .env and configure your persistent test settings, including an API token.

go test -short can be used to run live API tests that do not require an account token.

This will be simplified in future versions.

To update the test fixtures, run make fixtures. This will record the API responses into the fixtures/ directory. Be careful about committing any sensitive account details. An attempt has been made to sanitize IP addresses and dates, but no automated sanitization will be performed against fixtures/*Account*.yaml, for example.

To prevent disrupting unaffected fixtures, target fixture generation like so: make ARGS="-run TestListVolumes" fixtures.

Discussion / Help

Join us at #linodego on the gophers slack

License

MIT License

Documentation

Overview

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/Example")
defer teardown()

var linode *linodego.Instance
linode, err := linodeClient.GetInstance(context.Background(), 1231)
fmt.Println("## Instance request with Invalid ID")
fmt.Println("### Linode:", linode)
fmt.Println("### Error:", err)

if spendMoney {
	linode, err = linodeClient.CreateInstance(context.Background(), linodego.InstanceCreateOptions{Region: "us-central", Type: "g5-nanode-1"})
	if err != nil {
		log.Fatalln("* While creating instance: ", err)
	}
	linode, err = linodeClient.UpdateInstance(context.Background(), linode.ID, linodego.InstanceUpdateOptions{Label: linode.Label + "-renamed"})
	if err != nil {
		log.Fatalln("* While renaming instance: ", err)
	}
	fmt.Println("## Created Instance")
	event, errEvent := linodeClient.WaitForEventFinished(context.Background(), linode.ID, linodego.EntityLinode, linodego.ActionLinodeCreate, *linode.Created, 240)
	if errEvent != nil {
		log.Fatalf("* Failed to wait for Linode %d to finish creation: %s", linode.ID, errEvent)
	}
	if errEvent = linodeClient.MarkEventRead(context.Background(), event); errEvent != nil {
		log.Fatalln("* Failed to mark Linode create event seen", errEvent)
	}

	diskSwap, errSwap := linodeClient.CreateInstanceDisk(context.Background(), linode.ID, linodego.InstanceDiskCreateOptions{Size: 50, Filesystem: "swap", Label: "linodego_swap"})
	if errSwap != nil {
		log.Fatalln("* While creating swap disk:", errSwap)
	}
	eventSwap, errSwapEvent := linodeClient.WaitForEventFinished(context.Background(), linode.ID, linodego.EntityLinode, linodego.ActionDiskCreate, diskSwap.Created, 240)
	// @TODO it is not sufficient that a disk was created. Which disk was it?
	// Sounds like we'll need a WaitForEntityStatus function.
	if errSwapEvent != nil {
		log.Fatalf("* Failed to wait for swap disk %d to finish creation: %s", diskSwap.ID, errSwapEvent)
	}
	if errSwapEvent = linodeClient.MarkEventRead(context.Background(), eventSwap); errSwapEvent != nil {
		log.Fatalln("* Failed to mark swap disk create event seen", errSwapEvent)
	}

	diskRaw, errRaw := linodeClient.CreateInstanceDisk(context.Background(), linode.ID, linodego.InstanceDiskCreateOptions{Size: 50, Filesystem: "raw", Label: "linodego_raw"})
	if errRaw != nil {
		log.Fatalln("* While creating raw disk:", errRaw)
	}
	eventRaw, errRawEvent := linodeClient.WaitForEventFinished(context.Background(), linode.ID, linodego.EntityLinode, linodego.ActionDiskCreate, diskRaw.Created, 240)
	// @TODO it is not sufficient that a disk was created. Which disk was it?
	// Sounds like we'll need a WaitForEntityStatus function.
	if errRawEvent != nil {
		log.Fatalf("* Failed to wait for raw disk %d to finish creation: %s", diskRaw.ID, errRawEvent)
	}
	if errRawEvent = linodeClient.MarkEventRead(context.Background(), eventRaw); errRawEvent != nil {
		log.Fatalln("* Failed to mark raw disk create event seen", errRawEvent)
	}

	diskDebian, errDebian := linodeClient.CreateInstanceDisk(
		context.Background(),
		linode.ID,
		linodego.InstanceDiskCreateOptions{
			Size:       1500,
			Filesystem: "ext4",
			Image:      "linode/debian9",
			Label:      "linodego_debian",
			RootPass:   randPassword(),
		},
	)
	if errDebian != nil {
		log.Fatalln("* While creating Debian disk:", errDebian)
	}
	eventDebian, errDebianEvent := linodeClient.WaitForEventFinished(context.Background(), linode.ID, linodego.EntityLinode, linodego.ActionDiskCreate, diskDebian.Created, 240)
	// @TODO it is not sufficient that a disk was created. Which disk was it?
	// Sounds like we'll need a WaitForEntityStatus function.
	if errDebianEvent != nil {
		log.Fatalf("* Failed to wait for Debian disk %d to finish creation: %s", diskDebian.ID, errDebianEvent)
	}
	if errDebianEvent = linodeClient.MarkEventRead(context.Background(), eventDebian); errDebianEvent != nil {
		log.Fatalln("* Failed to mark Debian disk create event seen", errDebianEvent)
	}
	fmt.Println("### Created Disks")

	createOpts := linodego.InstanceConfigCreateOptions{
		Devices: linodego.InstanceConfigDeviceMap{
			SDA: &linodego.InstanceConfigDevice{DiskID: diskDebian.ID},
			SDB: &linodego.InstanceConfigDevice{DiskID: diskRaw.ID},
			SDC: &linodego.InstanceConfigDevice{DiskID: diskSwap.ID},
		},
		Kernel: "linode/direct-disk",
		Label:  "example config label",
		// RunLevel:   "default",
		// VirtMode:   "paravirt",
		Comments: "example config comment",
		// RootDevice: "/dev/sda",
		Helpers: &linodego.InstanceConfigHelpers{
			Network:    true,
			ModulesDep: false,
		},
	}
	config, errConfig := linodeClient.CreateInstanceConfig(context.Background(), linode.ID, createOpts)
	if errConfig != nil {
		log.Fatalln("* Failed to create Config", errConfig)
	}
	fmt.Println("### Created Config:")
	updateOpts := linodego.InstanceConfigUpdateOptions{
		Comments: "updated example config comment",
	}
	config, errConfig = linodeClient.UpdateInstanceConfig(context.Background(), linode.ID, config.ID, updateOpts)
	if errConfig != nil {
		log.Fatalln("* Failed to update Config", errConfig)
	}
	fmt.Println("### Updated Config:")

	errBoot := linodeClient.BootInstance(context.Background(), linode.ID, config.ID)
	if errBoot != nil {
		log.Fatalln("* Failed to boot Instance", errBoot)
	}
	fmt.Println("### Booted Instance")

	eventBooted, errBootEvent := linodeClient.WaitForEventFinished(context.Background(), linode.ID, linodego.EntityLinode, linodego.ActionLinodeBoot, *config.Updated, 240)
	if errBootEvent != nil {
		fmt.Println("### Boot Instance failed as expected:", errBootEvent)
	} else {
		log.Fatalln("* Expected boot Instance to fail")
	}

	if errBootEvent = linodeClient.MarkEventRead(context.Background(), eventBooted); errBootEvent != nil {
		log.Fatalln("* Failed to mark boot event seen", errBootEvent)
	}

	err = linodeClient.DeleteInstanceConfig(context.Background(), linode.ID, config.ID)
	if err != nil {
		log.Fatalln("* Failed to delete Config", err)
	}
	fmt.Println("### Deleted Config")

	err = linodeClient.DeleteInstanceDisk(context.Background(), linode.ID, diskSwap.ID)
	if err != nil {
		log.Fatalln("* Failed to delete Disk", err)
	}
	fmt.Println("### Deleted Disk")

	err = linodeClient.DeleteInstance(context.Background(), linode.ID)
	if err != nil {
		log.Fatalln("* Failed to delete Instance", err)
	}
	fmt.Println("### Deleted Instance")
}

linodes, err := linodeClient.ListInstances(context.Background(), nil)
if err != nil {
	log.Fatal(err)
}
fmt.Println("## List Instances")

if len(linodes) == 0 {
	log.Println("No Linodes to inspect.")
} else {
	// This is redundantly used for illustrative purposes
	linode, err = linodeClient.GetInstance(context.Background(), linodes[0].ID)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("## First Linode")

	configs, err := linodeClient.ListInstanceConfigs(context.Background(), linode.ID, nil)
	if err != nil {
		log.Fatal(err)
	} else if len(configs) > 0 {
		config, err := linodeClient.GetInstanceConfig(context.Background(), linode.ID, configs[0].ID)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("### First Config:", config.ID > 0)
	} else {
		fmt.Println("### No Configs")
	}

	disks, err := linodeClient.ListInstanceDisks(context.Background(), linode.ID, nil)
	if err != nil {
		log.Fatal(err)
	} else if len(disks) > 0 {
		disk, err := linodeClient.GetInstanceDisk(context.Background(), linode.ID, disks[0].ID)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("### First Disk:", disk.ID > 0)
	} else {
		fmt.Println("### No Disks")
	}

	backups, err := linodeClient.GetInstanceBackups(context.Background(), linode.ID)
	if err != nil {
		log.Fatal(err)
	}
	if len(backups.Automatic) > 0 {
		fmt.Println("### First Auto Backup")
	} else {
		fmt.Println("### No Auto Backups")
	}
	fmt.Println("### Snapshots")
	if backups.Snapshot.Current != nil {
		// snapshot fetched will be exactly the same as backups.Snapshot.Current
		// just being redundant for illustrative purposes
		if snapshot, err := linodeClient.GetInstanceSnapshot(context.Background(), linode.ID, backups.Snapshot.Current.ID); err == nil {
			fmt.Println("#### Current:", snapshot.ID > 0)
		} else {
			fmt.Println("#### No Current Snapshot:", err)
		}
	} else {
		fmt.Println("### No Current Snapshot")
	}

	volumes, err := linodeClient.ListInstanceVolumes(context.Background(), linode.ID, nil)
	if err != nil {
		log.Fatal(err)
	} else if len(volumes) > 0 {
		volume, err := linodeClient.GetVolume(context.Background(), volumes[0].ID)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("### First Volume:", volume.ID > 0)
	} else {
		fmt.Println("### No Volumes")
	}

	stackscripts, err := linodeClient.ListStackscripts(context.Background(), &linodego.ListOptions{Filter: "{\"mine\":true}"})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("## Your Stackscripts:", len(stackscripts) > 0)
}
Output:

## Instance request with Invalid ID
### Linode: <nil>
### Error: [404] Not found
## List Instances
## First Linode
### First Config: true
### First Disk: true
### No Auto Backups
### Snapshots
#### Current: true
### First Volume: true
## Your Stackscripts: true

Index

Examples

Constants

View Source
const (
	// APIHost Linode API hostname
	APIHost = "api.linode.com"
	// APIHostVar environment var to check for alternate API URL
	APIHostVar = "LINODE_URL"
	// APIHostCert environment var containing path to CA cert to validate against
	APIHostCert = "LINODE_CA"
	// APIVersion Linode API version
	APIVersion = "v4"
	// APIVersionVar environment var to check for alternate API Version
	APIVersionVar = "LINODE_API_VERSION"
	// APIProto connect to API with http(s)
	APIProto = "https"
	// Version of linodego
	Version = "0.12.0"
	// APIEnvVar environment var to check for API token
	APIEnvVar = "LINODE_TOKEN"
	// APISecondsPerPoll how frequently to poll for new Events or Status in WaitFor functions
	APISecondsPerPoll = 3
	// DefaultUserAgent is the default User-Agent sent in HTTP request headers
	DefaultUserAgent = "linodego " + Version + " https://github.com/linode/linodego"
)
View Source
const (
	// ErrorFromString is the Code identifying Errors created by string types
	ErrorFromString = 1
	// ErrorFromError is the Code identifying Errors created by error types
	ErrorFromError = 2
	// ErrorFromStringer is the Code identifying Errors created by fmt.Stringer types
	ErrorFromStringer = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Errors []APIErrorReason `json:"errors"`
}

APIError is the error-set returned by the Linode API when presented with an invalid request

func (APIError) Error

func (e APIError) Error() string

type APIErrorReason

type APIErrorReason struct {
	Reason string `json:"reason"`
	Field  string `json:"field"`
}

APIErrorReason is an individual invalid request message returned by the Linode API

func (APIErrorReason) Error

func (r APIErrorReason) Error() string

type Account

type Account struct {
	FirstName         string      `json:"first_name"`
	LastName          string      `json:"last_name"`
	Email             string      `json:"email"`
	Company           string      `json:"company"`
	Address1          string      `json:"address_1"`
	Address2          string      `json:"address_2"`
	Balance           float32     `json:"balance"`
	BalanceUninvoiced float32     `json:"balance_uninvoiced"`
	City              string      `json:"city"`
	State             string      `json:"state"`
	Zip               string      `json:"zip"`
	Country           string      `json:"country"`
	TaxID             string      `json:"tax_id"`
	Phone             string      `json:"phone"`
	CreditCard        *CreditCard `json:"credit_card"`
}

Account associated with the token in use

type AccountSettings added in v0.12.3

type AccountSettings struct {
	// The default backups enrollment status for all new Linodes for all users on the account.  When enabled, backups are mandatory per instance.
	BackupsEnabled bool `json:"backups_enabled"`

	// Wether or not Linode Managed service is enabled for the account.
	Managed bool `json:"managed"`

	// Wether or not the Network Helper is enabled for all new Linode Instance Configs on the account.
	NetworkHelper bool `json:"network_helper"`

	// A plan name like "longview-3"..."longview-100", or a nil value for to cancel any existing subscription plan.
	LongviewSubscription *string `json:"longview_subscription"`
}

AccountSettings are the account wide flags or plans that effect new resources

type AccountSettingsUpdateOptions added in v0.12.3

type AccountSettingsUpdateOptions struct {
	// The default backups enrollment status for all new Linodes for all users on the account.  When enabled, backups are mandatory per instance.
	BackupsEnabled *bool `json:"backups_enabled,omitempty"`

	// A plan name like "longview-3"..."longview-100", or a nil value for to cancel any existing subscription plan.
	LongviewSubscription *string `json:"longview_subscription,omitempty"`

	// The default network helper setting for all new Linodes and Linode Configs for all users on the account.
	NetworkHelper *bool `json:"network_helper,omitempty"`
}

AccountSettingsUpdateOptions are the updateable account wide flags or plans that effect new resources.

type Client

type Client struct {
	Account               *Resource
	AccountSettings       *Resource
	DomainRecords         *Resource
	Domains               *Resource
	Events                *Resource
	IPAddresses           *Resource
	IPv6Pools             *Resource
	IPv6Ranges            *Resource
	Images                *Resource
	InstanceConfigs       *Resource
	InstanceDisks         *Resource
	InstanceIPs           *Resource
	InstanceSnapshots     *Resource
	InstanceStats         *Resource
	InstanceVolumes       *Resource
	Instances             *Resource
	InvoiceItems          *Resource
	Invoices              *Resource
	Kernels               *Resource
	Longview              *Resource
	LongviewClients       *Resource
	LongviewSubscriptions *Resource
	Managed               *Resource
	NodeBalancerConfigs   *Resource
	NodeBalancerNodes     *Resource
	NodeBalancers         *Resource
	Notifications         *Resource
	OAuthClients          *Resource
	ObjectStorageBuckets  *Resource
	ObjectStorageClusters *Resource
	ObjectStorageKeys     *Resource
	Payments              *Resource
	Profile               *Resource
	Regions               *Resource
	SSHKeys               *Resource
	StackScripts          *Resource
	Tags                  *Resource
	Tickets               *Resource
	TicketReplies         *Resource
	Token                 *Resource
	Tokens                *Resource
	Types                 *Resource
	Users                 *Resource
	Volumes               *Resource
	// contains filtered or unexported fields
}

Client is a wrapper around the Resty client

func NewClient

func NewClient(hc *http.Client) (client Client)

NewClient factory to create new Client struct

func (*Client) AddInstanceIPAddress

func (c *Client) AddInstanceIPAddress(ctx context.Context, linodeID int, public bool) (*InstanceIP, error)

AddInstanceIPAddress adds a public or private IP to a Linode instance

func (*Client) AttachVolume

func (c *Client) AttachVolume(ctx context.Context, id int, options *VolumeAttachOptions) (*Volume, error)

AttachVolume attaches a volume to a Linode instance

func (*Client) BootInstance

func (c *Client) BootInstance(ctx context.Context, id int, configID int) error

BootInstance will boot a Linode instance A configID of 0 will cause Linode to choose the last/best config

func (*Client) CancelInstanceBackups added in v0.2.0

func (c *Client) CancelInstanceBackups(ctx context.Context, linodeID int) error

CancelInstanceBackups Cancels backups for the specified Linode.

func (*Client) CloneInstance

func (c *Client) CloneInstance(ctx context.Context, id int, options InstanceCloneOptions) (*Instance, error)

CloneInstance clone an existing Instances Disks and Configuration profiles to another Linode Instance

func (*Client) CloneVolume

func (c *Client) CloneVolume(ctx context.Context, id int, label string) (*Volume, error)

CloneVolume clones a Linode volume

func (*Client) CreateDomain

func (c *Client) CreateDomain(ctx context.Context, domain DomainCreateOptions) (*Domain, error)

CreateDomain creates a Domain

func (*Client) CreateDomainRecord added in v0.1.1

func (c *Client) CreateDomainRecord(ctx context.Context, domainID int, domainrecord DomainRecordCreateOptions) (*DomainRecord, error)

CreateDomainRecord creates a DomainRecord

func (*Client) CreateImage added in v0.2.0

func (c *Client) CreateImage(ctx context.Context, createOpts ImageCreateOptions) (*Image, error)

CreateImage creates a Image

func (*Client) CreateInstance

func (c *Client) CreateInstance(ctx context.Context, instance InstanceCreateOptions) (*Instance, error)

CreateInstance creates a Linode instance

func (*Client) CreateInstanceConfig

func (c *Client) CreateInstanceConfig(ctx context.Context, linodeID int, createOpts InstanceConfigCreateOptions) (*InstanceConfig, error)

CreateInstanceConfig creates a new InstanceConfig for the given Instance

func (*Client) CreateInstanceDisk

func (c *Client) CreateInstanceDisk(ctx context.Context, linodeID int, createOpts InstanceDiskCreateOptions) (*InstanceDisk, error)

CreateInstanceDisk creates a new InstanceDisk for the given Instance

func (*Client) CreateInstanceSnapshot added in v0.2.0

func (c *Client) CreateInstanceSnapshot(ctx context.Context, linodeID int, label string) (*InstanceSnapshot, error)

CreateInstanceSnapshot Creates or Replaces the snapshot Backup of a Linode. If a previous snapshot exists for this Linode, it will be deleted.

func (*Client) CreateNodeBalancer

func (c *Client) CreateNodeBalancer(ctx context.Context, nodebalancer NodeBalancerCreateOptions) (*NodeBalancer, error)

CreateNodeBalancer creates a NodeBalancer

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleCreateNodeBalancer")
defer teardown()

fmt.Println("## NodeBalancer create")
var nbID int
var nb = &linodego.NodeBalancer{
	ClientConnThrottle: 20,
	Region:             "us-east",
}

createOpts := nb.GetCreateOptions()
nb, err := linodeClient.CreateNodeBalancer(context.Background(), createOpts)
if err != nil {
	log.Fatal(err)
}
nbID = nb.ID

fmt.Println("### Get")
nb, err = linodeClient.GetNodeBalancer(context.Background(), nbID)
if err != nil {
	log.Fatal(err)
}

updateOpts := nb.GetUpdateOptions()
*updateOpts.Label += "_renamed"
nb, err = linodeClient.UpdateNodeBalancer(context.Background(), nbID, updateOpts)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### Delete")
if err := linodeClient.DeleteNodeBalancer(context.Background(), nbID); err != nil {
	log.Fatal(err)
}
Output:

## NodeBalancer create
### Get
### Delete

func (*Client) CreateNodeBalancerConfig

func (c *Client) CreateNodeBalancerConfig(ctx context.Context, nodebalancerID int, nodebalancerConfig NodeBalancerConfigCreateOptions) (*NodeBalancerConfig, error)

CreateNodeBalancerConfig creates a NodeBalancerConfig

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleCreateNodeBalancerConfig")
defer teardown()

fmt.Println("## NodeBalancer create")
clientConnThrottle := 20
nb, err := linodeClient.CreateNodeBalancer(context.Background(), linodego.NodeBalancerCreateOptions{
	ClientConnThrottle: &clientConnThrottle,
	Region:             "us-east",
})
if err != nil {
	log.Fatal(err)
}

fmt.Println("## NodeBalancer Config create")
createOpts := linodego.NodeBalancerConfigCreateOptions{
	Port: 80,
	/*
		Protocol:      linodego.ProtocolHTTP,
		Algorithm:     linodego.AlgorithmLeastConn,
		Stickiness:    linodego.StickinessHTTPCookie,
		Check:         linodego.CheckHTTP,
		CheckInterval: 30,
		CheckAttempts: 5,
		CipherSuite:   linodego.CipherRecommended,
	*/ed,
	*/
}
nbc, err := linodeClient.CreateNodeBalancerConfig(context.Background(), nb.ID, createOpts)
if err != nil {
	log.Fatal(err)
}
nbcID := nbc.ID

fmt.Println("## NodeBalancer Config update")
updateOpts := nbc.GetUpdateOptions()
updateOpts.Port += 8000
nbc, err = linodeClient.UpdateNodeBalancerConfig(context.Background(), nb.ID, nbc.ID, updateOpts)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### List")
configs, err := linodeClient.ListNodeBalancerConfigs(context.Background(), nb.ID, nil)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### Get")
nbc, err = linodeClient.GetNodeBalancerConfig(context.Background(), nb.ID, configs[0].ID)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### Delete")
if nbc.ID != nbcID {
	log.Fatalf("Unexpected Nodebalancer Config ID %d != %d", nbc.ID, nbcID)
}
if err := linodeClient.DeleteNodeBalancerConfig(context.Background(), nb.ID, nbc.ID); err != nil {
	log.Fatal(err)
}

if err := linodeClient.DeleteNodeBalancer(context.Background(), nb.ID); err != nil {
	log.Fatal(err)
}
Output:

## NodeBalancer create
## NodeBalancer Config create
## NodeBalancer Config update
### List
### Get
### Delete

func (*Client) CreateNodeBalancerNode

func (c *Client) CreateNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, createOpts NodeBalancerNodeCreateOptions) (*NodeBalancerNode, error)

CreateNodeBalancerNode creates a NodeBalancerNode

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleCreateNodeBalancerNode")
defer teardown()

fmt.Println("## NodeBalancer create")
clientConnThrottle := 20
nb, err := linodeClient.CreateNodeBalancer(context.Background(), linodego.NodeBalancerCreateOptions{
	ClientConnThrottle: &clientConnThrottle,
	Region:             "us-east",
})
if err != nil {
	log.Fatal(err)
}

fmt.Println("## NodeBalancer Config create")

nbc, err := linodeClient.CreateNodeBalancerConfig(context.Background(), nb.ID, linodego.NodeBalancerConfigCreateOptions{
	Port: 80,
})
if err != nil {
	log.Fatal(err)
}

fmt.Println("## NodeBalancer Node create")
createOpts := linodego.NodeBalancerNodeCreateOptions{
	Address: "192.168.129.255:80",
	Label:   "192.168.129.255-80",
}
nbn, err := linodeClient.CreateNodeBalancerNode(context.Background(), nb.ID, nbc.ID, createOpts)
if err != nil {
	log.Fatal(err)
}
nbnID := nbn.ID

fmt.Println("## NodeBalancer Node update")
updateOpts := nbn.GetUpdateOptions()
updateOpts.Address = "192.168.129.0:8080"
nbn, err = linodeClient.UpdateNodeBalancerNode(context.Background(), nb.ID, nbc.ID, nbn.ID, updateOpts)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### List")
nodes, err := linodeClient.ListNodeBalancerNodes(context.Background(), nb.ID, nbc.ID, nil)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### Get")
nbn, err = linodeClient.GetNodeBalancerNode(context.Background(), nb.ID, nbc.ID, nodes[0].ID)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### Delete")
if nbn.ID != nbnID {
	log.Fatalf("Unexpected Nodebalancer Node ID %d != %d", nbn.ID, nbnID)
}
if err := linodeClient.DeleteNodeBalancerNode(context.Background(), nb.ID, nbc.ID, nbn.ID); err != nil {
	log.Fatal(err)
}

if err := linodeClient.DeleteNodeBalancerConfig(context.Background(), nb.ID, nbc.ID); err != nil {
	log.Fatal(err)
}

if err := linodeClient.DeleteNodeBalancer(context.Background(), nb.ID); err != nil {
	log.Fatal(err)
}
Output:

## NodeBalancer create
## NodeBalancer Config create
## NodeBalancer Node create
## NodeBalancer Node update
### List
### Get
### Delete

func (*Client) CreateOAuthClient added in v0.12.3

func (c *Client) CreateOAuthClient(ctx context.Context, createOpts OAuthClientCreateOptions) (*OAuthClient, error)

CreateOAuthClient creates an OAuthClient

func (*Client) CreateObjectStorageBucket added in v0.12.3

func (c *Client) CreateObjectStorageBucket(ctx context.Context, createOpts ObjectStorageBucketCreateOptions) (*ObjectStorageBucket, error)

CreateObjectStorageBucket creates an ObjectStorageBucket

func (*Client) CreateObjectStorageKey added in v0.12.3

func (c *Client) CreateObjectStorageKey(ctx context.Context, createOpts ObjectStorageKeyCreateOptions) (*ObjectStorageKey, error)

CreateObjectStorageKey creates a ObjectStorageKey

func (*Client) CreatePayment added in v0.12.3

func (c *Client) CreatePayment(ctx context.Context, createOpts PaymentCreateOptions) (*Payment, error)

CreatePayment creates a Payment

func (*Client) CreateSSHKey added in v0.5.0

func (c *Client) CreateSSHKey(ctx context.Context, createOpts SSHKeyCreateOptions) (*SSHKey, error)

CreateSSHKey creates a SSHKey

func (*Client) CreateStackscript

func (c *Client) CreateStackscript(ctx context.Context, createOpts StackscriptCreateOptions) (*Stackscript, error)

CreateStackscript creates a StackScript

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleCreateStackscript")
defer teardown()

fmt.Println("## Stackscript create")

var ss *linodego.Stackscript
var err error
for rev := 1; rev < 4; rev++ {
	fmt.Println("### Revision", rev)
	if rev == 1 {
		stackscript := linodego.Stackscript{}.GetCreateOptions()
		stackscript.Description = "description for example stackscript " + time.Now().String()
		// stackscript.Images = make([]string, 2, 2)
		stackscript.Images = []string{"linode/debian9", "linode/ubuntu18.04"}
		stackscript.IsPublic = false
		stackscript.Label = "example stackscript " + time.Now().String()
		stackscript.RevNote = "revision " + strconv.Itoa(rev)
		stackscript.Script = "#!/bin/bash\n"
		ss, err = linodeClient.CreateStackscript(context.Background(), stackscript)
		if err != nil {
			log.Fatal(err)
		}
	} else {
		update := ss.GetUpdateOptions()
		update.RevNote = "revision " + strconv.Itoa(rev)
		update.Label = strconv.Itoa(rev) + " " + ss.Label
		update.Script += "echo " + strconv.Itoa(rev) + "\n"
		ss, err = linodeClient.UpdateStackscript(context.Background(), ss.ID, update)
		if err != nil {
			log.Fatal(err)
		}
	}
}

fmt.Println("### Get")
ss, err = linodeClient.GetStackscript(context.Background(), ss.ID)
if err != nil {
	log.Fatal(err)
}

fmt.Println("### Delete")
err = linodeClient.DeleteStackscript(context.Background(), ss.ID)
if err != nil {
	log.Fatal(err)
}
Output:

## Stackscript create
### Revision 1
### Revision 2
### Revision 3
### Get
### Delete

func (*Client) CreateTag added in v0.6.0

func (c *Client) CreateTag(ctx context.Context, createOpts TagCreateOptions) (*Tag, error)

CreateTag creates a Tag

func (*Client) CreateToken added in v0.6.0

func (c *Client) CreateToken(ctx context.Context, createOpts TokenCreateOptions) (*Token, error)

CreateToken creates a Token

func (*Client) CreateUser added in v0.6.0

func (c *Client) CreateUser(ctx context.Context, createOpts UserCreateOptions) (*User, error)

CreateUser creates a User. The email address must be confirmed before the User account can be accessed.

func (*Client) CreateVolume

func (c *Client) CreateVolume(ctx context.Context, createOpts VolumeCreateOptions) (*Volume, error)

CreateVolume creates a Linode Volume

func (*Client) DeleteDomain

func (c *Client) DeleteDomain(ctx context.Context, id int) error

DeleteDomain deletes the Domain with the specified id

func (*Client) DeleteDomainRecord added in v0.1.1

func (c *Client) DeleteDomainRecord(ctx context.Context, domainID int, id int) error

DeleteDomainRecord deletes the DomainRecord with the specified id

func (*Client) DeleteImage added in v0.2.0

func (c *Client) DeleteImage(ctx context.Context, id string) error

DeleteImage deletes the Image with the specified id

func (*Client) DeleteInstance

func (c *Client) DeleteInstance(ctx context.Context, id int) error

DeleteInstance deletes a Linode instance

func (*Client) DeleteInstanceConfig

func (c *Client) DeleteInstanceConfig(ctx context.Context, linodeID int, configID int) error

DeleteInstanceConfig deletes a Linode InstanceConfig

func (*Client) DeleteInstanceDisk

func (c *Client) DeleteInstanceDisk(ctx context.Context, linodeID int, diskID int) error

DeleteInstanceDisk deletes a Linode Instance Disk

func (*Client) DeleteNodeBalancer

func (c *Client) DeleteNodeBalancer(ctx context.Context, id int) error

DeleteNodeBalancer deletes the NodeBalancer with the specified id

func (*Client) DeleteNodeBalancerConfig

func (c *Client) DeleteNodeBalancerConfig(ctx context.Context, nodebalancerID int, configID int) error

DeleteNodeBalancerConfig deletes the NodeBalancerConfig with the specified id

func (*Client) DeleteNodeBalancerNode

func (c *Client) DeleteNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, nodeID int) error

DeleteNodeBalancerNode deletes the NodeBalancerNode with the specified id

func (*Client) DeleteOAuthClient added in v0.12.3

func (c *Client) DeleteOAuthClient(ctx context.Context, id string) error

DeleteOAuthClient deletes the OAuthClient with the specified id

func (*Client) DeleteObjectStorageBucket added in v0.12.3

func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterID, label string) error

DeleteObjectStorageBucket deletes the ObjectStorageBucket with the specified label

func (*Client) DeleteObjectStorageKey added in v0.12.3

func (c *Client) DeleteObjectStorageKey(ctx context.Context, id int) error

DeleteObjectStorageKey deletes the ObjectStorageKey with the specified id

func (*Client) DeleteSSHKey added in v0.5.0

func (c *Client) DeleteSSHKey(ctx context.Context, id int) error

DeleteSSHKey deletes the SSHKey with the specified id

func (*Client) DeleteStackscript

func (c *Client) DeleteStackscript(ctx context.Context, id int) error

DeleteStackscript deletes the StackScript with the specified id

func (*Client) DeleteTag added in v0.6.0

func (c *Client) DeleteTag(ctx context.Context, label string) error

DeleteTag deletes the Tag with the specified id

func (*Client) DeleteToken added in v0.6.0

func (c *Client) DeleteToken(ctx context.Context, id int) error

DeleteToken deletes the Token with the specified id

func (*Client) DeleteUser added in v0.6.0

func (c *Client) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes the User with the specified id

func (*Client) DeleteVolume

func (c *Client) DeleteVolume(ctx context.Context, id int) error

DeleteVolume deletes the Volume with the specified id

func (*Client) DetachVolume

func (c *Client) DetachVolume(ctx context.Context, id int) error

DetachVolume detaches a Linode volume

func (*Client) EnableInstanceBackups added in v0.2.0

func (c *Client) EnableInstanceBackups(ctx context.Context, linodeID int) error

EnableInstanceBackups Enables backups for the specified Linode.

func (*Client) GetAccount

func (c *Client) GetAccount(ctx context.Context) (*Account, error)

GetAccount gets the contact and billing information related to the Account

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleGetAccount")
defer teardown()

account, err := linodeClient.GetAccount(context.Background())
if err != nil {
	log.Fatalln("* While getting account: ", err)
}
fmt.Println("Account email has @:", strings.Contains(account.Email, "@"))
Output:

Account email has @: true

func (*Client) GetAccountSettings added in v0.12.3

func (c *Client) GetAccountSettings(ctx context.Context) (*AccountSettings, error)

GetAccountSettings gets the account wide flags or plans that effect new resources

func (*Client) GetDomain

func (c *Client) GetDomain(ctx context.Context, id int) (*Domain, error)

GetDomain gets the domain with the provided ID

func (*Client) GetDomainRecord

func (c *Client) GetDomainRecord(ctx context.Context, domainID int, id int) (*DomainRecord, error)

GetDomainRecord gets the domainrecord with the provided ID

func (*Client) GetEvent

func (c *Client) GetEvent(ctx context.Context, id int) (*Event, error)

GetEvent gets the Event with the Event ID

func (*Client) GetIPAddress

func (c *Client) GetIPAddress(ctx context.Context, id string) (*InstanceIP, error)

GetIPAddress gets the template with the provided ID

func (*Client) GetIPv6Pool

func (c *Client) GetIPv6Pool(ctx context.Context, id string) (*IPv6Range, error)

GetIPv6Pool gets the template with the provided ID

func (*Client) GetIPv6Range

func (c *Client) GetIPv6Range(ctx context.Context, id string) (*IPv6Range, error)

GetIPv6Range gets the template with the provided ID

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, id string) (*Image, error)

GetImage gets the Image with the provided ID

Example (Missing)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleGetImage_missing")
defer teardown()

_, err := linodeClient.GetImage(context.Background(), "not-found")
if err != nil {
	if v, ok := err.(*linodego.Error); ok {
		fmt.Println("Request was:", v.Response.Request.URL)
		fmt.Println("Response was:", v.Response.Status)
		fmt.Println("Error was:", v)
	}
}
Output:

Request was: https://api.linode.com/v4beta/images/not-found
Response was: 404 NOT FOUND
Error was: [404] Not found

func (*Client) GetInstance

func (c *Client) GetInstance(ctx context.Context, linodeID int) (*Instance, error)

GetInstance gets the instance with the provided ID

func (*Client) GetInstanceBackups

func (c *Client) GetInstanceBackups(ctx context.Context, linodeID int) (*InstanceBackupsResponse, error)

GetInstanceBackups gets the Instance's available Backups. This is not called ListInstanceBackups because a single object is returned, matching the API response.

func (*Client) GetInstanceConfig

func (c *Client) GetInstanceConfig(ctx context.Context, linodeID int, configID int) (*InstanceConfig, error)

GetInstanceConfig gets the template with the provided ID

func (*Client) GetInstanceDisk

func (c *Client) GetInstanceDisk(ctx context.Context, linodeID int, configID int) (*InstanceDisk, error)

GetInstanceDisk gets the template with the provided ID

func (*Client) GetInstanceIPAddress

func (c *Client) GetInstanceIPAddress(ctx context.Context, linodeID int, ipaddress string) (*InstanceIP, error)

GetInstanceIPAddress gets the IPAddress for a Linode instance matching a supplied IP address

func (*Client) GetInstanceIPAddresses

func (c *Client) GetInstanceIPAddresses(ctx context.Context, linodeID int) (*InstanceIPAddressResponse, error)

GetInstanceIPAddresses gets the IPAddresses for a Linode instance

func (*Client) GetInstanceSnapshot

func (c *Client) GetInstanceSnapshot(ctx context.Context, linodeID int, snapshotID int) (*InstanceSnapshot, error)

GetInstanceSnapshot gets the snapshot with the provided ID

func (*Client) GetInstanceStats added in v0.12.3

func (c *Client) GetInstanceStats(ctx context.Context, linodeID int) (*InstanceStats, error)

GetInstanceStats gets the template with the provided ID

func (*Client) GetInstanceStatsByDate added in v0.12.3

func (c *Client) GetInstanceStatsByDate(ctx context.Context, linodeID int, year int, month int) (*InstanceStats, error)

GetInstanceStatsByDate gets the template with the provided ID, year, and month

func (*Client) GetInstanceTransfer added in v0.12.3

func (c *Client) GetInstanceTransfer(ctx context.Context, linodeID int) (*InstanceTransfer, error)

GetInstance gets the instance with the provided ID

func (*Client) GetInvoice

func (c *Client) GetInvoice(ctx context.Context, id int) (*Invoice, error)

GetInvoice gets the a single Invoice matching the provided ID

func (*Client) GetKernel

func (c *Client) GetKernel(ctx context.Context, kernelID string) (*LinodeKernel, error)

GetKernel gets the kernel with the provided ID

Example (Specific)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleGetKernel_specific")
defer teardown()

l32, err := linodeClient.GetKernel(context.Background(), "linode/latest-32bit")
if err == nil {
	fmt.Println("Label starts:", l32.Label[0:9])
} else {
	log.Fatalln(err)
}

l64, err := linodeClient.GetKernel(context.Background(), "linode/latest-64bit")
if err == nil {
	fmt.Println("Label starts:", l64.Label[0:9])
} else {
	log.Fatalln(err)
}
// Interference check
fmt.Println("First Label still starts:", l32.Label[0:9])
Output:

Label starts: Latest 32
Label starts: Latest 64
First Label still starts: Latest 32

func (*Client) GetLongviewClient

func (c *Client) GetLongviewClient(ctx context.Context, id string) (*LongviewClient, error)

GetLongviewClient gets the template with the provided ID

func (*Client) GetLongviewSubscription

func (c *Client) GetLongviewSubscription(ctx context.Context, id string) (*LongviewSubscription, error)

GetLongviewSubscription gets the template with the provided ID

func (*Client) GetNodeBalancer

func (c *Client) GetNodeBalancer(ctx context.Context, id int) (*NodeBalancer, error)

GetNodeBalancer gets the NodeBalancer with the provided ID

func (*Client) GetNodeBalancerConfig

func (c *Client) GetNodeBalancerConfig(ctx context.Context, nodebalancerID int, configID int) (*NodeBalancerConfig, error)

GetNodeBalancerConfig gets the template with the provided ID

func (*Client) GetNodeBalancerNode

func (c *Client) GetNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, nodeID int) (*NodeBalancerNode, error)

GetNodeBalancerNode gets the template with the provided ID

func (*Client) GetOAuthClient added in v0.12.3

func (c *Client) GetOAuthClient(ctx context.Context, id string) (*OAuthClient, error)

GetOAuthClient gets the OAuthClient with the provided ID

func (*Client) GetObjectStorageBucket added in v0.12.3

func (c *Client) GetObjectStorageBucket(ctx context.Context, clusterID, label string) (*ObjectStorageBucket, error)

GetObjectStorageBucket gets the ObjectStorageBucket with the provided label

func (*Client) GetObjectStorageCluster added in v0.12.3

func (c *Client) GetObjectStorageCluster(ctx context.Context, id string) (*ObjectStorageCluster, error)

GetObjectStorageCluster gets the template with the provided ID

func (*Client) GetObjectStorageKey added in v0.12.3

func (c *Client) GetObjectStorageKey(ctx context.Context, id int) (*ObjectStorageKey, error)

GetObjectStorageKey gets the object storage key with the provided ID

func (*Client) GetPayment added in v0.12.3

func (c *Client) GetPayment(ctx context.Context, id int) (*Payment, error)

GetPayment gets the payment with the provided ID

func (*Client) GetProfile added in v0.6.1

func (c *Client) GetProfile(ctx context.Context) (*Profile, error)

GetProfile returns the Profile of the authenticated user

func (*Client) GetRegion

func (c *Client) GetRegion(ctx context.Context, id string) (*Region, error)

GetRegion gets the template with the provided ID

func (*Client) GetSSHKey added in v0.5.0

func (c *Client) GetSSHKey(ctx context.Context, id int) (*SSHKey, error)

GetSSHKey gets the sshkey with the provided ID

func (*Client) GetStackscript

func (c *Client) GetStackscript(ctx context.Context, id int) (*Stackscript, error)

GetStackscript gets the Stackscript with the provided ID

func (*Client) GetTicket

func (c *Client) GetTicket(ctx context.Context, id int) (*Ticket, error)

GetTicket gets a Support Ticket on the Account with the specified ID

func (*Client) GetToken added in v0.6.0

func (c *Client) GetToken(ctx context.Context, id int) (*Token, error)

GetToken gets the token with the provided ID

func (*Client) GetType

func (c *Client) GetType(ctx context.Context, typeID string) (*LinodeType, error)

GetType gets the type with the provided ID

Example (Missing)

ExampleGetType_missing demonstrates the Error type, which allows inspecting the request and response. Error codes will be the HTTP status code, or sub-100 for errors before the request was issued.

// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleGetType_missing")
defer teardown()

_, err := linodeClient.GetType(context.Background(), "missing-type")
if err != nil {
	if v, ok := err.(*linodego.Error); ok {
		fmt.Println("Request was:", v.Response.Request.URL)
		fmt.Println("Response was:", v.Response.Status)
		fmt.Println("Error was:", v)
	}
}
Output:

Request was: https://api.linode.com/v4beta/linode/types/missing-type
Response was: 404 NOT FOUND
Error was: [404] Not found

func (*Client) GetUser added in v0.6.0

func (c *Client) GetUser(ctx context.Context, id string) (*User, error)

GetUser gets the user with the provided ID

func (*Client) GetVolume

func (c *Client) GetVolume(ctx context.Context, id int) (*Volume, error)

GetVolume gets the template with the provided ID

func (*Client) ListDomainRecords

func (c *Client) ListDomainRecords(ctx context.Context, domainID int, opts *ListOptions) ([]DomainRecord, error)

ListDomainRecords lists DomainRecords

func (*Client) ListDomains

func (c *Client) ListDomains(ctx context.Context, opts *ListOptions) ([]Domain, error)

ListDomains lists Domains

func (*Client) ListEvents

func (c *Client) ListEvents(ctx context.Context, opts *ListOptions) ([]Event, error)

ListEvents gets a collection of Event objects representing actions taken on the Account. The Events returned depend on the token grants and the grants of the associated user.

func (*Client) ListIPAddresses

func (c *Client) ListIPAddresses(ctx context.Context, opts *ListOptions) ([]InstanceIP, error)

ListIPAddresses lists IPAddresses

func (*Client) ListIPv6Pools

func (c *Client) ListIPv6Pools(ctx context.Context, opts *ListOptions) ([]IPv6Range, error)

ListIPv6Pools lists IPv6Pools

func (*Client) ListIPv6Ranges

func (c *Client) ListIPv6Ranges(ctx context.Context, opts *ListOptions) ([]IPv6Range, error)

ListIPv6Ranges lists IPv6Ranges

func (*Client) ListImages

func (c *Client) ListImages(ctx context.Context, opts *ListOptions) ([]Image, error)

ListImages lists Images

Example (All)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListImages_all")
defer teardown()

filterOpt := linodego.NewListOptions(0, "")
images, err := linodeClient.ListImages(context.Background(), filterOpt)
if err != nil {
	log.Fatal(err)
}
fmt.Println("Fetched Results/100 pages:", filterOpt.Pages > filterOpt.Results/100)
fmt.Println("Fetched all results:", filterOpt.Results == len(images))
Output:

Fetched Results/100 pages: true
Fetched all results: true
Example (Badfilter)

ExampleListImages_notfound demonstrates that an error is returned by the API and linodego when an invalid filter is provided

// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListImages_badfilter")
defer teardown()

filterOpt := linodego.ListOptions{Filter: "{\"foo\":\"bar\"}"}
images, err := linodeClient.ListImages(context.Background(), &filterOpt)
if err == nil {
	log.Fatal(err)
}
fmt.Println("Error given on bad filter:", err)
fmt.Println("Images on bad filter:", images) // TODO: nil would be better here
Output:

Error given on bad filter: [400] [X-Filter] Cannot filter on foo
Images on bad filter: []
Example (Notfound)

ExampleListImages_notfound demonstrates that an empty slice is returned, not an error, when a filter matches no results.

// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListImages_notfound")
defer teardown()

filterOpt := linodego.ListOptions{Filter: "{\"label\":\"not-found\"}"}
images, err := linodeClient.ListImages(context.Background(), &filterOpt)
if err != nil {
	log.Fatal(err)
}
fmt.Println("Images with Label 'not-found':", len(images))
Output:

Images with Label 'not-found': 0

func (*Client) ListInstanceConfigs

func (c *Client) ListInstanceConfigs(ctx context.Context, linodeID int, opts *ListOptions) ([]InstanceConfig, error)

ListInstanceConfigs lists InstanceConfigs

func (*Client) ListInstanceDisks

func (c *Client) ListInstanceDisks(ctx context.Context, linodeID int, opts *ListOptions) ([]InstanceDisk, error)

ListInstanceDisks lists InstanceDisks

func (*Client) ListInstanceVolumes

func (c *Client) ListInstanceVolumes(ctx context.Context, linodeID int, opts *ListOptions) ([]Volume, error)

ListInstanceVolumes lists InstanceVolumes

func (*Client) ListInstances

func (c *Client) ListInstances(ctx context.Context, opts *ListOptions) ([]Instance, error)

ListInstances lists linode instances

func (*Client) ListInvoiceItems

func (c *Client) ListInvoiceItems(ctx context.Context, id int, opts *ListOptions) ([]InvoiceItem, error)

ListInvoiceItems gets the invoice items associated with a specific Invoice

func (*Client) ListInvoices

func (c *Client) ListInvoices(ctx context.Context, opts *ListOptions) ([]Invoice, error)

ListInvoices gets a paginated list of Invoices against the Account

func (*Client) ListKernels

func (c *Client) ListKernels(ctx context.Context, opts *ListOptions) ([]LinodeKernel, error)

ListKernels lists linode kernels

Example (All)

ExampleListKernels_all Demonstrates how to list all Linode Kernels. Paginated responses are automatically traversed and concatenated when the ListOptions are nil

// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListKernels_all")
defer teardown()

kernels, err := linodeClient.ListKernels(context.Background(), nil)
if err != nil {
	log.Fatal(err)
}

// The Linode API default pagination size is 100.
fmt.Println("Fetched > 100:", len(kernels) > 100)
Output:

Fetched > 100: true
Example (AllWithOpts)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListKernels_allWithOpts")
defer teardown()

filterOpt := linodego.NewListOptions(0, "")
kernels, err := linodeClient.ListKernels(context.Background(), filterOpt)
if err != nil {
	log.Fatal(err)
}

// The Linode API default pagination size is 100.
fmt.Println("Fetched > 100:", len(kernels) > 100)
fmt.Println("Fetched Results/100 pages:", filterOpt.Pages > filterOpt.Results/100)
fmt.Println("Fetched all results:", filterOpt.Results == len(kernels))
Output:

Fetched > 100: true
Fetched Results/100 pages: true
Fetched all results: true
Example (Filtered)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListKernels_filtered")
defer teardown()

filterOpt := linodego.ListOptions{Filter: "{\"label\":\"Recovery - Finnix (kernel)\"}"}
kernels, err := linodeClient.ListKernels(context.Background(), &filterOpt)
if err != nil {
	log.Fatal(err)
}
for _, kern := range kernels {
	fmt.Println(kern.ID, kern.Label)
}
Output:

linode/finnix Recovery - Finnix (kernel)
linode/finnix-legacy Recovery - Finnix (kernel)
Example (Page1)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListKernels_page1")
defer teardown()

filterOpt := linodego.NewListOptions(1, "")
kernels, err := linodeClient.ListKernels(context.Background(), filterOpt)
if err != nil {
	log.Fatal(err)
}
// The Linode API default pagination size is 100.
fmt.Println("Fetched == 100:", len(kernels) == 100)
fmt.Println("Results > 100:", filterOpt.Results > 100)
fmt.Println("Pages > 1:", filterOpt.Pages > 1)
k := kernels[len(kernels)-1]
fmt.Println("Kernel Version in ID:", strings.Contains(k.ID, k.Label))
Output:

Fetched == 100: true
Results > 100: true
Pages > 1: true
Kernel Version in ID: true

func (*Client) ListLongviewClients

func (c *Client) ListLongviewClients(ctx context.Context, opts *ListOptions) ([]LongviewClient, error)

ListLongviewClients lists LongviewClients

func (*Client) ListLongviewSubscriptions

func (c *Client) ListLongviewSubscriptions(ctx context.Context, opts *ListOptions) ([]LongviewSubscription, error)

ListLongviewSubscriptions lists LongviewSubscriptions

Example (Page1)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListLongviewSubscriptions_page1")
defer teardown()

pageOpt := linodego.ListOptions{PageOptions: &linodego.PageOptions{Page: 1}}
subscriptions, err := linodeClient.ListLongviewSubscriptions(context.Background(), &pageOpt)
if err != nil {
	log.Fatal(err)
}
fmt.Println("Longview Subscription Types:", len(subscriptions))
Output:

Longview Subscription Types: 4

func (*Client) ListNodeBalancerConfigs

func (c *Client) ListNodeBalancerConfigs(ctx context.Context, nodebalancerID int, opts *ListOptions) ([]NodeBalancerConfig, error)

ListNodeBalancerConfigs lists NodeBalancerConfigs

func (*Client) ListNodeBalancerNodes

func (c *Client) ListNodeBalancerNodes(ctx context.Context, nodebalancerID int, configID int, opts *ListOptions) ([]NodeBalancerNode, error)

ListNodeBalancerNodes lists NodeBalancerNodes

func (*Client) ListNodeBalancers

func (c *Client) ListNodeBalancers(ctx context.Context, opts *ListOptions) ([]NodeBalancer, error)

ListNodeBalancers lists NodeBalancers

func (*Client) ListNotifications

func (c *Client) ListNotifications(ctx context.Context, opts *ListOptions) ([]Notification, error)

ListNotifications gets a collection of Notification objects representing important, often time-sensitive items related to the Account. An account cannot interact directly with Notifications, and a Notification will disappear when the circumstances causing it have been resolved. For example, if the account has an important Ticket open, a response to the Ticket will dismiss the Notification.

func (*Client) ListOAuthClients added in v0.12.3

func (c *Client) ListOAuthClients(ctx context.Context, opts *ListOptions) ([]OAuthClient, error)

ListOAuthClients lists OAuthClients

func (*Client) ListObjectStorageBuckets added in v0.12.3

func (c *Client) ListObjectStorageBuckets(ctx context.Context, opts *ListOptions) ([]ObjectStorageBucket, error)

ListObjectStorageBuckets lists ObjectStorageBuckets

func (*Client) ListObjectStorageClusters added in v0.12.3

func (c *Client) ListObjectStorageClusters(ctx context.Context, opts *ListOptions) ([]ObjectStorageCluster, error)

ListObjectStorageClusters lists ObjectStorageClusters

func (*Client) ListObjectStorageKeys added in v0.12.3

func (c *Client) ListObjectStorageKeys(ctx context.Context, opts *ListOptions) ([]ObjectStorageKey, error)

ListObjectStorageKeys lists ObjectStorageKeys

func (*Client) ListPayments added in v0.12.3

func (c *Client) ListPayments(ctx context.Context, opts *ListOptions) ([]Payment, error)

ListPayments lists Payments

func (*Client) ListRegions

func (c *Client) ListRegions(ctx context.Context, opts *ListOptions) ([]Region, error)

ListRegions lists Regions

func (*Client) ListReplies added in v0.12.3

func (c *Client) ListReplies(ctx context.Context, opts *ListOptions, id int) ([]TicketReply, error)

func (*Client) ListSSHKeys added in v0.5.0

func (c *Client) ListSSHKeys(ctx context.Context, opts *ListOptions) ([]SSHKey, error)

ListSSHKeys lists SSHKeys

func (*Client) ListStackscripts

func (c *Client) ListStackscripts(ctx context.Context, opts *ListOptions) ([]Stackscript, error)

ListStackscripts lists Stackscripts

Example (Page1)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListStackscripts_page1")
defer teardown()

filterOpt := linodego.NewListOptions(1, "")
scripts, err := linodeClient.ListStackscripts(context.Background(), filterOpt)
if err != nil {
	log.Fatal(err)
}
// The Linode API default pagination size is 100.
fmt.Println("Fetched == 100:", len(scripts) == 100)
fmt.Println("Results > 100:", filterOpt.Results > 100)
fmt.Println("Pages > 1:", filterOpt.Pages > 1)
s := scripts[len(scripts)-1]
fmt.Println("StackScript Script has shebang:", strings.Contains(s.Script, "#!/"))
fmt.Println("Created is parsed:", s.Created != nil)
Output:

Fetched == 100: true
Results > 100: true
Pages > 1: true
StackScript Script has shebang: true
Created is parsed: true

func (*Client) ListTaggedObjects added in v0.6.0

func (c *Client) ListTaggedObjects(ctx context.Context, label string, opts *ListOptions) (TaggedObjectList, error)

ListTaggedObjects lists Tagged Objects

func (*Client) ListTags added in v0.6.0

func (c *Client) ListTags(ctx context.Context, opts *ListOptions) ([]Tag, error)

ListTags lists Tags

func (*Client) ListTickets

func (c *Client) ListTickets(ctx context.Context, opts *ListOptions) ([]Ticket, error)

ListTickets returns a collection of Support Tickets on the Account. Support Tickets can be both tickets opened with Linode for support, as well as tickets generated by Linode regarding the Account. This collection includes all Support Tickets generated on the Account, with open tickets returned first.

func (*Client) ListTokens added in v0.6.0

func (c *Client) ListTokens(ctx context.Context, opts *ListOptions) ([]Token, error)

ListTokens lists Tokens

func (*Client) ListTypes

func (c *Client) ListTypes(ctx context.Context, opts *ListOptions) ([]LinodeType, error)

ListTypes lists linode types

Example (All)
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListTypes_all")
defer teardown()

types, err := linodeClient.ListTypes(context.Background(), nil)
if err != nil {
	log.Fatal(err)
}

fmt.Println("ID contains class:", strings.Contains(types[0].ID, string(types[0].Class)))
fmt.Println("Plan has Ram:", types[0].Memory > 0)
Output:

ID contains class: true
Plan has Ram: true

func (*Client) ListUsers added in v0.6.0

func (c *Client) ListUsers(ctx context.Context, opts *ListOptions) ([]User, error)

ListUsers lists Users on the account

Example
// Example readers, Ignore this bit of setup code needed to record test fixtures
linodeClient, teardown := createTestClient(nil, "fixtures/ExampleListUsers")
defer teardown()

users, err := linodeClient.ListUsers(context.Background(), nil)
if err != nil {
	log.Fatalln("* While getting users: ", err)
}
user := users[0]
fmt.Println("Account email has @:", strings.Contains(user.Email, "@"))
Output:

Account email has @: true

func (*Client) ListVolumes

func (c *Client) ListVolumes(ctx context.Context, opts *ListOptions) ([]Volume, error)

ListVolumes lists Volumes

func (*Client) MarkEventRead

func (c *Client) MarkEventRead(ctx context.Context, event *Event) error

MarkEventRead marks a single Event as read.

func (*Client) MarkEventsSeen

func (c *Client) MarkEventsSeen(ctx context.Context, event *Event) error

MarkEventsSeen marks all Events up to and including this Event by ID as seen.

func (*Client) MigrateInstance added in v0.4.0

func (c *Client) MigrateInstance(ctx context.Context, id int) error

MigrateInstance - Migrate an instance

func (*Client) MutateInstance

func (c *Client) MutateInstance(ctx context.Context, id int) error

MutateInstance Upgrades a Linode to its next generation.

func (*Client) PasswordResetInstanceDisk added in v0.6.0

func (c *Client) PasswordResetInstanceDisk(ctx context.Context, linodeID int, diskID int, password string) error

PasswordResetInstanceDisk resets the "root" account password on the Instance disk

func (*Client) R

func (c *Client) R(ctx context.Context) *resty.Request

R wraps resty's R method

func (*Client) RebootInstance

func (c *Client) RebootInstance(ctx context.Context, id int, configID int) error

RebootInstance reboots a Linode instance A configID of 0 will cause Linode to choose the last/best config

func (*Client) RebuildInstance

func (c *Client) RebuildInstance(ctx context.Context, id int, opts InstanceRebuildOptions) (*Instance, error)

RebuildInstance Deletes all Disks and Configs on this Linode, then deploys a new Image to this Linode with the given attributes.

func (*Client) RebuildNodeBalancerConfig added in v0.5.0

func (c *Client) RebuildNodeBalancerConfig(ctx context.Context, nodeBalancerID int, configID int, rebuildOpts NodeBalancerConfigRebuildOptions) (*NodeBalancerConfig, error)

RebuildNodeBalancerConfig updates the NodeBalancer with the specified id

func (*Client) RenameInstance

func (c *Client) RenameInstance(ctx context.Context, linodeID int, label string) (*Instance, error)

RenameInstance renames an Instance

func (*Client) RenameInstanceConfig

func (c *Client) RenameInstanceConfig(ctx context.Context, linodeID int, configID int, label string) (*InstanceConfig, error)

RenameInstanceConfig renames an InstanceConfig

func (*Client) RenameInstanceDisk

func (c *Client) RenameInstanceDisk(ctx context.Context, linodeID int, diskID int, label string) (*InstanceDisk, error)

RenameInstanceDisk renames an InstanceDisk

func (*Client) RenameVolume

func (c *Client) RenameVolume(ctx context.Context, id int, label string) (*Volume, error)

RenameVolume renames the label of a Linode volume DEPRECATED: use UpdateVolume

func (*Client) RescueInstance added in v0.2.0

func (c *Client) RescueInstance(ctx context.Context, id int, opts InstanceRescueOptions) error

RescueInstance reboots an instance into a safe environment for performing many system recovery and disk management tasks. Rescue Mode is based on the Finnix recovery distribution, a self-contained and bootable Linux distribution. You can also use Rescue Mode for tasks other than disaster recovery, such as formatting disks to use different filesystems, copying data between disks, and downloading files from a disk via SSH and SFTP.

func (*Client) ResizeInstance

func (c *Client) ResizeInstance(ctx context.Context, id int, opts InstanceResizeOptions) error

ResizeInstance resizes an instance to new Linode type

func (*Client) ResizeInstanceDisk

func (c *Client) ResizeInstanceDisk(ctx context.Context, linodeID int, diskID int, size int) error

ResizeInstanceDisk resizes the size of the Instance disk

func (*Client) ResizeVolume

func (c *Client) ResizeVolume(ctx context.Context, id int, size int) error

ResizeVolume resizes an instance to new Linode type

func (Client) Resource

func (c Client) Resource(resourceName string) *Resource

Resource looks up a resource by name

func (*Client) RestoreInstanceBackup added in v0.2.0

func (c *Client) RestoreInstanceBackup(ctx context.Context, linodeID int, backupID int, opts RestoreInstanceOptions) error

RestoreInstanceBackup Restores a Linode's Backup to the specified Linode.

func (*Client) SetAPIVersion added in v0.12.3

func (c *Client) SetAPIVersion(apiVersion string) *Client

func (*Client) SetBaseURL added in v0.1.0

func (c *Client) SetBaseURL(url string) *Client

SetBaseURL sets the base URL of the Linode v4 API (https://api.linode.com/v4)

func (*Client) SetDebug

func (c *Client) SetDebug(debug bool) *Client

SetDebug sets the debug on resty's client

func (*Client) SetLinodeBusyRetry added in v0.12.3

func (c *Client) SetLinodeBusyRetry() *Client

SetLinodeBusyRetry configures resty to retry specifically on "Linode busy." errors The retry wait time is configured in SetPollDelay

func (*Client) SetPollDelay added in v0.6.0

func (c *Client) SetPollDelay(delay time.Duration) *Client

SetPollDelay sets the number of milliseconds to wait between events or status polls. Affects all WaitFor* functions and retries.

func (*Client) SetRootCertificate added in v0.12.3

func (c *Client) SetRootCertificate(path string) *Client

func (*Client) SetToken added in v0.12.3

func (c *Client) SetToken(token string) *Client

SetToken sets the API token for all requests from this client Only necessary if you haven't already provided an http client to NewClient() configured with the token.

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(ua string) *Client

SetUserAgent sets a custom user-agent for HTTP requests

func (*Client) ShutdownInstance

func (c *Client) ShutdownInstance(ctx context.Context, id int) error

ShutdownInstance - Shutdown an instance

func (*Client) UpdateAccountSettings added in v0.12.3

func (c *Client) UpdateAccountSettings(ctx context.Context, settings AccountSettingsUpdateOptions) (*AccountSettings, error)

UpdateAccountSettings updates the settings associated with the account

func (*Client) UpdateDomain

func (c *Client) UpdateDomain(ctx context.Context, id int, domain DomainUpdateOptions) (*Domain, error)

UpdateDomain updates the Domain with the specified id

func (*Client) UpdateDomainRecord added in v0.1.1

func (c *Client) UpdateDomainRecord(ctx context.Context, domainID int, id int, domainrecord DomainRecordUpdateOptions) (*DomainRecord, error)

UpdateDomainRecord updates the DomainRecord with the specified id

func (*Client) UpdateIPAddress added in v0.7.0

func (c *Client) UpdateIPAddress(ctx context.Context, id string, updateOpts IPAddressUpdateOptions) (*InstanceIP, error)

UpdateIPAddress updates the IPAddress with the specified id

func (*Client) UpdateImage added in v0.2.0

func (c *Client) UpdateImage(ctx context.Context, id string, updateOpts ImageUpdateOptions) (*Image, error)

UpdateImage updates the Image with the specified id

func (*Client) UpdateInstance

func (c *Client) UpdateInstance(ctx context.Context, id int, instance InstanceUpdateOptions) (*Instance, error)

UpdateInstance creates a Linode instance

func (*Client) UpdateInstanceConfig

func (c *Client) UpdateInstanceConfig(ctx context.Context, linodeID int, configID int, updateOpts InstanceConfigUpdateOptions) (*InstanceConfig, error)

UpdateInstanceConfig update an InstanceConfig for the given Instance

func (*Client) UpdateInstanceDisk

func (c *Client) UpdateInstanceDisk(ctx context.Context, linodeID int, diskID int, updateOpts InstanceDiskUpdateOptions) (*InstanceDisk, error)

UpdateInstanceDisk creates a new InstanceDisk for the given Instance

func (*Client) UpdateInstanceIPAddress added in v0.12.3

func (c *Client) UpdateInstanceIPAddress(ctx context.Context, linodeID int, ipAddress string, updateOpts IPAddressUpdateOptions) (*InstanceIP, error)

UpdateInstanceIPAddress updates the IPAddress with the specified instance id and IP address

func (*Client) UpdateNodeBalancer

func (c *Client) UpdateNodeBalancer(ctx context.Context, id int, updateOpts NodeBalancerUpdateOptions) (*NodeBalancer, error)

UpdateNodeBalancer updates the NodeBalancer with the specified id

func (*Client) UpdateNodeBalancerConfig

func (c *Client) UpdateNodeBalancerConfig(ctx context.Context, nodebalancerID int, configID int, updateOpts NodeBalancerConfigUpdateOptions) (*NodeBalancerConfig, error)

UpdateNodeBalancerConfig updates the NodeBalancerConfig with the specified id

func (*Client) UpdateNodeBalancerNode

func (c *Client) UpdateNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, nodeID int, updateOpts NodeBalancerNodeUpdateOptions) (*NodeBalancerNode, error)

UpdateNodeBalancerNode updates the NodeBalancerNode with the specified id

func (*Client) UpdateOAuthClient added in v0.12.3

func (c *Client) UpdateOAuthClient(ctx context.Context, id string, updateOpts OAuthClientUpdateOptions) (*OAuthClient, error)

UpdateOAuthClient updates the OAuthClient with the specified id

func (*Client) UpdateObjectStorageKey added in v0.12.3

func (c *Client) UpdateObjectStorageKey(ctx context.Context, id int, updateOpts ObjectStorageKeyUpdateOptions) (*ObjectStorageKey, error)

UpdateObjKey updates the object storage key with the specified id

func (*Client) UpdateProfile added in v0.6.1

func (c *Client) UpdateProfile(ctx context.Context, updateOpts ProfileUpdateOptions) (*Profile, error)

UpdateProfile updates the Profile with the specified id

func (*Client) UpdateSSHKey added in v0.5.0

func (c *Client) UpdateSSHKey(ctx context.Context, id int, updateOpts SSHKeyUpdateOptions) (*SSHKey, error)

UpdateSSHKey updates the SSHKey with the specified id

func (*Client) UpdateStackscript

func (c *Client) UpdateStackscript(ctx context.Context, id int, updateOpts StackscriptUpdateOptions) (*Stackscript, error)

UpdateStackscript updates the StackScript with the specified id

func (*Client) UpdateToken added in v0.6.0

func (c *Client) UpdateToken(ctx context.Context, id int, updateOpts TokenUpdateOptions) (*Token, error)

UpdateToken updates the Token with the specified id

func (*Client) UpdateUser added in v0.6.0

func (c *Client) UpdateUser(ctx context.Context, id string, updateOpts UserUpdateOptions) (*User, error)

UpdateUser updates the User with the specified id

func (*Client) UpdateVolume added in v0.7.0

func (c *Client) UpdateVolume(ctx context.Context, id int, volume VolumeUpdateOptions) (*Volume, error)

UpdateVolume updates the Volume with the specified id

func (Client) WaitForEventFinished

func (client Client) WaitForEventFinished(ctx context.Context, id interface{}, entityType EntityType, action EventAction, minStart time.Time, timeoutSeconds int) (*Event, error)

WaitForEventFinished waits for an entity action to reach the 'finished' state before returning. It will timeout with an error after timeoutSeconds. If the event indicates a failure both the failed event and the error will be returned. nolint

func (Client) WaitForInstanceDiskStatus added in v0.6.0

func (client Client) WaitForInstanceDiskStatus(ctx context.Context, instanceID int, diskID int, status DiskStatus, timeoutSeconds int) (*InstanceDisk, error)

WaitForInstanceDiskStatus waits for the Linode instance disk to reach the desired state before returning. It will timeout with an error after timeoutSeconds.

func (Client) WaitForInstanceStatus added in v0.2.0

func (client Client) WaitForInstanceStatus(ctx context.Context, instanceID int, status InstanceStatus, timeoutSeconds int) (*Instance, error)

WaitForInstanceStatus waits for the Linode instance to reach the desired state before returning. It will timeout with an error after timeoutSeconds.

func (Client) WaitForSnapshotStatus added in v0.2.0

func (client Client) WaitForSnapshotStatus(ctx context.Context, instanceID int, snapshotID int, status InstanceSnapshotStatus, timeoutSeconds int) (*InstanceSnapshot, error)

WaitForSnapshotStatus waits for the Snapshot to reach the desired state before returning. It will timeout with an error after timeoutSeconds.

func (Client) WaitForVolumeLinodeID added in v0.2.0

func (client Client) WaitForVolumeLinodeID(ctx context.Context, volumeID int, linodeID *int, timeoutSeconds int) (*Volume, error)

WaitForVolumeLinodeID waits for the Volume to match the desired LinodeID before returning. An active Instance will not immediately attach or detach a volume, so the the LinodeID must be polled to determine volume readiness from the API. WaitForVolumeLinodeID will timeout with an error after timeoutSeconds.

func (Client) WaitForVolumeStatus added in v0.2.0

func (client Client) WaitForVolumeStatus(ctx context.Context, volumeID int, status VolumeStatus, timeoutSeconds int) (*Volume, error)

WaitForVolumeStatus waits for the Volume to reach the desired state before returning. It will timeout with an error after timeoutSeconds.

type ConfigAlgorithm

type ConfigAlgorithm string

ConfigAlgorithm constants start with Algorithm and include Linode API NodeBalancer Config Algorithms

const (
	AlgorithmRoundRobin ConfigAlgorithm = "roundrobin"
	AlgorithmLeastConn  ConfigAlgorithm = "leastconn"
	AlgorithmSource     ConfigAlgorithm = "source"
)

ConfigAlgorithm constants reflect the NodeBalancer Config Algorithm

type ConfigCheck

type ConfigCheck string

ConfigCheck constants start with Check and include Linode API NodeBalancer Config Check methods

const (
	CheckNone       ConfigCheck = "none"
	CheckConnection ConfigCheck = "connection"
	CheckHTTP       ConfigCheck = "http"
	CheckHTTPBody   ConfigCheck = "http_body"
)

ConfigCheck constants reflect the node health status checking method for a NodeBalancer Config

type ConfigCipher

type ConfigCipher string

ConfigCipher constants start with Cipher and include Linode API NodeBalancer Config Cipher values

const (
	CipherRecommended ConfigCipher = "recommended"
	CipherLegacy      ConfigCipher = "legacy"
)

ConfigCipher constants reflect the preferred cipher set for a NodeBalancer Config

type ConfigProtocol

type ConfigProtocol string

ConfigProtocol constants start with Protocol and include Linode API Nodebalancer Config protocols

const (
	ProtocolHTTP  ConfigProtocol = "http"
	ProtocolHTTPS ConfigProtocol = "https"
	ProtocolTCP   ConfigProtocol = "tcp"
)

ConfigProtocol constants reflect the protocol used by a NodeBalancer Config

type ConfigStickiness

type ConfigStickiness string

ConfigStickiness constants start with Stickiness and include Linode API NodeBalancer Config Stickiness

const (
	StickinessNone       ConfigStickiness = "none"
	StickinessTable      ConfigStickiness = "table"
	StickinessHTTPCookie ConfigStickiness = "http_cookie"
)

ConfigStickiness constants reflect the node stickiness method for a NodeBalancer Config

type CreditCard

type CreditCard struct {
	LastFour string `json:"last_four"`
	Expiry   string `json:"expiry"`
}

CreditCard information associated with the Account.

type DiskFilesystem added in v0.2.0

type DiskFilesystem string

DiskFilesystem constants start with Filesystem and include Linode API Filesystems

const (
	FilesystemRaw    DiskFilesystem = "raw"
	FilesystemSwap   DiskFilesystem = "swap"
	FilesystemExt3   DiskFilesystem = "ext3"
	FilesystemExt4   DiskFilesystem = "ext4"
	FilesystemInitrd DiskFilesystem = "initrd"
)

DiskFilesystem constants represent the filesystems types an Instance Disk may use

type DiskStatus added in v0.6.0

type DiskStatus string

DiskStatus constants have the prefix "Disk" and include Linode API Instance Disk Status

const (
	DiskReady    DiskStatus = "ready"
	DiskNotReady DiskStatus = "not ready"
	DiskDeleting DiskStatus = "deleting"
)

DiskStatus constants represent the status values an Instance Disk may have

type Domain

type Domain struct {
	//	This Domain's unique ID
	ID int `json:"id"`

	// The domain this Domain represents. These must be unique in our system; you cannot have two Domains representing the same domain.
	Domain string `json:"domain"`

	// If this Domain represents the authoritative source of information for the domain it describes, or if it is a read-only copy of a master (also called a slave).
	Type DomainType `json:"type"` // Enum:"master" "slave"

	// Deprecated: The group this Domain belongs to. This is for display purposes only.
	Group string `json:"group"`

	// Used to control whether this Domain is currently being rendered.
	Status DomainStatus `json:"status"` // Enum:"disabled" "active" "edit_mode" "has_errors"

	// A description for this Domain. This is for display purposes only.
	Description string `json:"description"`

	// Start of Authority email address. This is required for master Domains.
	SOAEmail string `json:"soa_email"`

	// The interval, in seconds, at which a failed refresh should be retried.
	// Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	RetrySec int `json:"retry_sec"`

	// The IP addresses representing the master DNS for this Domain.
	MasterIPs []string `json:"master_ips"`

	// The list of IPs that may perform a zone transfer for this Domain. This is potentially dangerous, and should be set to an empty list unless you intend to use it.
	AXfrIPs []string `json:"axfr_ips"`

	// An array of tags applied to this object. Tags are for organizational purposes only.
	Tags []string `json:"tags"`

	// The amount of time in seconds that may pass before this Domain is no longer authoritative. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	ExpireSec int `json:"expire_sec"`

	// The amount of time in seconds before this Domain should be refreshed. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	RefreshSec int `json:"refresh_sec"`

	// "Time to Live" - the amount of time in seconds that this Domain's records may be cached by resolvers or other domain servers. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	TTLSec int `json:"ttl_sec"`
}

Domain represents a Domain object

func (Domain) GetUpdateOptions

func (d Domain) GetUpdateOptions() (du DomainUpdateOptions)

GetUpdateOptions converts a Domain to DomainUpdateOptions for use in UpdateDomain

type DomainCreateOptions

type DomainCreateOptions struct {
	// The domain this Domain represents. These must be unique in our system; you cannot have two Domains representing the same domain.
	Domain string `json:"domain"`

	// If this Domain represents the authoritative source of information for the domain it describes, or if it is a read-only copy of a master (also called a slave).
	// Enum:"master" "slave"
	Type DomainType `json:"type"`

	// Deprecated: The group this Domain belongs to. This is for display purposes only.
	Group string `json:"group,omitempty"`

	// Used to control whether this Domain is currently being rendered.
	// Enum:"disabled" "active" "edit_mode" "has_errors"
	Status DomainStatus `json:"status,omitempty"`

	// A description for this Domain. This is for display purposes only.
	Description string `json:"description,omitempty"`

	// Start of Authority email address. This is required for master Domains.
	SOAEmail string `json:"soa_email,omitempty"`

	// The interval, in seconds, at which a failed refresh should be retried.
	// Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	RetrySec int `json:"retry_sec,omitempty"`

	// The IP addresses representing the master DNS for this Domain.
	MasterIPs []string `json:"master_ips,omitempty"`

	// The list of IPs that may perform a zone transfer for this Domain. This is potentially dangerous, and should be set to an empty list unless you intend to use it.
	AXfrIPs []string `json:"axfr_ips,omitempty"`

	// An array of tags applied to this object. Tags are for organizational purposes only.
	Tags []string `json:"tags"`

	// The amount of time in seconds that may pass before this Domain is no longer authoritative. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	ExpireSec int `json:"expire_sec,omitempty"`

	// The amount of time in seconds before this Domain should be refreshed. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	RefreshSec int `json:"refresh_sec,omitempty"`

	// "Time to Live" - the amount of time in seconds that this Domain's records may be cached by resolvers or other domain servers. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	TTLSec int `json:"ttl_sec,omitempty"`
}

DomainCreateOptions fields are those accepted by CreateDomain

type DomainRecord

type DomainRecord struct {
	ID       int              `json:"id"`
	Type     DomainRecordType `json:"type"`
	Name     string           `json:"name"`
	Target   string           `json:"target"`
	Priority int              `json:"priority"`
	Weight   int              `json:"weight"`
	Port     int              `json:"port"`
	Service  *string          `json:"service"`
	Protocol *string          `json:"protocol"`
	TTLSec   int              `json:"ttl_sec"`
	Tag      *string          `json:"tag"`
}

DomainRecord represents a DomainRecord object

func (DomainRecord) GetUpdateOptions added in v0.1.1

func (d DomainRecord) GetUpdateOptions() (du DomainRecordUpdateOptions)

GetUpdateOptions converts a DomainRecord to DomainRecordUpdateOptions for use in UpdateDomainRecord

type DomainRecordCreateOptions added in v0.1.1

type DomainRecordCreateOptions struct {
	Type     DomainRecordType `json:"type"`
	Name     string           `json:"name"`
	Target   string           `json:"target"`
	Priority *int             `json:"priority,omitempty"`
	Weight   *int             `json:"weight,omitempty"`
	Port     *int             `json:"port,omitempty"`
	Service  *string          `json:"service,omitempty"`
	Protocol *string          `json:"protocol,omitempty"`
	TTLSec   int              `json:"ttl_sec,omitempty"` // 0 is not accepted by Linode, so can be omitted
	Tag      *string          `json:"tag,omitempty"`
}

DomainRecordCreateOptions fields are those accepted by CreateDomainRecord

type DomainRecordType added in v0.1.1

type DomainRecordType string

DomainRecordType constants start with RecordType and include Linode API Domain Record Types

const (
	RecordTypeA     DomainRecordType = "A"
	RecordTypeAAAA  DomainRecordType = "AAAA"
	RecordTypeNS    DomainRecordType = "NS"
	RecordTypeMX    DomainRecordType = "MX"
	RecordTypeCNAME DomainRecordType = "CNAME"
	RecordTypeTXT   DomainRecordType = "TXT"
	RecordTypeSRV   DomainRecordType = "SRV"
	RecordTypePTR   DomainRecordType = "PTR"
	RecordTypeCAA   DomainRecordType = "CAA"
)

DomainRecordType contants are the DNS record types a DomainRecord can assign

type DomainRecordUpdateOptions added in v0.1.1

type DomainRecordUpdateOptions struct {
	Type     DomainRecordType `json:"type,omitempty"`
	Name     string           `json:"name,omitempty"`
	Target   string           `json:"target,omitempty"`
	Priority *int             `json:"priority,omitempty"` // 0 is valid, so omit only nil values
	Weight   *int             `json:"weight,omitempty"`   // 0 is valid, so omit only nil values
	Port     *int             `json:"port,omitempty"`     // 0 is valid to spec, so omit only nil values
	Service  *string          `json:"service,omitempty"`
	Protocol *string          `json:"protocol,omitempty"`
	TTLSec   int              `json:"ttl_sec,omitempty"` // 0 is not accepted by Linode, so can be omitted
	Tag      *string          `json:"tag,omitempty"`
}

DomainRecordUpdateOptions fields are those accepted by UpdateDomainRecord

type DomainRecordsPagedResponse

type DomainRecordsPagedResponse struct {
	*PageOptions
	Data []DomainRecord `json:"data"`
}

DomainRecordsPagedResponse represents a paginated DomainRecord API response

type DomainStatus added in v0.1.1

type DomainStatus string

DomainStatus constants start with DomainStatus and include Linode API Domain Status values

const (
	DomainStatusDisabled  DomainStatus = "disabled"
	DomainStatusActive    DomainStatus = "active"
	DomainStatusEditMode  DomainStatus = "edit_mode"
	DomainStatusHasErrors DomainStatus = "has_errors"
)

DomainStatus constants reflect the current status of a Domain

type DomainType added in v0.1.1

type DomainType string

DomainType constants start with DomainType and include Linode API Domain Type values

const (
	DomainTypeMaster DomainType = "master"
	DomainTypeSlave  DomainType = "slave"
)

DomainType constants reflect the DNS zone type of a Domain

type DomainUpdateOptions

type DomainUpdateOptions struct {
	// The domain this Domain represents. These must be unique in our system; you cannot have two Domains representing the same domain.
	Domain string `json:"domain,omitempty"`

	// If this Domain represents the authoritative source of information for the domain it describes, or if it is a read-only copy of a master (also called a slave).
	// Enum:"master" "slave"
	Type DomainType `json:"type,omitempty"`

	// Deprecated: The group this Domain belongs to. This is for display purposes only.
	Group string `json:"group,omitempty"`

	// Used to control whether this Domain is currently being rendered.
	// Enum:"disabled" "active" "edit_mode" "has_errors"
	Status DomainStatus `json:"status,omitempty"`

	// A description for this Domain. This is for display purposes only.
	Description string `json:"description,omitempty"`

	// Start of Authority email address. This is required for master Domains.
	SOAEmail string `json:"soa_email,omitempty"`

	// The interval, in seconds, at which a failed refresh should be retried.
	// Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	RetrySec int `json:"retry_sec,omitempty"`

	// The IP addresses representing the master DNS for this Domain.
	MasterIPs []string `json:"master_ips,omitempty"`

	// The list of IPs that may perform a zone transfer for this Domain. This is potentially dangerous, and should be set to an empty list unless you intend to use it.
	AXfrIPs []string `json:"axfr_ips,omitempty"`

	// An array of tags applied to this object. Tags are for organizational purposes only.
	Tags []string `json:"tags"`

	// The amount of time in seconds that may pass before this Domain is no longer authoritative. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	ExpireSec int `json:"expire_sec,omitempty"`

	// The amount of time in seconds before this Domain should be refreshed. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	RefreshSec int `json:"refresh_sec,omitempty"`

	// "Time to Live" - the amount of time in seconds that this Domain's records may be cached by resolvers or other domain servers. Valid values are 300, 3600, 7200, 14400, 28800, 57600, 86400, 172800, 345600, 604800, 1209600, and 2419200 - any other value will be rounded to the nearest valid value.
	TTLSec int `json:"ttl_sec,omitempty"`
}

DomainUpdateOptions converts a Domain to DomainUpdateOptions for use in UpdateDomain

type DomainsPagedResponse

type DomainsPagedResponse struct {
	*PageOptions
	Data []Domain `json:"data"`
}

DomainsPagedResponse represents a paginated Domain API response

type EntityType

type EntityType string

EntityType constants start with Entity and include Linode API Event Entity Types

const (
	EntityLinode       EntityType = "linode"
	EntityDisk         EntityType = "disk"
	EntityDomain       EntityType = "domain"
	EntityNodebalancer EntityType = "nodebalancer"
)

EntityType contants are the entities an Event can be related to.

type Error

type Error struct {
	Response *http.Response
	Code     int
	Message  string
}

Error wraps the LinodeGo error with the relevant http.Response

func NewError

func NewError(err interface{}) *Error

NewError creates a linodego.Error with a Code identifying the source err type, - ErrorFromString (1) from a string - ErrorFromError (2) for an error - ErrorFromStringer (3) for a Stringer - HTTP Status Codes (100-600) for a resty.Response object

func (Error) Error

func (g Error) Error() string

type Event

type Event struct {
	CreatedStr string `json:"created"`

	// The unique ID of this Event.
	ID int `json:"id"`

	// Current status of the Event, Enum: "failed" "finished" "notification" "scheduled" "started"
	Status EventStatus `json:"status"`

	// The action that caused this Event. New actions may be added in the future.
	Action EventAction `json:"action"`

	// A percentage estimating the amount of time remaining for an Event. Returns null for notification events.
	PercentComplete int `json:"percent_complete"`

	// The rate of completion of the Event. Only some Events will return rate; for example, migration and resize Events.
	Rate *string `json:"rate"`

	// If this Event has been read.
	Read bool `json:"read"`

	// If this Event has been seen.
	Seen bool `json:"seen"`

	// The estimated time remaining until the completion of this Event. This value is only returned for in-progress events.
	TimeRemainingMsg json.RawMessage `json:"time_remaining"`
	TimeRemaining    *int            `json:"-"`

	// The username of the User who caused the Event.
	Username string `json:"username"`

	// Detailed information about the Event's entity, including ID, type, label, and URL used to access it.
	Entity *EventEntity `json:"entity"`

	// When this Event was created.
	Created *time.Time `json:"-"`
}

Event represents an action taken on the Account.

type EventAction

type EventAction string

EventAction constants start with Action and include all known Linode API Event Actions.

const (
	ActionAccountUpdate            EventAction = "account_update"
	ActionAccountSettingsUpdate    EventAction = "account_settings_update"
	ActionBackupsEnable            EventAction = "backups_enable"
	ActionBackupsCancel            EventAction = "backups_cancel"
	ActionBackupsRestore           EventAction = "backups_restore"
	ActionCommunityQuestionReply   EventAction = "community_question_reply"
	ActionCommunityLike            EventAction = "community_like"
	ActionCreateCardUpdated        EventAction = "credit_card_updated"
	ActionDiskCreate               EventAction = "disk_create"
	ActionDiskDelete               EventAction = "disk_delete"
	ActionDiskUpdate               EventAction = "disk_update"
	ActionDiskDuplicate            EventAction = "disk_duplicate"
	ActionDiskImagize              EventAction = "disk_imagize"
	ActionDiskResize               EventAction = "disk_resize"
	ActionDNSRecordCreate          EventAction = "dns_record_create"
	ActionDNSRecordDelete          EventAction = "dns_record_delete"
	ActionDNSRecordUpdate          EventAction = "dns_record_update"
	ActionDNSZoneCreate            EventAction = "dns_zone_create"
	ActionDNSZoneDelete            EventAction = "dns_zone_delete"
	ActionDNSZoneUpdate            EventAction = "dns_zone_update"
	ActionHostReboot               EventAction = "host_reboot"
	ActionImageDelete              EventAction = "image_delete"
	ActionImageUpdate              EventAction = "image_update"
	ActionLassieReboot             EventAction = "lassie_reboot"
	ActionLinodeAddIP              EventAction = "linode_addip"
	ActionLinodeBoot               EventAction = "linode_boot"
	ActionLinodeClone              EventAction = "linode_clone"
	ActionLinodeCreate             EventAction = "linode_create"
	ActionLinodeDelete             EventAction = "linode_delete"
	ActionLinodeUpdate             EventAction = "linode_update"
	ActionLinodeDeleteIP           EventAction = "linode_deleteip"
	ActionLinodeMigrate            EventAction = "linode_migrate"
	ActionLinodeMutate             EventAction = "linode_mutate"
	ActionLinodeMutateCreate       EventAction = "linode_mutate_create"
	ActionLinodeReboot             EventAction = "linode_reboot"
	ActionLinodeRebuild            EventAction = "linode_rebuild"
	ActionLinodeResize             EventAction = "linode_resize"
	ActionLinodeResizeCreate       EventAction = "linode_resize_create"
	ActionLinodeShutdown           EventAction = "linode_shutdown"
	ActionLinodeSnapshot           EventAction = "linode_snapshot"
	ActionLinodeConfigCreate       EventAction = "linode_config_create"
	ActionLinodeConfigDelete       EventAction = "linode_config_delete"
	ActionLinodeConfigUpdate       EventAction = "linode_config_update"
	ActionLishBoot                 EventAction = "lish_boot"
	ActionLongviewClientCreate     EventAction = "longviewclient_create"
	ActionLongviewClientDelete     EventAction = "longviewclient_delete"
	ActionLongviewClientUpdate     EventAction = "longviewclient_update"
	ActionManagedDisabled          EventAction = "managed_disabled"
	ActionManagedEnabled           EventAction = "managed_enabled"
	ActionManagedServiceCreate     EventAction = "managed_service_create"
	ActionManagedServiceDelete     EventAction = "managed_service_delete"
	ActionNodebalancerCreate       EventAction = "nodebalancer_create"
	ActionNodebalancerDelete       EventAction = "nodebalancer_delete"
	ActionNodebalancerUpdate       EventAction = "nodebalancer_update"
	ActionNodebalancerConfigCreate EventAction = "nodebalancer_config_create"
	ActionNodebalancerConfigDelete EventAction = "nodebalancer_config_delete"
	ActionNodebalancerConfigUpdate EventAction = "nodebalancer_config_update"
	ActionPasswordReset            EventAction = "password_reset"
	ActionPaymentSubmitted         EventAction = "payment_submitted"
	ActionStackScriptCreate        EventAction = "stackscript_create"
	ActionStackScriptDelete        EventAction = "stackscript_delete"
	ActionStackScriptUpdate        EventAction = "stackscript_update"
	ActionStackScriptPublicize     EventAction = "stackscript_publicize"
	ActionStackScriptRevise        EventAction = "stackscript_revise"
	ActionTFADisabled              EventAction = "tfa_disabled"
	ActionTFAEnabled               EventAction = "tfa_enabled"
	ActionTicketAttachmentUpload   EventAction = "ticket_attachment_upload"
	ActionTicketCreate             EventAction = "ticket_create"
	ActionTicketUpdate             EventAction = "ticket_update"
	ActionVolumeAttach             EventAction = "volume_attach"
	ActionVolumeClone              EventAction = "volume_clone"
	ActionVolumeCreate             EventAction = "volume_create"
	ActionVolumeDelte              EventAction = "volume_delete"
	ActionVolumeUpdate             EventAction = "volume_update"
	ActionVolumeDetach             EventAction = "volume_detach"
	ActionVolumeResize             EventAction = "volume_resize"
)

EventAction constants represent the actions that cause an Event. New actions may be added in the future.

type EventEntity

type EventEntity struct {
	// ID may be a string or int, it depends on the EntityType
	ID    interface{} `json:"id"`
	Label string      `json:"label"`
	Type  EntityType  `json:"type"`
	URL   string      `json:"url"`
}

EventEntity provides detailed information about the Event's associated entity, including ID, Type, Label, and a URL that can be used to access it.

type EventStatus

type EventStatus string

EventStatus constants start with Event and include Linode API Event Status values

const (
	EventFailed       EventStatus = "failed"
	EventFinished     EventStatus = "finished"
	EventNotification EventStatus = "notification"
	EventScheduled    EventStatus = "scheduled"
	EventStarted      EventStatus = "started"
)

EventStatus constants reflect the current status of an Event

type EventsPagedResponse

type EventsPagedResponse struct {
	*PageOptions
	Data []Event `json:"data"`
}

EventsPagedResponse represents a paginated Events API response

type IPAddressUpdateOptions added in v0.7.0

type IPAddressUpdateOptions struct {
	// The reverse DNS assigned to this address. For public IPv4 addresses, this will be set to a default value provided by Linode if set to nil.
	RDNS *string `json:"rdns"`
}

IPAddressUpdateOptions fields are those accepted by UpdateToken

type IPAddressesPagedResponse

type IPAddressesPagedResponse struct {
	*PageOptions
	Data []InstanceIP `json:"data"`
}

IPAddressesPagedResponse represents a paginated IPAddress API response

type IPv6PoolsPagedResponse

type IPv6PoolsPagedResponse struct {
	*PageOptions
	Data []IPv6Range `json:"data"`
}

IPv6PoolsPagedResponse represents a paginated IPv6Pool API response

type IPv6Range

type IPv6Range struct {
	Range  string `json:"range"`
	Region string `json:"region"`
	Prefix int    `json:"prefix"`
}

IPv6Range represents a range of IPv6 addresses routed to a single Linode in a given Region

type IPv6RangesPagedResponse

type IPv6RangesPagedResponse struct {
	*PageOptions
	Data []IPv6Range `json:"data"`
}

IPv6RangesPagedResponse represents a paginated IPv6Range API response

type Image

type Image struct {
	CreatedStr  string `json:"created"`
	ExpiryStr   string `json:"expiry"`
	ID          string `json:"id"`
	CreatedBy   string `json:"created_by"`
	Label       string `json:"label"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Vendor      string `json:"vendor"`
	Size        int    `json:"size"`
	IsPublic    bool   `json:"is_public"`
	Deprecated  bool   `json:"deprecated"`

	Created *time.Time `json:"-"`
	Expiry  *time.Time `json:"-"`
}

Image represents a deployable Image object for use with Linode Instances

func (Image) GetUpdateOptions added in v0.2.0

func (i Image) GetUpdateOptions() (iu ImageUpdateOptions)

GetUpdateOptions converts an Image to ImageUpdateOptions for use in UpdateImage

type ImageCreateOptions added in v0.2.0

type ImageCreateOptions struct {
	DiskID      int    `json:"disk_id"`
	Label       string `json:"label"`
	Description string `json:"description,omitempty"`
}

ImageCreateOptions fields are those accepted by CreateImage

type ImageUpdateOptions added in v0.2.0

type ImageUpdateOptions struct {
	Label       string  `json:"label,omitempty"`
	Description *string `json:"description,omitempty"`
}

ImageUpdateOptions fields are those accepted by UpdateImage

type ImagesPagedResponse

type ImagesPagedResponse struct {
	*PageOptions
	Data []Image `json:"data"`
}

ImagesPagedResponse represents a linode API response for listing of images

type Instance

type Instance struct {
	CreatedStr string `json:"created"`
	UpdatedStr string `json:"updated"`

	ID              int             `json:"id"`
	Created         *time.Time      `json:"-"`
	Updated         *time.Time      `json:"-"`
	Region          string          `json:"region"`
	Alerts          *InstanceAlert  `json:"alerts"`
	Backups         *InstanceBackup `json:"backups"`
	Image           string          `json:"image"`
	Group           string          `json:"group"`
	IPv4            []*net.IP       `json:"ipv4"`
	IPv6            string          `json:"ipv6"`
	Label           string          `json:"label"`
	Type            string          `json:"type"`
	Status          InstanceStatus  `json:"status"`
	Hypervisor      string          `json:"hypervisor"`
	Specs           *InstanceSpec   `json:"specs"`
	WatchdogEnabled bool            `json:"watchdog_enabled"`
	Tags            []string        `json:"tags"`
}

Instance represents a linode object

func (*Instance) GetUpdateOptions added in v0.6.0

func (l *Instance) GetUpdateOptions() InstanceUpdateOptions

GetUpdateOptions converts an Instance to InstanceUpdateOptions for use in UpdateInstance

type InstanceAlert

type InstanceAlert struct {
	CPU           int `json:"cpu"`
	IO            int `json:"io"`
	NetworkIn     int `json:"network_in"`
	NetworkOut    int `json:"network_out"`
	TransferQuota int `json:"transfer_quota"`
}

InstanceAlert represents a metric alert

type InstanceBackup

type InstanceBackup struct {
	Enabled  bool `json:"enabled"`
	Schedule struct {
		Day    string `json:"day,omitempty"`
		Window string `json:"window,omitempty"`
	}
}

InstanceBackup represents backup settings for an instance

type InstanceBackupSnapshotResponse

type InstanceBackupSnapshotResponse struct {
	Current    *InstanceSnapshot `json:"current"`
	InProgress *InstanceSnapshot `json:"in_progress"`
}

InstanceBackupSnapshotResponse fields are those representing Instance Backup Snapshots

type InstanceBackupsResponse

type InstanceBackupsResponse struct {
	Automatic []*InstanceSnapshot             `json:"automatic"`
	Snapshot  *InstanceBackupSnapshotResponse `json:"snapshot"`
}

InstanceBackupsResponse response struct for backup snapshot

type InstanceCloneOptions

type InstanceCloneOptions struct {
	Region string `json:"region,omitempty"`
	Type   string `json:"type,omitempty"`

	// LinodeID is an optional existing instance to use as the target of the clone
	LinodeID       int    `json:"linode_id,omitempty"`
	Label          string `json:"label,omitempty"`
	Group          string `json:"group,omitempty"`
	BackupsEnabled bool   `json:"backups_enabled"`
	Disks          []int  `json:"disks,omitempty"`
	Configs        []int  `json:"configs,omitempty"`
}

InstanceCloneOptions is an options struct sent when Cloning an Instance

type InstanceConfig

type InstanceConfig struct {
	CreatedStr string `json:"created"`
	UpdatedStr string `json:"updated"`

	ID          int                      `json:"id"`
	Label       string                   `json:"label"`
	Comments    string                   `json:"comments"`
	Devices     *InstanceConfigDeviceMap `json:"devices"`
	Helpers     *InstanceConfigHelpers   `json:"helpers"`
	MemoryLimit int                      `json:"memory_limit"`
	Kernel      string                   `json:"kernel"`
	InitRD      *int                     `json:"init_rd"`
	RootDevice  string                   `json:"root_device"`
	RunLevel    string                   `json:"run_level"`
	VirtMode    string                   `json:"virt_mode"`
	Created     *time.Time               `json:"-"`
	Updated     *time.Time               `json:"-"`
}

InstanceConfig represents all of the settings that control the boot and run configuration of a Linode Instance

func (InstanceConfig) GetCreateOptions

func (i InstanceConfig) GetCreateOptions() InstanceConfigCreateOptions

GetCreateOptions converts a InstanceConfig to InstanceConfigCreateOptions for use in CreateInstanceConfig

func (InstanceConfig) GetUpdateOptions

func (i InstanceConfig) GetUpdateOptions() InstanceConfigUpdateOptions

GetUpdateOptions converts a InstanceConfig to InstanceConfigUpdateOptions for use in UpdateInstanceConfig

type InstanceConfigCreateOptions

type InstanceConfigCreateOptions struct {
	Label       string                  `json:"label,omitempty"`
	Comments    string                  `json:"comments,omitempty"`
	Devices     InstanceConfigDeviceMap `json:"devices"`
	Helpers     *InstanceConfigHelpers  `json:"helpers,omitempty"`
	MemoryLimit int                     `json:"memory_limit,omitempty"`
	Kernel      string                  `json:"kernel,omitempty"`
	InitRD      int                     `json:"init_rd,omitempty"`
	RootDevice  *string                 `json:"root_device,omitempty"`
	RunLevel    string                  `json:"run_level,omitempty"`
	VirtMode    string                  `json:"virt_mode,omitempty"`
}

InstanceConfigCreateOptions are InstanceConfig settings that can be used at creation

type InstanceConfigDevice

type InstanceConfigDevice struct {
	DiskID   int `json:"disk_id,omitempty"`
	VolumeID int `json:"volume_id,omitempty"`
}

InstanceConfigDevice contains either the DiskID or VolumeID assigned to a Config Device

type InstanceConfigDeviceMap

type InstanceConfigDeviceMap struct {
	SDA *InstanceConfigDevice `json:"sda,omitempty"`
	SDB *InstanceConfigDevice `json:"sdb,omitempty"`
	SDC *InstanceConfigDevice `json:"sdc,omitempty"`
	SDD *InstanceConfigDevice `json:"sdd,omitempty"`
	SDE *InstanceConfigDevice `json:"sde,omitempty"`
	SDF *InstanceConfigDevice `json:"sdf,omitempty"`
	SDG *InstanceConfigDevice `json:"sdg,omitempty"`
	SDH *InstanceConfigDevice `json:"sdh,omitempty"`
}

InstanceConfigDeviceMap contains SDA-SDH InstanceConfigDevice settings

type InstanceConfigHelpers

type InstanceConfigHelpers struct {
	UpdateDBDisabled  bool `json:"updatedb_disabled"`
	Distro            bool `json:"distro"`
	ModulesDep        bool `json:"modules_dep"`
	Network           bool `json:"network"`
	DevTmpFsAutomount bool `json:"devtmpfs_automount"`
}

InstanceConfigHelpers are Instance Config options that control Linux distribution specific tweaks

type InstanceConfigUpdateOptions

type InstanceConfigUpdateOptions struct {
	Label    string                   `json:"label,omitempty"`
	Comments string                   `json:"comments"`
	Devices  *InstanceConfigDeviceMap `json:"devices,omitempty"`
	Helpers  *InstanceConfigHelpers   `json:"helpers,omitempty"`
	// MemoryLimit 0 means unlimitted, this is not omitted
	MemoryLimit int    `json:"memory_limit"`
	Kernel      string `json:"kernel,omitempty"`
	// InitRD is nullable, permit the sending of null
	InitRD     *int   `json:"init_rd"`
	RootDevice string `json:"root_device,omitempty"`
	RunLevel   string `json:"run_level,omitempty"`
	VirtMode   string `json:"virt_mode,omitempty"`
}

InstanceConfigUpdateOptions are InstanceConfig settings that can be used in updates

type InstanceConfigsPagedResponse

type InstanceConfigsPagedResponse struct {
	*PageOptions
	Data []InstanceConfig `json:"data"`
}

InstanceConfigsPagedResponse represents a paginated InstanceConfig API response

type InstanceCreateOptions

type InstanceCreateOptions struct {
	Region          string            `json:"region"`
	Type            string            `json:"type"`
	Label           string            `json:"label,omitempty"`
	Group           string            `json:"group,omitempty"`
	RootPass        string            `json:"root_pass,omitempty"`
	AuthorizedKeys  []string          `json:"authorized_keys,omitempty"`
	AuthorizedUsers []string          `json:"authorized_users,omitempty"`
	StackScriptID   int               `json:"stackscript_id,omitempty"`
	StackScriptData map[string]string `json:"stackscript_data,omitempty"`
	BackupID        int               `json:"backup_id,omitempty"`
	Image           string            `json:"image,omitempty"`
	BackupsEnabled  bool              `json:"backups_enabled,omitempty"`
	PrivateIP       bool              `json:"private_ip,omitempty"`
	Tags            []string          `json:"tags,omitempty"`

	// Creation fields that need to be set explicitly false, "", or 0 use pointers
	SwapSize *int  `json:"swap_size,omitempty"`
	Booted   *bool `json:"booted,omitempty"`
}

InstanceCreateOptions require only Region and Type

type InstanceDisk

type InstanceDisk struct {
	CreatedStr string `json:"created"`
	UpdatedStr string `json:"updated"`

	ID         int            `json:"id"`
	Label      string         `json:"label"`
	Status     DiskStatus     `json:"status"`
	Size       int            `json:"size"`
	Filesystem DiskFilesystem `json:"filesystem"`
	Created    time.Time      `json:"-"`
	Updated    time.Time      `json:"-"`
}

InstanceDisk represents an Instance Disk object

type InstanceDiskCreateOptions

type InstanceDiskCreateOptions struct {
	Label string `json:"label"`
	Size  int    `json:"size"`

	// Image is optional, but requires RootPass if provided
	Image    string `json:"image,omitempty"`
	RootPass string `json:"root_pass,omitempty"`

	Filesystem      string            `json:"filesystem,omitempty"`
	AuthorizedKeys  []string          `json:"authorized_keys,omitempty"`
	AuthorizedUsers []string          `json:"authorized_users,omitempty"`
	ReadOnly        bool              `json:"read_only,omitempty"`
	StackscriptID   int               `json:"stackscript_id,omitempty"`
	StackscriptData map[string]string `json:"stackscript_data,omitempty"`
}

InstanceDiskCreateOptions are InstanceDisk settings that can be used at creation

type InstanceDiskUpdateOptions

type InstanceDiskUpdateOptions struct {
	Label    string `json:"label"`
	ReadOnly bool   `json:"read_only"`
}

InstanceDiskUpdateOptions are InstanceDisk settings that can be used in updates

type InstanceDisksPagedResponse

type InstanceDisksPagedResponse struct {
	*PageOptions
	Data []InstanceDisk `json:"data"`
}

InstanceDisksPagedResponse represents a paginated InstanceDisk API response

type InstanceIP

type InstanceIP struct {
	Address    string         `json:"address"`
	Gateway    string         `json:"gateway"`
	SubnetMask string         `json:"subnet_mask"`
	Prefix     int            `json:"prefix"`
	Type       InstanceIPType `json:"type"`
	Public     bool           `json:"public"`
	RDNS       string         `json:"rdns"`
	LinodeID   int            `json:"linode_id"`
	Region     string         `json:"region"`
}

InstanceIP represents an Instance IP with additional DNS and networking details

func (InstanceIP) GetUpdateOptions added in v0.7.0

func (i InstanceIP) GetUpdateOptions() (o IPAddressUpdateOptions)

GetUpdateOptions converts a IPAddress to IPAddressUpdateOptions for use in UpdateIPAddress

type InstanceIPAddressResponse

type InstanceIPAddressResponse struct {
	IPv4 *InstanceIPv4Response `json:"ipv4"`
	IPv6 *InstanceIPv6Response `json:"ipv6"`
}

InstanceIPAddressResponse contains the IPv4 and IPv6 details for an Instance

type InstanceIPType added in v0.12.3

type InstanceIPType string

InstanceIPType constants start with IPType and include Linode Instance IP Types

const (
	IPTypeIPv4      InstanceIPType = "ipv4"
	IPTypeIPv6      InstanceIPType = "ipv6"
	IPTypeIPv6Pool  InstanceIPType = "ipv6/pool"
	IPTypeIPv6Range InstanceIPType = "ipv6/range"
)

InstanceIPType constants represent the IP types an Instance IP may be

type InstanceIPv4Response

type InstanceIPv4Response struct {
	Public   []*InstanceIP `json:"public"`
	Private  []*InstanceIP `json:"private"`
	Shared   []*InstanceIP `json:"shared"`
	Reserved []*InstanceIP `json:"reserved"`
}

InstanceIPv4Response contains the details of all IPv4 addresses associated with an Instance

type InstanceIPv6Response

type InstanceIPv6Response struct {
	LinkLocal *InstanceIP  `json:"link_local"`
	SLAAC     *InstanceIP  `json:"slaac"`
	Global    []*IPv6Range `json:"global"`
}

InstanceIPv6Response contains the IPv6 addresses and ranges for an Instance

type InstanceRebuildOptions added in v0.12.3

type InstanceRebuildOptions struct {
	Image           string            `json:"image"`
	RootPass        string            `json:"root_pass"`
	AuthorizedKeys  []string          `json:"authorized_keys"`
	AuthorizedUsers []string          `json:"authorized_users"`
	StackscriptID   int               `json:"stackscript_id"`
	StackscriptData map[string]string `json:"stackscript_data"`
	Booted          bool              `json:"booted"`
}

InstanceRebuildOptions is a struct representing the options to send to the rebuild linode endpoint

type InstanceRescueOptions added in v0.12.3

type InstanceRescueOptions struct {
	Devices InstanceConfigDeviceMap `json:"devices"`
}

InstanceRescueOptions fields are those accepted by RescueInstance

type InstanceResizeOptions added in v0.12.3

type InstanceResizeOptions struct {
	Type string `json:"type"`

	// When enabled, an instance resize will also resize a data disk if the instance has no more than one data disk and one swap disk
	AllowAutoDiskResize *bool `json:"allow_auto_disk_resize,omitempty"`
}

InstanceResizeOptions

type InstanceSnapshot

type InstanceSnapshot struct {
	CreatedStr  string `json:"created"`
	UpdatedStr  string `json:"updated"`
	FinishedStr string `json:"finished"`

	ID       int                     `json:"id"`
	Label    string                  `json:"label"`
	Status   InstanceSnapshotStatus  `json:"status"`
	Type     string                  `json:"type"`
	Created  *time.Time              `json:"-"`
	Updated  *time.Time              `json:"-"`
	Finished *time.Time              `json:"-"`
	Configs  []string                `json:"configs"`
	Disks    []*InstanceSnapshotDisk `json:"disks"`
}

InstanceSnapshot represents a linode backup snapshot

type InstanceSnapshotDisk

type InstanceSnapshotDisk struct {
	Label      string `json:"label"`
	Size       int    `json:"size"`
	Filesystem string `json:"filesystem"`
}

InstanceSnapshotDisk fields represent the source disk of a Snapshot

type InstanceSnapshotStatus added in v0.2.0

type InstanceSnapshotStatus string

InstanceSnapshotStatus constants start with Snapshot and include Linode API Instance Backup Snapshot status values

var (
	SnapshotPaused              InstanceSnapshotStatus = "paused"
	SnapshotPending             InstanceSnapshotStatus = "pending"
	SnapshotRunning             InstanceSnapshotStatus = "running"
	SnapshotNeedsPostProcessing InstanceSnapshotStatus = "needsPostProcessing"
	SnapshotSuccessful          InstanceSnapshotStatus = "successful"
	SnapshotFailed              InstanceSnapshotStatus = "failed"
	SnapshotUserAborted         InstanceSnapshotStatus = "userAborted"
)

InstanceSnapshotStatus constants reflect the current status of an Instance Snapshot

type InstanceSpec

type InstanceSpec struct {
	Disk     int `json:"disk"`
	Memory   int `json:"memory"`
	VCPUs    int `json:"vcpus"`
	Transfer int `json:"transfer"`
}

InstanceSpec represents a linode spec

type InstanceStats added in v0.12.3

type InstanceStats struct {
	Title string            `json:"title"`
	Data  InstanceStatsData `json:"data"`
}

InstanceStats represents an instance stats object

type InstanceStatsData added in v0.12.3

type InstanceStatsData struct {
	CPU   [][]float64 `json:"cpu"`
	IO    StatsIO     `json:"io"`
	NetV4 StatsNet    `json:"netv4"`
	NetV6 StatsNet    `json:"netv6"`
}

InstanceStatsData represents an instance stats data object

type InstanceStatus

type InstanceStatus string

InstanceStatus constants start with Instance and include Linode API Instance Status values

const (
	InstanceBooting      InstanceStatus = "booting"
	InstanceRunning      InstanceStatus = "running"
	InstanceOffline      InstanceStatus = "offline"
	InstanceShuttingDown InstanceStatus = "shutting_down"
	InstanceRebooting    InstanceStatus = "rebooting"
	InstanceProvisioning InstanceStatus = "provisioning"
	InstanceDeleting     InstanceStatus = "deleting"
	InstanceMigrating    InstanceStatus = "migrating"
	InstanceRebuilding   InstanceStatus = "rebuilding"
	InstanceCloning      InstanceStatus = "cloning"
	InstanceRestoring    InstanceStatus = "restoring"
	InstanceResizing     InstanceStatus = "resizing"
)

InstanceStatus constants reflect the current status of an Instance

type InstanceTransfer added in v0.12.3

type InstanceTransfer struct {
	// Bytes of transfer this instance has consumed
	Used int `json:"used"`

	// GB of billable transfer this instance has consumed
	Billable int `json:"billable"`

	// GB of transfer this instance adds to the Transfer pool
	Quota int `json:"quota"`
}

InstanceTransfer pool stats for a Linode Instance during the current billing month

type InstanceUpdateOptions

type InstanceUpdateOptions struct {
	Label           string          `json:"label,omitempty"`
	Group           string          `json:"group,omitempty"`
	Backups         *InstanceBackup `json:"backups,omitempty"`
	Alerts          *InstanceAlert  `json:"alerts,omitempty"`
	WatchdogEnabled *bool           `json:"watchdog_enabled,omitempty"`
	Tags            *[]string       `json:"tags,omitempty"`
}

InstanceUpdateOptions is an options struct used when Updating an Instance

type InstanceVolumesPagedResponse

type InstanceVolumesPagedResponse struct {
	*PageOptions
	Data []Volume `json:"data"`
}

InstanceVolumesPagedResponse represents a paginated InstanceVolume API response

type InstancesPagedResponse

type InstancesPagedResponse struct {
	*PageOptions
	Data []Instance `json:"data"`
}

InstancesPagedResponse represents a linode API response for listing

type Invoice

type Invoice struct {
	DateStr string `json:"date"`

	ID    int        `json:"id"`
	Label string     `json:"label"`
	Total float32    `json:"total"`
	Date  *time.Time `json:"-"`
}

Invoice structs reflect an invoice for billable activity on the account.

type InvoiceItem

type InvoiceItem struct {
	FromStr string `json:"from"`
	ToStr   string `json:"to"`

	Label     string     `json:"label"`
	Type      string     `json:"type"`
	UnitPrice int        `json:"unitprice"`
	Quantity  int        `json:"quantity"`
	Amount    float32    `json:"amount"`
	From      *time.Time `json:"-"`
	To        *time.Time `json:"-"`
}

InvoiceItem structs reflect an single billable activity associate with an Invoice

type InvoiceItemsPagedResponse

type InvoiceItemsPagedResponse struct {
	*PageOptions
	Data []InvoiceItem `json:"data"`
}

InvoiceItemsPagedResponse represents a paginated Invoice Item API response

type InvoicesPagedResponse

type InvoicesPagedResponse struct {
	*PageOptions
	Data []Invoice `json:"data"`
}

InvoicesPagedResponse represents a paginated Invoice API response

type LinodeAddons

type LinodeAddons struct {
	Backups *LinodeBackupsAddon `json:"backups"`
}

LinodeAddons represent the linode addons object

type LinodeBackupsAddon

type LinodeBackupsAddon struct {
	Price *LinodePrice `json:"price"`
}

LinodeBackupsAddon represents a linode backups addon object

type LinodeKernel

type LinodeKernel struct {
	ID           string `json:"id"`
	Label        string `json:"label"`
	Version      string `json:"version"`
	Architecture string `json:"architecture"`
	KVM          bool   `json:"kvm"`
	XEN          bool   `json:"xen"`
	PVOPS        bool   `json:"pvops"`
}

LinodeKernel represents a Linode Instance kernel object

type LinodeKernelsPagedResponse

type LinodeKernelsPagedResponse struct {
	*PageOptions
	Data []LinodeKernel `json:"data"`
}

LinodeKernelsPagedResponse represents a Linode kernels API response for listing

type LinodePrice

type LinodePrice struct {
	Hourly  float32 `json:"hourly"`
	Monthly float32 `json:"monthly"`
}

LinodePrice represents a linode type price object

type LinodeType

type LinodeType struct {
	ID         string          `json:"id"`
	Disk       int             `json:"disk"`
	Class      LinodeTypeClass `json:"class"` // enum: nanode, standard, highmem, dedicated
	Price      *LinodePrice    `json:"price"`
	Label      string          `json:"label"`
	Addons     *LinodeAddons   `json:"addons"`
	NetworkOut int             `json:"network_out"`
	Memory     int             `json:"memory"`
	Transfer   int             `json:"transfer"`
	VCPUs      int             `json:"vcpus"`
}

LinodeType represents a linode type object

type LinodeTypeClass added in v0.4.0

type LinodeTypeClass string

LinodeTypeClass constants start with Class and include Linode API Instance Type Classes

const (
	ClassNanode    LinodeTypeClass = "nanode"
	ClassStandard  LinodeTypeClass = "standard"
	ClassHighmem   LinodeTypeClass = "highmem"
	ClassDedicated LinodeTypeClass = "dedicated"
)

LinodeTypeClass contants are the Instance Type Classes that an Instance Type can be assigned

type LinodeTypesPagedResponse

type LinodeTypesPagedResponse struct {
	*PageOptions
	Data []LinodeType `json:"data"`
}

LinodeTypesPagedResponse represents a linode types API response for listing

type LishAuthMethod added in v0.6.1

type LishAuthMethod string

LishAuthMethod constants start with AuthMethod and include Linode API Lish Authentication Methods

const (
	AuthMethodPasswordKeys LishAuthMethod = "password_keys"
	AuthMethodKeysOnly     LishAuthMethod = "keys_only"
	AuthMethodDisabled     LishAuthMethod = "disabled"
)

LishAuthMethod constants are the methods of authentication allowed when connecting via Lish

type ListOptions

type ListOptions struct {
	*PageOptions
	Filter string
}

ListOptions are the pagination and filtering (TODO) parameters for endpoints

func NewListOptions

func NewListOptions(page int, filter string) *ListOptions

NewListOptions simplified construction of ListOptions using only the two writable properties, Page and Filter

type LongviewClient

type LongviewClient struct {
	ID int `json:"id"`
}

LongviewClient represents a LongviewClient object

type LongviewClientsPagedResponse

type LongviewClientsPagedResponse struct {
	*PageOptions
	Data []LongviewClient `json:"data"`
}

LongviewClientsPagedResponse represents a paginated LongviewClient API response

type LongviewSubscription

type LongviewSubscription struct {
	ID              string       `json:"id"`
	Label           string       `json:"label"`
	ClientsIncluded int          `json:"clients_included"`
	Price           *LinodePrice `json:"price"`
}

LongviewSubscription represents a LongviewSubscription object

type LongviewSubscriptionsPagedResponse

type LongviewSubscriptionsPagedResponse struct {
	*PageOptions
	Data []LongviewSubscription `json:"data"`
}

LongviewSubscriptionsPagedResponse represents a paginated LongviewSubscription API response

type NodeBalancer

type NodeBalancer struct {
	CreatedStr string `json:"created"`
	UpdatedStr string `json:"updated"`
	// This NodeBalancer's unique ID.
	ID int `json:"id"`
	// This NodeBalancer's label. These must be unique on your Account.
	Label *string `json:"label"`
	// The Region where this NodeBalancer is located. NodeBalancers only support backends in the same Region.
	Region string `json:"region"`
	// This NodeBalancer's hostname, ending with .nodebalancer.linode.com
	Hostname *string `json:"hostname"`
	// This NodeBalancer's public IPv4 address.
	IPv4 *string `json:"ipv4"`
	// This NodeBalancer's public IPv6 address.
	IPv6 *string `json:"ipv6"`
	// Throttle connections per second (0-20). Set to 0 (zero) to disable throttling.
	ClientConnThrottle int `json:"client_conn_throttle"`
	// Information about the amount of transfer this NodeBalancer has had so far this month.
	Transfer NodeBalancerTransfer `json:"transfer"`

	// An array of tags applied to this object. Tags are for organizational purposes only.
	Tags []string `json:"tags"`

	Created *time.Time `json:"-"`
	Updated *time.Time `json:"-"`
}

NodeBalancer represents a NodeBalancer object

func (NodeBalancer) GetCreateOptions

func (i NodeBalancer) GetCreateOptions() NodeBalancerCreateOptions

GetCreateOptions converts a NodeBalancer to NodeBalancerCreateOptions for use in CreateNodeBalancer

func (NodeBalancer) GetUpdateOptions

func (i NodeBalancer) GetUpdateOptions() NodeBalancerUpdateOptions

GetUpdateOptions converts a NodeBalancer to NodeBalancerUpdateOptions for use in UpdateNodeBalancer

type NodeBalancerConfig

type NodeBalancerConfig struct {
	ID             int                     `json:"id"`
	Port           int                     `json:"port"`
	Protocol       ConfigProtocol          `json:"protocol"`
	Algorithm      ConfigAlgorithm         `json:"algorithm"`
	Stickiness     ConfigStickiness        `json:"stickiness"`
	Check          ConfigCheck             `json:"check"`
	CheckInterval  int                     `json:"check_interval"`
	CheckAttempts  int                     `json:"check_attempts"`
	CheckPath      string                  `json:"check_path"`
	CheckBody      string                  `json:"check_body"`
	CheckPassive   bool                    `json:"check_passive"`
	CheckTimeout   int                     `json:"check_timeout"`
	CipherSuite    ConfigCipher            `json:"cipher_suite"`
	NodeBalancerID int                     `json:"nodebalancer_id"`
	SSLCommonName  string                  `json:"ssl_commonname"`
	SSLFingerprint string                  `json:"ssl_fingerprint"`
	SSLCert        string                  `json:"ssl_cert"`
	SSLKey         string                  `json:"ssl_key"`
	NodesStatus    *NodeBalancerNodeStatus `json:"nodes_status"`
}

NodeBalancerConfig objects allow a NodeBalancer to accept traffic on a new port

func (NodeBalancerConfig) GetCreateOptions

GetCreateOptions converts a NodeBalancerConfig to NodeBalancerConfigCreateOptions for use in CreateNodeBalancerConfig

func (NodeBalancerConfig) GetRebuildOptions added in v0.5.0

GetRebuildOptions converts a NodeBalancerConfig to NodeBalancerConfigRebuildOptions for use in RebuildNodeBalancerConfig

func (NodeBalancerConfig) GetUpdateOptions

GetUpdateOptions converts a NodeBalancerConfig to NodeBalancerConfigUpdateOptions for use in UpdateNodeBalancerConfig

type NodeBalancerConfigCreateOptions

type NodeBalancerConfigCreateOptions struct {
	Port          int                             `json:"port"`
	Protocol      ConfigProtocol                  `json:"protocol,omitempty"`
	Algorithm     ConfigAlgorithm                 `json:"algorithm,omitempty"`
	Stickiness    ConfigStickiness                `json:"stickiness,omitempty"`
	Check         ConfigCheck                     `json:"check,omitempty"`
	CheckInterval int                             `json:"check_interval,omitempty"`
	CheckAttempts int                             `json:"check_attempts,omitempty"`
	CheckPath     string                          `json:"check_path,omitempty"`
	CheckBody     string                          `json:"check_body,omitempty"`
	CheckPassive  *bool                           `json:"check_passive,omitempty"`
	CheckTimeout  int                             `json:"check_timeout,omitempty"`
	CipherSuite   ConfigCipher                    `json:"cipher_suite,omitempty"`
	SSLCert       string                          `json:"ssl_cert,omitempty"`
	SSLKey        string                          `json:"ssl_key,omitempty"`
	Nodes         []NodeBalancerNodeCreateOptions `json:"nodes,omitempty"`
}

NodeBalancerConfigCreateOptions are permitted by CreateNodeBalancerConfig

type NodeBalancerConfigRebuildOptions added in v0.5.0

type NodeBalancerConfigRebuildOptions struct {
	Port          int                             `json:"port"`
	Protocol      ConfigProtocol                  `json:"protocol,omitempty"`
	Algorithm     ConfigAlgorithm                 `json:"algorithm,omitempty"`
	Stickiness    ConfigStickiness                `json:"stickiness,omitempty"`
	Check         ConfigCheck                     `json:"check,omitempty"`
	CheckInterval int                             `json:"check_interval,omitempty"`
	CheckAttempts int                             `json:"check_attempts,omitempty"`
	CheckPath     string                          `json:"check_path,omitempty"`
	CheckBody     string                          `json:"check_body,omitempty"`
	CheckPassive  *bool                           `json:"check_passive,omitempty"`
	CheckTimeout  int                             `json:"check_timeout,omitempty"`
	CipherSuite   ConfigCipher                    `json:"cipher_suite,omitempty"`
	SSLCert       string                          `json:"ssl_cert,omitempty"`
	SSLKey        string                          `json:"ssl_key,omitempty"`
	Nodes         []NodeBalancerNodeCreateOptions `json:"nodes"`
}

NodeBalancerConfigRebuildOptions used by RebuildNodeBalancerConfig

type NodeBalancerConfigUpdateOptions

type NodeBalancerConfigUpdateOptions NodeBalancerConfigCreateOptions

NodeBalancerConfigUpdateOptions are permitted by UpdateNodeBalancerConfig

type NodeBalancerConfigsPagedResponse

type NodeBalancerConfigsPagedResponse struct {
	*PageOptions
	Data []NodeBalancerConfig `json:"data"`
}

NodeBalancerConfigsPagedResponse represents a paginated NodeBalancerConfig API response

type NodeBalancerCreateOptions

type NodeBalancerCreateOptions struct {
	Label              *string                            `json:"label,omitempty"`
	Region             string                             `json:"region,omitempty"`
	ClientConnThrottle *int                               `json:"client_conn_throttle,omitempty"`
	Configs            []*NodeBalancerConfigCreateOptions `json:"configs,omitempty"`
	Tags               []string                           `json:"tags"`
}

NodeBalancerCreateOptions are the options permitted for CreateNodeBalancer

type NodeBalancerNode

type NodeBalancerNode struct {
	ID             int      `json:"id"`
	Address        string   `json:"address"`
	Label          string   `json:"label"`
	Status         string   `json:"status"`
	Weight         int      `json:"weight"`
	Mode           NodeMode `json:"mode"`
	ConfigID       int      `json:"config_id"`
	NodeBalancerID int      `json:"nodebalancer_id"`
}

NodeBalancerNode objects represent a backend that can accept traffic for a NodeBalancer Config

func (NodeBalancerNode) GetCreateOptions

func (i NodeBalancerNode) GetCreateOptions() NodeBalancerNodeCreateOptions

GetCreateOptions converts a NodeBalancerNode to NodeBalancerNodeCreateOptions for use in CreateNodeBalancerNode

func (NodeBalancerNode) GetUpdateOptions

func (i NodeBalancerNode) GetUpdateOptions() NodeBalancerNodeUpdateOptions

GetUpdateOptions converts a NodeBalancerNode to NodeBalancerNodeUpdateOptions for use in UpdateNodeBalancerNode

type NodeBalancerNodeCreateOptions

type NodeBalancerNodeCreateOptions struct {
	Address string   `json:"address"`
	Label   string   `json:"label"`
	Weight  int      `json:"weight,omitempty"`
	Mode    NodeMode `json:"mode,omitempty"`
}

NodeBalancerNodeCreateOptions fields are those accepted by CreateNodeBalancerNode

type NodeBalancerNodeStatus

type NodeBalancerNodeStatus struct {
	Up   int `json:"up"`
	Down int `json:"down"`
}

NodeBalancerNodeStatus represents the total number of nodes whose status is Up or Down

type NodeBalancerNodeUpdateOptions

type NodeBalancerNodeUpdateOptions struct {
	Address string   `json:"address,omitempty"`
	Label   string   `json:"label,omitempty"`
	Weight  int      `json:"weight,omitempty"`
	Mode    NodeMode `json:"mode,omitempty"`
}

NodeBalancerNodeUpdateOptions fields are those accepted by UpdateNodeBalancerNode

type NodeBalancerNodesPagedResponse

type NodeBalancerNodesPagedResponse struct {
	*PageOptions
	Data []NodeBalancerNode `json:"data"`
}

NodeBalancerNodesPagedResponse represents a paginated NodeBalancerNode API response

type NodeBalancerTransfer

type NodeBalancerTransfer struct {
	// The total transfer, in MB, used by this NodeBalancer this month.
	Total *float64 `json:"total"`
	// The total inbound transfer, in MB, used for this NodeBalancer this month.
	Out *float64 `json:"out"`
	// The total outbound transfer, in MB, used for this NodeBalancer this month.
	In *float64 `json:"in"`
}

NodeBalancerTransfer contains information about the amount of transfer a NodeBalancer has had in the current month

type NodeBalancerUpdateOptions

type NodeBalancerUpdateOptions struct {
	Label              *string   `json:"label,omitempty"`
	ClientConnThrottle *int      `json:"client_conn_throttle,omitempty"`
	Tags               *[]string `json:"tags,omitempty"`
}

NodeBalancerUpdateOptions are the options permitted for UpdateNodeBalancer

type NodeBalancersPagedResponse

type NodeBalancersPagedResponse struct {
	*PageOptions
	Data []NodeBalancer `json:"data"`
}

NodeBalancersPagedResponse represents a paginated NodeBalancer API response

type NodeMode added in v0.2.0

type NodeMode string

NodeMode is the mode a NodeBalancer should use when sending traffic to a NodeBalancer Node

var (
	// ModeAccept is the NodeMode indicating a NodeBalancer Node is accepting traffic
	ModeAccept NodeMode = "accept"

	// ModeReject is the NodeMode indicating a NodeBalancer Node is not receiving traffic
	ModeReject NodeMode = "reject"

	// ModeDrain is the NodeMode indicating a NodeBalancer Node is not receiving new traffic, but may continue receiving traffic from pinned connections
	ModeDrain NodeMode = "drain"
)

type Notification

type Notification struct {
	UntilStr string `json:"until"`
	WhenStr  string `json:"when"`

	Label    string               `json:"label"`
	Body     *string              `json:"body"`
	Message  string               `json:"message"`
	Type     NotificationType     `json:"type"`
	Severity NotificationSeverity `json:"severity"`
	Entity   *NotificationEntity  `json:"entity"`
	Until    *time.Time           `json:"-"`
	When     *time.Time           `json:"-"`
}

Notification represents a notification on an Account

type NotificationEntity

type NotificationEntity struct {
	ID    int    `json:"id"`
	Label string `json:"label"`
	Type  string `json:"type"`
	URL   string `json:"url"`
}

NotificationEntity adds detailed information about the Notification. This could refer to the ticket that triggered the notification, for example.

type NotificationSeverity added in v0.7.1

type NotificationSeverity string

NotificationSeverity constants start with Notification and include all known Linode API Notification Severities.

const (
	NotificationMinor    NotificationSeverity = "minor"
	NotificationMajor    NotificationSeverity = "major"
	NotificationCritical NotificationSeverity = "critical"
)

NotificationSeverity constants represent the actions that cause a Notification. New severities may be added in the future.

type NotificationType added in v0.7.1

type NotificationType string

NotificationType constants start with Notification and include all known Linode API Notification Types.

const (
	NotificationMigrationScheduled NotificationType = "migration_scheduled"
	NotificationMigrationImminent  NotificationType = "migration_imminent"
	NotificationMigrationPending   NotificationType = "migration_pending"
	NotificationRebootScheduled    NotificationType = "reboot_scheduled"
	NotificationOutage             NotificationType = "outage"
	NotificationPaymentDue         NotificationType = "payment_due"
	NotificationTicketImportant    NotificationType = "ticket_important"
	NotificationTicketAbuse        NotificationType = "ticket_abuse"
	NotificationNotice             NotificationType = "notice"
	NotificationMaintenance        NotificationType = "maintenance"
)

NotificationType constants represent the actions that cause a Notification. New types may be added in the future.

type NotificationsPagedResponse

type NotificationsPagedResponse struct {
	*PageOptions
	Data []Notification `json:"data"`
}

NotificationsPagedResponse represents a paginated Notifications API response

type OAuthClient added in v0.12.3

type OAuthClient struct {
	// The unique ID of this OAuth Client.
	ID string `json:"id"`

	// The location a successful log in from https://login.linode.com should be redirected to for this client. The receiver of this redirect should be ready to accept an OAuth exchange code and finish the OAuth exchange.
	RedirectURI string `json:"redirect_uri"`

	// The name of this application. This will be presented to users when they are asked to grant it access to their Account.
	Label string `json:"label"`

	// Current status of the OAuth Client, Enum: "active" "disabled" "suspended"
	Status OAuthClientStatus `json:"status"`

	// The OAuth Client secret, used in the OAuth exchange. This is returned as <REDACTED> except when an OAuth Client is created or its secret is reset. This is a secret, and should not be shared or disclosed publicly.
	Secret string `json:"secret"`

	// If this OAuth Client is public or private.
	Public bool `json:"public"`

	// The URL where this client's thumbnail may be viewed, or nil if this client does not have a thumbnail set.
	ThumbnailURL *string `json:"thumbnail_url"`
}

OAuthClient represents a OAuthClient object

func (OAuthClient) GetCreateOptions added in v0.12.3

func (i OAuthClient) GetCreateOptions() (o OAuthClientCreateOptions)

GetCreateOptions converts a OAuthClient to OAuthClientCreateOptions for use in CreateOAuthClient

func (OAuthClient) GetUpdateOptions added in v0.12.3

func (i OAuthClient) GetUpdateOptions() (o OAuthClientUpdateOptions)

GetUpdateOptions converts a OAuthClient to OAuthClientUpdateOptions for use in UpdateOAuthClient

type OAuthClientCreateOptions added in v0.12.3

type OAuthClientCreateOptions struct {
	// The location a successful log in from https://login.linode.com should be redirected to for this client. The receiver of this redirect should be ready to accept an OAuth exchange code and finish the OAuth exchange.
	RedirectURI string `json:"redirect_uri"`

	// The name of this application. This will be presented to users when they are asked to grant it access to their Account.
	Label string `json:"label"`

	// If this OAuth Client is public or private.
	Public bool `json:"public"`
}

OAuthClientCreateOptions fields are those accepted by CreateOAuthClient

type OAuthClientStatus added in v0.12.3

type OAuthClientStatus string

OAuthClientStatus constants start with OAuthClient and include Linode API Instance Status values

const (
	OAuthClientActive    OAuthClientStatus = "active"
	OAuthClientDisabled  OAuthClientStatus = "disabled"
	OAuthClientSuspended OAuthClientStatus = "suspended"
)

OAuthClientStatus constants reflect the current status of an OAuth Client

type OAuthClientUpdateOptions added in v0.12.3

type OAuthClientUpdateOptions struct {
	// The location a successful log in from https://login.linode.com should be redirected to for this client. The receiver of this redirect should be ready to accept an OAuth exchange code and finish the OAuth exchange.
	RedirectURI string `json:"redirect_uri"`

	// The name of this application. This will be presented to users when they are asked to grant it access to their Account.
	Label string `json:"label"`

	// If this OAuth Client is public or private.
	Public bool `json:"public"`
}

OAuthClientUpdateOptions fields are those accepted by UpdateOAuthClient

type OAuthClientsPagedResponse added in v0.12.3

type OAuthClientsPagedResponse struct {
	*PageOptions
	Data []OAuthClient `json:"data"`
}

OAuthClientsPagedResponse represents a paginated OAuthClient API response

type ObjectStorageBucket added in v0.12.3

type ObjectStorageBucket struct {
	CreatedStr string `json:"created"`

	Label   string `json:"label"`
	Cluster string `json:"cluster"`

	Created  *time.Time `json:"-"`
	Hostname string     `json:"hostname"`
}

ObjectStorageBucket represents a ObjectStorage object

type ObjectStorageBucketCreateOptions added in v0.12.3

type ObjectStorageBucketCreateOptions struct {
	Cluster string `json:"cluster"`
	Label   string `json:"label"`
}

ObjectStorageBucketCreateOptions fields are those accepted by CreateObjectStorageBucket

type ObjectStorageBucketsPagedResponse added in v0.12.3

type ObjectStorageBucketsPagedResponse struct {
	*PageOptions
	Data []ObjectStorageBucket `json:"data"`
}

ObjectStorageBucketsPagedResponse represents a paginated ObjectStorageBucket API response

type ObjectStorageCluster added in v0.12.3

type ObjectStorageCluster struct {
	ID               string `json:"id"`
	Domain           string `json:"domain"`
	Status           string `json:"status"`
	Region           string `json:"region"`
	StaticSiteDomain string `json:"static_site_domain"`
}

ObjectStorageCluster represents a linode object storage cluster object

type ObjectStorageClustersPagedResponse added in v0.12.3

type ObjectStorageClustersPagedResponse struct {
	*PageOptions
	Data []ObjectStorageCluster `json:"data"`
}

ObjectStorageClustersPagedResponse represents a linode API response for listing

type ObjectStorageKey added in v0.12.3

type ObjectStorageKey struct {
	ID        int    `json:"id"`
	Label     string `json:"label"`
	AccessKey string `json:"access_key"`
	SecretKey string `json:"secret_key"`
}

ObjectStorageKey represents a linode object storage key object

type ObjectStorageKeyCreateOptions added in v0.12.3

type ObjectStorageKeyCreateOptions struct {
	Label string `json:"label"`
}

ObjectStorageKeyCreateOptions fields are those accepted by CreateObjectStorageKey

type ObjectStorageKeyUpdateOptions added in v0.12.3

type ObjectStorageKeyUpdateOptions struct {
	Label string `json:"label"`
}

ObjectStorageKeyUpdateOptions fields are those accepted by UpdateObjectStorageKey

type ObjectStorageKeysPagedResponse added in v0.12.3

type ObjectStorageKeysPagedResponse struct {
	*PageOptions
	Data []ObjectStorageKey `json:"data"`
}

ObjectStorageKeysPagedResponse represents a linode API response for listing

type PageOptions

type PageOptions struct {
	Page    int `url:"page,omitempty" json:"page"`
	Pages   int `url:"pages,omitempty" json:"pages"`
	Results int `url:"results,omitempty" json:"results"`
}

PageOptions are the pagination parameters for List endpoints

type Payment added in v0.12.3

type Payment struct {
	// The unique ID of the Payment
	ID int `json:"id"`

	// The amount, in US dollars, of the Payment.
	USD json.Number `json:"usd,Number"`

	// When the Payment was made.
	DateStr string     `json:"date"`
	Date    *time.Time `json:"-"`
}

Payment represents a Payment object

func (Payment) GetCreateOptions added in v0.12.3

func (i Payment) GetCreateOptions() (o PaymentCreateOptions)

GetCreateOptions converts a Payment to PaymentCreateOptions for use in CreatePayment

type PaymentCreateOptions added in v0.12.3

type PaymentCreateOptions struct {
	// CVV (Card Verification Value) of the credit card to be used for the Payment
	CVV string `json:"cvv,omitempty"`

	// The amount, in US dollars, of the Payment
	USD json.Number `json:"usd,Number"`
}

PaymentCreateOptions fields are those accepted by CreatePayment

type PaymentsPagedResponse added in v0.12.3

type PaymentsPagedResponse struct {
	*PageOptions
	Data []Payment `json:"data"`
}

PaymentsPagedResponse represents a paginated Payment API response

type Profile added in v0.6.1

type Profile struct {
	UID                int              `json:"uid"`
	Username           string           `json:"username"`
	Email              string           `json:"email"`
	Timezone           string           `json:"timezone"`
	EmailNotifications bool             `json:"email_notifications"`
	IPWhitelistEnabled bool             `json:"ip_whitelist_enabled"`
	TwoFactorAuth      bool             `json:"two_factor_auth"`
	Restricted         bool             `json:"restricted"`
	LishAuthMethod     LishAuthMethod   `json:"lish_auth_method"`
	Referrals          ProfileReferrals `json:"referrals"`
	AuthorizedKeys     []string         `json:"authorized_keys"`
}

Profile represents a Profile object

func (Profile) GetUpdateOptions added in v0.6.1

func (i Profile) GetUpdateOptions() (o ProfileUpdateOptions)

GetUpdateOptions converts a Profile to ProfileUpdateOptions for use in UpdateProfile

type ProfileReferrals added in v0.6.1

type ProfileReferrals struct {
	Total     int     `json:"total"`
	Completed int     `json:"completed"`
	Pending   int     `json:"pending"`
	Credit    float64 `json:"credit"`
	Code      string  `json:"code"`
	URL       string  `json:"url"`
}

ProfileReferrals represent a User's status in the Referral Program

type ProfileUpdateOptions added in v0.6.1

type ProfileUpdateOptions struct {
	Email              string         `json:"email,omitempty"`
	Timezone           string         `json:"timezone,omitempty"`
	EmailNotifications *bool          `json:"email_notifications,omitempty"`
	IPWhitelistEnabled *bool          `json:"ip_whitelist_enabled,omitempty"`
	LishAuthMethod     LishAuthMethod `json:"lish_auth_method,omitempty"`
	AuthorizedKeys     *[]string      `json:"authorized_keys,omitempty"`
	TwoFactorAuth      *bool          `json:"two_factor_auth,omitempty"`
	Restricted         *bool          `json:"restricted,omitempty"`
}

ProfileUpdateOptions fields are those accepted by UpdateProfile

type Region

type Region struct {
	ID      string `json:"id"`
	Country string `json:"country"`
}

Region represents a linode region object

type RegionsPagedResponse

type RegionsPagedResponse struct {
	*PageOptions
	Data []Region `json:"data"`
}

RegionsPagedResponse represents a linode API response for listing

type Resource

type Resource struct {
	R  func(ctx context.Context) *resty.Request
	PR func(ctx context.Context) *resty.Request
	// contains filtered or unexported fields
}

Resource represents a linode API resource

func NewResource

func NewResource(client *Client, name string, endpoint string, useTemplate bool, singleType interface{}, pagedType interface{}) *Resource

NewResource is the factory to create a new Resource struct. If it has a template string the useTemplate bool must be set.

func (Resource) Endpoint

func (r Resource) Endpoint() (string, error)

Endpoint will return the non-templated endpoint string for resource

type RestoreInstanceOptions added in v0.2.0

type RestoreInstanceOptions struct {
	LinodeID  int  `json:"linode_id"`
	Overwrite bool `json:"overwrite"`
}

RestoreInstanceOptions fields are those accepted by InstanceRestore

type SSHKey added in v0.5.0

type SSHKey struct {
	ID         int        `json:"id"`
	Label      string     `json:"label"`
	SSHKey     string     `json:"ssh_key"`
	CreatedStr string     `json:"created"`
	Created    *time.Time `json:"-"`
}

SSHKey represents a SSHKey object

func (SSHKey) GetCreateOptions added in v0.5.0

func (i SSHKey) GetCreateOptions() (o SSHKeyCreateOptions)

GetCreateOptions converts a SSHKey to SSHKeyCreateOptions for use in CreateSSHKey

func (SSHKey) GetUpdateOptions added in v0.5.0

func (i SSHKey) GetUpdateOptions() (o SSHKeyUpdateOptions)

GetUpdateOptions converts a SSHKey to SSHKeyCreateOptions for use in UpdateSSHKey

type SSHKeyCreateOptions added in v0.5.0

type SSHKeyCreateOptions struct {
	Label  string `json:"label"`
	SSHKey string `json:"ssh_key"`
}

SSHKeyCreateOptions fields are those accepted by CreateSSHKey

type SSHKeyUpdateOptions added in v0.5.0

type SSHKeyUpdateOptions struct {
	Label string `json:"label"`
}

SSHKeyUpdateOptions fields are those accepted by UpdateSSHKey

type SSHKeysPagedResponse added in v0.5.0

type SSHKeysPagedResponse struct {
	*PageOptions
	Data []SSHKey `json:"data"`
}

SSHKeysPagedResponse represents a paginated SSHKey API response

type SortedObjects added in v0.6.0

type SortedObjects struct {
	Instances     []Instance
	Domains       []Domain
	Volumes       []Volume
	NodeBalancers []NodeBalancer
}

SortedObjects currently only includes Instances

type Stackscript

type Stackscript struct {
	CreatedStr string `json:"created"`
	UpdatedStr string `json:"updated"`

	ID                int               `json:"id"`
	Username          string            `json:"username"`
	Label             string            `json:"label"`
	Description       string            `json:"description"`
	Ordinal           int               `json:"ordinal"`
	LogoURL           string            `json:"logo_url"`
	Images            []string          `json:"images"`
	DeploymentsTotal  int               `json:"deployments_total"`
	DeploymentsActive int               `json:"deployments_active"`
	IsPublic          bool              `json:"is_public"`
	Created           *time.Time        `json:"-"`
	Updated           *time.Time        `json:"-"`
	RevNote           string            `json:"rev_note"`
	Script            string            `json:"script"`
	UserDefinedFields *[]StackscriptUDF `json:"user_defined_fields"`
	UserGravatarID    string            `json:"user_gravatar_id"`
}

Stackscript represents a Linode StackScript

func (Stackscript) GetCreateOptions

func (i Stackscript) GetCreateOptions() StackscriptCreateOptions

GetCreateOptions converts a Stackscript to StackscriptCreateOptions for use in CreateStackscript

func (Stackscript) GetUpdateOptions

func (i Stackscript) GetUpdateOptions() StackscriptUpdateOptions

GetUpdateOptions converts a Stackscript to StackscriptUpdateOptions for use in UpdateStackscript

type StackscriptCreateOptions

type StackscriptCreateOptions struct {
	Label       string   `json:"label"`
	Description string   `json:"description"`
	Images      []string `json:"images"`
	IsPublic    bool     `json:"is_public"`
	RevNote     string   `json:"rev_note"`
	Script      string   `json:"script"`
}

StackscriptCreateOptions fields are those accepted by CreateStackscript

type StackscriptUDF added in v0.4.0

type StackscriptUDF struct {
	// A human-readable label for the field that will serve as the input prompt for entering the value during deployment.
	Label string `json:"label"`

	// The name of the field.
	Name string `json:"name"`

	// An example value for the field.
	Example string `json:"example"`

	// A list of acceptable single values for the field.
	OneOf string `json:"oneOf,omitempty"`

	// A list of acceptable values for the field in any quantity, combination or order.
	ManyOf string `json:"manyOf,omitempty"`

	// The default value. If not specified, this value will be used.
	Default string `json:"default,omitempty"`
}

StackscriptUDF define a single variable that is accepted by a Stackscript

type StackscriptUpdateOptions

type StackscriptUpdateOptions StackscriptCreateOptions

StackscriptUpdateOptions fields are those accepted by UpdateStackscript

type StackscriptsPagedResponse

type StackscriptsPagedResponse struct {
	*PageOptions
	Data []Stackscript `json:"data"`
}

StackscriptsPagedResponse represents a paginated Stackscript API response

type StatsIO added in v0.12.3

type StatsIO struct {
	IO   [][]float64 `json:"io"`
	Swap [][]float64 `json:"swap"`
}

StatsIO represents an IO stats object

type StatsNet added in v0.12.3

type StatsNet struct {
	In         [][]float64 `json:"in"`
	Out        [][]float64 `json:"out"`
	PrivateIn  [][]float64 `json:"private_in"`
	PrivateOut [][]float64 `json:"private_out"`
}

StatsNet represents a network stats object

type Tag added in v0.6.0

type Tag struct {
	Label string `json:"label"`
}

Tag represents a Tag object

func (Tag) GetCreateOptions added in v0.6.0

func (i Tag) GetCreateOptions() (o TagCreateOptions)

GetCreateOptions converts a Tag to TagCreateOptions for use in CreateTag

type TagCreateOptions added in v0.6.0

type TagCreateOptions struct {
	Label         string `json:"label"`
	Linodes       []int  `json:"linodes,omitempty"`
	Domains       []int  `json:"domains,omitempty"`
	Volumes       []int  `json:"volumes,omitempty"`
	NodeBalancers []int  `json:"nodebalancers,omitempty"`
}

TagCreateOptions fields are those accepted by CreateTag

type TaggedObject added in v0.6.0

type TaggedObject struct {
	Type    string          `json:"type"`
	RawData json.RawMessage `json:"data"`
	Data    interface{}     `json:"-"`
}

TaggedObject represents a Tagged Object object

type TaggedObjectList added in v0.6.0

type TaggedObjectList []TaggedObject

TaggedObjectList are a list of TaggedObjects, as returning by ListTaggedObjects

func (TaggedObjectList) SortedObjects added in v0.6.0

func (t TaggedObjectList) SortedObjects() (SortedObjects, error)

SortedObjects converts a list of TaggedObjects into a Sorted Objects struct, for easier access

type TaggedObjectsPagedResponse added in v0.6.0

type TaggedObjectsPagedResponse struct {
	*PageOptions
	Data []TaggedObject `json:"data"`
}

TaggedObjectsPagedResponse represents a paginated Tag API response

type TagsPagedResponse added in v0.6.0

type TagsPagedResponse struct {
	*PageOptions
	Data []Tag `json:"data"`
}

TagsPagedResponse represents a paginated Tag API response

type Ticket

type Ticket struct {
	ID          int           `json:"id"`
	Attachments []string      `json:"attachments"`
	Closed      *time.Time    `json:"-"`
	Description string        `json:"description"`
	Entity      *TicketEntity `json:"entity"`
	GravatarID  string        `json:"gravatar_id"`
	Opened      *time.Time    `json:"-"`
	OpenedBy    string        `json:"opened_by"`
	Status      TicketStatus  `json:"status"`
	Summary     string        `json:"summary"`
	Updated     *time.Time    `json:"-"`
	UpdatedBy   string        `json:"updated_by"`
}

Ticket represents a support ticket object

type TicketEntity

type TicketEntity struct {
	ID    int    `json:"id"`
	Label string `json:"label"`
	Type  string `json:"type"`
	URL   string `json:"url"`
}

TicketEntity refers a ticket to a specific entity

type TicketRepliesPagedResponse added in v0.12.3

type TicketRepliesPagedResponse struct {
	*PageOptions
	Data []TicketReply `json:"data"`
}

TicketRepliesPagedResponse represents a paginated ticket replies API response

type TicketReply added in v0.12.3

type TicketReply struct {
	ID          int        `json:"id"`
	Created     *time.Time `json:"-"`
	GravatarID  string     `json:"gravatar_id"`
	Description string     `json:"description"`
	CreatedBy   string     `json:"created_by"`
	FromLinode  bool       `json:"from_linode"`
}

type TicketStatus added in v0.4.0

type TicketStatus string

TicketStatus constants start with Ticket and include Linode API Ticket Status values

const (
	TicketNew    TicketStatus = "new"
	TicketClosed TicketStatus = "closed"
	TicketOpen   TicketStatus = "open"
)

TicketStatus constants reflect the current status of a Ticket

type TicketsPagedResponse

type TicketsPagedResponse struct {
	*PageOptions
	Data []Ticket `json:"data"`
}

TicketsPagedResponse represents a paginated ticket API response

type Token added in v0.6.0

type Token struct {
	// This token's unique ID, which can be used to revoke it.
	ID int `json:"id"`

	// The scopes this token was created with. These define what parts of the Account the token can be used to access. Many command-line tools, such as the Linode CLI, require tokens with access to *. Tokens with more restrictive scopes are generally more secure.
	// Valid values are "*" or a comma separated list of scopes https://developers.linode.com/api/v4/#o-auth
	Scopes string `json:"scopes"`

	// This token's label. This is for display purposes only, but can be used to more easily track what you're using each token for. (1-100 Characters)
	Label string `json:"label"`

	// The token used to access the API. When the token is created, the full token is returned here. Otherwise, only the first 16 characters are returned.
	Token string `json:"token"`

	// The date and time this token was created.
	Created    *time.Time `json:"-"`
	CreatedStr string     `json:"created"`

	// When this token will expire. Personal Access Tokens cannot be renewed, so after this time the token will be completely unusable and a new token will need to be generated. Tokens may be created with "null" as their expiry and will never expire unless revoked.
	Expiry    *time.Time `json:"-"`
	ExpiryStr string     `json:"expiry"`
}

Token represents a Token object

func (Token) GetCreateOptions added in v0.6.0

func (i Token) GetCreateOptions() (o TokenCreateOptions)

GetCreateOptions converts a Token to TokenCreateOptions for use in CreateToken

func (Token) GetUpdateOptions added in v0.6.0

func (i Token) GetUpdateOptions() (o TokenUpdateOptions)

GetUpdateOptions converts a Token to TokenUpdateOptions for use in UpdateToken

type TokenCreateOptions added in v0.6.0

type TokenCreateOptions struct {
	// The scopes this token was created with. These define what parts of the Account the token can be used to access. Many command-line tools, such as the Linode CLI, require tokens with access to *. Tokens with more restrictive scopes are generally more secure.
	Scopes string `json:"scopes"`

	// This token's label. This is for display purposes only, but can be used to more easily track what you're using each token for. (1-100 Characters)
	Label string `json:"label"`

	// When this token will expire. Personal Access Tokens cannot be renewed, so after this time the token will be completely unusable and a new token will need to be generated. Tokens may be created with "null" as their expiry and will never expire unless revoked.
	Expiry *time.Time `json:"expiry"`
}

TokenCreateOptions fields are those accepted by CreateToken

type TokenUpdateOptions added in v0.6.0

type TokenUpdateOptions struct {
	// This token's label. This is for display purposes only, but can be used to more easily track what you're using each token for. (1-100 Characters)
	Label string `json:"label"`
}

TokenUpdateOptions fields are those accepted by UpdateToken

type TokensPagedResponse added in v0.6.0

type TokensPagedResponse struct {
	*PageOptions
	Data []Token `json:"data"`
}

TokensPagedResponse represents a paginated Token API response

type User added in v0.6.0

type User struct {
	Username   string   `json:"username"`
	Email      string   `json:"email"`
	Restricted bool     `json:"restricted"`
	SSHKeys    []string `json:"ssh_keys"`
}

User represents a User object

func (User) GetCreateOptions added in v0.6.0

func (i User) GetCreateOptions() (o UserCreateOptions)

GetCreateOptions converts a User to UserCreateOptions for use in CreateUser

func (User) GetUpdateOptions added in v0.6.0

func (i User) GetUpdateOptions() (o UserUpdateOptions)

GetUpdateOptions converts a User to UserUpdateOptions for use in UpdateUser

type UserCreateOptions added in v0.6.0

type UserCreateOptions struct {
	Username   string `json:"username"`
	Email      string `json:"email"`
	Restricted bool   `json:"restricted,omitempty"`
}

UserCreateOptions fields are those accepted by CreateUser

type UserUpdateOptions added in v0.6.0

type UserUpdateOptions struct {
	Username   string    `json:"username,omitempty"`
	Email      string    `json:"email,omitempty"`
	Restricted *bool     `json:"restricted,omitempty"`
	SSHKeys    *[]string `json:"ssh_keys,omitempty"`
}

UserUpdateOptions fields are those accepted by UpdateUser

type UsersPagedResponse added in v0.6.0

type UsersPagedResponse struct {
	*PageOptions
	Data []User `json:"data"`
}

UsersPagedResponse represents a paginated User API response

type Volume

type Volume struct {
	CreatedStr string `json:"created"`
	UpdatedStr string `json:"updated"`

	ID             int          `json:"id"`
	Label          string       `json:"label"`
	Status         VolumeStatus `json:"status"`
	Region         string       `json:"region"`
	Size           int          `json:"size"`
	LinodeID       *int         `json:"linode_id"`
	FilesystemPath string       `json:"filesystem_path"`
	Tags           []string     `json:"tags"`
	Created        time.Time    `json:"-"`
	Updated        time.Time    `json:"-"`
}

Volume represents a linode volume object

func (Volume) GetCreateOptions added in v0.7.0

func (v Volume) GetCreateOptions() (createOpts VolumeCreateOptions)

GetCreateOptions converts a Volume to VolumeCreateOptions for use in CreateVolume

func (Volume) GetUpdateOptions added in v0.7.0

func (v Volume) GetUpdateOptions() (updateOpts VolumeUpdateOptions)

GetUpdateOptions converts a Volume to VolumeUpdateOptions for use in UpdateVolume

type VolumeAttachOptions

type VolumeAttachOptions struct {
	LinodeID           int   `json:"linode_id"`
	ConfigID           int   `json:"config_id,omitempty"`
	PersistAcrossBoots *bool `json:"persist_across_boots,omitempty"`
}

VolumeAttachOptions fields are those accepted by AttachVolume

type VolumeCreateOptions

type VolumeCreateOptions struct {
	Label    string `json:"label,omitempty"`
	Region   string `json:"region,omitempty"`
	LinodeID int    `json:"linode_id,omitempty"`
	ConfigID int    `json:"config_id,omitempty"`
	// The Volume's size, in GiB. Minimum size is 10GiB, maximum size is 10240GiB. A "0" value will result in the default size.
	Size int `json:"size,omitempty"`
	// An array of tags applied to this object. Tags are for organizational purposes only.
	Tags               []string `json:"tags"`
	PersistAcrossBoots *bool    `json:"persist_across_boots,omitempty"`
}

VolumeCreateOptions fields are those accepted by CreateVolume

type VolumeStatus

type VolumeStatus string

VolumeStatus indicates the status of the Volume

const (
	// VolumeCreating indicates the Volume is being created and is not yet available for use
	VolumeCreating VolumeStatus = "creating"

	// VolumeActive indicates the Volume is online and available for use
	VolumeActive VolumeStatus = "active"

	// VolumeResizing indicates the Volume is in the process of upgrading its current capacity
	VolumeResizing VolumeStatus = "resizing"

	// VolumeContactSupport indicates there is a problem with the Volume. A support ticket must be opened to resolve the issue
	VolumeContactSupport VolumeStatus = "contact_support"
)

type VolumeUpdateOptions added in v0.7.0

type VolumeUpdateOptions struct {
	Label string    `json:"label,omitempty"`
	Tags  *[]string `json:"tags,omitempty"`
}

VolumeUpdateOptions fields are those accepted by UpdateVolume

type VolumesPagedResponse

type VolumesPagedResponse struct {
	*PageOptions
	Data []Volume `json:"data"`
}

VolumesPagedResponse represents a linode API response for listing of volumes

Jump to

Keyboard shortcuts

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