civogo

package module
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 12 Imported by: 78

README

Civogo - The Golang client library for Civo

go.dev reference Build Status Lint

Civogo is a Go client library for accessing the Civo cloud API.

You can view the client API docs at https://pkg.go.dev/github.com/civo/civogo and view the API documentation at https://api.civo.com

Install

go get github.com/civo/civogo

Usage

import "github.com/civo/civogo"

From there you create a Civo client specifying your API key and use public methods to interact with Civo's API.

Authentication

Your API key is listed within the Civo control panel's security page. You can also reset the token there, for example, if accidentally put it in source code and found it had been leaked.

You can then use your API key to create a new client:

package main

import (
	"context"
	"github.com/civo/civogo"
)

const (
    apiKey = "mykeygoeshere"
)

func main() {
  client, err := civogo.NewClient(apiKey)
  // ...
}

Examples

To create a new Instance:

config, err := client.NewInstanceConfig()
if err != nil {
  t.Errorf("Failed to create a new config: %s", err)
  return err
}

config.Hostname = "foo.example.com"

instance, err := client.CreateInstance(config)
if err != nil {
  t.Errorf("Failed to create instance: %s", err)
  return err
}

To get all Instances:

instances, err := client.ListAllInstances()
if err != nil {
  t.Errorf("Failed to create instance: %s", err)
  return err
}

for _, i := range instances {
    fmt.Println(i.Hostname)
}
Pagination

If a list of objects is paginated by the API, you must request pages individually. For example, to fetch all instances without using the ListAllInstances method:

func MyListAllInstances(client *civogo.Client) ([]civogo.Instance, error) {
    list := []civogo.Instance{}

    pageOfItems, err := client.ListInstances(1, 50)
    if err != nil {
        return []civogo.Instance{}, err
    }

    if pageOfItems.Pages == 1 {
        return pageOfItems.Items, nil
    }

    for page := 2;  page<=pageOfItems.Pages; page++ {
        pageOfItems, err := client.ListInstances(1, 50)
        if err != nil {
            return []civogo.Instance{}, err
        }

        list = append(list, pageOfItems.Items)
    }

    return list, nil
}

Contributing

If you want to get involved, we'd love to receive a pull request - or an offer to help over our KUBE100 Slack channel. Please see the contribution guidelines.

Documentation

Index

Constants

View Source
const (
	// DNSRecordTypeA represents an A record
	DNSRecordTypeA = "a"

	// DNSRecordTypeCName represents an CNAME record
	DNSRecordTypeCName = "cname"

	// DNSRecordTypeMX represents an MX record
	DNSRecordTypeMX = "mx"

	// DNSRecordTypeTXT represents an TXT record
	DNSRecordTypeTXT = "txt"
)
View Source
const ResultSuccess = "success"

ResultSuccess represents a successful SimpleResponse

View Source
const Version = "0.0.1"

Version represents the version of the CLI

Variables

View Source
var (
	// ErrDNSDomainNotFound is returned when the domain is not found
	ErrDNSDomainNotFound = fmt.Errorf("domain not found")

	// ErrDNSRecordNotFound is returned when the record is not found
	ErrDNSRecordNotFound = fmt.Errorf("record not found")
)

Functions

This section is empty.

Types

type ApplicationConfiguration added in v0.2.8

type ApplicationConfiguration map[string]string

ApplicationConfiguration is a configuration for installed application

type Charge

type Charge struct {
	Code          string    `json:"code"`
	Label         string    `json:"label"`
	From          time.Time `json:"from"`
	To            time.Time `json:"to"`
	NumHours      int       `json:"num_hours"`
	SizeGigabytes int       `json:"size_gb"`
}

Charge represents a Civo resource with number of hours within the specified billing period

type Client

type Client struct {
	BaseURL          *url.URL
	UserAgent        string
	APIKey           string
	LastJSONResponse string
	// contains filtered or unexported fields
}

Client is the means of connecting to the Civo API service

func NewAdvancedClientForTesting

func NewAdvancedClientForTesting(responses map[string]map[string]string) (*Client, *httptest.Server, error)

NewAdvancedClientForTesting initializes a Client connecting to a local test server and allows for specifying methods

func NewClient

func NewClient(apiKey string) (*Client, error)

NewClient initializes a Client connecting to the production API

func NewClientForTesting

func NewClientForTesting(responses map[string]string) (*Client, *httptest.Server, error)

NewClientForTesting initializes a Client connecting to a local test server

func NewClientForTestingWithServer

func NewClientForTestingWithServer(server *httptest.Server) (*Client, error)

NewClientForTestingWithServer initializes a Client connecting to a passed-in local test server

func NewClientWithURL

func NewClientWithURL(apiKey string, civoAPIURL string) (*Client, error)

NewClientWithURL initializes a Client with a specific API URL

func (*Client) AttachVolume

func (c *Client) AttachVolume(id string, instance string) (*SimpleResponse, error)

AttachVolume attaches a volume to an instance https://www.civo.com/api/volumes#attach-a-volume-to-an-instance

func (*Client) CreateDNSDomain

