gobrightbox

package module
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 10 Imported by: 8

README

Brightbox Go Library

Go Reference

gobrightbox is a Brightbox API client library written in Go.

Documentation is available at pkg.go.dev

The following are the instructions for version 1 of the GO library.

version 2 instructions are in the v2 directory.

Install

go get github.com/brightbox/gobrightbox@vX.Y.Z

where X.Y.Z is the version you need.

Authentication

This client does not itself handle authentication. Instead, use the standard OAuth2 golang library to authenticate and create tokens.

Supported Objects

Help

If you need help using this library, drop an email to support at brightbox dot com.

Licence

This code is released under an MIT License.

Copyright (c) 2015-2022 Brightbox Systems Ltd.

Documentation

Overview

Package gobrightbox is for interacting with the Brightbox Cloud API

Brightbox Cloud is a UK-based infrastructure-as-a-service provider. More details available at https://www.brightbox.com

The Brightbox Cloud API documentation is available at https://api.gb1.brightbox.com/1.0/

Example

Authenticate using an API Client identifier and secret, and get a list of servers

package main

import (
	"fmt"

	brightbox "github.com/brightbox/gobrightbox"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/clientcredentials"
)

func main() {
	apiURL := "https://api.gb1.brightbox.com"
	clientID := "cli-xxxxx"
	clientSecret := "somesecret"

	// Setup OAuth2 authentication
	conf := clientcredentials.Config{
		ClientID:     clientID,
		ClientSecret: clientSecret,
		Scopes:       []string{},
		TokenURL:     apiURL + "/token",
	}
	oc := conf.Client(oauth2.NoContext)

	// Setup connection to API
	client, err := brightbox.NewClient(apiURL, "", oc)
	if err != nil {
		fmt.Println(err)
		return
	}

	// Get a list of servers
	servers, err := client.Servers()
	if err != nil {
		fmt.Println(err)
		return
	}
	for _, server := range servers {
		fmt.Printf("id:%s name:%s\n", server.ID, server.Name)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// DefaultRegionAPIURL is the default API URL for the region. Use with NewClient.
	DefaultRegionAPIURL = "https://api.gb1.brightbox.com/"
	// DefaultOrbitAuthURL is the default Auth URL for Orbit.
	DefaultOrbitAuthURL = "https://orbit.brightbox.com/v1/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient added in v0.8.0

type APIClient struct {
	ID               string
	Name             string
	Description      string
	Secret           string
	PermissionsGroup string     `json:"permissions_group"`
	RevokedAt        *time.Time `json:"revoked_at"`
	Account          Account
}

APIClient represents an API client. https://api.gb1.brightbox.com/1.0/#api_client

type APIClientOptions added in v0.8.0

type APIClientOptions struct {
	ID               string  `json:"-"`
	Name             *string `json:"name,omitempty"`
	Description      *string `json:"description,omitempty"`
	PermissionsGroup *string `json:"permissions_group,omitempty"`
}

APIClientOptions is used in conjunction with CreateAPIClient and UpdateAPIClient to create and update api clients

type APIError added in v0.8.0

type APIError struct {
	// StatusCode will hold the HTTP status code from the request that errored
	StatusCode int
	// Status will hold the HTTP status line from the request that errored
	Status string
	// AuthError will hold any available OAuth "error" field contents. See
	// https://api.gb1.brightbox.com/1.0/#errors
	AuthError string `json:"error"`
	// AuthErrorDescription will hold any available OAuth "error_description"
	// field contents. See https://api.gb1.brightbox.com/1.0/#errors
	AuthErrorDescription string `json:"error_description"`
	// ErrorName will hold any available Brightbox API "error_name" field
	// contents. See https://api.gb1.brightbox.com/1.0/#request_errors
	ErrorName string `json:"error_name"`
	// Errors will hold any available Brightbox API "errors" field contents. See
	// https://api.gb1.brightbox.com/1.0/#request_errors
	Errors []string `json:"errors"`
	// ParseError will hold any errors from the JSON parser whilst parsing an
	// API response
	ParseError error
	// RequestURL will hold the full URL used to make the request that errored,
	// if available
	RequestURL *url.URL
	// ResponseBody will hold the raw respose body of the request that errored,
	// if available
	ResponseBody []byte
}

APIError can be returned when an API request fails. It provides any error messages provided by the API, along with other details about the response.

func (*APIError) Error added in v0.8.0

func (e *APIError) Error() string

Error implements the error interface

func (*APIError) Unwrap added in v0.8.2

func (e *APIError) Unwrap() error

Unwrap implements the error wrapping interface

type Account

type Account struct {
	ID                    string
	Name                  string
	Status                string
	Address1              string `json:"address_1"`
	Address2              string `json:"address_2"`
	City                  string
	County                string
	Postcode              string
	CountryCode           string     `json:"country_code"`
	CountryName           string     `json:"country_name"`
	VatRegistrationNumber string     `json:"vat_registration_number"`
	TelephoneNumber       string     `json:"telephone_number"`
	TelephoneVerified     bool       `json:"telephone_verified"`
	VerifiedTelephone     string     `json:"verified_telephone"`
	VerifiedAt            *time.Time `json:"verified_at"`
	VerifiedIP            string     `json:"verified_ip"`
	ValidCreditCard       bool       `json:"valid_credit_card"`
	CreatedAt             *time.Time `json:"created_at"`
	RAMLimit              int        `json:"ram_limit"`
	RAMUsed               int        `json:"ram_used"`
	DbsRAMLimit           int        `json:"dbs_ram_limit"`
	DbsRAMUsed            int        `json:"dbs_ram_used"`
	CloudIPsLimit         int        `json:"cloud_ips_limit"`
	CloudIPsUsed          int        `json:"cloud_ips_used"`
	LoadBalancersLimit    int        `json:"load_balancers_limit"`
	LoadBalancersUsed     int        `json:"load_balancers_used"`
	LibraryFtpHost        string     `json:"library_ftp_host"`
	LibraryFtpUser        string     `json:"library_ftp_user"`
	LibraryFtpPassword    string     `json:"library_ftp_password"`
	Owner                 User
	Users                 []User
}

Account represents a Brightbox Cloud Account https://api.gb1.brightbox.com/1.0/#account

type Client

type Client struct {
	BaseURL *url.URL

	UserAgent string
	// The identifier of the account to use by default with this Client.
	AccountID string
	// contains filtered or unexported fields
}

Client represents a connection to the Brightbox API. You should use NewClient to allocate and configure Clients. Authentication is handled externally by a http.Client with the appropriate Transport, such as those provided by https://github.com/golang/oauth2/

func NewClient

func NewClient(apiURL string, accountID string, httpClient *http.Client) (*Client, error)

NewClient allocates and configures a Client for interacting with the API.

apiURL should be an url of the form https://api.region.brightbox.com, e.g: https://api.gb1.brightbox.com. You can use the default defined in this package instead, i.e. brightbox.DefaultRegionAPIURL

accountId should be the identifier of the default account to be used with this Client. Clients authenticated with Brightbox APIClient credentials are only ever associated with one single Account, so you can leave this empty for those. Client's authenticated with Brightbox User credentials can have access to multiple accounts, so this parameter should be provided.

httpClient should be a http.Client with a transport that will handle the OAuth token authentication, such as those provided by https://github.com/golang/oauth2/

func (*Client) APIClient added in v0.8.0

func (c *Client) APIClient(identifier string) (*APIClient, error)

APIClient retrieves a detailed view of one API client

func (*Client) APIClients added in v0.8.0

func (c *Client) APIClients() ([]APIClient, error)

APIClients retrieves a list of all API clients

func (*Client) Account

func (c *Client) Account(identifier string) (*Account, error)

Account retrieves a detailed view of one account

func (*Client) Accounts

func (c *Client) Accounts() ([]Account, error)

Accounts retrieves a list of all accounts associated with the client.

API Clients are only ever associated with one single account. User clients can have multiple accounts, through collaborations.

func (*Client) ActivateConsoleForServer

func (c *Client) ActivateConsoleForServer(identifier string) (*Server, error)

ActivateConsoleForServer issues a request to enable the graphical console for an existing server. The temporarily allocated ConsoleURL, ConsoleToken and ConsoleTokenExpires data are returned within an instance of Server.

func (*Client) AddListenersToLoadBalancer

func (c *Client) AddListenersToLoadBalancer(loadBalancerID string, listeners []LoadBalancerListener) (*LoadBalancer, error)

AddListenersToLoadBalancer adds listeners to an existing load balancer.

func (*Client) AddNodesToLoadBalancer

func (c *Client) AddNodesToLoadBalancer(loadBalancerID string, nodes []LoadBalancerNode) (*LoadBalancer, error)

AddNodesToLoadBalancer adds nodes to an existing load balancer.

func (*Client) AddServersToServerGroup

func (c *Client) AddServersToServerGroup(identifier string, serverIDs []string) (*ServerGroup, error)

AddServersToServerGroup adds servers to an existing server group.

The identifier parameter specifies the destination group.

The serverIDs paramater specifies the identifiers of the servers you want to add.

func (*Client) ApplyFirewallPolicy

func (c *Client) ApplyFirewallPolicy(policyID string, serverGroupID string) (*FirewallPolicy, error)

ApplyFirewallPolicy issues a request to apply the given firewall policy to the given server group.

func (*Client) CloudIP

func (c *Client) CloudIP(identifier string) (*CloudIP, error)

CloudIP retrieves a detailed view of one cloud ip

func (*Client) CloudIPs

func (c *Client) CloudIPs() ([]CloudIP, error)

CloudIPs retrieves a list of all cloud ips

func (*Client) Collaboration

func (c *Client) Collaboration(identifier string) (*Collaboration, error)

Collaboration retrieves a detailed view of one of the current user's collaborations

func (*Client) Collaborations

func (c *Client) Collaborations() ([]Collaboration, error)

Collaborations retrieves a list of all the current user's collaborations

func (*Client) ConfigMap added in v0.5.0

func (c *Client) ConfigMap(identifier string) (*ConfigMap, error)

ConfigMap retrieves a detailed view on one config map

func (*Client) ConfigMaps added in v0.5.0

func (c *Client) ConfigMaps() ([]ConfigMap, error)

ConfigMaps retrieves a list of all config maps

func (*Client) CreateAPIClient added in v0.8.0

func (c *Client) CreateAPIClient(options *APIClientOptions) (*APIClient, error)

CreateAPIClient creates a new API client.

It takes a APIClientOptions struct for specifying name and other attributes. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateCloudIP

func (c *Client) CreateCloudIP(newCloudIP *CloudIPOptions) (*CloudIP, error)

CreateCloudIP creates a new Cloud IP.

It takes a CloudIPOptions struct for specifying name and other attributes. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateConfigMap added in v0.5.0

func (c *Client) CreateConfigMap(newConfigMap *ConfigMapOptions) (*ConfigMap, error)

CreateConfigMap creates a new config map

It takes an instance of ConfigMapOptions. Not all attributes can be specified at create time (such as ID, which is allocated for you).

func (*Client) CreateDatabaseServer

func (c *Client) CreateDatabaseServer(options *DatabaseServerOptions) (*DatabaseServer, error)

CreateDatabaseServer creates a new database server.

It takes a DatabaseServerOptions struct for specifying name and other attributes. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateFirewallPolicy

func (c *Client) CreateFirewallPolicy(policyOptions *FirewallPolicyOptions) (*FirewallPolicy, error)

CreateFirewallPolicy creates a new firewall policy.

It takes a FirewallPolicyOptions struct for specifying name and other attributes. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateFirewallRule

func (c *Client) CreateFirewallRule(ruleOptions *FirewallRuleOptions) (*FirewallRule, error)

CreateFirewallRule creates a new firewall rule.

It takes a FirewallRuleOptions struct for specifying name and other attributes. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateLoadBalancer

func (c *Client) CreateLoadBalancer(newLB *LoadBalancerOptions) (*LoadBalancer, error)

CreateLoadBalancer creates a new load balancer.

It takes a LoadBalancerOptions struct for specifying name and other attributes. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateServer

func (c *Client) CreateServer(newServer *ServerOptions) (*Server, error)

CreateServer creates a new server.

It takes a ServerOptions struct which requires, at minimum, a valid Image identifier. Not all attributes can be specified at create time (such as ID, which is allocated for you)

func (*Client) CreateServerGroup

func (c *Client) CreateServerGroup(newServerGroup *ServerGroupOptions) (*ServerGroup, error)

CreateServerGroup creates a new server group

It takes an instance of ServerGroupOptions. Not all attributes can be specified at create time (such as ID, which is allocated for you).

func (*Client) DatabaseServer

func (c *Client) DatabaseServer(identifier string) (*DatabaseServer, error)

DatabaseServer retrieves a detailed view of one database server

func (*Client) DatabaseServerType

func (c *Client) DatabaseServerType(identifier string) (*DatabaseServerType, error)

DatabaseServerType retrieves a detailed view of one Database Type

func (*Client) DatabaseServerTypes

func (c *Client) DatabaseServerTypes() ([]DatabaseServerType, error)

DatabaseServerTypes retrieves a list of Database Types

func (*Client) DatabaseServers

func (c *Client) DatabaseServers() ([]DatabaseServer, error)

DatabaseServers retrieves a list of all database servers

func (*Client) DatabaseSnapshot added in v0.3.1

func (c *Client) DatabaseSnapshot(identifier string) (*DatabaseSnapshot, error)

DatabaseSnapshot retrieves a detailed view of one database snapshot

func (*Client) DatabaseSnapshots added in v0.3.1

func (c *Client) DatabaseSnapshots() ([]DatabaseSnapshot, error)

DatabaseSnapshots retrieves a list of all database snapshot

func (*Client) DestroyAPIClient added in v0.8.0

func (c *Client) DestroyAPIClient(identifier string) error

DestroyAPIClient issues a request to deletes an existing api client

func (*Client) DestroyCloudIP

func (c *Client) DestroyCloudIP(identifier string) error

DestroyCloudIP issues a request to destroy the cloud ip

func (*Client) DestroyConfigMap added in v0.5.0

func (c *Client) DestroyConfigMap(identifier string) error

DestroyConfigMap destroys an existing config map

func (*Client) DestroyDatabaseServer

func (c *Client) DestroyDatabaseServer(identifier string) error

DestroyDatabaseServer issues a request to deletes an existing database server

func (*Client) DestroyDatabaseSnapshot added in v0.3.1

func (c *Client) DestroyDatabaseSnapshot(identifier string) error

DestroyDatabaseSnapshot issues a request to destroy the database snapshot

func (*Client) DestroyFirewallPolicy

func (c *Client) DestroyFirewallPolicy(identifier string) error

DestroyFirewallPolicy issues a request to destroy the firewall policy

func (*Client) DestroyFirewallRule

func (c *Client) DestroyFirewallRule(identifier string) error

DestroyFirewallRule destroys an existing firewall rule

func (*Client) DestroyImage

func (c *Client) DestroyImage(identifier string) error

DestroyImage issues a request to destroy the image

func (*Client) DestroyLoadBalancer

func (c *Client) DestroyLoadBalancer(identifier string) error

DestroyLoadBalancer issues a request to destroy the load balancer

func (*Client) DestroyServer

func (c *Client) DestroyServer(identifier string) error

DestroyServer issues a request to destroy the server

func (*Client) DestroyServerGroup

func (c *Client) DestroyServerGroup(identifier string) error

DestroyServerGroup destroys an existing server group

func (*Client) FirewallPolicies

func (c *Client) FirewallPolicies() ([]FirewallPolicy, error)

FirewallPolicies retrieves a list of all firewall policies

func (*Client) FirewallPolicy

func (c *Client) FirewallPolicy(identifier string) (*FirewallPolicy, error)

FirewallPolicy retrieves a detailed view of one firewall policy

func (*Client) FirewallRule

func (c *Client) FirewallRule(identifier string) (*FirewallRule, error)

FirewallRule retrieves a detailed view of one firewall rule

func (*Client) Image

func (c *Client) Image(identifier string) (*Image, error)

Image retrieves a detailed view of one image

func (*Client) Images

func (c *Client) Images() ([]Image, error)

Images retrieves a list of all images

func (*Client) LoadBalancer

func (c *Client) LoadBalancer(identifier string) (*LoadBalancer, error)

LoadBalancer retrieves a detailed view of one load balancer

func (*Client) LoadBalancers

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

LoadBalancers retrieves a list of all load balancers

func (*Client) LockResource

func (c *Client) LockResource(resource interface{}) error

LockResource locks a resource against destroy requests. Support brightbox.Server, brightbox.Image, brightbox.DatabaseServer and brightbox.LoadBalancer

func (*Client) LockServer

func (c *Client) LockServer(identifier string) error

LockServer locks an existing server, preventing it's destruction without first unlocking. Deprecated, use LockResource instead.

func (*Client) MakeAPIRequest added in v0.8.0

func (c *Client) MakeAPIRequest(method string, path string, reqBody interface{}, resBody interface{}) (*http.Response, error)

MakeAPIRequest makes a http request to the API, JSON encoding any given data and decoding any JSON response.

method should be the desired http method, e.g: "GET", "POST", "PUT" etc.

urlStr should be the url path, relative to the api url e.g: "/1.0/servers"

if reqBody is non-nil, it will be Marshaled to JSON and set as the request body.

Optionally, the response body will be Unmarshaled from JSON into whatever resBody is a pointer to. Leave nil to skip.

If the response is non-2xx, MakeAPIRequest will try to parse the error message and return an APIError struct.

func (*Client) MapCloudIP

func (c *Client) MapCloudIP(identifier string, destination string) error

MapCloudIP issues a request to map the cloud ip to the destination. The destination can be an identifier of any resource capable of receiving a Cloud IP, such as a server interface, a load balancer, or a cloud sql instace.

To map a Cloud IP to a server, first lookup the server to get it's interface identifier (or use the MapCloudIPtoServer convenience method)

func (*Client) MapCloudIPtoServer

func (c *Client) MapCloudIPtoServer(identifier string, serverid string) error

MapCloudIPtoServer is a convenience method to map a Cloud IP to a server. First looks up the server to get the network interface id. Uses the first interface found.

func (*Client) MoveServersToServerGroup

func (c *Client) MoveServersToServerGroup(src string, dst string, serverIDs []string) (*ServerGroup, error)

MoveServersToServerGroup atomically moves servers from one group to another.

The src parameter specifies the group to which the servers currently belong

The dst parameter specifies the group to which you want to move the servers.

The serverIDs parameter specifies the identifiers of the servers you want to move.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest allocates and configures a http.Request ready to make an API call.

method should be the desired http method, e.g: "GET", "POST", "PUT" etc.

urlStr should be the url path, relative to the api url e.g: "/1.0/servers"

if body is non-nil, it will be Marshaled to JSON and set as the request body

func (*Client) RebootServer

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

RebootServer issues a request to reboot ("ctrl+alt+delete") an existing server

func (*Client) RemoveFirewallPolicy

func (c *Client) RemoveFirewallPolicy(policyID string, serverGroupID string) (*FirewallPolicy, error)

RemoveFirewallPolicy issues a request to remove the given firewall policy from the given server group.

func (*Client) RemoveListenersFromLoadBalancer

func (c *Client) RemoveListenersFromLoadBalancer(loadBalancerID string, listeners []LoadBalancerListener) (*LoadBalancer, error)

RemoveListenersFromLoadBalancer removes listeners to an existing load balancer.

func (*Client) RemoveNodesFromLoadBalancer

func (c *Client) RemoveNodesFromLoadBalancer(loadBalancerID string, nodes []LoadBalancerNode) (*LoadBalancer, error)

RemoveNodesFromLoadBalancer removes nodes from an existing load balancer.

func (*Client) RemoveServersFromServerGroup

func (c *Client) RemoveServersFromServerGroup(identifier string, serverIDs []string) (*ServerGroup, error)

RemoveServersFromServerGroup removes servers from an existing server group.

The identifier parameter specifies the group.

The serverIDs paramater specifies the identifiers of the servers you want to remove.

func (*Client) ResetPasswordForDatabaseServer

func (c *Client) ResetPasswordForDatabaseServer(identifier string) (*DatabaseServer, error)

ResetPasswordForDatabaseServer requests a snapshot of an existing database server.

func (*Client) ResetSecretForAPIClient added in v0.8.0

func (c *Client) ResetSecretForAPIClient(identifier string) (*APIClient, error)

ResetSecretForAPIClient requests a snapshot of an existing api client

func (*Client) ResetServer

func (c *Client) ResetServer(identifier string) error

ResetServer issues a request to reset ("power cycle") an existing server

func (*Client) ResizeServer added in v0.8.3

func (c *Client) ResizeServer(identifier string, newTypeID string) error

ResizeServer issues a request to change the server type of a server changing the amount of cpu and ram it has.

func (*Client) ResizeVolume added in v0.8.2

func (c *Client) ResizeVolume(identifier string, oldSize int, newSize int) error

ResizeVolume changes the size of a volume

func (*Client) Server

func (c *Client) Server(identifier string) (*Server, error)

Server retrieves a detailed view of one server

func (*Client) ServerGroup

func (c *Client) ServerGroup(identifier string) (*ServerGroup, error)

ServerGroup retrieves a detailed view on one server group

func (*Client) ServerGroups

func (c *Client) ServerGroups() ([]ServerGroup, error)

ServerGroups retrieves a list of all server groups

func (*Client) ServerType

func (c *Client) ServerType(identifier string) (*ServerType, error)

ServerType retrieves a detailed view of one Server Type using an identifier

func (*Client) ServerTypeByHandle

func (c *Client) ServerTypeByHandle(handle string) (*ServerType, error)

ServerTypeByHandle retrieves a detailed view of one Server Type using a handle

func (*Client) ServerTypes

func (c *Client) ServerTypes() ([]ServerType, error)

ServerTypes retrieves a list of all Server Types

func (*Client) Servers

func (c *Client) Servers() ([]Server, error)

Servers retrieves a list of all servers

func (*Client) ShutdownServer

func (c *Client) ShutdownServer(identifier string) error

ShutdownServer issues a request to shut down ("tap the power button") an existing server

func (*Client) SnapshotDatabaseServer

func (c *Client) SnapshotDatabaseServer(identifier string) (*DatabaseSnapshot, error)

SnapshotDatabaseServer requests a snapshot of an existing database server.

func (*Client) SnapshotServer

func (c *Client) SnapshotServer(identifier string) (*Image, error)

SnapshotServer issues a request to snapshot the disk of an existing server. The snapshot is allocated an Image ID which is returned within an instance of Image.

func (*Client) StartServer

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

StartServer issues a request to start ("power on") an existing server

func (*Client) StopServer

func (c *Client) StopServer(identifier string) error

StopServer issues a request to stop ("power off") an existing server

func (*Client) UnLockResource

func (c *Client) UnLockResource(resource interface{}) error

UnLockResource unlocks a resource, renabling destroy requests

func (*Client) UnMapCloudIP

func (c *Client) UnMapCloudIP(identifier string) error

UnMapCloudIP issues a request to unmap the cloud ip.

func (*Client) UnlockServer

func (c *Client) UnlockServer(identifier string) error

UnlockServer unlocks a previously locked existing server, allowing destruction again. Deprecated, use UnLockResource instead.

func (*Client) UpdateAPIClient added in v0.8.0

func (c *Client) UpdateAPIClient(options *APIClientOptions) (*APIClient, error)

UpdateAPIClient updates an existing api client.

It takes a APIClientOptions struct for specifying ID, name and other attributes. Not all attributes can be specified at update time.

func (*Client) UpdateCloudIP

func (c *Client) UpdateCloudIP(updateCloudIP *CloudIPOptions) (*CloudIP, error)

UpdateCloudIP updates an existing cloud ip's attributes. Not all attributes can be changed after creation time (such as ID, which is allocated for you).

Specify the cloud ip you want to update using the CloudIPOptions ID field

func (*Client) UpdateConfigMap added in v0.5.0

func (c *Client) UpdateConfigMap(updateConfigMap *ConfigMapOptions) (*ConfigMap, error)

UpdateConfigMap updates an existing config maps's attributes. Not all attributes can be changed (such as ID).

Specify the config map you want to update using the ConfigMapOptions ID field.

func (*Client) UpdateDatabaseServer

func (c *Client) UpdateDatabaseServer(options *DatabaseServerOptions) (*DatabaseServer, error)

UpdateDatabaseServer updates an existing database server.

It takes a DatabaseServerOptions struct for specifying ID, name and other attributes. Not all attributes can be specified at update time.

func (*Client) UpdateFirewallPolicy

func (c *Client) UpdateFirewallPolicy(policyOptions *FirewallPolicyOptions) (*FirewallPolicy, error)

UpdateFirewallPolicy updates an existing firewall policy.

It takes a FirewallPolicyOptions struct for specifying name and other attributes. Not all attributes can be update(such as server_group which is instead changed with ApplyFirewallPolicy).

Specify the policy you want to update using the ID field

func (*Client) UpdateFirewallRule

func (c *Client) UpdateFirewallRule(ruleOptions *FirewallRuleOptions) (*FirewallRule, error)

UpdateFirewallRule updates an existing firewall rule.

It takes a FirewallRuleOptions struct for specifying the attributes. Not all attributes can be updated (such as firewall_policy)

func (*Client) UpdateLoadBalancer

func (c *Client) UpdateLoadBalancer(newLB *LoadBalancerOptions) (*LoadBalancer, error)

UpdateLoadBalancer updates an existing load balancer.

It takes a LoadBalancerOptions struct for specifying name and other attributes. Provide the identifier using the ID attribute.

func (*Client) UpdateServer

func (c *Client) UpdateServer(updateServer *ServerOptions) (*Server, error)

UpdateServer updates an existing server's attributes. Not all attributes can be changed after creation time (such as Image, ServerType and Zone).

Specify the server you want to update using the ServerOptions ID field

func (*Client) UpdateServerGroup

func (c *Client) UpdateServerGroup(updateServerGroup *ServerGroupOptions) (*ServerGroup, error)

UpdateServerGroup updates an existing server groups's attributes. Not all attributes can be changed (such as ID).

Specify the server group you want to update using the ServerGroupOptions ID field.

To change group memberships, use AddServersToServerGroup, RemoveServersFromServerGroup and MoveServersToServerGroup.

func (*Client) Zone

func (c *Client) Zone(identifier string) (*Zone, error)

Zone retrieves a detailed view of one Zone using an identifier

func (*Client) ZoneByHandle

func (c *Client) ZoneByHandle(handle string) (*Zone, error)

ZoneByHandle retrieves a detailed view of one Zone using a handle

func (*Client) Zones

func (c *Client) Zones() ([]Zone, error)

Zones retrieves a list of all Zones

type CloudIP

type CloudIP struct {
	ID              string
	Name            string
	PublicIP        string `json:"public_ip"`
	PublicIPv4      string `json:"public_ipv4"`
	PublicIPv6      string `json:"public_ipv6"`
	Status          string
	ReverseDNS      string           `json:"reverse_dns"`
	PortTranslators []PortTranslator `json:"port_translators"`
	Account         Account
	Fqdn            string
	Interface       *ServerInterface
	Server          *Server
	ServerGroup     *ServerGroup    `json:"server_group"`
	LoadBalancer    *LoadBalancer   `json:"load_balancer"`
	DatabaseServer  *DatabaseServer `json:"database_server"`
}

CloudIP represents a Cloud IP https://api.gb1.brightbox.com/1.0/#cloud_ip

type CloudIPOptions

type CloudIPOptions struct {
	ID              string           `json:"-"`
	ReverseDNS      *string          `json:"reverse_dns,omitempty"`
	Name            *string          `json:"name,omitempty"`
	PortTranslators []PortTranslator `json:"port_translators,omitempty"`
}

CloudIPOptions is used in conjunction with CreateCloudIP and UpdateCloudIP to create and update cloud IPs.

type Collaboration

type Collaboration struct {
	ID         string
	Email      string
	Role       string
	RoleLabel  string `json:"role_label"`
	Status     string
	CreatedAt  *time.Time `json:"created_at"`
	StartedAt  *time.Time `json:"started_at"`
	FinishedAt *time.Time `json:"finished_at"`
	Account    Account
	User       User
	Inviter    User
}

Collaboration represents a User's links to it's Accounts https://api.gb1.brightbox.com/1.0/#user

type ConfigMap added in v0.5.0

type ConfigMap struct {
	ID   string                 `json:"id"`
	Name string                 `json:"name"`
	Data map[string]interface{} `json:"data"`
}

ConfigMap represents a config map https://api.gb1.brightbox.com/1.0/#config_maps

type ConfigMapOptions added in v0.5.0

type ConfigMapOptions struct {
	ID   string                  `json:"-"`
	Name *string                 `json:"name,omitempty"`
	Data *map[string]interface{} `json:"data,omitempty"`
}

ConfigMapOptions is used in combination with CreateConfigMap and UpdateConfigMap to create and update config maps

type DatabaseServer

type DatabaseServer struct {
	ID                      string
	Name                    string
	Description             string
	Status                  string
	Account                 Account
	DatabaseEngine          string             `json:"database_engine"`
	DatabaseVersion         string             `json:"database_version"`
	AdminUsername           string             `json:"admin_username"`
	AdminPassword           string             `json:"admin_password"`
	CreatedAt               *time.Time         `json:"created_at"`
	UpdatedAt               *time.Time         `json:"updated_at"`
	DeletedAt               *time.Time         `json:"deleted_at"`
	SnapshotsScheduleNextAt *time.Time         `json:"snapshots_schedule_next_at"`
	AllowAccess             []string           `json:"allow_access"`
	MaintenanceWeekday      int                `json:"maintenance_weekday"`
	MaintenanceHour         int                `json:"maintenance_hour"`
	SnapshotsSchedule       string             `json:"snapshots_schedule"`
	CloudIPs                []CloudIP          `json:"cloud_ips"`
	DatabaseServerType      DatabaseServerType `json:"database_server_type"`
	Locked                  bool
	Zone                    Zone
}

DatabaseServer represents a database server. https://api.gb1.brightbox.com/1.0/#database_server

type DatabaseServerOptions

type DatabaseServerOptions struct {
	ID                 string   `json:"-"`
	Name               *string  `json:"name,omitempty"`
	Description        *string  `json:"description,omitempty"`
	Engine             string   `json:"engine,omitempty"`
	Version            string   `json:"version,omitempty"`
	AllowAccess        []string `json:"allow_access,omitempty"`
	Snapshot           string   `json:"snapshot,omitempty"`
	Zone               string   `json:"zone,omitempty"`
	DatabaseType       string   `json:"database_type,omitempty"`
	MaintenanceWeekday *int     `json:"maintenance_weekday,omitempty"`
	MaintenanceHour    *int     `json:"maintenance_hour,omitempty"`
	SnapshotsSchedule  *string  `json:"snapshots_schedule,omitempty"`
}

DatabaseServerOptions is used in conjunction with CreateDatabaseServer and UpdateDatabaseServer to create and update database servers.

type DatabaseServerType

type DatabaseServerType struct {
	ID          string
	Name        string
	Description string
	DiskSize    int `json:"disk_size"`
	RAM         int
}

DatabaseServerType represents a database server type https://api.gb1.brightbox.com/1.0/#database_type

type DatabaseSnapshot

type DatabaseSnapshot struct {
	ID              string
	Name            string
	Description     string
	Status          string
	Account         Account
	DatabaseEngine  string `json:"database_engine"`
	DatabaseVersion string `json:"database_version"`
	Size            int
	CreatedAt       *time.Time `json:"created_at"`
	UpdatedAt       *time.Time `json:"updated_at"`
	DeletedAt       *time.Time `json:"deleted_at"`
	Locked          bool
}

DatabaseSnapshot represents a snapshot of a database server. https://api.gb1.brightbox.com/1.0/#databaseSnapshot

type FirewallPolicy

type FirewallPolicy struct {
	ID          string
	Name        string
	Default     bool
	CreatedAt   time.Time `json:"created_at"`
	Description string
	ServerGroup *ServerGroup   `json:"server_group"`
	Rules       []FirewallRule `json:"rules"`
}

FirewallPolicy represents a firewall policy. https://api.gb1.brightbox.com/1.0/#firewall_policy

type FirewallPolicyOptions

type FirewallPolicyOptions struct {
	ID          string  `json:"-"`
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
	ServerGroup *string `json:"server_group,omitempty"`
}

FirewallPolicyOptions is used in conjunction with CreateFirewallPolicy and UpdateFirewallPolicy to create and update firewall policies.

type FirewallRule

type FirewallRule struct {
	ID              string
	Source          string         `json:"source"`
	SourcePort      string         `json:"source_port"`
	Destination     string         `json:"destination"`
	DestinationPort string         `json:"destination_port"`
	Protocol        string         `json:"protocol"`
	IcmpTypeName    string         `json:"icmp_type_name"`
	CreatedAt       time.Time      `json:"created_at"`
	Description     string         `json:"description"`
	FirewallPolicy  FirewallPolicy `json:"firewall_policy"`
}

FirewallRule represents a firewall rule. https://api.gb1.brightbox.com/1.0/#firewall_rule

type FirewallRuleOptions

type FirewallRuleOptions struct {
	ID              string  `json:"-"`
	FirewallPolicy  string  `json:"firewall_policy,omitempty"`
	Protocol        *string `json:"protocol,omitempty"`
	Source          *string `json:"source,omitempty"`
	SourcePort      *string `json:"source_port,omitempty"`
	Destination     *string `json:"destination,omitempty"`
	DestinationPort *string `json:"destination_port,omitempty"`
	IcmpTypeName    *string `json:"icmp_type_name,omitempty"`
	Description     *string `json:"description,omitempty"`
}

FirewallRuleOptions is used in conjunction with CreateFirewallRule and UpdateFirewallRule to create and update firewall rules.

type Image

type Image struct {
	ID                string
	Name              string
	Username          string
	Status            string
	Locked            bool
	Description       string
	Source            string
	Arch              string
	CreatedAt         time.Time `json:"created_at"`
	Official          bool
	Public            bool
	Owner             string
	SourceType        string `json:"source_type"`
	VirtualSize       int    `json:"virtual_size"`
	DiskSize          int    `json:"disk_size"`
	CompatibilityMode bool   `json:"compatibility_mode"`
	AncestorID        string `json:"ancestor_id"`
	LicenceName       string `json:"licence_name"`
}

Image represents a Machine Image https://api.gb1.brightbox.com/1.0/#image

type LoadBalancer

type LoadBalancer struct {
	ID                string
	Name              string
	Status            string
	CreatedAt         *time.Time `json:"created_at"`
	DeletedAt         *time.Time `json:"deleted_at"`
	Locked            bool
	HTTPSRedirect     bool   `json:"https_redirect"`
	SslMinimumVersion string `json:"ssl_minimum_version"`
	Account           Account
	Nodes             []Server
	CloudIPs          []CloudIP `json:"cloud_ips"`
	Policy            string
	BufferSize        int `json:"buffer_size"`
	Listeners         []LoadBalancerListener
	Healthcheck       LoadBalancerHealthcheck
	Certificate       *LoadBalancerCertificate
	Acme              *LoadBalancerAcme
}

LoadBalancer represents a Load Balancer https://api.gb1.brightbox.com/1.0/#load_balancer

type LoadBalancerAcme

type LoadBalancerAcme struct {
	Certificate *LoadBalancerAcmeCertificate `json:"certificate"`
	Domains     []LoadBalancerAcmeDomain     `json:"domains"`
}

LoadBalancerAcme represents an ACME object on a LoadBalancer

type LoadBalancerAcmeCertificate

type LoadBalancerAcmeCertificate struct {
	Fingerprint string    `json:"fingerprint"`
	ExpiresAt   time.Time `json:"expires_at"`
	IssuedAt    time.Time `json:"issued_at"`
}

LoadBalancerAcmeCertificate represents an ACME issued certificate on a LoadBalancer

type LoadBalancerAcmeDomain

type LoadBalancerAcmeDomain struct {
	Identifier  string `json:"identifier"`
	Status      string `json:"status"`
	LastMessage string `json:"last_message"`
}

LoadBalancerAcmeDomain represents a domain for which ACME support has been requested

type LoadBalancerCertificate

type LoadBalancerCertificate struct {
	ExpiresAt time.Time `json:"expires_at"`
	ValidFrom time.Time `json:"valid_from"`
	SslV3     bool      `json:"sslv3"`
	Issuer    string    `json:"issuer"`
	Subject   string    `json:"subject"`
}

LoadBalancerCertificate represents a certificate on a LoadBalancer

type LoadBalancerHealthcheck

type LoadBalancerHealthcheck struct {
	Type          string `json:"type"`
	Port          int    `json:"port"`
	Request       string `json:"request,omitempty"`
	Interval      int    `json:"interval,omitempty"`
	Timeout       int    `json:"timeout,omitempty"`
	ThresholdUp   int    `json:"threshold_up,omitempty"`
	ThresholdDown int    `json:"threshold_down,omitempty"`
}

LoadBalancerHealthcheck represents a health check on a LoadBalancer

type LoadBalancerListener

type LoadBalancerListener struct {
	Protocol      string `json:"protocol,omitempty"`
	In            int    `json:"in,omitempty"`
	Out           int    `json:"out,omitempty"`
	Timeout       int    `json:"timeout,omitempty"`
	ProxyProtocol string `json:"proxy_protocol,omitempty"`
}

LoadBalancerListener represents a listener on a LoadBalancer

type LoadBalancerNode

type LoadBalancerNode struct {
	Node string `json:"node"`
}

LoadBalancerNode is used in conjunction with LoadBalancerOptions, AddNodesToLoadBalancer, RemoveNodesFromLoadBalancer to specify a list of servers to use as load balancer nodes. The Node parameter should be a server identifier.

type LoadBalancerOptions

type LoadBalancerOptions struct {
	ID                    string                   `json:"-"`
	Name                  *string                  `json:"name,omitempty"`
	Nodes                 []LoadBalancerNode       `json:"nodes,omitempty"`
	Policy                *string                  `json:"policy,omitempty"`
	BufferSize            *int                     `json:"buffer_size,omitempty"`
	Listeners             []LoadBalancerListener   `json:"listeners,omitempty"`
	Healthcheck           *LoadBalancerHealthcheck `json:"healthcheck,omitempty"`
	Domains               *[]string                `json:"domains,omitempty"`
	CertificatePem        *string                  `json:"certificate_pem,omitempty"`
	CertificatePrivateKey *string                  `json:"certificate_private_key,omitempty"`
	SslMinimumVersion     *string                  `json:"ssl_minimum_version,omitempty"`
	SslV3                 *bool                    `json:"sslv3,omitempty"`
	HTTPSRedirect         *bool                    `json:"https_redirect,omitempty"`
}

LoadBalancerOptions is used in conjunction with CreateLoadBalancer and UpdateLoadBalancer to create and update load balancers

type PortTranslator

type PortTranslator struct {
	Incoming int    `json:"incoming"`
	Outgoing int    `json:"outgoing"`
	Protocol string `json:"protocol"`
}

PortTranslator represents a port translator on a Cloud IP

type Server

type Server struct {
	ServerConsole
	ID                string
	Name              string
	Status            string
	Locked            bool
	Hostname          string
	Fqdn              string
	CreatedAt         *time.Time `json:"created_at"`
	DeletedAt         *time.Time `json:"deleted_at"`
	StartedAt         *time.Time `json:"started_at"`
	UserData          string     `json:"user_data"`
	CompatibilityMode bool       `json:"compatibility_mode"`
	DiskEncrypted     bool       `json:"disk_encrypted"`
	Account           Account
	Image             Image
	ServerType        ServerType `json:"server_type"`
	Zone              Zone
	Snapshots         []Image
	CloudIPs          []CloudIP `json:"cloud_ips"`
	Interfaces        []ServerInterface
	ServerGroups      []ServerGroup `json:"server_groups"`
	Volumes           []Volume
}

Server represents a Cloud Server https://api.gb1.brightbox.com/1.0/#server

func (*Server) FullConsoleURL added in v0.8.0

func (s *Server) FullConsoleURL() string

FullConsoleURL returns the console url for the server with the token in the query string. Server needs a ConsoleURL and ConsoleToken, retrieved using ActivateConsoleForServer

type ServerConsole

type ServerConsole struct {
	ConsoleToken        string     `json:"console_token"`
	ConsoleURL          string     `json:"console_url"`
	ConsoleTokenExpires *time.Time `json:"console_token_expires"`
}

ServerConsole is embedded into Server and contains the fields used in response to an ActivateConsoleForServer request.

type ServerGroup

type ServerGroup struct {
	ID             string
	Name           string
	CreatedAt      *time.Time `json:"created_at"`
	Description    string
	Default        bool
	Fqdn           string
	Account        Account `json:"account"`
	Servers        []Server
	FirewallPolicy *FirewallPolicy `json:"firewall_policy"`
}

ServerGroup represents a server group https://api.gb1.brightbox.com/1.0/#server_group

type ServerGroupOptions

type ServerGroupOptions struct {
	ID          string  `json:"-"`
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
}

ServerGroupOptions is used in combination with CreateServerGroup and UpdateServerGroup to create and update server groups

type ServerInterface

type ServerInterface struct {
	ID          string
	MacAddress  string `json:"mac_address"`
	IPv4Address string `json:"ipv4_address"`
	IPv6Address string `json:"ipv6_address"`
}

ServerInterface represent a server's network interface(s)

type ServerOptions

type ServerOptions struct {
	ID                string          `json:"-"`
	Image             string          `json:"image,omitempty"`
	Name              *string         `json:"name,omitempty"`
	ServerType        string          `json:"server_type,omitempty"`
	Zone              string          `json:"zone,omitempty"`
	UserData          *string         `json:"user_data,omitempty"`
	ServerGroups      []string        `json:"server_groups,omitempty"`
	CompatibilityMode *bool           `json:"compatibility_mode,omitempty"`
	DiskEncrypted     *bool           `json:"disk_encrypted,omitempty"`
	Volumes           []VolumeOptions `json:"volumes,omitempty"`
}

ServerOptions is used in conjunction with CreateServer and UpdateServer to create and update servers.

type ServerType

type ServerType struct {
	ID          string
	Name        string
	Status      string
	Handle      string
	Cores       int
	RAM         int
	DiskSize    int    `json:"disk_size"`
	StorageType string `json:"storage_type"`
}

ServerType represents a Server Type https://api.gb1.brightbox.com/1.0/#server_type

type User

type User struct {
	ID             string
	Name           string
	EmailAddress   string `json:"email_address"`
	EmailVerified  bool   `json:"email_verified"`
	SSHKey         string `json:"ssh_key"`
	MessagingPref  bool   `json:"messaging_pref"`
	Accounts       []*Account
	DefaultAccount *Account `json:"default_account"`
}

User represents a Brightbox User https://api.gb1.brightbox.com/1.0/#user

type Volume added in v0.8.2

type Volume struct {
	ID          string
	Name        string
	Status      string
	Description string
	Encrypted   bool
	Size        int
	StorageType string `json:"storage_type"`
	Server      *Server
	Account     *Account
	Image       *Image
}

Volume represents a Brightbox Volume https://api.gb1.brightbox.com/1.0/#volume

type VolumeOptions added in v0.8.2

type VolumeOptions struct {
	ID    string  `json:"-"`
	Size  *int    `json:"size,omitempty"`
	Image *string `json:"image,omitempty"`
}

VolumeOptions is used to create and update volumes create and update servers.

type Zone

type Zone struct {
	ID     string
	Handle string
}

Zone represents a Zone https://api.gb1.brightbox.com/1.0/#zone

Directories

Path Synopsis
helper
Package swauth implements Swift's built-in authentication.
Package swauth implements Swift's built-in authentication.
testing
swauth unit tests
swauth unit tests

Jump to

Keyboard shortcuts

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