gobrightbox

package
v0.0.0-...-c2972a8 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0, MIT Imports: 10 Imported by: 0

README

Brightbox Golang Client

gobrightbox is a Brightbox Cloud API client implementation written in Go.

Documentation is available at godoc.org.

Authentication

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

Currently implemented

TODO

  • Orbit storage support
  • Collaboration support
  • User support
  • Account support
  • Cloud SQL Snapshot support
  • Cloud SQL Type support

Help

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

License

This code is released under an MIT License.

Copyright (c) 2015-2016 Brightbox Systems Ltd.

Documentation

Overview

Package brightbox 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/

Index

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 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 ApiClient

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

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

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

func (e ApiError) Error() string

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

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

ApiClient retrieves a detailed view of one API client

func (*Client) ApiClients

func (c *Client) ApiClients() ([]ApiClient, error)

ApiClients retrieves a list of all API clients

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

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

ConfigMap retrieves a detailed view on one config map

func (*Client) ConfigMaps

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

ConfigMaps retrieves a list of all config maps

func (*Client) CreateApiClient

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

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)

func (*Client) DatabaseServerTypes

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

func (*Client) DatabaseServers

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

DatabaseServers retrieves a list of all database servers

func (*Client) DatabaseSnapshot

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

DatabaseSnapshot retrieves a detailed view of one database snapshot

func (*Client) DatabaseSnapshots

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

DatabaseSnapshots retrieves a list of all database snapshot

func (*Client) DestroyApiClient

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

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

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

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 reponse.

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 parameter 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

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

func (*Client) ServerTypeByHandle

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

func (*Client) ServerTypes

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

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

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

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)

func (*Client) ZoneByHandle

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

func (*Client) Zones

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

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

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

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
}

DatabaseDatabaseServerType 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/#database_snapshot

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 {
	Id        string
	Name      string
	Status    string
	Locked    bool
	Hostname  string
	Fqdn      string
	CreatedAt *time.Time `json:"created_at"`
	// DeletedAt is nil if the server has not yet been deleted
	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"`
	ServerConsole
	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"`
}

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

func (*Server) FullConsoleUrl

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 reponse 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"`
}

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"`
}

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 Zone

type Zone struct {
	Id     string
	Handle string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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