hetzner

package module
v0.0.0-...-c038e08 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2018 License: Apache-2.0 Imports: 16 Imported by: 1

README

Go Report Card

WebsiteSlackForumTwitter

go-hetzner

Golang client for Hetzner

API Documentation

https://robot.your-server.de/doc/webservice/en.html

Documentation

Index

Constants

View Source
const (
	// Version of this libary
	Version = "0.1.0"

	// User agent for this library
	UserAgent = "appscode/" + Version

	// DefaultEndpoint to be used
	DefaultEndpoint = "https://robot-ws.your-server.de"
)
View Source
const (
	DefaultInitialInterval     = 50 * time.Millisecond
	DefaultRandomizationFactor = 0.5
	DefaultMultiplier          = 1.5
	DefaultMaxInterval         = 5 * time.Second
	DefaultMaxElapsedTime      = 60 * time.Second
)

Default values for ExponentialBackOff.

View Source
const (
	VServerCommand_Start    = "start"
	VServerCommand_Stop     = "stop"
	VServerCommand_Shutdown = "shutdown"
)

Variables

This section is empty.

Functions

func NewExponentialBackOff

func NewExponentialBackOff() *backoff.ExponentialBackOff

NewExponentialBackOff creates an instance of ExponentialBackOff using default values.

Types

type APIError

type APIError struct {
	// HTTP response that caused this error
	Response *http.Response `json:"-"`

	Status  int    `json:"status"`
	Code    string `json:"code"`
	Message string `json:"message"`

	// Array of missing input parameters or null
	Missing []string `json:"missing"`
	// Array of invalid input paramaters or null
	Invalid []string `json:"invalid"`

	// Maximum allowed requests
	MaxRequest int `json:"max_request"`
	// Time interval in seconds
	Interval int `json:"interval"`
}

An ErrorResponse reports the error caused by an API request

func (*APIError) Error

func (r *APIError) Error() string

type ActivateLinuxRequest

type ActivateLinuxRequest struct {
	ServerIP      string
	Dist          string   `url:"dist"`
	Arch          int      `url:"arch"`
	Lang          string   `url:"lang"`
	AuthorizedKey []string `url:"authorized_key,brackets"`
}

type AuthorizedKey

type AuthorizedKey struct {
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
	Type        string `json:"type"`
	Size        int    `json:"size"`
}

type Boot

type Boot struct {
	Rescue  *Rescue  `json:"rescue"`
	Linux   *Linux   `json:"linux"`
	Vnc     *Vnc     `json:"vnc"`
	Windows *Windows `json:"windows"`
	Plesk   *Plesk   `json:"plesk"`
	Cpanel  *Cpanel  `json:"cpanel"`
}

type BootService

type BootService interface {
	GetConfig(serverIP string) (*Boot, *http.Response, error)

	GetLinuxConfig(serverIP string) (*Linux, *http.Response, error)
	ActivateLinux(req *ActivateLinuxRequest) (*Linux, *http.Response, error)
	DeactivateLinux(serverIP string) (*http.Response, error)
}

See: https://wiki.hetzner.de/index.php/Robot_Webservice/en#Boot

type BootServiceImpl

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

func (*BootServiceImpl) ActivateLinux

func (s *BootServiceImpl) ActivateLinux(req *ActivateLinuxRequest) (*Linux, *http.Response, error)

func (*BootServiceImpl) DeactivateLinux

func (s *BootServiceImpl) DeactivateLinux(serverIP string) (*http.Response, error)

func (*BootServiceImpl) GetConfig

func (s *BootServiceImpl) GetConfig(serverIP string) (*Boot, *http.Response, error)

func (*BootServiceImpl) GetLinuxConfig

func (s *BootServiceImpl) GetLinuxConfig(serverIP string) (*Linux, *http.Response, error)

type CancelServerRequest

type CancelServerRequest struct {
	ServerIP           string
	CancellationDate   string `url:"cancellation_date"`
	CancellationReason string `url:"cancellation_reason,omitempty"`
}

type Cancellation

