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 a GleSYS Cloud account 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", "my-application/0.0.1")
CL12345 is the key of the Project you want to work with.
To be able to monitor usage and help track down issues, we encourage you to provide a user agent string identifying your application or library. Recommended syntax is "my-library/version" or "www.example.com".
The different modules of the GleSYS API are available on the client. For example:
client.IPs.List(...) client.NetworkAdapters.Create(...) client.Networks.Create(...) client.Servers.Create(...)
More examples provided below.
Index ¶
- type AddBackendParams
- type AddCertificateParams
- type AddFrontendParams
- type AddTargetParams
- type AvailableIPsParams
- type BlacklistParams
- type Client
- type CreateLoadBalancerParams
- type CreateNetworkAdapterParams
- type CreateNetworkParams
- type CreateServerParams
- type DestroyServerParams
- type EditBackendParams
- type EditFrontendParams
- type EditLoadBalancerParams
- type EditNetworkAdapterParams
- type EditNetworkParams
- type EditServerParams
- type EditTargetParams
- 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 LoadBalancer
- type LoadBalancerBackend
- type LoadBalancerDetails
- type LoadBalancerFrontend
- type LoadBalancerIP
- type LoadBalancerService
- func (lb *LoadBalancerService) AddBackend(context context.Context, loadbalancerID string, params AddBackendParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) AddCertificate(context context.Context, loadbalancerID string, params AddCertificateParams) error
- func (lb *LoadBalancerService) AddFrontend(context context.Context, loadbalancerID string, params AddFrontendParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) AddTarget(context context.Context, loadbalancerID string, params AddTargetParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) AddToBlacklist(context context.Context, loadbalancerID string, params BlacklistParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) Create(context context.Context, params CreateLoadBalancerParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) Destroy(context context.Context, loadbalancerID string) error
- func (lb *LoadBalancerService) Details(context context.Context, loadbalancerID string) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) DisableTarget(context context.Context, loadbalancerID string, params ToggleTargetParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) Edit(context context.Context, loadbalancerID string, params EditLoadBalancerParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) EditBackend(context context.Context, loadbalancerID string, params EditBackendParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) EditFrontend(context context.Context, loadbalancerID string, params EditFrontendParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) EditTarget(context context.Context, loadbalancerID string, params EditTargetParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) EnableTarget(context context.Context, loadbalancerID string, params ToggleTargetParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) List(context context.Context) (*[]LoadBalancer, error)
- func (lb *LoadBalancerService) ListCertificates(context context.Context, loadbalancerID string) (*[]string, error)
- func (lb *LoadBalancerService) RemoveBackend(context context.Context, loadbalancerID string, params RemoveBackendParams) error
- func (lb *LoadBalancerService) RemoveCertificate(context context.Context, loadbalancerID string, params string) error
- func (lb *LoadBalancerService) RemoveFromBlacklist(context context.Context, loadbalancerID string, params BlacklistParams) (*LoadBalancerDetails, error)
- func (lb *LoadBalancerService) RemoveFrontend(context context.Context, loadbalancerID string, params RemoveFrontendParams) error
- func (lb *LoadBalancerService) RemoveTarget(context context.Context, loadbalancerID string, params RemoveTargetParams) error
- type Network
- type NetworkAdapter
- type NetworkAdapterService
- func (s *NetworkAdapterService) Create(context context.Context, params CreateNetworkAdapterParams) (*NetworkAdapter, error)
- func (s *NetworkAdapterService) Destroy(context context.Context, networkAdapterID string) error
- func (s *NetworkAdapterService) Details(context context.Context, networkAdapterID string) (*NetworkAdapter, error)
- func (s *NetworkAdapterService) Edit(context context.Context, networkAdapterID string, ...) (*NetworkAdapter, error)
- type NetworkService
- func (s *NetworkService) Create(context context.Context, params CreateNetworkParams) (*Network, error)
- func (s *NetworkService) Destroy(context context.Context, networkID string) error
- func (s *NetworkService) Details(context context.Context, networkID string) (*Network, error)
- func (s *NetworkService) Edit(context context.Context, networkID string, params EditNetworkParams) (*Network, error)
- func (s *NetworkService) List(context context.Context) (*[]Network, error)
- type RemoveBackendParams
- type RemoveFrontendParams
- type RemoveTargetParams
- 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) Edit(context context.Context, serverID string, params EditServerParams) (*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
- type Target
- type ToggleTargetParams
Examples ¶
- IPService.Available
- IPService.Release
- IPService.Reserve
- IPService.Reserved
- LoadBalancerService.Create
- LoadBalancerService.Destroy
- LoadBalancerService.Details
- NetworkAdapterService.Create
- NetworkAdapterService.Destroy
- NetworkAdapterService.Details
- NetworkAdapterService.Edit
- NetworkService.Create
- NetworkService.Destroy
- NetworkService.Details
- NetworkService.Edit
- NetworkService.List
- ServerService.Create
- ServerService.Destroy
- ServerService.Details
- ServerService.Edit
- ServerService.List
- ServerService.Start
- ServerService.Stop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddBackendParams ¶
type AddBackendParams struct { ConnectTimeout int `json:"connecttimeout,omitempty"` Mode string `json:"mode,omitempty"` Name string `json:"name"` ResponseTimeout int `json:"responsetimeout,omitempty"` StickySession string `json:"stickysession,omitempty"` }
AddBackendParams used when creating backends
type AddCertificateParams ¶
type AddCertificateParams struct { Name string `json:"certificatename"` Certificate string `json:"certificate"` }
AddCertificateParams
type AddFrontendParams ¶
type AddFrontendParams struct { Backend string `json:"backendname"` ClientTimeout int `json:"clienttimeout,omitempty"` MaxConnections int `json:"maxconnections,omitempty"` Name string `json:"name"` Port int `json:"port"` SSLCertificate string `json:"sslcertificate,omitempty"` }
AddFrontendParams used when creating frontends
type AddTargetParams ¶
type AddTargetParams struct { Backend string `json:"backendname"` Name string `json:"name"` Port int `json:"port"` TargetIP string `json:"ipaddress"` Weight int `json:"weight"` }
AddTargetParams used when creating targets
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 BlacklistParams ¶
type BlacklistParams struct {
Prefix string `json:"prefix"`
}
BlacklistParams set prefix to add/delete
type Client ¶
type Client struct { IPs *IPService LoadBalancers *LoadBalancerService Servers *ServerService Networks *NetworkService NetworkAdapters *NetworkAdapterService // contains filtered or unexported fields }
Client is used to interact with the GleSYS API
type CreateLoadBalancerParams ¶
type CreateLoadBalancerParams struct { DataCenter string `json:"datacenter"` IPv4 string `json:"ip,omitempty"` IPv6 string `json:"ipv6,omitempty"` Name string `json:"name"` }
CreateLoadBalancerParams is used when creating a new loadbalancer
type CreateNetworkAdapterParams ¶
type CreateNetworkAdapterParams struct { AdapterType string `json:"adaptertype,omitempty"` Bandwidth int `json:"bandwidth,omitempty"` NetworkID string `json:"networkid,omitempty"` ServerID string `json:"serverid"` }
CreateNetworkAdapterParams is used when creating a new network adapter
type CreateNetworkParams ¶
type CreateNetworkParams struct { DataCenter string `json:"datacenter"` Description string `json:"description"` }
CreateNetworkParams is used when creating a new network
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 EditBackendParams ¶
type EditBackendParams struct { ConnectTimeout int `json:"connecttimeout,omitempty"` Mode string `json:"mode,omitempty"` Name string `json:"backendname"` ResponseTimeout int `json:"responsetimeout,omitempty"` StickySession string `json:"stickysession,omitempty"` }
EditBackendParams used to edit a backend
type EditFrontendParams ¶
type EditFrontendParams struct { ClientTimeout int `json:"clienttimeout,omitempty"` MaxConnections int `json:"maxconnections,omitempty"` Name string `json:"frontendname"` Port int `json:"port,omitempty"` SSLCertificate string `json:"sslcertificate,omitempty"` }
EditFrontendParams used to edit a frontend
type EditLoadBalancerParams ¶
type EditLoadBalancerParams struct {
Name string `json:"name"`
}
EditLoadBalancerParams is used when editing a loadbalancer
type EditNetworkAdapterParams ¶
type EditNetworkAdapterParams struct { Bandwidth int `json:"bandwidth,omitempty"` NetworkID string `json:"networkid,omitempty"` }
EditNetworkAdapterParams is used when editing an existing network adapter
type EditNetworkParams ¶
type EditNetworkParams struct {
Description string `json:"description"`
}
EditNetworkParams is used when editing an existing network
type EditServerParams ¶
type EditServerParams struct { Bandwidth int `json:"bandwidth,omitempty"` CPU int `json:"cpucores,omitempty"` Description string `json:"description,omitempty"` Hostname string `json:"hostname,omitempty"` Memory int `json:"memorysize,omitempty"` Storage int `json:"disksize,omitempty"` }
EditServerParams is used when editing an existing server
type EditTargetParams ¶
type EditTargetParams struct { Backend string `json:"backendname"` Name string `json:"targetname"` Port int `json:"port,omitempty"` TargetIP string `json:"ipaddress,omitempty"` Weight int `json:"weight,omitempty"` }
EditTargetParams used when editing targets
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", "my-application/0.0.1") 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", "my-application/0.0.1") 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", "my-application/0.0.1") 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", "my-application/0.0.1") ips, _ := client.IPs.Reserved(context.Background()) for _, ip := range *ips { fmt.Println(ip.Address) } }
Output:
type LoadBalancer ¶
type LoadBalancer struct { DataCenter string `json:"datacenter"` ID string `json:"loadbalancerid"` Name string `json:"name"` }
LoadBalancer represents a loadbalancer
type LoadBalancerBackend ¶
type LoadBalancerBackend struct { ConnectTimeout int `json:"connecttimeout"` Mode string `json:"mode"` Name string `json:"name"` ResponseTimeout int `json:"responsetimeout"` Status string `json:"status"` StickySession string `json:"stickysessions"` Targets []Target `json:"targets"` }
LoadBalancerBackend represents a LoadBalancer Backend
type LoadBalancerDetails ¶
type LoadBalancerDetails struct { BackendsList []LoadBalancerBackend `json:"backends"` Blacklists []string `json:"blacklist"` DataCenter string `json:"datacenter"` FrontendsList []LoadBalancerFrontend `json:"frontends"` ID string `json:"loadbalancerid"` IPList []LoadBalancerIP `json:"ipaddress"` Name string `json:"name"` }
type LoadBalancerFrontend ¶
type LoadBalancerFrontend struct { Backend string `json:"backend"` ClientTimeout int `json:"clienttimeout"` MaxConnections int `json:"maxconnections"` Name string `json:"name"` Port int `json:"port"` Status string `json:"status"` SSLCertificate string `json:"sslcertificate"` }
LoadBalancerFrontend represents a LoadBalancer Frontend
type LoadBalancerIP ¶
type LoadBalancerService ¶
type LoadBalancerService struct {
// contains filtered or unexported fields
}
LoadBalancerService provides functions to interact with LoadBalancers
func (*LoadBalancerService) AddBackend ¶
func (lb *LoadBalancerService) AddBackend(context context.Context, loadbalancerID string, params AddBackendParams) (*LoadBalancerDetails, error)
AddBackend creates a new backend used by the loadbalancer specified
func (*LoadBalancerService) AddCertificate ¶
func (lb *LoadBalancerService) AddCertificate(context context.Context, loadbalancerID string, params AddCertificateParams) error
AddCertificate adds a certificate to the loadbalancer specified
func (*LoadBalancerService) AddFrontend ¶
func (lb *LoadBalancerService) AddFrontend(context context.Context, loadbalancerID string, params AddFrontendParams) (*LoadBalancerDetails, error)
AddFrontend creates a new frontend used by the loadbalancer specified
func (*LoadBalancerService) AddTarget ¶
func (lb *LoadBalancerService) AddTarget(context context.Context, loadbalancerID string, params AddTargetParams) (*LoadBalancerDetails, error)
AddTarget adds a target to the backend specified
func (*LoadBalancerService) AddToBlacklist ¶
func (lb *LoadBalancerService) AddToBlacklist(context context.Context, loadbalancerID string, params BlacklistParams) (*LoadBalancerDetails, error)
AddToBlacklist adds a prefix to loadbalancer blacklist
func (*LoadBalancerService) Create ¶
func (lb *LoadBalancerService) Create(context context.Context, params CreateLoadBalancerParams) (*LoadBalancerDetails, error)
Create creates a new loadbalancer
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") loadbalancer, _ := client.LoadBalancers.Create(context.Background(), glesys.CreateLoadBalancerParams{ DataCenter: "Falkenberg", Name: "mylb-1", }) fmt.Println(loadbalancer.ID) }
Output:
func (*LoadBalancerService) Destroy ¶
func (lb *LoadBalancerService) Destroy(context context.Context, loadbalancerID string) error
Destroy deletes a loadbalancer
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") client.LoadBalancers.Destroy(context.Background(), "lb123456") }
Output:
func (*LoadBalancerService) Details ¶
func (lb *LoadBalancerService) Details(context context.Context, loadbalancerID string) (*LoadBalancerDetails, error)
Details returns a detailed information about one loadbalancer
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") loadbalancer, _ := client.LoadBalancers.Details(context.Background(), "lb123456") fmt.Println(loadbalancer.Name) }
Output:
func (*LoadBalancerService) DisableTarget ¶
func (lb *LoadBalancerService) DisableTarget(context context.Context, loadbalancerID string, params ToggleTargetParams) (*LoadBalancerDetails, error)
DisableTarget disables the specified target for the LoadBalancerBackend
func (*LoadBalancerService) Edit ¶
func (lb *LoadBalancerService) Edit(context context.Context, loadbalancerID string, params EditLoadBalancerParams) (*LoadBalancerDetails, error)
Edit edits a loadbalancer
func (*LoadBalancerService) EditBackend ¶
func (lb *LoadBalancerService) EditBackend(context context.Context, loadbalancerID string, params EditBackendParams) (*LoadBalancerDetails, error)
EditBackend edits a Backend
func (*LoadBalancerService) EditFrontend ¶
func (lb *LoadBalancerService) EditFrontend(context context.Context, loadbalancerID string, params EditFrontendParams) (*LoadBalancerDetails, error)
EditFrontend edits a frontend
func (*LoadBalancerService) EditTarget ¶
func (lb *LoadBalancerService) EditTarget(context context.Context, loadbalancerID string, params EditTargetParams) (*LoadBalancerDetails, error)
EditTarget edits a target for the specified backend
func (*LoadBalancerService) EnableTarget ¶
func (lb *LoadBalancerService) EnableTarget(context context.Context, loadbalancerID string, params ToggleTargetParams) (*LoadBalancerDetails, error)
EnableTarget enables a target for the specified LoadBalancerBackend
func (*LoadBalancerService) List ¶
func (lb *LoadBalancerService) List(context context.Context) (*[]LoadBalancer, error)
List returns a list of loadbalancers
func (*LoadBalancerService) ListCertificates ¶
func (lb *LoadBalancerService) ListCertificates(context context.Context, loadbalancerID string) (*[]string, error)
ListCertificates list certificates for the LoadBalancer
func (*LoadBalancerService) RemoveBackend ¶
func (lb *LoadBalancerService) RemoveBackend(context context.Context, loadbalancerID string, params RemoveBackendParams) error
RemoveBackend deletes a backend
func (*LoadBalancerService) RemoveCertificate ¶
func (lb *LoadBalancerService) RemoveCertificate(context context.Context, loadbalancerID string, params string) error
RemoveCertificate deletes a certificate from the loadbalancer
func (*LoadBalancerService) RemoveFromBlacklist ¶
func (lb *LoadBalancerService) RemoveFromBlacklist(context context.Context, loadbalancerID string, params BlacklistParams) (*LoadBalancerDetails, error)
RemoveFromBlacklist deletes a prefix from the LoadBalancer blacklist
func (*LoadBalancerService) RemoveFrontend ¶
func (lb *LoadBalancerService) RemoveFrontend(context context.Context, loadbalancerID string, params RemoveFrontendParams) error
RemoveFrontend deletes a frontend
func (*LoadBalancerService) RemoveTarget ¶
func (lb *LoadBalancerService) RemoveTarget(context context.Context, loadbalancerID string, params RemoveTargetParams) error
RemoveTarget deletes a target from the specified LoadBalancerBackend
type Network ¶
type Network struct { DataCenter string `json:"datacenter"` Description string `json:"description"` ID string `json:"networkid"` Public string `json:"public"` }
Network represents a network
type NetworkAdapter ¶
type NetworkAdapter struct { AdapterType string `json:"adaptertype,omitempty"` Bandwidth int `json:"bandwidth"` ID string `json:"networkadapterid"` Name string `json:"name"` NetworkID string `json:"networkid"` ServerID string `json:"serverid"` State string `json:"state"` }
NetworkAdapter represents a networkadapter
func (*NetworkAdapter) IsLocked ¶
func (na *NetworkAdapter) IsLocked() bool
IsLocked returns true if the network adapter is currently locked, false otherwise
func (*NetworkAdapter) IsReady ¶
func (na *NetworkAdapter) IsReady() bool
IsReady returns true if the network adapter is currently ready, false otherwise
type NetworkAdapterService ¶
type NetworkAdapterService struct {
// contains filtered or unexported fields
}
NetworkAdapterService provides functions to interact with Networks
func (*NetworkAdapterService) Create ¶
func (s *NetworkAdapterService) Create(context context.Context, params CreateNetworkAdapterParams) (*NetworkAdapter, error)
Create creates a new NetworkAdapter
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") // NOTE: All parameters except ServerID are optional, the values shown below // are defaults and can be omitted. networkAdapter, _ := client.NetworkAdapters.Create(context.Background(), glesys.CreateNetworkAdapterParams{ AdapterType: "VMXNET 3", // "E1000" also available Bandwidth: 100, NetworkID: "internet-fbg", ServerID: "wps123456", }) fmt.Println(networkAdapter.ID) }
Output:
func (*NetworkAdapterService) Destroy ¶
func (s *NetworkAdapterService) Destroy(context context.Context, networkAdapterID string) error
Destroy deletes a NetworkAdapter
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") client.NetworkAdapters.Destroy(context.Background(), "f590b422-453c-4fc4-99e7-af2b72a60f63") }
Output:
func (*NetworkAdapterService) Details ¶
func (s *NetworkAdapterService) Details(context context.Context, networkAdapterID string) (*NetworkAdapter, error)
Details returns detailed information about a NetworkAdapter
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") networkAdapter, _ := client.NetworkAdapters.Details(context.Background(), "f590b422-453c-4fc4-99e7-af2b72a60f63") fmt.Println(networkAdapter.Name) }
Output:
func (*NetworkAdapterService) Edit ¶
func (s *NetworkAdapterService) Edit(context context.Context, networkAdapterID string, params EditNetworkAdapterParams) (*NetworkAdapter, error)
Edit modifies a NetworkAdapter
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") // NOTE: Changes are not reflected immediately. networkAdapter, _ := client.NetworkAdapters.Edit(context.Background(), "f590b422-453c-4fc4-99e7-af2b72a60f63", glesys.EditNetworkAdapterParams{ Bandwidth: 200, NetworkID: "vl12345", }) fmt.Println(networkAdapter.Name) }
Output:
type NetworkService ¶
type NetworkService struct {
// contains filtered or unexported fields
}
NetworkService provides functions to interact with Networks
func (*NetworkService) Create ¶
func (s *NetworkService) Create(context context.Context, params CreateNetworkParams) (*Network, error)
Create creates a new network
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") network, _ := client.Networks.Create(context.Background(), glesys.CreateNetworkParams{ DataCenter: "Falkenberg", Description: "My Network", }) fmt.Println(network.ID) }
Output:
func (*NetworkService) Destroy ¶
func (s *NetworkService) Destroy(context context.Context, networkID string) error
Destroy deletes a network
Example ¶
package main import ( "context" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") client.Networks.Destroy(context.Background(), "vl123456") }
Output:
func (*NetworkService) Details ¶
Details returns detailed information about one network
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") network, _ := client.Networks.Details(context.Background(), "vl123456") fmt.Println(network.Description) }
Output:
func (*NetworkService) Edit ¶
func (s *NetworkService) Edit(context context.Context, networkID string, params EditNetworkParams) (*Network, error)
Edit modifies a network
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") network, _ := client.Networks.Edit(context.Background(), "vl123456", glesys.EditNetworkParams{ Description: "My Private Network", }) fmt.Println(network.Description) }
Output:
func (*NetworkService) List ¶
func (s *NetworkService) List(context context.Context) (*[]Network, error)
List returns a list of Networks available under your account
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") networks, _ := client.Networks.List(context.Background()) for _, network := range *networks { fmt.Println(network.ID) } }
Output:
type RemoveBackendParams ¶
type RemoveBackendParams struct {
Name string `json:"backendname"`
}
RemoveBackendParams used when removing
type RemoveFrontendParams ¶
type RemoveFrontendParams struct {
Name string `json:"frontendname"`
}
RemoveFrontendParams used when removing
type RemoveTargetParams ¶
RemoveTargetParams used when removing targets
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"` Bandwidth int `json:"bandwidth"` DataCenter string `json:"datacenter"` Description string `json:"description"` 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"` Template string `json:"templatename"` }
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", "my-application/0.0.1") 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", "my-application/0.0.1") 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", "my-application/0.0.1") server, _ := client.Servers.Details(context.Background(), "vz12345") fmt.Println(server.Hostname) }
Output:
func (*ServerService) Edit ¶
func (s *ServerService) Edit(context context.Context, serverID string, params EditServerParams) (*ServerDetails, error)
Edit modifies a server
Example ¶
package main import ( "context" "fmt" glesys "github.com/glesys/glesys-go" ) func main() { client := glesys.NewClient("CL12345", "your-api-key", "my-application/0.0.1") server, _ := client.Servers.Edit(context.Background(), "vz12345", glesys.EditServerParams{ Bandwidth: 100, CPU: 4, Description: "Web Server", Hostname: "example.com", Memory: 4096, Storage: 250, }) fmt.Println(server.ID) }
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", "my-application/0.0.1") 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", "my-application/0.0.1") 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", "my-application/0.0.1") 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`.
type Target ¶
type Target struct { Enabled bool `json:"enabled"` Name string `json:"name"` Port int `json:"port"` Status string `json:"status"` TargetIP string `json:"ipaddress"` Weight int `json:"weight"` }
Targets used in backends
type ToggleTargetParams ¶
type ToggleTargetParams struct { Backend string `json:"backendname"` Name string `json:"targetname"` }
ToggleTargetParams used when enabling/disabling targets