func (c *Client) CreateDNSDomain(name string) (*DNSDomain, error)

CreateDNSDomain registers a new Domain

func (*Client) CreateDNSRecord

func (c *Client) CreateDNSRecord(domainID string, r *DNSRecordConfig) (*DNSRecord, error)

CreateDNSRecord creates a new DNS record

func (*Client) CreateInstance

func (c *Client) CreateInstance(config *InstanceConfig) (*Instance, error)

CreateInstance creates a new instance in the account

func (*Client) CreateLoadBalancer

func (c *Client) CreateLoadBalancer(r *LoadBalancerConfig) (*LoadBalancer, error)

CreateLoadBalancer creates a new load balancer

func (*Client) CreateSnapshot

func (c *Client) CreateSnapshot(name string, r *SnapshotConfig) (*Snapshot, error)

CreateSnapshot create a new or update an old snapshot

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(r *WebhookConfig) (*Webhook, error)

CreateWebhook creates a new webhook

func (*Client) DecodeSimpleResponse

func (c *Client) DecodeSimpleResponse(resp []byte) (*SimpleResponse, error)

DecodeSimpleResponse parses a response body in to a SimpleResponse object

func (*Client) DeleteDNSDomain

func (c *Client) DeleteDNSDomain(d *DNSDomain) (*SimpleResponse, error)

DeleteDNSDomain deletes the Domain that matches the name

func (*Client) DeleteDNSRecord

func (c *Client) DeleteDNSRecord(r *DNSRecord) (*SimpleResponse, error)

DeleteDNSRecord deletes the DNS record

func (*Client) DeleteFirewall

func (c *Client) DeleteFirewall(id string) (*SimpleResponse, error)

DeleteFirewall deletes an firewall

func (*Client) DeleteFirewallRule

func (c *Client) DeleteFirewallRule(id string, ruleID string) (*SimpleResponse, error)

DeleteFirewallRule deletes an firewall

func (*Client) DeleteInstance

func (c *Client) DeleteInstance(id string) (*SimpleResponse, error)

DeleteInstance deletes an instance and frees its resources

func (*Client) DeleteKubernetesCluster

func (c *Client) DeleteKubernetesCluster(id string) (*SimpleResponse, error)

DeleteKubernetesCluster deletes a cluster

func (*Client) DeleteLoadBalancer

func (c *Client) DeleteLoadBalancer(id string) (*SimpleResponse, error)

DeleteLoadBalancer deletes a load balancer

func (*Client) DeleteNetwork

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

DeleteNetwork deletes a private network

func (*Client) DeleteSSHKey added in v0.2.0

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

DeleteSSHKey deletes an SSH key

func (*Client) DeleteSnapshot

func (c *Client) DeleteSnapshot(name string) (*SimpleResponse, error)

DeleteSnapshot deletes a snapshot

func (*Client) DeleteTemplate added in v0.2.1

func (c *Client) DeleteTemplate(id string) (*SimpleResponse, error)

DeleteTemplate deletes requested template

func (*Client) DeleteVolume

func (c *Client) DeleteVolume(id string) (*SimpleResponse, error)

DeleteVolume deletes a volumes https://www.civo.com/api/volumes#deleting-a-volume

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(id string) (*SimpleResponse, error)

DeleteWebhook deletes a webhook

func (*Client) DetachVolume

func (c *Client) DetachVolume(id string) (*SimpleResponse, error)

DetachVolume attach volume from any instances https://www.civo.com/api/volumes#attach-a-volume-to-an-instance

func (*Client) FindDNSDomain

func (c *Client) FindDNSDomain(search string) (*DNSDomain, error)

FindDNSDomain finds a domain name by either part of the ID or part of the name

func (*Client) FindFirewall

func (c *Client) FindFirewall(search string) (*Firewall, error)

FindFirewall finds a firewall by either part of the ID or part of the name

func (*Client) FindFirewallRule added in v0.1.7

func (c *Client) FindFirewallRule(firewallID string, search string) (*FirewallRule, error)

FindFirewallRule finds a firewall Rule by ID or part of the same

func (*Client) FindInstance

func (c *Client) FindInstance(search string) (*Instance, error)

FindInstance finds a instance by either part of the ID or part of the hostname

func (*Client) FindKubernetesCluster

func (c *Client) FindKubernetesCluster(search string) (*KubernetesCluster, error)

FindKubernetesCluster finds a Kubernetes cluster by either part of the ID or part of the name

func (*Client) FindLoadBalancer

func (c *Client) FindLoadBalancer(search string) (*LoadBalancer, error)

FindLoadBalancer finds a load balancer by either part of the ID or part of the name

func (*Client) FindNetwork

func (c *Client) FindNetwork(search string) (*Network, error)

FindNetwork finds a network by either part of the ID or part of the name

func (*Client) FindSSHKey

func (c *Client) FindSSHKey(search string) (*SSHKey, error)

FindSSHKey finds an SSH key by either part of the ID or part of the name

func (*Client) FindSnapshot

func (c *Client) FindSnapshot(search string) (*Snapshot, error)