type Cancellation struct {
	ServerIP                 string        `json:"server_ip"`
	ServerNumber             int           `json:"server_number"`
	ServerName               string        `json:"server_name"`
	EarliestCancellationDate string        `json:"earliest_cancellation_date"`
	Cancelled                bool          `json:"cancelled"`
	CancellationDate         string        `json:"cancellation_date"`
	CancellationReason       ArrayOrString `json:"cancellation_reason"`
}

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL string

	// User agent for client
	UserAgent string

	// Debug will dump http request and response
	Debug bool

	Boot     BootService
	Ordering OrderingService
	Reset    ResetService
	Server   ServerService
	SSHKey   SSHKeyService
	VServer  VServerService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(username, password string) *Client

func (*Client) Call

func (c *Client) Call(method, path string, reqBody, resType interface{}, needAuth bool) (*http.Response, error)

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, request interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. If specified, the value pointed to by request is www-form-urlencoded and included in as the request body.

func (*Client) WithBackOff

func (c *Client) WithBackOff(b backoff.BackOff) *Client

func (*Client) WithTimeout

func (c *Client) WithTimeout(timeout time.Duration) *Client

func (*Client) WithUserAgent

func (c *Client) WithUserAgent(ua string) *Client

type Cpanel

type Cpanel struct {
	ServerIP     string        `json:"server_ip"`
	ServerNumber int           `json:"server_number"`
	Dist         ArrayOrString `json:"dist"`
	Arch         ArrayOrInt    `json:"arch"`
	Lang         ArrayOrString `json:"lang"`
	Active       bool          `json:"active"`
	Password     *string       `json:"password"`
	Hostname     *string       `json:"hostname"`
}

type CreateTransactionRequest

type CreateTransactionRequest struct {
	ProductID     string   `url:"product_id"`
	AuthorizedKey []string `url:"authorized_key,brackets"`
	Password      string   `url:"password,omitempty"`
	Dist          string   `url:"dist,omitempty"`
	Arch          int      `url:"arch,omitempty"`
	Lang          string   `url:"lang,omitempty"`
	Comment       string   `url:"comment,omitempty"`
	Test          bool     `url:"test"`
}

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response *http.Response

	// Error message
	Message string `json:"message"`
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type HostKey

type HostKey struct {
	Fingerprint string `json:"fingerprint"`
	Type        string `json:"type"`
	Size        int    `json:"size"`
}

type Linux

type Linux struct {
	ServerIP      string           `json:"server_ip"`
	ServerNumber  int              `json:"server_number"`
	Dist          ArrayOrString    `json:"dist"`
	Arch          ArrayOrInt       `json:"arch"`
	Lang          ArrayOrString    `json:"lang"`
	Active        bool             `json:"active"`
	Password      *string          `json:"password"`
	AuthorizedKey []*AuthorizedKey `json:"authorized_key"`
	HostKey       []*HostKey       `json:"host_key"`
}

type OrderingService

type OrderingService interface {
	ListProducts() ([]*Product, *http.Response, error)
	GetProduct(id string) (*Product, *http.Response, error)

	ListTransactions() ([]*Transaction, *http.Response, error)
	CreateTransaction(req *CreateTransactionRequest) (*Transaction, *http.Response, error)
	GetTransaction(id string) (*Transaction, *http.Response, error)
}

See: https://wiki.hetzner.de/index.php/Robot_Webservice/en#Server_ordering

type OrderingServiceImpl

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

func (*OrderingServiceImpl) CreateTransaction

func (*OrderingServiceImpl) GetProduct

func (s *OrderingServiceImpl) GetProduct(id string) (*Product, *http.Response, error)

func (*OrderingServiceImpl) GetTransaction

func (s *OrderingServiceImpl) GetTransaction(id string) (*Transaction, *http.Response, error)

func (*OrderingServiceImpl) ListProducts

func (s *OrderingServiceImpl) ListProducts() ([]*Product, *http.Response, error)

func (*OrderingServiceImpl) ListTransactions

func (s *OrderingServiceImpl) ListTransactions() ([]*Transaction, *http.Response, error)

type Plesk

type Plesk struct {
	ServerIP     string        `json:"server_ip"`
	ServerNumber int           `json:"server_number"`
	Dist         ArrayOrString `json:"dist"`
	Arch         ArrayOrInt    `json:"arch"`
	Lang         ArrayOrString `json:"lang"`
	Active       bool          `json:"active"`
	Password     *string       `json:"password"`
	Hostname     *string       `json:"hostname"`
}

type Product

