Documentation ¶
Overview ¶
Package gridscale is a Go library to consume the Gridscale API (http://www.gridscale.de). The source is hosted on GitHub at https://github.com/parce-iot/gridscale
Usage:
package main import ( "github.com/parce-iot/gridscale" "fmt" "os" ) func main() { userID := os.Getenv("GRIDSCALE_USERID") apiToken := os.Getenv("GRIDSCALE_APITOKEN") endpoint := "https://api.gridscale.io" c, err := gridscale.NewClient(userID, apiToken, endpoint) if err != nil { fmt.Printf("ERROR: %s", err) return } c.GetPrices() }
Index ¶
- type Client
- func (c *Client) AddSSHKey(name string, publicKey string, labels []string) (*SSHKey, error)
- func (c *Client) ConnectIPAddress(ipAddressID, serverID string) error
- func (c *Client) ConnectIsoImage(isoImageID, serverID string) error
- func (c *Client) ConnectNetwork(networkID string, ordering int, serverID string) error
- func (c *Client) ConnectStorage(storageID string, bootdevice bool, serverID string) error
- func (c *Client) CreateIPv4(locationID string, failover bool, labels []string, reverseDNS *string) (*IP, error)
- func (c *Client) CreateIPv6(locationID string, failover bool, labels []string, reverseDNS *string) (*IP, error)
- func (c *Client) CreateNetwork(locationID string, name string, l2security bool, labels []string) (*Network, error)
- func (c *Client) CreateServer(locationID string, name string, cores int, memoryGB int, labels []string) (*Server, error)
- func (c *Client) CreateStorage(locationID string, name string, capacity int, ...) (*Storage, error)
- func (c *Client) DeleteIP(objectID string) error
- func (c *Client) DeleteNetwork(networkID string) error
- func (c *Client) DeleteSSHKey(sshkeyID string) error
- func (c *Client) DeleteServer(serverID string) error
- func (c *Client) DeleteStorage(storageID string) error
- func (c *Client) DisconnectIPAddress(ipAddressID, serverID string) error
- func (c *Client) DisconnectIsoImage(isoImageID, serverID string) error
- func (c *Client) DisconnectNetwork(networkID, serverID string) error
- func (c *Client) DisconnectStorage(storageID, serverID string) error
- func (c *Client) GetIP(objectID string) (*IP, error)
- func (c *Client) GetIPs() ([]IP, error)
- func (c *Client) GetLocations() ([]Location, error)
- func (c *Client) GetNetwork(networkID string) (*Network, error)
- func (c *Client) GetNetworks() ([]Network, error)
- func (c *Client) GetPrices() ([]Price, error)
- func (c *Client) GetPublicNetwork() (*Network, error)
- func (c *Client) GetSSHKey(sshKeyID string) (*SSHKey, error)
- func (c *Client) GetSSHKeys() ([]SSHKey, error)
- func (c *Client) GetServer(serverID string) (*Server, error)
- func (c *Client) GetServers() ([]Server, error)
- func (c *Client) GetStorage(storageID string) (*Storage, error)
- func (c *Client) GetStorages() ([]Storage, error)
- func (c *Client) GetTemplateByName(name string) (*Template, error)
- func (c *Client) GetTemplates() ([]Template, error)
- func (c *Client) PowerOffServer(serverID string) error
- func (c *Client) PowerOnServer(serverID string) error
- func (c *Client) UpdateIPFailover(ipID string, failover bool) error
- func (c *Client) UpdateIPLabels(ipID string, labels []string) error
- func (c *Client) UpdateIPReverseDNS(ipID string, reverseDNS string) error
- func (c *Client) UpdateNetworkLabels(networkID string, labels []string) error
- func (c *Client) UpdateNetworkName(networkID string, name string) error
- func (c *Client) UpdateSSHKeyLabels(sshkeyID string, labels []string) error
- func (c *Client) UpdateSSHKeyName(sshkeyID string, name string) error
- func (c *Client) UpdateSSHKeyPublicKey(sshkeyID string, publicKey string) error
- func (c *Client) UpdateServerCores(serverID string, cores int) error
- func (c *Client) UpdateServerLabels(serverID string, labels []string) error
- func (c *Client) UpdateServerMemory(serverID string, memoryGB int) error
- func (c *Client) UpdateServerName(serverID string, name string) error
- func (c *Client) UpdateStorageCapacity(storageID string, capacity int) error
- func (c *Client) UpdateStorageLabels(storageID string, labels []string) error
- func (c *Client) UpdateStorageName(storageID string, name string) error
- type IP
- type IPServerRelation
- type Location
- type Network
- type NetworkServerRelation
- type Price
- type SSHKey
- type Server
- type ServerNetworkRelation
- type ServerRelations
- type ServerStorageRelation
- type Storage
- type StorageServerRelation
- type StorageSnapshot
- type StorageTemplateParameters
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the gridscale Client class
func NewClient ¶
NewClient creates a new gridscale Client. You have to provide the gridscale API user-id UUID, auth token and the API endpoint URL.
func (*Client) ConnectIPAddress ¶
ConnectIPAddress maps a public IP address to a server connected to the public network.
func (*Client) ConnectIsoImage ¶
ConnectIsoImage connects an ISO image as an optical disk drive to a virtual machine.
func (*Client) ConnectNetwork ¶
ConnectNetwork connects a server to a network. A new ethernet device is added to the server.
func (*Client) ConnectStorage ¶
ConnectStorage connects a storage volume to a server.
func (*Client) CreateIPv4 ¶
func (c *Client) CreateIPv4(locationID string, failover bool, labels []string, reverseDNS *string) (*IP, error)
CreateIPv4 creates a new IPv4 address. locationID is the location ID (required). failover defines if the IP address is a failover IP. labels is a slice of strings (optional, set to nil if not used). reverseDNS is the reverse DNS entry (optional, set to nil if not used).
func (*Client) CreateIPv6 ¶
func (c *Client) CreateIPv6(locationID string, failover bool, labels []string, reverseDNS *string) (*IP, error)
CreateIPv6 creates a new IPv6 address. locationID is the location ID (required). failover defines if the IP address is a failover IP. labels is a slice of strings (optional, set to nil if not used). reverseDNS is the reverse DNS entry (optional, set to nil if not used).
func (*Client) CreateNetwork ¶
func (c *Client) CreateNetwork(locationID string, name string, l2security bool, labels []string) (*Network, error)
CreateNetwork creates a new network. locationID is required. name is required. labels are optional. returns information about the created network or an error.
func (*Client) CreateServer ¶
func (c *Client) CreateServer(locationID string, name string, cores int, memoryGB int, labels []string) (*Server, error)
CreateServer creates a new server volume.
func (*Client) CreateStorage ¶
func (c *Client) CreateStorage(locationID string, name string, capacity int, template *StorageTemplateParameters, labels []string) (*Storage, error)
CreateStorage creates a new storage volume.
func (*Client) DeleteIP ¶
DeleteIP deletes an IP address. This is only possible if the IP address has no relation to a server - remove the relation first!
func (*Client) DeleteNetwork ¶
DeleteNetwork deletes a network or answers with an error message.
func (*Client) DeleteSSHKey ¶
DeleteSSHKey deletes an SSH key or answers with an error message.
func (*Client) DeleteServer ¶
DeleteServer deletes a server or answers with an error message.
func (*Client) DeleteStorage ¶
DeleteStorage deletes a storage or answers with an error message.
func (*Client) DisconnectIPAddress ¶
DisconnectIPAddress disconnects an IP address from a server.
func (*Client) DisconnectIsoImage ¶
DisconnectIsoImage disconnects an ISO image from a virtual machine.
func (*Client) DisconnectNetwork ¶
DisconnectNetwork disconnects a network from a server.
func (*Client) DisconnectStorage ¶
DisconnectStorage disconnects a storage volume from a server.
func (*Client) GetLocations ¶
GetLocations returns a list of all gridscale locations.
func (*Client) GetNetwork ¶
GetNetwork returns information about a network identified by its ID.
func (*Client) GetNetworks ¶
GetNetworks returns a list of all networks.
func (*Client) GetPublicNetwork ¶
GetPublicNetwork returns a reference to a public network.
func (*Client) GetSSHKeys ¶
GetSSHKeys returns a list of all ssh keys.
func (*Client) GetServers ¶
GetServers returns a list of all servers.
func (*Client) GetStorage ¶
GetStorage returns information about a storage identified by its ID.
func (*Client) GetStorages ¶
GetStorages returns a list of all storages.
func (*Client) GetTemplateByName ¶
GetTemplateByName returns a template starting with `name`. Returns an error if not found or found more than one template.
func (*Client) GetTemplates ¶
GetTemplates returns a list templates.
func (*Client) PowerOffServer ¶
PowerOffServer turns a server off.
func (*Client) PowerOnServer ¶
PowerOnServer turns a server on.
func (*Client) UpdateIPFailover ¶
UpdateIPFailover enables or disables the IP's failover capability
func (*Client) UpdateIPLabels ¶
UpdateIPLabels sets the IP object's labels
func (*Client) UpdateIPReverseDNS ¶
UpdateIPReverseDNS updates an IP's reverse DNS entry.
func (*Client) UpdateNetworkLabels ¶
UpdateNetworkLabels changes the labels of a network identified by its id.
func (*Client) UpdateNetworkName ¶
UpdateNetworkName updates a networks name identified by the network id.
func (*Client) UpdateSSHKeyLabels ¶
UpdateSSHKeyLabels changes the labels of an SSH key identified by its id.
func (*Client) UpdateSSHKeyName ¶
UpdateSSHKeyName updates an SSH key name identified by the SSH key id.
func (*Client) UpdateSSHKeyPublicKey ¶
UpdateSSHKeyPublicKey updates an SSH public key.
func (*Client) UpdateServerCores ¶
UpdateServerCores changes the server's number of cores.
func (*Client) UpdateServerLabels ¶
UpdateServerLabels changes the labels of a server identified by its id.
func (*Client) UpdateServerMemory ¶
UpdateServerMemory changes the server's memory [GB].
func (*Client) UpdateServerName ¶
UpdateServerName updates a server's name identified by the network id.
func (*Client) UpdateStorageCapacity ¶
UpdateStorageCapacity changes the capacity of a storage identified by its id.
func (*Client) UpdateStorageLabels ¶
UpdateStorageLabels changes the labels of a storage identified by its id.
type IP ¶
type IP struct { ID string Failover bool Servers []IPServerRelation LocationID string ReverseDNS string Labels []string IP net.IP Prefix net.IPNet IPVersion int }
IP information from Gridscale
type IPServerRelation ¶
type IPServerRelation struct { ServerName string `json:"server_name"` ServerID string `json:"server_uuid"` RelationCreated time.Time `json:"create_time"` }
IPServerRelation holds server name and uuid and creation date of a serrver/object relation
type Location ¶
type Location struct { ID string `json:"object_uuid"` Name string `json:"name"` Iata string `json:"iata"` Country string `json:"country"` }
Location holds information about a gridscale Location.
type Network ¶
type Network struct { ID string Name string Status string Labels []string PublicNet bool L2Security bool Relations []NetworkServerRelation LocationID string }
Network holds information about a network.
type NetworkServerRelation ¶
type NetworkServerRelation struct { ServerName string `json:"object_name"` ServerID string `json:"object_uuid"` Ordering int `json:"ordering"` MAC string `json:"mac"` RelationCreated time.Time `json:"create_time"` }
NetworkServerRelation is a relation that describes the connection between a network and a server including the server's MAC address.
type Price ¶
type Price struct { Type string `json:"type"` PricePerUnit decimal.Decimal `json:"price_per_unit"` Name string `json:"name"` ProductNo int `json:"product_no"` Currency string `json:"currency"` Unit string `json:"unit"` }
Price holds pricing information about a gridscale object type.
type SSHKey ¶
type SSHKey struct { ID string `json:"object_uuid"` Name string `json:"name"` Labels []string `json:"labels"` PublicKey string `json:"sshkey"` }
SSHKey holds information about an ssh key.
type Server ¶
type Server struct { ID string `json:"object_uuid"` Name string `json:"name"` Status string `json:"status"` Labels []string `json:"labels"` Cores int `json:"cores"` Power bool `json:"power"` ConsoleToken string `json:"console_token"` CurrentPrice decimal.Decimal `json:"current_price"` Relations ServerRelations `json:"relations"` CreateTime time.Time `json:"create_time"` ChangeTime time.Time `json:"change_time"` LocationName string `json:"location_name"` LocationIata string `json:"location_iata"` LocationID string `json:"location_uuid"` LocationCountry string `json:"location_country"` }
Server holds information about a server.
type ServerNetworkRelation ¶
type ServerNetworkRelation struct { NetworkID string `json:"object_uuid"` NetworkName string `json:"object_name"` MAC string `json:"mac"` Ordering int `json:"ordering"` }
ServerNetworkRelation contains information about a network connected to a server.
type ServerRelations ¶
type ServerRelations struct { Distance []interface{} `json:"distance"` // TODO: what's that? IsoImages []interface{} `json:"isoimages"` // TODO Networks []ServerNetworkRelation `json:"networks"` PublicIPs []interface{} `json:"public_ips"` // TODO Storages []ServerStorageRelation `json:"storages"` }
ServerRelations holds all relations to other gridscale objects (storages, networks etc.).
type ServerStorageRelation ¶
type ServerStorageRelation struct { StorageID string `json:"object_uuid"` StorageName string `json:"object_name"` BootDevice bool `json:"bootdevice"` Bus int `json:"bus"` Capacity int `json:"capacity"` Controller int `json:"controller"` LUN int `json:"lun"` }
ServerStorageRelation contains information about a storage volume connected to a server
type Storage ¶
type Storage struct { ID string ParentID string LastUsedTemplateID *string Name string Status string Labels []string Capacity int Snapshots []StorageSnapshot CurrentPrice decimal.Decimal Relations []StorageServerRelation CreateTime time.Time ChangeTime time.Time LocationID string }
Storage holds information about a storage.
type StorageServerRelation ¶
type StorageServerRelation struct { ServerID string `json:"object_uuid"` ServerName string `json:"object_name"` RelationCreated time.Time `json:"create_time"` Lun int `json:"lun"` Bus int `json:"bus"` BootDevice bool `json:"bootdevice"` Controller int `json:"controller"` Target int `json:"target"` }
StorageServerRelation holds information about a server connected to a storage.
type StorageSnapshot ¶
type StorageSnapshot struct { ID string `json:"object_uuid"` Name string `json:"object_name"` Capacity string `json:"object_capacity"` LastUsedTemplateID *string `json:"last_used_template,omitempty"` CreateTime time.Time `json:"create_time"` }
StorageSnapshot holds information of a storage snapshot.
type StorageTemplateParameters ¶
type StorageTemplateParameters struct { Hostname string `json:"hostname,omitempty"` Password string `json:"password,omitempty"` PasswordType string `json:"password_type,omitempty"` // plain TemplateID string `json:"template_uuid"` SSHKeyIDs []string `json:"sshkeys,omitempty"` }
StorageTemplateParameters holds parameters to create a storage volume from a template
type Template ¶
type Template struct { Capacity int `json:"capacity"` ChangeTime time.Time `json:"change_time"` CreateTime time.Time `json:"create_time"` CurrentPrice decimal.Decimal `json:"current_price"` Description string `json:"description"` LocationCountry string `json:"location_country"` LocationIATA string `json:"location_iata"` LocationName string `json:"location_name"` LocationID string `json:"location_uuid"` Name string `json:"name"` ID string `json:"object_uuid"` OSType string `json:"ostype"` Private bool `json:"private"` Status string `json:"status"` Version string `json:"version"` }
Template holds information about a storage volume template