FindSnapshot finds a snapshot by either part of the ID or part of the name

func (*Client) FindVolume

func (c *Client) FindVolume(search string) (*Volume, error)

FindVolume finds a volume by either part of the ID or part of the name

func (*Client) FindWebhook

func (c *Client) FindWebhook(search string) (*Webhook, error)

FindWebhook finds a webhook by either part of the ID or part of the name

func (*Client) GetDNSDomain

func (c *Client) GetDNSDomain(name string) (*DNSDomain, error)

GetDNSDomain returns the DNS Domain that matches the name

func (*Client) GetDNSRecord

func (c *Client) GetDNSRecord(domainID, domainRecordID string) (*DNSRecord, error)

GetDNSRecord returns the Record that matches the domain ID and domain record ID

func (*Client) GetDefaultNetwork

func (c *Client) GetDefaultNetwork() (*Network, error)

GetDefaultNetwork finds the default private network for an account

func (*Client) GetInstance

func (c *Client) GetInstance(id string) (*Instance, error)

GetInstance returns a single Instance by its full ID

func (*Client) GetInstanceConsoleURL added in v0.1.1

func (c *Client) GetInstanceConsoleURL(id string) (string, error)

GetInstanceConsoleURL gets the web URL for an instance's console

func (*Client) GetKubernetesClusters

func (c *Client) GetKubernetesClusters(id string) (*KubernetesCluster, error)

GetKubernetesClusters returns a single kubernetes cluster by its full ID

func (*Client) GetQuota

func (c *Client) GetQuota() (*Quota, error)

GetQuota returns all load balancers owned by the calling API account

func (*Client) GetTemplateByCode

func (c *Client) GetTemplateByCode(code string) (*Template, error)

GetTemplateByCode finds the Template for an account with the specified code

func (*Client) HardRebootInstance

func (c *Client) HardRebootInstance(id string) (*SimpleResponse, error)

HardRebootInstance harshly reboots an instance (like shutting the power off and booting it again)

func (*Client) ListAllInstances

func (c *Client) ListAllInstances() ([]Instance, error)

ListAllInstances returns all (well, upto 99,999,999 instances) Instances owned by the calling API account

func (*Client) ListAvailableKubernetesVersions

func (c *Client) ListAvailableKubernetesVersions() ([]KubernetesVersion, error)

ListAvailableKubernetesVersions returns all version of kubernetes available

func (*Client) ListCharges

func (c *Client) ListCharges(from, to time.Time) ([]Charge, error)

ListCharges returns all charges for the calling API account

func (*Client) ListDNSDomains

func (c *Client) ListDNSDomains() ([]DNSDomain, error)

ListDNSDomains returns all Domains owned by the calling API account

func (*Client) ListDNSRecords

func (c *Client) ListDNSRecords(dnsDomainID string) ([]DNSRecord, error)

ListDNSRecords returns all the records associated with domainID

func (*Client) ListFirewallRules

func (c *Client) ListFirewallRules(id string) ([]FirewallRule, error)

ListFirewallRules get all rules for a firewall

func (*Client) ListFirewalls

func (c *Client) ListFirewalls() ([]Firewall, error)

ListFirewalls returns all firewall owned by the calling API account

func (*Client) ListInstanceSizes

func (c *Client) ListInstanceSizes() ([]InstanceSize, error)

ListInstanceSizes returns all availble sizes of instances

func (*Client) ListInstances

func (c *Client) ListInstances(page int, perPage int) (*PaginatedInstanceList, error)

ListInstances returns a page of Instances owned by the calling API account

func (*Client) ListKubernetesClusters

func (c *Client) ListKubernetesClusters() (*PaginatedKubernetesClusters, error)

ListKubernetesClusters returns all cluster of kubernetes in the account

func (*Client) ListKubernetesMarketplaceApplications

func (c *Client) ListKubernetesMarketplaceApplications() ([]KubernetesMarketplaceApplication, error)

ListKubernetesMarketplaceApplications returns all application inside marketplace

func (*Client) ListLoadBalancers

func (c *Client) ListLoadBalancers() ([]LoadBalancer, error)

ListLoadBalancers returns all load balancers owned by the calling API account

func (*Client) ListNetworks

func (c *Client) ListNetworks() ([]Network, error)

ListNetworks list all private networks

func (*Client) ListRegions

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

ListRegions returns all load balancers owned by the calling API account

func (*Client) ListSSHKeys

func (c *Client) ListSSHKeys() ([]SSHKey, error)

ListSSHKeys list all SSH key for an account

func (*Client) ListSnapshots

func (c *Client) ListSnapshots() ([]Snapshot, error)

ListSnapshots returns a list of all snapshots within the current account

func (*Client) ListTemplates added in v0.2.1

func (c *Client) ListTemplates() ([]Template, error)

ListTemplates return all template in system

func (*Client) ListVolumes

func (c *Client) ListVolumes() ([]Volume, error)

ListVolumes returns all volumes owned by the calling API account https://www.civo.com/api/volumes#list-volumes

func (*Client) ListWebhooks

