gridscale: github.com/parce-iot/gridscale Index | Files

package gridscale

import "github.com/parce-iot/gridscale"

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

Package Files

client.go common.go doc.go ip.go location.go network.go price.go server.go sshkey.go storage.go template.go

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client is the gridscale Client class

func NewClient Uses

func NewClient(userID, authToken, endpoint string) (*Client, error)

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

func (c *Client) AddSSHKey(name string, publicKey string, labels []string) (*SSHKey, error)

AddSSHKey adds a new ssh key.

func (*Client) ConnectIPAddress Uses

func (c *Client) ConnectIPAddress(ipAddressID, serverID string) error

ConnectIPAddress maps a public IP address to a server connected to the public network.

func (*Client) ConnectIsoImage Uses

func (c *Client) ConnectIsoImage(isoImageID, serverID string) error

ConnectIsoImage connects an ISO image as an optical disk drive to a virtual machine.

func (*Client) ConnectNetwork Uses

func (c *Client) ConnectNetwork(networkID string, ordering int, serverID string) error

ConnectNetwork connects a server to a network. A new ethernet device is added to the server.

func (*Client) ConnectStorage Uses

func (c *Client) ConnectStorage(storageID string, bootdevice bool, serverID string) error

ConnectStorage connects a storage volume to a server.

func (*Client) CreateIPv4 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (c *Client) DeleteIP(objectID string) error

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 Uses

func (c *Client) DeleteNetwork(networkID string) error

DeleteNetwork deletes a network or answers with an error message.

func (*Client) DeleteSSHKey Uses

func (c *Client) DeleteSSHKey(sshkeyID string) error

DeleteSSHKey deletes an SSH key or answers with an error message.

func (*Client) DeleteServer Uses

func (c *Client) DeleteServer(serverID string) error

DeleteServer deletes a server or answers with an error message.

func (*Client) DeleteStorage Uses

func (c *Client) DeleteStorage(storageID string) error

DeleteStorage deletes a storage or answers with an error message.

func (*Client) DisconnectIPAddress Uses

func (c *Client) DisconnectIPAddress(ipAddressID, serverID string) error

DisconnectIPAddress disconnects an IP address from a server.

func (*Client) DisconnectIsoImage Uses

func (c *Client) DisconnectIsoImage(isoImageID, serverID string) error

DisconnectIsoImage disconnects an ISO image from a virtual machine.

func (*Client) DisconnectNetwork Uses

func (c *Client) DisconnectNetwork(networkID, serverID string) error

DisconnectNetwork disconnects a network from a server.

func (*Client) DisconnectStorage Uses

func (c *Client) DisconnectStorage(storageID, serverID string) error

DisconnectStorage disconnects a storage volume from a server.

func (*Client) GetIP Uses

func (c *Client) GetIP(objectID string) (*IP, error)

GetIP returns IP information.

func (*Client) GetIPs Uses

func (c *Client) GetIPs() ([]IP, error)

GetIPs returns a list of IP addresses.

func (*Client) GetLocations Uses

func (c *Client) GetLocations() ([]Location, error)

GetLocations returns a list of all gridscale locations.

func (*Client) GetNetwork Uses

func (c *Client) GetNetwork(networkID string) (*Network, error)

GetNetwork returns information about a network identified by its ID.

func (*Client) GetNetworks Uses

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

GetNetworks returns a list of all networks.

func (*Client) GetPrices Uses

func (c *Client) GetPrices() ([]Price, error)

GetPrices returns a list of object prices.

func (*Client) GetPublicNetwork Uses

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

GetPublicNetwork returns a reference to a public network.

func (*Client) GetSSHKey Uses

func (c *Client) GetSSHKey(sshKeyID string) (*SSHKey, error)

GetSSHKey returns information about an ssh key identified by its ID.

func (*Client) GetSSHKeys Uses

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

GetSSHKeys returns a list of all ssh keys.

func (*Client) GetServer Uses

