Documentation
¶
Overview ¶
Package glesys is the official Go client for interacting with the GleSYS API.
Please note that only a subset of features available in the GleSYS API has been implemented. We greatly appreciate contributions.
Getting Started ¶
To get started you need to signup for an account to GleSYS Cloud and create an API key. Signup is available at https://glesys.com/signup and API keys can be created at https://customer.glesys.com.
client := glesys.NewClient("CL12345", "your-api-key")
CL12345 is the key of the Project you want to work with.
The different modules of the GleSYS API are available on the client. For example:
client.IPs.List(...) client.Servers.Create(...)
More examples provided below.
Index ¶
- type AvailableIPsParams
- type Client
- type CreateServerParams
- type DestroyServerParams
- type IP
- type IPService
- func (s *IPService) Available(context context.Context, params AvailableIPsParams) (*[]IP, error)
- func (s *IPService) Release(context context.Context, ipAddress string) error
- func (s *IPService) Reserve(context context.Context, ipAddress string) (*IP, error)
- func (s *IPService) Reserved(context context.Context) (*[]IP, error)
- type Server
- type ServerDetails
- type ServerService
- func (s *ServerService) Create(context context.Context, params CreateServerParams) (*ServerDetails, error)
- func (s *ServerService) Destroy(context context.Context, serverID string, params DestroyServerParams) error
- func (s *ServerService) Details(context context.Context, serverID string) (*ServerDetails, error)
- func (s *ServerService) List(context context.Context) (*[]Server, error)
- func (s *ServerService) Start(context context.Context, serverID string) error
- func (s *ServerService) Stop(context context.Context, serverID string, params StopServerParams) error
- type StopServerParams
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvailableIPsParams ¶
type AvailableIPsParams struct { DataCenter string `json:"datacenter"` Platform string `json:"platform"` Version int `json:"ipversion"` }
AvailableIPsParams is used to filter results when listing available IP addresses
type Client ¶
type Client struct { IPs *IPService Servers *ServerService Version string // contains filtered or unexported fields }
Client is used to interact with the GleSYS API
type CreateServerParams ¶
type CreateServerParams struct { Bandwidth int `json:"bandwidth"` CampaignCode string `json:"campaigncode,omitempty"` CPU int `json:"cpucores"` DataCenter string `json:"datacenter"` Description string `json:"description,omitempty"` Hostname string `json:"hostname"` IPv4 string `json:"ip"` IPv6 string `json:"ipv6"` Memory int `json:"memorysize"` Password string `json:"rootpassword,omitempty"` Platform string `json:"platform"` PublicKey string `json:"sshkey,omitempty"` Storage int `json:"disksize"` Template string `json:"templatename"` }
CreateServerParams is used when creating a new server
func (CreateServerParams) WithDefaults ¶
func (p CreateServerParams) WithDefaults() CreateServerParams
WithDefaults populates the parameters with default values. Existing parameters will not be overwritten.
type DestroyServerParams ¶
type DestroyServerParams struct {
KeepIP bool `json:"keepip"`
}
DestroyServerParams is used when destroying a server
type IPService ¶
type IPService struct {
// contains filtered or unexported fields
}
IPService provides functions to interact with IP addresses
func (*IPService) Available ¶
Available returns a list of IP addresses available for reservation
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") ips, _ := client.IPs.Available(context.Background(), glesys.AvailableIPsParams{ DataCenter: "Falkenberg", Platform: "OpenVZ", Version: 4, }) for _, ip := range *ips { fmt.Println(ip.Address) } }
Output:
func (*IPService) Release ¶
Release releases a reserved IP address
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") client.IPs.Release(context.Background(), "1.2.3.4") }
Output:
func (*IPService) Reserve ¶
Reserve reserves an available IP address
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") ip, _ := client.IPs.Reserve(context.Background(), "1.2.3.4") fmt.Println(ip.Address) }
Output:
func (*IPService) Reserved ¶
Reserved returns a list of reserved IP addresses
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") ips, _ := client.IPs.Reserved(context.Background()) for _, ip := range *ips { fmt.Println(ip.Address) } }
Output:
type Server ¶
type Server struct { DataCenter string `json:"datacenter"` Hostname string `json:"hostname"` ID string `json:"serverid"` Platform string `json:"platform"` }
Server is a simplified version of a server
type ServerDetails ¶
type ServerDetails struct { CPU int `json:"cpucores"` DataCenter string `json:"datacenter"` Hostname string `json:"hostname"` ID string `json:"serverid"` IPList []IP `json:"iplist"` Platform string `json:"platform"` Memory int `json:"memorysize"` State string `json:"state"` Storage int `json:"disksize"` }
ServerDetails is a more complete representation of a server
func (*ServerDetails) IsLocked ¶
func (sd *ServerDetails) IsLocked() bool
IsLocked returns true if the server is currently locked, false otherwise
func (*ServerDetails) IsRunning ¶
func (sd *ServerDetails) IsRunning() bool
IsRunning returns true if the server is currently running, false otherwise
type ServerService ¶
type ServerService struct {
// contains filtered or unexported fields
}
ServerService provides functions to interact with servers
func (*ServerService) Create ¶
func (s *ServerService) Create(context context.Context, params CreateServerParams) (*ServerDetails, error)
Create creates a new server
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") server, _ := client.Servers.Create(context.Background(), glesys.CreateServerParams{ Bandwidth: 100, CampaignCode: "", CPU: 2, DataCenter: "Falkenberg", Description: "", Hostname: "my-hostname", IPv4: "any", IPv6: "any", Memory: 2048, Password: "...", Platform: "OpenVZ", PublicKey: "...", Storage: 50, Template: "Debian 8 64-bit", }) fmt.Println(server.ID) // NOTE: You can also use the WithDefaults() to provide defaults values for // all required parameters except Password (or PublicKey) server2, _ := client.Servers.Create(context.Background(), glesys.CreateServerParams{ Password: "...", }.WithDefaults()) fmt.Println(server2.ID) }
Output:
func (*ServerService) Destroy ¶
func (s *ServerService) Destroy(context context.Context, serverID string, params DestroyServerParams) error
Destroy deletes a server
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") client.Servers.Destroy(context.Background(), "vz12345", glesys.DestroyServerParams{ KeepIP: true, // KeepIP defaults to false }) }
Output:
func (*ServerService) Details ¶
func (s *ServerService) Details(context context.Context, serverID string) (*ServerDetails, error)
Details returns detailed information about one server
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") server, _ := client.Servers.Details(context.Background(), "vz12345") fmt.Println(server.Hostname) }
Output:
func (*ServerService) List ¶
func (s *ServerService) List(context context.Context) (*[]Server, error)
List returns a list of servers
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") servers, _ := client.Servers.List(context.Background()) for _, server := range *servers { fmt.Println(server.Hostname) } }
Output:
func (*ServerService) Start ¶
func (s *ServerService) Start(context context.Context, serverID string) error
Start turns on a server
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") client.Servers.Start(context.Background(), "vz12345") }
Output:
func (*ServerService) Stop ¶
func (s *ServerService) Stop(context context.Context, serverID string, params StopServerParams) error
Stop turns off a server
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key") client.Servers.Stop(context.Background(), "vz12345", glesys.StopServerParams{ Type: "reboot", // Type "soft", "hard" and "reboot" available }) }
Output:
type StopServerParams ¶
type StopServerParams struct {
Type string `json:"type"`
}
StopServerParams is used when stopping a server. Supported types are `soft` `hard` and `reboot`.