func (c *Client) ListWebhooks() ([]Webhook, error)

ListWebhooks returns a list of all webhook within the current account

func (*Client) MovePublicIPToInstance

func (c *Client) MovePublicIPToInstance(id, ipAddress string) (*SimpleResponse, error)

MovePublicIPToInstance moves a public IP to the specified instance

func (*Client) NewFirewall

func (c *Client) NewFirewall(name string) (*FirewallResult, error)

NewFirewall creates a new firewall record

func (*Client) NewFirewallRule

func (c *Client) NewFirewallRule(r *FirewallRuleConfig) (*FirewallRule, error)

NewFirewallRule creates a new rule within a firewall

func (*Client) NewInstanceConfig

func (c *Client) NewInstanceConfig() (*InstanceConfig, error)

NewInstanceConfig returns an initialized config for a new instance

func (*Client) NewKubernetesClusters

func (c *Client) NewKubernetesClusters(kc *KubernetesClusterConfig) (*KubernetesCluster, error)

NewKubernetesClusters create a new cluster of kubernetes

func (*Client) NewNetwork

func (c *Client) NewNetwork(label string) (*NetworkResult, error)

NewNetwork creates a new private network

func (*Client) NewSSHKey added in v0.2.0

func (c *Client) NewSSHKey(name string, publicKey string) (*SimpleResponse, error)

NewSSHKey creates a new SSH key record

func (*Client) NewTemplate added in v0.2.1

func (c *Client) NewTemplate(conf *Template) (*SimpleResponse, error)

NewTemplate will create a new template for the current user

func (*Client) NewVolume

func (c *Client) NewVolume(v *VolumeConfig) (*VolumeResult, error)

NewVolume creates a new volume https://www.civo.com/api/volumes#create-a-new-volume

func (*Client) RebootInstance

func (c *Client) RebootInstance(id string) (*SimpleResponse, error)

RebootInstance reboots an instance (short version of HardRebootInstance)

func (*Client) RecycleKubernetesCluster

func (c *Client) RecycleKubernetesCluster(id string, hostname string) (*SimpleResponse, error)

RecycleKubernetesCluster create a new cluster of kubernetes

func (*Client) RenameFirewall added in v0.1.9

func (c *Client) RenameFirewall(id string, name string) (*SimpleResponse, error)

RenameFirewall rename firewall

func (*Client) RenameNetwork

func (c *Client) RenameNetwork(label, id string) (*NetworkResult, error)

RenameNetwork renames an existing private network

func (*Client) ResizeVolume

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

ResizeVolume resizes a volume https://www.civo.com/api/volumes#resizing-a-volume

func (*Client) SendDeleteRequest

func (c *Client) SendDeleteRequest(requestURL string) ([]byte, error)

SendDeleteRequest sends a correctly authenticated delete request to the API server

func (*Client) SendGetRequest

func (c *Client) SendGetRequest(requestURL string) ([]byte, error)

SendGetRequest sends a correctly authenticated get request to the API server

func (*Client) SendPostRequest

func (c *Client) SendPostRequest(requestURL string, params interface{}) ([]byte, error)

SendPostRequest sends a correctly authenticated post request to the API server

func (*Client) SendPutRequest

func (c *Client) SendPutRequest(requestURL string, params interface{}) ([]byte, error)

SendPutRequest sends a correctly authenticated put request to the API server

func (*Client) SetInstanceFirewall

func (c *Client) SetInstanceFirewall(id, firewallID string) (*SimpleResponse, error)

SetInstanceFirewall changes the current firewall for an instance

func (*Client) SetInstanceTags

func (c *Client) SetInstanceTags(i *Instance, tags string) (*SimpleResponse, error)

SetInstanceTags sets the tags for the specified instance

func (*Client) SoftRebootInstance

func (c *Client) SoftRebootInstance(id string) (*SimpleResponse, error)

SoftRebootInstance requests the VM to shut down nicely

func (*Client) StartInstance

func (c *Client) StartInstance(id string) (*SimpleResponse, error)

StartInstance starts the instance booting from the shutdown state

func (*Client) StopInstance

func (c *Client) StopInstance(id string) (*SimpleResponse, error)

StopInstance shuts the power down to the instance

func (*Client) UpdateDNSDomain

func (c *Client) UpdateDNSDomain(d *DNSDomain, name string) (*DNSDomain, error)

UpdateDNSDomain updates the provided domain with name

func (*Client) UpdateDNSRecord added in v0.1.4

func (c *Client) UpdateDNSRecord(r *DNSRecord, rc *DNSRecordConfig) (*DNSRecord, error)

UpdateDNSRecord updates the DNS record

func (*Client) UpdateInstance

func (c *Client) UpdateInstance(i *Instance) (*SimpleResponse, error)

UpdateInstance updates an Instance's hostname, reverse DNS or notes

func (*Client) UpdateKubernetesCluster

func (c *Client) UpdateKubernetesCluster(id string, i *KubernetesClusterConfig) (*KubernetesCluster, error)

UpdateKubernetesCluster update a single kubernetes cluster by its full ID