type Product struct {
	ID            string   `json:"id"`
	Name          string   `json:"name"`
	Description   []string `json:"description"`
	Traffic       string   `json:"traffic"`
	Dist          []string `json:"dist"`
	Arch          []int    `json:"arch"`
	Lang          []string `json:"lang"`
	Price         string   `json:"price"`
	PriceSetup    string   `json:"price_setup"`
	PriceVat      string   `json:"price_vat"`
	PriceSetupVat string   `json:"price_setup_vat"`
}

type Rescue

type Rescue struct {
	ServerIP      string           `json:"server_ip"`
	ServerNumber  int              `json:"server_number"`
	Os            ArrayOrString    `json:"os"`
	Arch          ArrayOrInt       `json:"arch"`
	Active        bool             `json:"active"`
	Password      *string          `json:"password"`
	AuthorizedKey []*AuthorizedKey `json:"authorized_key"`
	HostKey       []*HostKey       `json:"host_key"`
}

type Reset

type Reset struct {
	ServerIP        string   `json:"server_ip"`
	ServerNumber    int      `json:"server_number"`
	Type            []string `json:"type"`
	OperatingStatus string   `json:"operating_status"`
}

type ResetCreateRequest

type ResetCreateRequest struct {
	ServerIP string
	Type     string `url:"type"`
}

type ResetCreateResponse

type ResetCreateResponse struct {
	ServerIP     string `json:"server_ip"`
	ServerNumber int    `json:"server_number"`
	Type         string `json:"type"`
}

type ResetService

type ResetService interface {
	List() ([]*Reset, *http.Response, error)
	Get(serverIP string) (*Reset, *http.Response, error)
	Create(req *ResetCreateRequest) (*Reset, *http.Response, error)
}

See: https://wiki.hetzner.de/index.php/Robot_Webservice/en#Reset

type ResetServiceImpl

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

func (*ResetServiceImpl) Create

func (*ResetServiceImpl) Get

func (s *ResetServiceImpl) Get(serverIP string) (*Reset, *http.Response, error)

func (*ResetServiceImpl) List

func (s *ResetServiceImpl) List() ([]*Reset, *http.Response, error)

type SSHKey

type SSHKey struct {
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
	Type        string `json:"type"`
	Size        int    `json:"size"`
	Data        string `json:"data"`
}

type SSHKeyCreateRequest

type SSHKeyCreateRequest struct {
	Name string `url:"name"`
	Data string `url:"data"`
}

type SSHKeyService

type SSHKeyService interface {
	List() ([]*SSHKey, *http.Response, error)
	Create(req *SSHKeyCreateRequest) (*SSHKey, *http.Response, error)
	Get(fingerprint string) (*SSHKey, *http.Response, error)
	Update(req *SSHKeyUpdateRequest) (*SSHKey, *http.Response, error)
	Delete(fingerprint string) (*http.Response, error)
}

See: https://wiki.hetzner.de/index.php/Robot_Webservice/en#SSH_keys

type SSHKeyServiceImpl

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

func (*SSHKeyServiceImpl) Create

func (*SSHKeyServiceImpl) Delete

func (s *SSHKeyServiceImpl) Delete(fingerprint string) (*http.Response, error)

func (*SSHKeyServiceImpl) Get

func (s *SSHKeyServiceImpl) Get(fingerprint string) (*SSHKey, *http.Response, error)

func (*SSHKeyServiceImpl) List

func (s *SSHKeyServiceImpl) List() ([]*SSHKey, *http.Response, error)

func (*SSHKeyServiceImpl) Update

type SSHKeyUpdateRequest

type SSHKeyUpdateRequest struct {
	Fingerprint string
	Name        string `url:"name"`
}

type Server

type Server struct {
	ServerSummary
	IP     []string `json:"ip"`
	Subnet []struct {
		IP   string `json:"ip"`
		Mask string `json:"mask"`
	} `json:"subnet"`
	Reset   bool `json:"reset"`
	Rescue  bool `json:"rescue"`
	Vnc     bool `json:"vnc"`
	Windows bool `json:"windows"`
	Plesk   bool `json:"plesk"`
	Cpanel  bool `json:"cpanel"`
	Wol     bool `json:"wol"`
}

type ServerService

