Documentation
¶
Overview ¶
Package hcloud is a library for the Hetzner Cloud API.
Index ¶
- Constants
- func Int(i int) *int
- func IsError(err error, code ErrorCode) bool
- func String(s string) *string
- type Action
- type ActionClient
- func (c *ActionClient) All(ctx context.Context) ([]*Action, error)
- func (c *ActionClient) GetByID(ctx context.Context, id int) (*Action, *Response, error)
- func (c *ActionClient) List(ctx context.Context, opts ActionListOpts) ([]*Action, *Response, error)
- func (c *ActionClient) WatchProgress(ctx context.Context, action *Action) (<-chan int, <-chan error)
- type ActionError
- type ActionListOpts
- type ActionResource
- type ActionResourceType
- type ActionStatus
- type BackoffFunc
- type Client
- type ClientOption
- type Datacenter
- type DatacenterClient
- func (c *DatacenterClient) All(ctx context.Context) ([]*Datacenter, error)
- func (c *DatacenterClient) Get(ctx context.Context, idOrName string) (*Datacenter, *Response, error)
- func (c *DatacenterClient) GetByID(ctx context.Context, id int) (*Datacenter, *Response, error)
- func (c *DatacenterClient) GetByName(ctx context.Context, name string) (*Datacenter, *Response, error)
- func (c *DatacenterClient) List(ctx context.Context, opts DatacenterListOpts) ([]*Datacenter, *Response, error)
- type DatacenterListOpts
- type DatacenterServerTypes
- type Error
- type ErrorCode
- type ErrorDetailsInvalidInput
- type ErrorDetailsInvalidInputField
- type FloatingIP
- type FloatingIPClient
- func (c *FloatingIPClient) All(ctx context.Context) ([]*FloatingIP, error)
- func (c *FloatingIPClient) Assign(ctx context.Context, floatingIP *FloatingIP, server *Server) (*Action, *Response, error)
- func (c *FloatingIPClient) ChangeDNSPtr(ctx context.Context, floatingIP *FloatingIP, ip string, ptr *string) (*Action, *Response, error)
- func (c *FloatingIPClient) Create(ctx context.Context, opts FloatingIPCreateOpts) (FloatingIPCreateResult, *Response, error)
- func (c *FloatingIPClient) Delete(ctx context.Context, floatingIP *FloatingIP) (*Response, error)
- func (c *FloatingIPClient) GetByID(ctx context.Context, id int) (*FloatingIP, *Response, error)
- func (c *FloatingIPClient) List(ctx context.Context, opts FloatingIPListOpts) ([]*FloatingIP, *Response, error)
- func (c *FloatingIPClient) Unassign(ctx context.Context, floatingIP *FloatingIP) (*Action, *Response, error)
- func (c *FloatingIPClient) Update(ctx context.Context, floatingIP *FloatingIP, opts FloatingIPUpdateOpts) (*FloatingIP, *Response, error)
- type FloatingIPCreateOpts
- type FloatingIPCreateResult
- type FloatingIPListOpts
- type FloatingIPPricing
- type FloatingIPType
- type FloatingIPUpdateOpts
- type ISO
- type ISOClient
- func (c *ISOClient) All(ctx context.Context) ([]*ISO, error)
- func (c *ISOClient) Get(ctx context.Context, idOrName string) (*ISO, *Response, error)
- func (c *ISOClient) GetByID(ctx context.Context, id int) (*ISO, *Response, error)
- func (c *ISOClient) GetByName(ctx context.Context, name string) (*ISO, *Response, error)
- func (c *ISOClient) List(ctx context.Context, opts ISOListOpts) ([]*ISO, *Response, error)
- type ISOListOpts
- type ISOType
- type Image
- type ImageClient
- func (c *ImageClient) All(ctx context.Context) ([]*Image, error)
- func (c *ImageClient) Delete(ctx context.Context, image *Image) (*Response, error)
- func (c *ImageClient) Get(ctx context.Context, idOrName string) (*Image, *Response, error)
- func (c *ImageClient) GetByID(ctx context.Context, id int) (*Image, *Response, error)
- func (c *ImageClient) GetByName(ctx context.Context, name string) (*Image, *Response, error)
- func (c *ImageClient) List(ctx context.Context, opts ImageListOpts) ([]*Image, *Response, error)
- func (c *ImageClient) Update(ctx context.Context, image *Image, opts ImageUpdateOpts) (*Image, *Response, error)
- type ImageListOpts
- type ImagePricing
- type ImageStatus
- type ImageType
- type ImageUpdateOpts
- type ListOpts
- type Location
- type LocationClient
- func (c *LocationClient) All(ctx context.Context) ([]*Location, error)
- func (c *LocationClient) Get(ctx context.Context, idOrName string) (*Location, *Response, error)
- func (c *LocationClient) GetByID(ctx context.Context, id int) (*Location, *Response, error)
- func (c *LocationClient) GetByName(ctx context.Context, name string) (*Location, *Response, error)
- func (c *LocationClient) List(ctx context.Context, opts LocationListOpts) ([]*Location, *Response, error)
- type LocationListOpts
- type Meta
- type Pagination
- type Price
- type Pricing
- type PricingClient
- type Ratelimit
- type Response
- type SSHKey
- type SSHKeyClient
- func (c *SSHKeyClient) All(ctx context.Context) ([]*SSHKey, error)
- func (c *SSHKeyClient) Create(ctx context.Context, opts SSHKeyCreateOpts) (*SSHKey, *Response, error)
- func (c *SSHKeyClient) Delete(ctx context.Context, sshKey *SSHKey) (*Response, error)
- func (c *SSHKeyClient) Get(ctx context.Context, idOrName string) (*SSHKey, *Response, error)
- func (c *SSHKeyClient) GetByID(ctx context.Context, id int) (*SSHKey, *Response, error)
- func (c *SSHKeyClient) GetByName(ctx context.Context, name string) (*SSHKey, *Response, error)
- func (c *SSHKeyClient) List(ctx context.Context, opts SSHKeyListOpts) ([]*SSHKey, *Response, error)
- func (c *SSHKeyClient) Update(ctx context.Context, sshKey *SSHKey, opts SSHKeyUpdateOpts) (*SSHKey, *Response, error)
- type SSHKeyCreateOpts
- type SSHKeyListOpts
- type SSHKeyUpdateOpts
- type Server
- type ServerBackupPricing
- type ServerChangeTypeOpts
- type ServerClient
- func (c *ServerClient) All(ctx context.Context) ([]*Server, error)
- func (c *ServerClient) AttachISO(ctx context.Context, server *Server, iso *ISO) (*Action, *Response, error)
- func (c *ServerClient) ChangeDNSPtr(ctx context.Context, server *Server, ip string, ptr *string) (*Action, *Response, error)
- func (c *ServerClient) ChangeType(ctx context.Context, server *Server, opts ServerChangeTypeOpts) (*Action, *Response, error)
- func (c *ServerClient) Create(ctx context.Context, opts ServerCreateOpts) (ServerCreateResult, *Response, error)
- func (c *ServerClient) CreateImage(ctx context.Context, server *Server, opts *ServerCreateImageOpts) (ServerCreateImageResult, *Response, error)
- func (c *ServerClient) Delete(ctx context.Context, server *Server) (*Response, error)
- func (c *ServerClient) DetachISO(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) DisableBackup(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) DisableRescue(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) EnableBackup(ctx context.Context, server *Server, window string) (*Action, *Response, error)
- func (c *ServerClient) EnableRescue(ctx context.Context, server *Server, opts ServerEnableRescueOpts) (ServerEnableRescueResult, *Response, error)
- func (c *ServerClient) Get(ctx context.Context, idOrName string) (*Server, *Response, error)
- func (c *ServerClient) GetByID(ctx context.Context, id int) (*Server, *Response, error)
- func (c *ServerClient) GetByName(ctx context.Context, name string) (*Server, *Response, error)
- func (c *ServerClient) List(ctx context.Context, opts ServerListOpts) ([]*Server, *Response, error)
- func (c *ServerClient) Poweroff(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) Poweron(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) Reboot(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) Rebuild(ctx context.Context, server *Server, opts ServerRebuildOpts) (*Action, *Response, error)
- func (c *ServerClient) Reset(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) ResetPassword(ctx context.Context, server *Server) (ServerResetPasswordResult, *Response, error)
- func (c *ServerClient) Shutdown(ctx context.Context, server *Server) (*Action, *Response, error)
- func (c *ServerClient) Update(ctx context.Context, server *Server, opts ServerUpdateOpts) (*Server, *Response, error)
- type ServerCreateImageOpts
- type ServerCreateImageResult
- type ServerCreateOpts
- type ServerCreateResult
- type ServerEnableRescueOpts
- type ServerEnableRescueResult
- type ServerListOpts
- type ServerPublicNet
- type ServerPublicNetIPv4
- type ServerPublicNetIPv6
- type ServerRebuildOpts
- type ServerRescueType
- type ServerResetPasswordResult
- type ServerStatus
- type ServerType
- type ServerTypeClient
- func (c *ServerTypeClient) All(ctx context.Context) ([]*ServerType, error)
- func (c *ServerTypeClient) Get(ctx context.Context, idOrName string) (*ServerType, *Response, error)
- func (c *ServerTypeClient) GetByID(ctx context.Context, id int) (*ServerType, *Response, error)
- func (c *ServerTypeClient) GetByName(ctx context.Context, name string) (*ServerType, *Response, error)
- func (c *ServerTypeClient) List(ctx context.Context, opts ServerTypeListOpts) ([]*ServerType, *Response, error)
- type ServerTypeListOpts
- type ServerTypeLocationPricing
- type ServerTypePricing
- type ServerUpdateOpts
- type StorageType
- type TrafficPricing
Constants ¶
const ( ActionStatusRunning ActionStatus = "running" ActionStatusSuccess = "success" ActionStatusError = "error" )
List of action statuses.
const ( ActionResourceTypeServer ActionResourceType = "server" ActionResourceTypeImage = "image" ActionResourceTypeISO = "iso" ActionResourceTypeFloatingIP = "floating_ip" )
List of action resource reference types.
const ( ErrorCodeServiceError ErrorCode = "service_error" // Generic server error ErrorCodeRateLimitExceeded = "rate_limit_exceeded" // Rate limit exceeded ErrorCodeUnknownError = "unknown_error" // Unknown error ErrorCodeNotFound = "not_found" // Resource not found ErrorCodeInvalidInput = "invalid_input" // Validation error // Deprecated error codes ErrorCodeLimitReached = "limit_reached" )
Error codes returned from the API.
const ( // ImageTypeSnapshot represents a snapshot image. ImageTypeSnapshot ImageType = "snapshot" // ImageTypeBackup represents a backup image. ImageTypeBackup = "backup" // ImageTypeSystem represents a system image. ImageTypeSystem = "system" )
const ( // ServerStatusInitializing is the status when a server is initializing. ServerStatusInitializing ServerStatus = "initializing" // ServerStatusOff is the status when a server is off. ServerStatusOff = "off" // ServerStatusRunning is the status when a server is running. ServerStatusRunning = "running" )
const ( ServerRescueTypeLinux32 ServerRescueType = "linux32" ServerRescueTypeLinux64 = "linux64" ServerRescueTypeFreeBSD64 = "freebsd64" )
List of rescue types.
const Endpoint = "https://api.hetzner.cloud/v1"
Endpoint is the base URL of the API.
const UserAgent = "hcloud-go/" + Version
UserAgent is the value for the User-Agent header sent with each request.
const Version = "1.2.0"
Version is the library's version following Semantic Versioning.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct {
ID int
Status ActionStatus
Command string
Progress int
Started time.Time
Finished time.Time
ErrorCode string
ErrorMessage string
Resources []*ActionResource
}
Action represents an action in the Hetzner Cloud.
func ActionFromSchema ¶
ActionFromSchema converts a schema.Action to an Action.
type ActionClient ¶
type ActionClient struct {
// contains filtered or unexported fields
}
ActionClient is a client for the actions API.
func (*ActionClient) All ¶
func (c *ActionClient) All(ctx context.Context) ([]*Action, error)
All returns all actions.
func (*ActionClient) List ¶
func (c *ActionClient) List(ctx context.Context, opts ActionListOpts) ([]*Action, *Response, error)
List returns a list of actions for a specific page.
func (*ActionClient) WatchProgress ¶ added in v1.2.0
func (c *ActionClient) WatchProgress(ctx context.Context, action *Action) (<-chan int, <-chan error)
WatchProgress watches the actions progress until it completes with success or error.
type ActionError ¶ added in v1.2.0
ActionError is the error of an action.
func (ActionError) Error ¶ added in v1.2.0
func (e ActionError) Error() string
type ActionListOpts ¶
type ActionListOpts struct {
ListOpts
}
ActionListOpts specifies options for listing actions.
type ActionResource ¶
type ActionResource struct {
ID int
Type ActionResourceType
}
ActionResource references other resources from an action.
type ActionResourceType ¶
type ActionResourceType string
ActionResourceType represents an action's resource reference type.
type BackoffFunc ¶
A BackoffFunc returns the duration to wait before performing the next retry. The retries argument specifies how many retries have already been performed. When called for the first time, retries is 0.
func ConstantBackoff ¶
func ConstantBackoff(d time.Duration) BackoffFunc
ConstantBackoff returns a BackoffFunc which backs off for constant duration d.
func ExponentialBackoff ¶
func ExponentialBackoff(b float64, d time.Duration) BackoffFunc
ExponentialBackoff returns a BackoffFunc which implements an exponential backoff using the formula: b^retries * d
type Client ¶
type Client struct {
Action ActionClient
Datacenter DatacenterClient
FloatingIP FloatingIPClient
Image ImageClient
ISO ISOClient
Location LocationClient
Pricing PricingClient
Server ServerClient
ServerType ServerTypeClient
SSHKey SSHKeyClient
// contains filtered or unexported fields
}
Client is a client for the Hetzner Cloud API.
type ClientOption ¶
type ClientOption func(*Client)
A ClientOption is used to configure a Client.
func WithBackoffFunc ¶
func WithBackoffFunc(f BackoffFunc) ClientOption
WithBackoffFunc configures a Client to use the specified backoff function.
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientOption
WithEndpoint configures a Client to use the specified API endpoint.
func WithToken ¶
func WithToken(token string) ClientOption
WithToken configures a Client to use the specified token for authentication.
type Datacenter ¶
type Datacenter struct {
ID int
Name string
Description string
Location *Location
ServerTypes DatacenterServerTypes
}
Datacenter represents a datacenter in the Hetzner Cloud.
func DatacenterFromSchema ¶
func DatacenterFromSchema(s schema.Datacenter) *Datacenter
DatacenterFromSchema converts a schema.Datacenter to a Datacenter.
type DatacenterClient ¶
type DatacenterClient struct {
// contains filtered or unexported fields
}
DatacenterClient is a client for the datacenter API.
func (*DatacenterClient) All ¶
func (c *DatacenterClient) All(ctx context.Context) ([]*Datacenter, error)
All returns all datacenters.
func (*DatacenterClient) Get ¶
func (c *DatacenterClient) Get(ctx context.Context, idOrName string) (*Datacenter, *Response, error)
Get retrieves a datacenter by its ID if the input can be parsed as an integer, otherwise it retrieves a datacenter by its name.
func (*DatacenterClient) GetByID ¶
func (c *DatacenterClient) GetByID(ctx context.Context, id int) (*Datacenter, *Response, error)
GetByID retrieves a datacenter by its ID.
func (*DatacenterClient) GetByName ¶
func (c *DatacenterClient) GetByName(ctx context.Context, name string) (*Datacenter, *Response, error)
GetByName retrieves an datacenter by its name.
func (*DatacenterClient) List ¶
func (c *DatacenterClient) List(ctx context.Context, opts DatacenterListOpts) ([]*Datacenter, *Response, error)
List returns a list of datacenters for a specific page.
type DatacenterListOpts ¶
type DatacenterListOpts struct {
ListOpts
}
DatacenterListOpts specifies options for listing datacenters.
type DatacenterServerTypes ¶
type DatacenterServerTypes struct {
Supported []*ServerType
Available []*ServerType
}
DatacenterServerTypes represents the server types available and supported in a datacenter.
type Error ¶
Error is an error returned from the API.
func ErrorFromSchema ¶
ErrorFromSchema converts a schema.Error to an Error.
type ErrorDetailsInvalidInput ¶
type ErrorDetailsInvalidInput struct {
Fields []ErrorDetailsInvalidInputField
}
ErrorDetailsInvalidInput contains the details of an 'invalid_input' error.
type ErrorDetailsInvalidInputField ¶
ErrorDetailsInvalidInputField contains the validation errors reported on a field.
type FloatingIP ¶
type FloatingIP struct {
ID int
Description string
IP net.IP
Network *net.IPNet
Type FloatingIPType
Server *Server
DNSPtr map[string]string
HomeLocation *Location
Blocked bool
}
FloatingIP represents a Floating IP in the Hetzner Cloud.
func FloatingIPFromSchema ¶
func FloatingIPFromSchema(s schema.FloatingIP) *FloatingIP
FloatingIPFromSchema converts a schema.FloatingIP to a FloatingIP.
func (*FloatingIP) DNSPtrForIP ¶
func (f *FloatingIP) DNSPtrForIP(ip net.IP) string
DNSPtrForIP returns the reverse DNS pointer of the IP address.
type FloatingIPClient ¶
type FloatingIPClient struct {
// contains filtered or unexported fields
}
FloatingIPClient is a client for the Floating IP API.
func (*FloatingIPClient) All ¶
func (c *FloatingIPClient) All(ctx context.Context) ([]*FloatingIP, error)
All returns all Floating IPs.
func (*FloatingIPClient) Assign ¶
func (c *FloatingIPClient) Assign(ctx context.Context, floatingIP *FloatingIP, server *Server) (*Action, *Response, error)
Assign assigns a Floating IP to a server.
func (*FloatingIPClient) ChangeDNSPtr ¶
func (c *FloatingIPClient) ChangeDNSPtr(ctx context.Context, floatingIP *FloatingIP, ip string, ptr *string) (*Action, *Response, error)
ChangeDNSPtr changes or resets the reverse DNS pointer for a Floating IP address. Pass a nil ptr to reset the reverse DNS pointer to its default value.
func (*FloatingIPClient) Create ¶
func (c *FloatingIPClient) Create(ctx context.Context, opts FloatingIPCreateOpts) (FloatingIPCreateResult, *Response, error)
Create creates a Floating IP.
func (*FloatingIPClient) Delete ¶
func (c *FloatingIPClient) Delete(ctx context.Context, floatingIP *FloatingIP) (*Response, error)
Delete deletes a Floating IP.
func (*FloatingIPClient) GetByID ¶
func (c *FloatingIPClient) GetByID(ctx context.Context, id int) (*FloatingIP, *Response, error)
GetByID retrieves a Floating IP by its ID.
func (*FloatingIPClient) List ¶
func (c *FloatingIPClient) List(ctx context.Context, opts FloatingIPListOpts) ([]*FloatingIP, *Response, error)
List returns a list of Floating IPs for a specific page.
func (*FloatingIPClient) Unassign ¶
func (c *FloatingIPClient) Unassign(ctx context.Context, floatingIP *FloatingIP) (*Action, *Response, error)
Unassign unassigns a Floating IP from the currently assigned server.
func (*FloatingIPClient) Update ¶
func (c *FloatingIPClient) Update(ctx context.Context, floatingIP *FloatingIP, opts FloatingIPUpdateOpts) (*FloatingIP, *Response, error)
Update updates a Floating IP.
type FloatingIPCreateOpts ¶
type FloatingIPCreateOpts struct {
Type FloatingIPType
HomeLocation *Location
Server *Server
Description *string
}
FloatingIPCreateOpts specifies options for creating a Floating IP.
func (FloatingIPCreateOpts) Validate ¶
func (o FloatingIPCreateOpts) Validate() error
Validate checks if options are valid.
type FloatingIPCreateResult ¶
type FloatingIPCreateResult struct {
FloatingIP *FloatingIP
Action *Action
}
FloatingIPCreateResult is the result of creating a Floating IP.
type FloatingIPListOpts ¶
type FloatingIPListOpts struct {
ListOpts
}
FloatingIPListOpts specifies options for listing Floating IPs.
type FloatingIPPricing ¶
type FloatingIPPricing struct {
Monthly Price
}
FloatingIPPricing provides pricing information for Floating IPs.
type FloatingIPType ¶
type FloatingIPType string
FloatingIPType represents the type of a Floating IP.
const ( FloatingIPTypeIPv4 FloatingIPType = "ipv4" FloatingIPTypeIPv6 = "ipv6" )
Floating IP types.
type FloatingIPUpdateOpts ¶
type FloatingIPUpdateOpts struct {
Description string
}
FloatingIPUpdateOpts specifies options for updating a Floating IP.
type ISO ¶
ISO represents an ISO image in the Hetzner Cloud.
func ISOFromSchema ¶
ISOFromSchema converts a schema.ISO to an ISO.
type ISOClient ¶
type ISOClient struct {
// contains filtered or unexported fields
}
ISOClient is a client for the ISO API.
func (*ISOClient) Get ¶
Get retrieves an ISO by its ID if the input can be parsed as an integer, otherwise it retrieves an ISO by its name.
type ISOListOpts ¶
type ISOListOpts struct {
ListOpts
}
ISOListOpts specifies options for listing isos.
type ISOType ¶
type ISOType string
ISOType specifies the type of an ISO image.
const ( // ISOTypePublic is the type of a public ISO image. ISOTypePublic ISOType = "public" // ISOTypePrivate is the type of a private ISO image. ISOTypePrivate = "private" )
type Image ¶
type Image struct {
ID int
Name string
Type ImageType
Status ImageStatus
Description string
ImageSize float32
DiskSize float32
Created time.Time
CreatedFrom *Server
BoundTo *Server
RapidDeploy bool
OSFlavor string
OSVersion string
}
Image represents an Image in the Hetzner Cloud.
func ImageFromSchema ¶
ImageFromSchema converts a schema.Image to an Image.
type ImageClient ¶
type ImageClient struct {
// contains filtered or unexported fields
}
ImageClient is a client for the image API.
func (*ImageClient) All ¶
func (c *ImageClient) All(ctx context.Context) ([]*Image, error)
All returns all images.
func (*ImageClient) Get ¶
Get retrieves an image by its ID if the input can be parsed as an integer, otherwise it retrieves an image by its name.
func (*ImageClient) List ¶
func (c *ImageClient) List(ctx context.Context, opts ImageListOpts) ([]*Image, *Response, error)
List returns a list of images for a specific page.
func (*ImageClient) Update ¶
func (c *ImageClient) Update(ctx context.Context, image *Image, opts ImageUpdateOpts) (*Image, *Response, error)
Update updates an image.
type ImageListOpts ¶
type ImageListOpts struct {
ListOpts
}
ImageListOpts specifies options for listing images.
type ImagePricing ¶
type ImagePricing struct {
PerGBMonth Price
}
ImagePricing provides pricing information for imaegs.
type ImageStatus ¶
type ImageStatus string
ImageStatus specifies the status of an image.
const ( // ImageStatusCreating is the status when an image is being created. ImageStatusCreating ImageStatus = "creating" // ImageStatusAvailable is the stats when an image is available. ImageStatusAvailable = "available" )
type ImageUpdateOpts ¶
ImageUpdateOpts specifies options for updating an image.
type ListOpts ¶
type ListOpts struct {
Page int // Page (starting at 1)
PerPage int // Items per page (0 means default)
}
ListOpts specifies options for listing resources.
type Location ¶
type Location struct {
ID int
Name string
Description string
Country string
City string
Latitude float64
Longitude float64
}
Location represents a location in the Hetzner Cloud.
func LocationFromSchema ¶
LocationFromSchema converts a schema.Location to a Location.
type LocationClient ¶
type LocationClient struct {
// contains filtered or unexported fields
}
LocationClient is a client for the location API.
func (*LocationClient) All ¶
func (c *LocationClient) All(ctx context.Context) ([]*Location, error)
All returns all locations.
func (*LocationClient) Get ¶
Get retrieves a location by its ID if the input can be parsed as an integer, otherwise it retrieves a location by its name.
func (*LocationClient) List ¶
func (c *LocationClient) List(ctx context.Context, opts LocationListOpts) ([]*Location, *Response, error)
List returns a list of locations for a specific page.
type LocationListOpts ¶
type LocationListOpts struct {
ListOpts
}
LocationListOpts specifies options for listing location.
type Meta ¶
type Meta struct {
Pagination *Pagination
Ratelimit Ratelimit
}
Meta represents meta information included in an API response.
type Pagination ¶
type Pagination struct {
Page int
PerPage int
PreviousPage int
NextPage int
LastPage int
TotalEntries int
}
Pagination represents pagination meta information.
func PaginationFromSchema ¶
func PaginationFromSchema(s schema.MetaPagination) Pagination
PaginationFromSchema converts a schema.MetaPagination to a Pagination.
type Price ¶
Price represents a price. Net amount, gross amount, as well as VAT rate are specified as strings and it is the user's responsibility to convert them to appropriate types for calculations.
type Pricing ¶
type Pricing struct {
Image ImagePricing
FloatingIP FloatingIPPricing
Traffic TrafficPricing
ServerBackup ServerBackupPricing
ServerTypes []ServerTypePricing
}
Pricing specifies pricing information for various resources.
func PricingFromSchema ¶
PricingFromSchema converts a schema.Pricing to a Pricing.
type PricingClient ¶
type PricingClient struct {
// contains filtered or unexported fields
}
PricingClient is a client for the pricing API.
type SSHKey ¶
SSHKey represents a SSH key in the Hetzner Cloud.
func SSHKeyFromSchema ¶
SSHKeyFromSchema converts a schema.SSHKey to a SSHKey.
type SSHKeyClient ¶
type SSHKeyClient struct {
// contains filtered or unexported fields
}
SSHKeyClient is a client for the SSH keys API.
func (*SSHKeyClient) All ¶
func (c *SSHKeyClient) All(ctx context.Context) ([]*SSHKey, error)
All returns all SSH keys.
func (*SSHKeyClient) Create ¶
func (c *SSHKeyClient) Create(ctx context.Context, opts SSHKeyCreateOpts) (*SSHKey, *Response, error)
Create creates a new SSH key with the given options.
func (*SSHKeyClient) Get ¶
Get retrieves a SSH key by its ID if the input can be parsed as an integer, otherwise it retrieves a SSH key by its name.
func (*SSHKeyClient) List ¶
func (c *SSHKeyClient) List(ctx context.Context, opts SSHKeyListOpts) ([]*SSHKey, *Response, error)
List returns a list of SSH keys for a specific page.
func (*SSHKeyClient) Update ¶
func (c *SSHKeyClient) Update(ctx context.Context, sshKey *SSHKey, opts SSHKeyUpdateOpts) (*SSHKey, *Response, error)
Update updates a SSH key.
type SSHKeyCreateOpts ¶
SSHKeyCreateOpts specifies parameters for creating a SSH key.
func (SSHKeyCreateOpts) Validate ¶
func (o SSHKeyCreateOpts) Validate() error
Validate checks if options are valid.
type SSHKeyListOpts ¶
type SSHKeyListOpts struct {
ListOpts
}
SSHKeyListOpts specifies options for listing SSH keys.
type SSHKeyUpdateOpts ¶
type SSHKeyUpdateOpts struct {
Name string
}
SSHKeyUpdateOpts specifies options for updating a SSH key.
type Server ¶
type Server struct {
ID int
Name string
Status ServerStatus
Created time.Time
PublicNet ServerPublicNet
ServerType *ServerType
Datacenter *Datacenter
IncludedTraffic uint64
OutgoingTraffic uint64
IngoingTraffic uint64
BackupWindow string
RescueEnabled bool
Locked bool
ISO *ISO
Image *Image
}
Server represents a server in the Hetzner Cloud.
func ServerFromSchema ¶
ServerFromSchema converts a schema.Server to a Server.
type ServerBackupPricing ¶
type ServerBackupPricing struct {
Percentage string
}
ServerBackupPricing provides pricing information for server backups.
type ServerChangeTypeOpts ¶
type ServerChangeTypeOpts struct {
ServerType *ServerType // new server type
UpgradeDisk bool // whether disk should be upgraded
}
ServerChangeTypeOpts specifies options for changing a server's type.
type ServerClient ¶
type ServerClient struct {
// contains filtered or unexported fields
}
ServerClient is a client for the servers API.
func (*ServerClient) All ¶
func (c *ServerClient) All(ctx context.Context) ([]*Server, error)
All returns all servers.
func (*ServerClient) AttachISO ¶
func (c *ServerClient) AttachISO(ctx context.Context, server *Server, iso *ISO) (*Action, *Response, error)
AttachISO attaches an ISO to a server.
func (*ServerClient) ChangeDNSPtr ¶
func (c *ServerClient) ChangeDNSPtr(ctx context.Context, server *Server, ip string, ptr *string) (*Action, *Response, error)
ChangeDNSPtr changes or resets the reverse DNS pointer for a server IP address. Pass a nil ptr to reset the reverse DNS pointer to its default value.
func (*ServerClient) ChangeType ¶
func (c *ServerClient) ChangeType(ctx context.Context, server *Server, opts ServerChangeTypeOpts) (*Action, *Response, error)
ChangeType changes a server's type.
func (*ServerClient) Create ¶
func (c *ServerClient) Create(ctx context.Context, opts ServerCreateOpts) (ServerCreateResult, *Response, error)
Create creates a new server.
func (*ServerClient) CreateImage ¶
func (c *ServerClient) CreateImage(ctx context.Context, server *Server, opts *ServerCreateImageOpts) (ServerCreateImageResult, *Response, error)
CreateImage creates an image from a server.
func (*ServerClient) DisableBackup ¶
func (c *ServerClient) DisableBackup(ctx context.Context, server *Server) (*Action, *Response, error)
DisableBackup disables backup for a server.
func (*ServerClient) DisableRescue ¶
func (c *ServerClient) DisableRescue(ctx context.Context, server *Server) (*Action, *Response, error)
DisableRescue disables rescue mode for a server.
func (*ServerClient) EnableBackup ¶
func (c *ServerClient) EnableBackup(ctx context.Context, server *Server, window string) (*Action, *Response, error)
EnableBackup enables backup for a server. Pass in an empty backup window to let the API pick a window for you. See the API documentation at docs.hetzner.cloud for a list of valid backup windows.
func (*ServerClient) EnableRescue ¶
func (c *ServerClient) EnableRescue(ctx context.Context, server *Server, opts ServerEnableRescueOpts) (ServerEnableRescueResult, *Response, error)
EnableRescue enables rescue mode for a server.
func (*ServerClient) Get ¶
Get retrieves a server by its ID if the input can be parsed as an integer, otherwise it retrieves a server by its name.
func (*ServerClient) List ¶
func (c *ServerClient) List(ctx context.Context, opts ServerListOpts) ([]*Server, *Response, error)
List returns a list of servers for a specific page.
func (*ServerClient) Rebuild ¶
func (c *ServerClient) Rebuild(ctx context.Context, server *Server, opts ServerRebuildOpts) (*Action, *Response, error)
Rebuild rebuilds a server.
func (*ServerClient) ResetPassword ¶
func (c *ServerClient) ResetPassword(ctx context.Context, server *Server) (ServerResetPasswordResult, *Response, error)
ResetPassword resets a server's password.
func (*ServerClient) Update ¶
func (c *ServerClient) Update(ctx context.Context, server *Server, opts ServerUpdateOpts) (*Server, *Response, error)
Update updates a server.
type ServerCreateImageOpts ¶
ServerCreateImageOpts specifies options for creating an image from a server.
func (ServerCreateImageOpts) Validate ¶
func (o ServerCreateImageOpts) Validate() error
Validate checks if options are valid.
type ServerCreateImageResult ¶
ServerCreateImageResult is the result of creating an image from a server.
type ServerCreateOpts ¶
type ServerCreateOpts struct {
Name string
ServerType *ServerType
Image *Image
SSHKeys []*SSHKey
Location *Location
Datacenter *Datacenter
}
ServerCreateOpts specifies options for creating a new server.
func (ServerCreateOpts) Validate ¶
func (o ServerCreateOpts) Validate() error
Validate checks if options are valid.
type ServerCreateResult ¶
ServerCreateResult is the result of a create server call.
type ServerEnableRescueOpts ¶
type ServerEnableRescueOpts struct {
Type ServerRescueType
SSHKeys []*SSHKey
}
ServerEnableRescueOpts specifies options for enabling rescue mode for a server.
type ServerEnableRescueResult ¶
ServerEnableRescueResult is the result of enabling rescue mode for a server.
type ServerListOpts ¶
type ServerListOpts struct {
ListOpts
}
ServerListOpts specifies options for listing servers.
type ServerPublicNet ¶
type ServerPublicNet struct {
IPv4 ServerPublicNetIPv4
IPv6 ServerPublicNetIPv6
FloatingIPs []*FloatingIP
}
ServerPublicNet represents a server's public network.
func ServerPublicNetFromSchema ¶
func ServerPublicNetFromSchema(s schema.ServerPublicNet) ServerPublicNet
ServerPublicNetFromSchema converts a schema.ServerPublicNet to a ServerPublicNet.
type ServerPublicNetIPv4 ¶
ServerPublicNetIPv4 represents a server's public IPv4 address.
func ServerPublicNetIPv4FromSchema ¶
func ServerPublicNetIPv4FromSchema(s schema.ServerPublicNetIPv4) ServerPublicNetIPv4
ServerPublicNetIPv4FromSchema converts a schema.ServerPublicNetIPv4 to a ServerPublicNetIPv4.
type ServerPublicNetIPv6 ¶
type ServerPublicNetIPv6 struct {
IP net.IP
Network *net.IPNet
Blocked bool
DNSPtr map[string]string
}
ServerPublicNetIPv6 represents a server's public IPv6 network and address.
func ServerPublicNetIPv6FromSchema ¶
func ServerPublicNetIPv6FromSchema(s schema.ServerPublicNetIPv6) ServerPublicNetIPv6
ServerPublicNetIPv6FromSchema converts a schema.ServerPublicNetIPv6 to a ServerPublicNetIPv6.
func (*ServerPublicNetIPv6) DNSPtrForIP ¶
func (s *ServerPublicNetIPv6) DNSPtrForIP(ip net.IP) string
DNSPtrForIP returns the reverse dns pointer of the ip address.
type ServerRebuildOpts ¶
type ServerRebuildOpts struct {
Image *Image
}
ServerRebuildOpts specifies options for rebuilding a server.
type ServerResetPasswordResult ¶
ServerResetPasswordResult is the result of resetting a server's password.
type ServerType ¶
type ServerType struct {
ID int
Name string
Description string
Cores int
Memory float32
Disk int
StorageType StorageType
Pricings []ServerTypeLocationPricing
}
ServerType represents a server type in the Hetzner Cloud.
func ServerTypeFromSchema ¶
func ServerTypeFromSchema(s schema.ServerType) *ServerType
ServerTypeFromSchema converts a schema.ServerType to a ServerType.
type ServerTypeClient ¶
type ServerTypeClient struct {
// contains filtered or unexported fields
}
ServerTypeClient is a client for the server types API.
func (*ServerTypeClient) All ¶
func (c *ServerTypeClient) All(ctx context.Context) ([]*ServerType, error)
All returns all server types.
func (*ServerTypeClient) Get ¶
func (c *ServerTypeClient) Get(ctx context.Context, idOrName string) (*ServerType, *Response, error)
Get retrieves a server type by its ID if the input can be parsed as an integer, otherwise it retrieves a server type by its name.
func (*ServerTypeClient) GetByID ¶
func (c *ServerTypeClient) GetByID(ctx context.Context, id int) (*ServerType, *Response, error)
GetByID retrieves a server type by its ID.
func (*ServerTypeClient) GetByName ¶
func (c *ServerTypeClient) GetByName(ctx context.Context, name string) (*ServerType, *Response, error)
GetByName retrieves a server type by its name.
func (*ServerTypeClient) List ¶
func (c *ServerTypeClient) List(ctx context.Context, opts ServerTypeListOpts) ([]*ServerType, *Response, error)
List returns a list of server types for a specific page.
type ServerTypeListOpts ¶
type ServerTypeListOpts struct {
ListOpts
}
ServerTypeListOpts specifies options for listing server types.
type ServerTypeLocationPricing ¶
ServerTypeLocationPricing provides pricing information for a server type at a location.
type ServerTypePricing ¶
type ServerTypePricing struct {
ServerType *ServerType
Pricings []ServerTypeLocationPricing
}
ServerTypePricing provides pricing information for a server type.
type ServerUpdateOpts ¶
type ServerUpdateOpts struct {
Name string
}
ServerUpdateOpts specifies options for updating a server.
type StorageType ¶
type StorageType string
StorageType specifies the type of storage.
const ( // StorageTypeLocal is the type for local storage. StorageTypeLocal StorageType = "local" // StorageTypeCeph is the type for remote storage. StorageTypeCeph = "ceph" )
type TrafficPricing ¶
type TrafficPricing struct {
PerTB Price
}
TrafficPricing provides pricing information for traffic.