func (*Client) UpdateLoadBalancer

func (c *Client) UpdateLoadBalancer(id string, r *LoadBalancerConfig) (*LoadBalancer, error)

UpdateLoadBalancer updates a load balancer

func (*Client) UpdateSSHKey added in v0.2.0

func (c *Client) UpdateSSHKey(name string, sshKeyID string) (*SSHKey, error)

UpdateSSHKey update a SSH key record

func (*Client) UpdateTemplate added in v0.2.1

func (c *Client) UpdateTemplate(id string, conf *Template) (*Template, error)

UpdateTemplate will update a template for the current user

func (*Client) UpdateWebhook

func (c *Client) UpdateWebhook(id string, r *WebhookConfig) (*Webhook, error)

UpdateWebhook updates a webhook

func (*Client) UpgradeInstance

func (c *Client) UpgradeInstance(id, newSize string) (*SimpleResponse, error)

UpgradeInstance resizes the instance up to the new specification it's not possible to resize the instance to a smaller size

type DNSDomain

type DNSDomain struct {
	// The ID of the domain
	ID string `json:"id"`

	// The ID of the account
	AccountID string `json:"account_id"`

	// The Name of the domain
	Name string `json:"name"`
}

DNSDomain represents a domain registered within Civo's infrastructure

type DNSRecord

type DNSRecord struct {
	ID          string        `json:"id"`
	AccountID   string        `json:"account_id"`
	DNSDomainID string        `json:"domain_id"`
	Name        string        `json:"name"`
	Value       string        `json:"value"`
	Type        DNSRecordType `json:"type"`
	Priority    int           `json:"priority"`
	TTL         int           `json:"ttl"`
	CreatedAt   time.Time     `json:"created_at"`
	UpdatedAt   time.Time     `json:"updated_at"`
}

DNSRecord represents a DNS record registered within Civo's infrastructure

type DNSRecordConfig

type DNSRecordConfig struct {
	Type     DNSRecordType `json:"type"`
	Name     string        `json:"name"`
	Value    string        `json:"value"`
	Priority int           `json:"priority"`
	TTL      int           `json:"ttl"`
}

DNSRecordConfig describes the parameters for a new DNS record none of the fields are mandatory and will be automatically set with default values

type DNSRecordType

type DNSRecordType string

DNSRecordType represents the allowed record types: a, cname, mx or txt

type Firewall

type Firewall struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	RulesCount     int    `json:"rules_count"`
	InstancesCount int    `json:"instances_count"`
	Region         string `json:"region"`
}

Firewall represents list of rule in Civo's infrastructure

type FirewallResult

type FirewallResult struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Result string `json:"result"`
}

FirewallResult is the response from the Civo Firewall APIs

type FirewallRule

type FirewallRule struct {
	ID         string   `json:"id"`
	FirewallID string   `json:"firewall_id"`
	Protocol   string   `json:"protocol"`
	StartPort  string   `json:"start_port"`
	EndPort    string   `json:"end_port"`
	Cidr       []string `json:"cidr"`
	Direction  string   `json:"direction"`
	Label      string   `json:"label,omitempty"`
}

FirewallRule represents a single rule for a given firewall, regarding which ports to open and which protocol, to which CIDR

type FirewallRuleConfig

type FirewallRuleConfig struct {
	FirewallID string   `json:"firewall_id"`
	Protocol   string   `json:"protocol"`
	StartPort  string   `json:"start_port"`
	EndPort    string   `json:"end_port"`
	Cidr       []string `json:"cidr"`
	Direction  string   `json:"direction"`
	Label      string   `json:"label,omitempty"`
}

FirewallRuleConfig is how you specify the details when creating a new rule

type HTTPError

type HTTPError struct {
	Code   int
	Status string
	Reason string
}

HTTPError is the error returned when the API fails with an HTTP error

func (HTTPError) Error

func (e HTTPError) Error() string

type Instance

type Instance struct {
	ID                       string    `json:"id"`
	OpenstackServerID        string    `json:"openstack_server_id"`
	Hostname                 string    `json:"hostname"`
	ReverseDNS               string    `json:"reverse_dns"`
	Size                     string    `json:"size"`
	Region                   string    `json:"region"`
	NetworkID                string    `json:"network_id"`
	PrivateIP                string    `json:"private_ip"`
	PublicIP                 string    `json:"public_ip"`
	PseudoIP                 string    `json:"pseudo_ip"`
	TemplateID               string    `json:"template_id"`
	SnapshotID               string    `json:"snapshot_id"`
	InitialUser              string    `json:"initial_user"`
	InitialPassword          string    `json:"initial_password"`
	SSHKey                   string    `json:"ssh_key"`
	Status                   string    `json:"status"`
	Notes                    string    `json:"notes"`
	FirewallID               string    `json:"firewall_id"`
	Tags                     []string  `json:"tags"`
	CivostatsdToken          string    `json:"civostatsd_token"`
	CivostatsdStats          string    `json:"civostatsd_stats"`
	CivostatsdStatsPerMinute []string  `json:"civostatsd_stats_per_minute"`
	CivostatsdStatsPerHour   []string  `json:"civostatsd_stats_per_hour"`
	OpenstackImageID         string    `json:"openstack_image_id"`
	RescuePassword           string    `json:"rescue_password"`
	VolumeBacked             bool      `json:"volume_backed"`
	CPUCores                 int       `json:"cpu_cores"`
	RAMMegabytes             int       `json:"ram_mb"`
	DiskGigabytes            int       `json:"disk_gb"`
	Script                   string    `json:"script"`
	CreatedAt                time.Time `json:"created_at"`
}