type ServerService interface {
	ListServers() ([]*ServerSummary, *http.Response, error)
	GetServer(serverIP string) (*Server, *http.Response, error)
	UpdateServer(req *ServerUpdateRequest) (*Server, *http.Response, error)

	GetCancellation(serverIP string) (*Cancellation, *http.Response, error)
	CancelServer(req *CancelServerRequest) (*Cancellation, *http.Response, error)
	WithdrawCancellation(serverIP string) (*http.Response, error)
}

See: https://wiki.hetzner.de/index.php/Robot_Webservice/en#Server

type ServerServiceImpl

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

func (*ServerServiceImpl) CancelServer

func (*ServerServiceImpl) GetCancellation

func (s *ServerServiceImpl) GetCancellation(serverIP string) (*Cancellation, *http.Response, error)

func (*ServerServiceImpl) GetServer

func (s *ServerServiceImpl) GetServer(serverIP string) (*Server, *http.Response, error)

func (*ServerServiceImpl) ListServers

func (s *ServerServiceImpl) ListServers() ([]*ServerSummary, *http.Response, error)

func (*ServerServiceImpl) UpdateServer

func (s *ServerServiceImpl) UpdateServer(req *ServerUpdateRequest) (*Server, *http.Response, error)

func (*ServerServiceImpl) WithdrawCancellation

func (s *ServerServiceImpl) WithdrawCancellation(serverIP string) (*http.Response, error)

type ServerSummary

type ServerSummary struct {
	ServerIP     string `json:"server_ip"`
	ServerNumber int    `json:"server_number"`
	ServerName   string `json:"server_name"`
	Product      string `json:"product"`
	Dc           string `json:"dc"`
	Traffic      string `json:"traffic"`
	Flatrate     bool   `json:"flatrate"`
	Status       string `json:"status"`
	Throttled    bool   `json:"throttled"`
	Cancelled    bool   `json:"cancelled"`
	PaidUntil    string `json:"paid_until"`
}

type ServerUpdateRequest

type ServerUpdateRequest struct {
	ServerIP   string
	ServerName string `url:"server_name"`
}

type Transaction

type Transaction struct {
	ID            string    `json:"id"`
	Date          time.Time `json:"date"`
	Status        string    `json:"status"`
	ServerNumber  *string   `json:"server_number"`
	ServerIP      *string   `json:"server_ip"`
	AuthorizedKey []struct {
		Key *AuthorizedKey `json:"key"`
	} `json:"authorized_key"`
	HostKey []struct {
		Key *HostKey `json:"key"`
	} `json:"host_key"`
	Comment *string `json:"comment"`
	Product struct {
		ID          string   `json:"id"`
		Name        string   `json:"name"`
		Description []string `json:"description"`
		Traffic     string   `json:"traffic"`
		Dist        string   `json:"dist"`
		Arch        string   `json:"arch"`
		Lang        string   `json:"lang"`
	} `json:"product"`
}

type VServerCommandRequest

type VServerCommandRequest struct {
	ServerIP string
	Type     string `url:"type"`
}

type VServerServiceImpl

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

func (*VServerServiceImpl) Command

type Vnc

type Vnc struct {
	ServerIP     string        `json:"server_ip"`
	ServerNumber int           `json:"server_number"`
	Dist         ArrayOrString `json:"dist"`
	Arch         ArrayOrInt    `json:"arch"`
	Lang         ArrayOrString `json:"lang"`
	Active       bool          `json:"active"`
	Password     *string       `json:"password"`
}

type WOL

type WOL struct {
	ServerIP     string `json:"server_ip"`
	ServerNumber int    `json:"server_number"`
}

type WOLService

type WOLService interface {
	Create(serverIP string) (*WOL, *http.Response, error)
	Get(serverIP string) (*WOL, *http.Response, error)
}

See: https://wiki.hetzner.de/index.php/Robot_Webservice/en#Wake_on_LAN

type WOLServiceImpl

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

func (*WOLServiceImpl) Create

func (s *WOLServiceImpl) Create(serverIP string) (*WOL, *http.Response, error)

func (*WOLServiceImpl) Get

func (s *WOLServiceImpl) Get(serverIP string) (*WOL, *http.Response, error)

type Windows

type Windows struct {
	ServerIP     string        `json:"server_ip"`
	ServerNumber int           `json:"server_number"`
	Dist         ArrayOrString `json:"dist"`
	Lang         ArrayOrString `json:"lang"`
	Active       bool          `json:"active"`
	Password     *string       `json:"password"`
}

Jump to

Keyboard shortcuts

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