func (c *Client) GetServer(serverID string) (*Server, error)

GetServer returns information about a server identified by its ID.

func (*Client) GetServers Uses

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

GetServers returns a list of all servers.

func (*Client) GetStorage Uses

func (c *Client) GetStorage(storageID string) (*Storage, error)

GetStorage returns information about a storage identified by its ID.

func (*Client) GetStorages Uses

func (c *Client) GetStorages() ([]Storage, error)

GetStorages returns a list of all storages.

func (*Client) GetTemplateByName Uses

func (c *Client) GetTemplateByName(name string) (*Template, error)

GetTemplateByName returns a template starting with `name`. Returns an error if not found or found more than one template.

func (*Client) GetTemplates Uses

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

GetTemplates returns a list templates.

func (*Client) PowerOffServer Uses

func (c *Client) PowerOffServer(serverID string) error

PowerOffServer turns a server off.

func (*Client) PowerOnServer Uses

func (c *Client) PowerOnServer(serverID string) error

PowerOnServer turns a server on.

func (*Client) UpdateIPFailover Uses

func (c *Client) UpdateIPFailover(ipID string, failover bool) error

UpdateIPFailover enables or disables the IP's failover capability

func (*Client) UpdateIPLabels Uses

func (c *Client) UpdateIPLabels(ipID string, labels []string) error

UpdateIPLabels sets the IP object's labels

func (*Client) UpdateIPReverseDNS Uses

func (c *Client) UpdateIPReverseDNS(ipID string, reverseDNS string) error

UpdateIPReverseDNS updates an IP's reverse DNS entry.

func (*Client) UpdateNetworkLabels Uses

func (c *Client) UpdateNetworkLabels(networkID string, labels []string) error

UpdateNetworkLabels changes the labels of a network identified by its id.

func (*Client) UpdateNetworkName Uses

func (c *Client) UpdateNetworkName(networkID string, name string) error

UpdateNetworkName updates a networks name identified by the network id.

func (*Client) UpdateSSHKeyLabels Uses

func (c *Client) UpdateSSHKeyLabels(sshkeyID string, labels []string) error

UpdateSSHKeyLabels changes the labels of an SSH key identified by its id.

func (*Client) UpdateSSHKeyName Uses

func (c *Client) UpdateSSHKeyName(sshkeyID string, name string) error

UpdateSSHKeyName updates an SSH key name identified by the SSH key id.

func (*Client) UpdateSSHKeyPublicKey Uses

func (c *Client) UpdateSSHKeyPublicKey(sshkeyID string, publicKey string) error

UpdateSSHKeyPublicKey updates an SSH public key.

func (*Client) UpdateServerCores Uses

func (c *Client) UpdateServerCores(serverID string, cores int) error

UpdateServerCores changes the server's number of cores.

func (*Client) UpdateServerLabels Uses

func (c *Client) UpdateServerLabels(serverID string, labels []string) error

UpdateServerLabels changes the labels of a server identified by its id.

func (*Client) UpdateServerMemory Uses

func (c *Client) UpdateServerMemory(serverID string, memoryGB int) error

UpdateServerMemory changes the server's memory [GB].

func (*Client) UpdateServerName Uses

func (c *Client) UpdateServerName(serverID string, name string) error

UpdateServerName updates a server's name identified by the network id.

func (*Client) UpdateStorageCapacity Uses

func (c *Client) UpdateStorageCapacity(storageID string, capacity int) error

UpdateStorageCapacity changes the capacity of a storage identified by its id.

func (*Client) UpdateStorageLabels Uses

func (c *Client) UpdateStorageLabels(storageID string, labels []string) error

UpdateStorageLabels changes the labels of a storage identified by its id.

func (*Client) UpdateStorageName Uses

func (c *Client) UpdateStorageName(storageID string, name string) error

UpdateStorageName updates a storage's name identified by the network id.

type IP Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

Package gridscale imports 8 packages (graph). Updated 2018-12-17. Refresh now. Tools for package owners.