Instance represents a virtual server within Civo's infrastructure

type InstanceConfig

type InstanceConfig struct {
	Count            int      `json:"count"`
	Hostname         string   `json:"hostname"`
	ReverseDNS       string   `json:"reverse_dns"`
	Size             string   `json:"size"`
	Region           string   `json:"region"`
	PublicIPRequired string   `json:"public_ip_required"`
	NetworkID        string   `json:"network_id"`
	TemplateID       string   `json:"template_id"`
	SnapshotID       string   `json:"snapshot_id"`
	InitialUser      string   `json:"initial_user"`
	SSHKeyID         string   `json:"ssh_key_id"`
	Script           string   `json:"script"`
	Tags             []string `json:"-"`
	TagsList         string   `json:"tags"`
}

InstanceConfig describes the parameters for a new instance none of the fields are mandatory and will be automatically set with default values

type InstanceConsole added in v0.1.1

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

InstanceConsole represents a link to a webconsole for an instances

type InstanceSize

type InstanceSize struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	NiceName      string `json:"nice_name"`
	CPUCores      int    `json:"cpu_cores"`
	RAMMegabytes  int    `json:"ram_mb"`
	DiskGigabytes int    `json:"disk_gb"`
	Description   string `json:"description"`
	Selectable    bool   `json:"selectable"`
}

InstanceSize represents an available size for instances to launch

type KubernetesCluster

type KubernetesCluster struct {
	ID                    string                           `json:"id"`
	Name                  string                           `json:"name"`
	Version               string                           `json:"version"`
	Status                string                           `json:"status"`
	Ready                 bool                             `json:"ready"`
	NumTargetNode         int                              `json:"num_target_nodes"`
	TargetNodeSize        string                           `json:"target_nodes_size"`
	BuiltAt               time.Time                        `json:"built_at"`
	KubeConfig            string                           `json:"kubeconfig"`
	KubernetesVersion     string                           `json:"kubernetes_version"`
	APIEndPoint           string                           `json:"api_endpoint"`
	MasterIP              string                           `json:"master_ip"`
	DNSEntry              string                           `json:"dns_entry"`
	UpgradeAvailableTo    string                           `json:"upgrade_available_to"`
	Tags                  []string                         `json:"tags"`
	CreatedAt             time.Time                        `json:"created_at"`
	Instances             []KubernetesInstance             `json:"instances"`
	InstalledApplications []KubernetesInstalledApplication `json:"installed_applications"`
}

KubernetesCluster is a Kubernetes item inside the cluster

type KubernetesClusterConfig

type KubernetesClusterConfig struct {
	Name              string `json:"name"`
	NumTargetNodes    int    `json:"num_target_nodes"`
	TargetNodesSize   string `json:"target_nodes_size"`
	KubernetesVersion string `json:"kubernetes_version"`
	NodeDestroy       string `json:"node_destroy"`
	Tags              string `json:"tags"`
	Applications      string `json:"applications"`
}

KubernetesClusterConfig is used to create a new cluster

type KubernetesInstalledApplication

type KubernetesInstalledApplication struct {
	Application   string                              `json:"application"`
	Title         string                              `json:"title,omitempty"`
	Version       string                              `json:"version"`
	Dependencies  []string                            `json:"dependencies,omitempty"`
	Maintainer    string                              `json:"maintainer"`
	Description   string                              `json:"description"`
	PostInstall   string                              `json:"post_install"`
	Installed     bool                                `json:"installed"`
	URL           string                              `json:"url"`
	Category      string                              `json:"category"`
	UpdatedAt     time.Time                           `json:"updated_at"`
	ImageURL      string                              `json:"image_url"`
	Plan          string                              `json:"plan,omitempty"`
	Configuration map[string]ApplicationConfiguration `json:"configuration,omitempty"`
}

KubernetesInstalledApplication is an application within our marketplace available for installation

type KubernetesInstance

type KubernetesInstance struct {
	Hostname      string    `json:"hostname"`
	Size          string    `json:"size"`
	Region        string    `json:"region"`
	CreatedAt     time.Time `json:"created_at"`
	Status        string    `json:"status"`
	FirewallID    string    `json:"firewall_id"`
	PublicIP      string    `json:"public_ip"`
	CPUCores      int       `json:"cpu_cores"`
	RAMMegabytes  int       `json:"ram_mb"`
	DiskGigabytes int       `json:"disk_gb"`
	Tags          []string  `json:"tags"`
}

KubernetesInstance represents a single node/master within a Kubernetes cluster

type KubernetesMarketplaceApplication

type KubernetesMarketplaceApplication struct {
	Name         string                      `json:"name"`
	Title        string                      `json:"title,omitempty"`
	Version      string                      `json:"version"`
	Default      bool                        `json:"default,omitempty"`
	Dependencies []string                    `json:"dependencies,omitempty"`
	Maintainer   string                      `json:"maintainer"`
	Description  string                      `json:"description"`
	PostInstall  string                      `json:"post_install"`
	URL          string                      `json:"url"`
	Category     string                      `json:"category"`
	Plans        []KubernetesMarketplacePlan `json:"plans"`
}

KubernetesMarketplaceApplication is an application within our marketplace available for installation

type KubernetesMarketplacePlan

type KubernetesMarketplacePlan struct {
	Label         string                                 `json:"label"`
	Configuration map[string]KubernetesPlanConfiguration `json:"configuration"`
}

KubernetesMarketplacePlan is a plan for

type KubernetesPlanConfiguration

type KubernetesPlanConfiguration struct {
	Value string `json:"value"`
}

KubernetesPlanConfiguration is a value within a configuration for an application's plan

type KubernetesVersion

type KubernetesVersion struct {
	Version string `json:"version"`
	Type    string `json:"type"`
	Default bool   `json:"default,omitempty"`
}

KubernetesVersion represents an available version of k3s to install

type LoadBalancer

type LoadBalancer struct {
	ID                      string `json:"id"`
	DefaultHostname         bool   `json:"default_hostname"`
	Hostname                string `json:"hostname"`
	Protocol                string `json:"protocol"`
	Port                    int    `json:"port"`
	MaxRequestSize          int    `json:"max_request_size"`
	TLSCertificate          string `json:"tls_certificate"`
	TLSKey                  string `json:"tls_key"`
	Policy                  string `json:"policy"`
	HealthCheckPath         string `json:"health_check_path"`
	FailTimeout             int    `json:"fail_timeout"`
	MaxConns                int    `json:"max_conns"`
	IgnoreInvalidBackendTLS bool   `json:"ignore_invalid_backend_tls"`
	Backends                []LoadBalancerBackend
}

LoadBalancer represents a load balancer configuration within Civo

type LoadBalancerBackend

type LoadBalancerBackend struct {
	InstanceID string `json:"instance_id"`
	Protocol   string `json:"protocol"`
	Port       int    `json:"port"`
}

LoadBalancerBackend represents a backend instance being load-balanced

type LoadBalancerBackendConfig

type LoadBalancerBackendConfig struct {
	InstanceID string `json:"instance_id"`
	Protocol   string `json:"protocol"`
	Port       int    `json:"port"`
}

LoadBalancerBackendConfig is the configuration for creating backends

type LoadBalancerConfig

type LoadBalancerConfig struct {
	Hostname                string                      `json:"hostname"`
	Protocol                string                      `json:"protocol"`
	TLSCertificate          string                      `json:"tls_certificate"`
	TLSKey                  string                      `json:"tls_key"`
	Policy                  string                      `json:"policy"`
	Port                    int                         `json:"port"`
	MaxRequestSize          int                         `json:"max_request_size"`
	HealthCheckPath         string                      `json:"health_check_path"`
	FailTimeout             int                         `json:"fail_timeout"`
	MaxConns                int                         `json:"max_conns"`
	IgnoreInvalidBackendTLS bool                        `json:"ignore_invalid_backend_tls"`
	Backends                []LoadBalancerBackendConfig `json:"backends"`
}

LoadBalancerConfig represents a load balancer to be created

type Network

type Network struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Region  string `json:"region"`
	Default bool   `json:"default"`
	CIDR    string `json:"cidr"`
	Label   string `json:"label"`
}

Network represents a private network for instances to connect to

type NetworkResult

type NetworkResult struct {
	ID     string `json:"id"`
	Label  string `json:"label"`
	Result string `json:"result"`
}

NetworkResult represents the result from a network create/update call

type PaginatedInstanceList

type PaginatedInstanceList struct {
	Page    int        `json:"page"`
	PerPage int        `json:"per_page"`
	Pages   int        `json:"pages"`
	Items   []Instance `json:"items"`
}

PaginatedInstanceList returns a paginated list of Instance object

type PaginatedKubernetesClusters added in v0.2.4

type PaginatedKubernetesClusters struct {
	Page    int                 `json:"page"`
	PerPage int                 `json:"per_page"`
	Pages   int                 `json:"pages"`
	Items   []KubernetesCluster `json:"items"`
}

PaginatedKubernetesClusters is a Kubernetes k3s cluster

type Quota

type Quota struct {
	ID                      string `json:"id"`
	DefaultUserID           string `json:"default_user_id"`
	DefaultUserEmailAddress string `json:"default_user_email_address"`
	InstanceCountLimit      int    `json:"instance_count_limit"`
	InstanceCountUsage      int    `json:"instance_count_usage"`
	CPUCoreLimit            int    `json:"cpu_core_limit"`
	CPUCoreUsage            int    `json:"cpu_core_usage"`
	RAMMegabytesLimit       int    `json:"ram_mb_limit"`
	RAMMegabytesUsage       int    `json:"ram_mb_usage"`
	DiskGigabytesLimit      int    `json:"disk_gb_limit"`
	DiskGigabytesUsage      int    `json:"disk_gb_usage"`
	DiskVolumeCountLimit    int    `json:"disk_volume_count_limit"`
	DiskVolumeCountUsage    int    `json:"disk_volume_count_usage"`
	DiskSnapshotCountLimit  int    `json:"disk_snapshot_count_limit"`
	DiskSnapshotCountUsage  int    `json:"disk_snapshot_count_usage"`
	PublicIPAddressLimit    int    `json:"public_ip_address_limit"`
	PublicIPAddressUsage    int    `json:"public_ip_address_usage"`
	SubnetCountLimit        int    `json:"subnet_count_limit"`
	SubnetCountUsage        int    `json:"subnet_count_usage"`
	NetworkCountLimit       int    `json:"network_count_limit"`
	NetworkCountUsage       int    `json:"network_count_usage"`
	SecurityGroupLimit      int    `json:"security_group_limit"`
	SecurityGroupUsage      int    `json:"security_group_usage"`
	SecurityGroupRuleLimit  int    `json:"security_group_rule_limit"`
	SecurityGroupRuleUsage  int    `json:"security_group_rule_usage"`
	PortCountLimit          int    `json:"port_count_limit"`
	PortCountUsage          int    `json:"port_count_usage"`
}

Quota represents the available limits and usage for an account's Civo quota

type Region

type Region struct {
	Code    string `json:"code"`
	Name    string `json:"name"`
	Default bool   `json:"default"`
}

Region represents a geographical/DC region for Civo resources

type Result

type Result string

Result is the result of a SimpleResponse

type SSHKey

type SSHKey struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
}

SSHKey represents an SSH public key, uploaded to access instances

type SimpleResponse

type SimpleResponse struct {
	ID           string `json:"id"`
	Result       Result `json:"result"`
	ErrorCode    string `json:"code"`
	ErrorReason  string `json:"reason"`
	ErrorDetails string `json:"details"`
}

SimpleResponse is a structure that returns success and/or any error

type Snapshot

type Snapshot struct {
	ID            string    `json:"id"`
	InstanceID    string    `json:"instance_id"`
	Hostname      string    `json:"hostname"`
	Template      string    `json:"template_id"`
	Region        string    `json:"region"`
	Name          string    `json:"name"`
	Safe          int       `json:"safe"`
	SizeGigabytes int       `json:"size_gb"`
	State         string    `json:"state"`
	Cron          string    `json:"cron_timing,omitempty"`
	RequestedAt   time.Time `json:"requested_at,omitempty"`
	CompletedAt   time.Time `json:"completed_at,omitempty"`
}

Snapshot is a backup of an instance

type SnapshotConfig

type SnapshotConfig struct {
	InstanceID string `json:"instance_id"`
	Safe       bool   `json:"safe"`
	Cron       string `json:"cron_timing"`
}

SnapshotConfig represents the options required for creating a new snapshot

type Template

type Template struct {
	ID               string `json:"id"`
	Code             string `json:"code"`
	Name             string `json:"name"`
	AccountID        string `json:"account_id,omitempty"`
	ImageID          string `json:"image_id,omitempty"`
	VolumeID         string `json:"volume_id"`
	ShortDescription string `json:"short_description"`
	Description      string `json:"description"`
	DefaultUsername  string `json:"default_username"`
	CloudConfig      string `json:"cloud_config"`
}

Template represents a Template for launching instances from

type Volume

type Volume struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	InstanceID    string    `json:"instance_id"`
	MountPoint    string    `json:"mountpoint"`
	SizeGigabytes int       `json:"size_gb"`
	Bootable      bool      `json:"bootable"`
	CreatedAt     time.Time `json:"created_at"`
}

Volume is a block of attachable storage for our IAAS products https://www.civo.com/api/volumes

type VolumeConfig

type VolumeConfig struct {
	Name          string `json:"name"`
	SizeGigabytes int    `json:"size_gb"`
	Bootable      bool   `json:"bootable"`
}

VolumeConfig are the settings required to create a new Volume

type VolumeResult

type VolumeResult struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	Result string `json:"result"`
}

VolumeResult is the response from one of our simple API calls

type Webhook

type Webhook struct {
	ID                string   `json:"id"`
	Events            []string `json:"events"`
	URL               string   `json:"url"`
	Secret            string   `json:"secret"`
	Disabled          bool     `json:"disabled"`
	Failures          int      `json:"failures"`
	LasrFailureReason string   `json:"last_failure_reason"`
}

Webhook is a representation of a saved webhook callback from changes in Civo

type WebhookConfig

type WebhookConfig struct {
	Events []string `json:"events"`
	URL    string   `json:"url"`
	Secret string   `json:"secret"`
}

WebhookConfig represents the options required for creating a new webhook

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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