hcloud

package
v0.0.0-...-fd14076 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Overview

Package hcloud is a library for the Hetzner Cloud API.

Index

Constants

View Source
const (
	VolumeFormatExt4 = "ext4"
	VolumeFormatXFS  = "xfs"
)
View Source
const Endpoint = "https://api.hetzner.cloud/v1"

Endpoint is the base URL of the API.

View Source
const UserAgent = "hcloud-go/" + Version

UserAgent is the value for the library part of the User-Agent header that is sent with each request.

View Source
const Version = "2.8.0" // x-release-please-version

Version is the library's version following Semantic Versioning.

Variables

This section is empty.

Functions

func Bool deprecated

func Bool(b bool) *bool

Bool returns a pointer to the passed bool b.

Deprecated: Use Ptr instead.

func Duration deprecated

func Duration(d time.Duration) *time.Duration

Duration returns a pointer to the passed time.Duration d.

Deprecated: Use Ptr instead.

func Int deprecated

func Int(i int) *int

Int returns a pointer to the passed integer i.

Deprecated: Use Ptr instead.

func IsError

func IsError(err error, code ErrorCode) bool

IsError returns whether err is an API error with the given error code.

func Ptr

func Ptr[T any](p T) *T

Ptr returns a pointer to p.

func RDNSLookup

func RDNSLookup(i interface{}, ip net.IP) (string, error)

RDNSLookup searches for the dns assigned to the given IP address. It returns an error if the object does not support reverse dns or if there is no dns set for the given IP address.

func SchemaFromAction

func SchemaFromAction(a *Action) schema.Action

SchemaFromAction converts an Action to a schema.Action.

func SchemaFromActions

func SchemaFromActions(a []*Action) []schema.Action

SchemaFromActions converts a slice of Action to a slice of schema.Action.

func SchemaFromCertificate

func SchemaFromCertificate(ct *Certificate) schema.Certificate

SchemaFromCertificate converts a Certificate to a schema.Certificate.

func SchemaFromDatacenter

func SchemaFromDatacenter(d *Datacenter) schema.Datacenter

SchemaFromDatacenter converts a Datacenter to a schema.Datacenter.

func SchemaFromDeprecation

func SchemaFromDeprecation(d *DeprecationInfo) *schema.DeprecationInfo

SchemaFromDeprecation converts a DeprecationInfo to a schema.DeprecationInfo.

func SchemaFromError

func SchemaFromError(e Error) schema.Error

SchemaFromError converts an Error to a schema.Error.

func SchemaFromFirewall

func SchemaFromFirewall(f *Firewall) schema.Firewall

SchemaFromFirewall converts a Firewall to a schema.Firewall.

func SchemaFromFloatingIP

func SchemaFromFloatingIP(f *FloatingIP) schema.FloatingIP

SchemaFromFloatingIP converts a FloatingIP to a schema.FloatingIP.

func SchemaFromISO

func SchemaFromISO(i *ISO) schema.ISO

SchemaFromISO converts an ISO to a schema.ISO.

func SchemaFromImage

func SchemaFromImage(i *Image) schema.Image

SchemaFromImage converts an Image to a schema.Image.

func SchemaFromLoadBalancer

func SchemaFromLoadBalancer(l *LoadBalancer) schema.LoadBalancer

SchemaFromLoadBalancer converts a LoadBalancer to a schema.LoadBalancer.

func SchemaFromLoadBalancerService

func SchemaFromLoadBalancerService(l LoadBalancerService) schema.LoadBalancerService

SchemaFromLoadBalancerService converts a LoadBalancerService to a schema.LoadBalancerService.

func SchemaFromLoadBalancerServiceHealthCheck

func SchemaFromLoadBalancerServiceHealthCheck(l LoadBalancerServiceHealthCheck) *schema.LoadBalancerServiceHealthCheck

SchemaFromLoadBalancerServiceHealthCheck converts a LoadBalancerServiceHealthCheck to a schema.LoadBalancerServiceHealthCheck.

func SchemaFromLoadBalancerTarget

func SchemaFromLoadBalancerTarget(l LoadBalancerTarget) schema.LoadBalancerTarget

SchemaFromLoadBalancerTarget converts a LoadBalancerTarget to a schema.LoadBalancerTarget.

func SchemaFromLoadBalancerTargetHealthStatus

func SchemaFromLoadBalancerTargetHealthStatus(l LoadBalancerTargetHealthStatus) schema.LoadBalancerTargetHealthStatus

SchemaFromLoadBalancerTargetHealthStatus converts a LoadBalancerTarget to a schema.LoadBalancerTarget.

func SchemaFromLoadBalancerType

func SchemaFromLoadBalancerType(l *LoadBalancerType) schema.LoadBalancerType

SchemaFromLoadBalancerType converts a LoadBalancerType to a schema.LoadBalancerType.

func SchemaFromLocation

func SchemaFromLocation(l *Location) schema.Location

SchemaFromLocation converts a Location to a schema.Location.

func SchemaFromNetwork

func SchemaFromNetwork(n *Network) schema.Network

SchemaFromNetwork converts a Network to a schema.Network.

func SchemaFromNetworkRoute

func SchemaFromNetworkRoute(n NetworkRoute) schema.NetworkRoute

SchemaFromNetworkRoute converts a NetworkRoute to a schema.NetworkRoute.

func SchemaFromNetworkSubnet

func SchemaFromNetworkSubnet(n NetworkSubnet) schema.NetworkSubnet

SchemaFromNetworkSubnet converts a NetworkSubnet to a schema.NetworkSubnet.

func SchemaFromPagination

func SchemaFromPagination(p Pagination) schema.MetaPagination

SchemaFromPagination converts a Pagination to a schema.MetaPagination.

func SchemaFromPlacementGroup

func SchemaFromPlacementGroup(p *PlacementGroup) schema.PlacementGroup

SchemaFromPlacementGroup converts a PlacementGroup to a schema.PlacementGroup.

func SchemaFromPricing

func SchemaFromPricing(p Pricing) schema.Pricing

SchemaFromPricing converts a Pricing to a schema.Pricing.

func SchemaFromPrimaryIP

func SchemaFromPrimaryIP(p *PrimaryIP) schema.PrimaryIP

SchemaFromPrimaryIP converts a PrimaryIP to a schema.PrimaryIP.

func SchemaFromSSHKey

func SchemaFromSSHKey(s *SSHKey) schema.SSHKey

SchemaFromSSHKey converts a SSHKey to a schema.SSHKey.

func SchemaFromServer

func SchemaFromServer(s *Server) schema.Server

SchemaFromServer converts a Server to a schema.Server.

func SchemaFromServerPrivateNet

func SchemaFromServerPrivateNet(s ServerPrivateNet) schema.ServerPrivateNet

SchemaFromServerPrivateNet converts a ServerPrivateNet to a schema.ServerPrivateNet.

func SchemaFromServerPublicNet

func SchemaFromServerPublicNet(s ServerPublicNet) schema.ServerPublicNet

SchemaFromServerPublicNet converts a ServerPublicNet to a schema.ServerPublicNet.

func SchemaFromServerPublicNetIPv4

func SchemaFromServerPublicNetIPv4(s ServerPublicNetIPv4) schema.ServerPublicNetIPv4

SchemaFromServerPublicNetIPv4 converts a ServerPublicNetIPv4 to a schema.ServerPublicNetIPv4.

func SchemaFromServerPublicNetIPv6

func SchemaFromServerPublicNetIPv6(s ServerPublicNetIPv6) schema.ServerPublicNetIPv6

SchemaFromServerPublicNetIPv6 converts a ServerPublicNetIPv6 to a schema.ServerPublicNetIPv6.

func SchemaFromServerType

func SchemaFromServerType(s *ServerType) schema.ServerType

SchemaFromServerType converts a ServerType to a schema.ServerType.

func SchemaFromVolume

func SchemaFromVolume(v *Volume) schema.Volume

SchemaFromVolume converts a Volume to a schema.Volume.

func String deprecated

func String(s string) *string

String returns a pointer to the passed string s.

Deprecated: Use Ptr instead.

func SupportsRDNS

func SupportsRDNS(i interface{}) bool

SupportsRDNS checks if the object supports reverse dns functions.

func ValidateResourceLabels

func ValidateResourceLabels(labels map[string]interface{}) (bool, error)

Types

type Action

type Action struct {
	ID           int64
	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

func ActionFromSchema(s schema.Action) *Action

ActionFromSchema converts a schema.Action to an Action.

func ActionsFromSchema

func ActionsFromSchema(s []schema.Action) []*Action

ActionsFromSchema converts a slice of schema.Action to a slice of Action.

func (*Action) Error

func (a *Action) Error() error

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) AllWithOpts

func (c *ActionClient) AllWithOpts(ctx context.Context, opts ActionListOpts) ([]*Action, error)

AllWithOpts returns all actions for the given options.

func (*ActionClient) GetByID

func (c *ActionClient) GetByID(ctx context.Context, id int64) (*Action, *Response, error)

GetByID retrieves an action by its ID. If the action does not exist, nil is returned.

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.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*ActionClient) WaitFor

func (c *ActionClient) WaitFor(ctx context.Context, actions ...*Action) error

WaitFor waits until all actions succeed by polling the API at the interval defined by WithPollBackoffFunc. An action is considered as succeeded when its status is either ActionStatusSuccess.

If a single action fails, the function will stop waiting and the error set in the action will be returned as an ActionError.

For more flexibility, see the ActionClient.WaitForFunc function.

func (*ActionClient) WaitForFunc

func (c *ActionClient) WaitForFunc(ctx context.Context, handleUpdate func(update *Action) error, actions ...*Action) error

WaitForFunc waits until all actions are completed by polling the API at the interval defined by WithPollBackoffFunc. An action is considered as complete when its status is either ActionStatusSuccess or ActionStatusError.

The handleUpdate callback is called every time an action is updated.

func (*ActionClient) WatchOverallProgress deprecated

func (c *ActionClient) WatchOverallProgress(ctx context.Context, actions []*Action) (<-chan int, <-chan error)

WatchOverallProgress watches several actions' progress until they complete with success or error. This watching happens in a goroutine and updates are provided through the two returned channels:

  • The first channel receives percentage updates of the progress, based on the number of completed versus total watched actions. The return value is an int between 0 and 100.
  • The second channel returned receives errors for actions that did not complete successfully, as well as any errors that happened while querying the API.

By default, the method keeps watching until all actions have finished processing. If you want to be able to cancel the method or configure a timeout, use the context.Context. Once the method has stopped watching, both returned channels are closed.

WatchOverallProgress uses the WithPollBackoffFunc of the Client to wait until sending the next request.

Deprecated: WatchOverallProgress is deprecated, use [WaitForFunc] instead.

func (*ActionClient) WatchProgress deprecated

func (c *ActionClient) WatchProgress(ctx context.Context, action *Action) (<-chan int, <-chan error)

WatchProgress watches one action's progress until it completes with success or error. This watching happens in a goroutine and updates are provided through the two returned channels:

  • The first channel receives percentage updates of the progress, based on the progress percentage indicated by the API. The return value is an int between 0 and 100.
  • The second channel receives any errors that happened while querying the API, as well as the error of the action if it did not complete successfully, or nil if it did.

By default, the method keeps watching until the action has finished processing. If you want to be able to cancel the method or configure a timeout, use the context.Context. Once the method has stopped watching, both returned channels are closed.

WatchProgress uses the WithPollBackoffFunc of the Client to wait until sending the next request.

Deprecated: WatchProgress is deprecated, use [WaitForFunc] instead.

type ActionError

type ActionError struct {
	Code    string
	Message string
}

ActionError is the error of an action.

func (ActionError) Error

func (e ActionError) Error() string

type ActionListOpts

type ActionListOpts struct {
	ListOpts
	ID     []int64
	Status []ActionStatus
	Sort   []string
}

ActionListOpts specifies options for listing actions.

type ActionResource

type ActionResource struct {
	ID   int64
	Type ActionResourceType
}

ActionResource references other resources from an action.

type ActionResourceType

type ActionResourceType string

ActionResourceType represents an action's resource reference type.

const (
	ActionResourceTypeServer     ActionResourceType = "server"
	ActionResourceTypeImage      ActionResourceType = "image"
	ActionResourceTypeISO        ActionResourceType = "iso"
	ActionResourceTypeFloatingIP ActionResourceType = "floating_ip"
	ActionResourceTypeVolume     ActionResourceType = "volume"
)

List of action resource reference types.

type ActionStatus

type ActionStatus string

ActionStatus represents an action's status.

const (
	ActionStatusRunning ActionStatus = "running"
	ActionStatusSuccess ActionStatus = "success"
	ActionStatusError   ActionStatus = "error"
)

List of action statuses.

type ActionWaiter

type ActionWaiter interface {
	WaitForFunc(ctx context.Context, handleUpdate func(update *Action) error, actions ...*Action) error
	WaitFor(ctx context.Context, actions ...*Action) error
}

type Architecture

type Architecture string

Architecture specifies the architecture of the CPU.

const (
	// ArchitectureX86 is the architecture for Intel/AMD x86 CPUs.
	ArchitectureX86 Architecture = "x86"

	// ArchitectureARM is the architecture for ARM CPUs.
	ArchitectureARM Architecture = "arm"
)

type BackoffFunc

type BackoffFunc func(retries int) time.Duration

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. It uses the formula:

b^retries * d

type CPUType

type CPUType string

CPUType specifies the type of the CPU.

const (
	// CPUTypeShared is the type for shared CPU.
	CPUTypeShared CPUType = "shared"

	// CPUTypeDedicated is the type for dedicated CPU.
	CPUTypeDedicated CPUType = "dedicated"
)

type Certificate

type Certificate struct {
	ID             int64
	Name           string
	Labels         map[string]string
	Type           CertificateType
	Certificate    string
	Created        time.Time
	NotValidBefore time.Time
	NotValidAfter  time.Time
	DomainNames    []string
	Fingerprint    string
	Status         *CertificateStatus
	UsedBy         []CertificateUsedByRef
}

Certificate represents a certificate in the Hetzner Cloud.

func CertificateFromSchema

func CertificateFromSchema(s schema.Certificate) *Certificate

CertificateFromSchema converts a schema.Certificate to a Certificate.

type CertificateClient

type CertificateClient struct {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

CertificateClient is a client for the Certificates API.

func (*CertificateClient) All

All returns all Certificates.

func (*CertificateClient) AllWithOpts

func (c *CertificateClient) AllWithOpts(ctx context.Context, opts CertificateListOpts) ([]*Certificate, error)

AllWithOpts returns all Certificates for the given options.

func (*CertificateClient) Create

Create creates a new uploaded certificate.

Create returns an error for certificates of any other type. Use CreateCertificate to create such certificates.

func (*CertificateClient) CreateCertificate

CreateCertificate creates a new certificate of any type.

func (*CertificateClient) Delete

func (c *CertificateClient) Delete(ctx context.Context, certificate *Certificate) (*Response, error)

Delete deletes a certificate.

func (*CertificateClient) Get

func (c *CertificateClient) Get(ctx context.Context, idOrName string) (*Certificate, *Response, error)

Get retrieves a Certificate by its ID if the input can be parsed as an integer, otherwise it retrieves a Certificate by its name. If the Certificate does not exist, nil is returned.

func (*CertificateClient) GetByID

func (c *CertificateClient) GetByID(ctx context.Context, id int64) (*Certificate, *Response, error)

GetByID retrieves a Certificate by its ID. If the Certificate does not exist, nil is returned.

func (*CertificateClient) GetByName

func (c *CertificateClient) GetByName(ctx context.Context, name string) (*Certificate, *Response, error)

GetByName retrieves a Certificate by its name. If the Certificate does not exist, nil is returned.

func (*CertificateClient) List

List returns a list of Certificates for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*CertificateClient) RetryIssuance

func (c *CertificateClient) RetryIssuance(ctx context.Context, certificate *Certificate) (*Action, *Response, error)

RetryIssuance retries the issuance of a failed managed certificate.

func (*CertificateClient) Update

Update updates a Certificate.

type CertificateCreateOpts

type CertificateCreateOpts struct {
	Name        string
	Type        CertificateType
	Certificate string
	PrivateKey  string
	Labels      map[string]string
	DomainNames []string
}

CertificateCreateOpts specifies options for creating a new Certificate.

func (CertificateCreateOpts) Validate

func (o CertificateCreateOpts) Validate() error

Validate checks if options are valid.

type CertificateCreateResult

type CertificateCreateResult struct {
	Certificate *Certificate
	Action      *Action
}

CertificateCreateResult is the result of creating a certificate.

type CertificateListOpts

type CertificateListOpts struct {
	ListOpts
	Name string
	Sort []string
}

CertificateListOpts specifies options for listing Certificates.

type CertificateStatus

type CertificateStatus struct {
	Issuance CertificateStatusType
	Renewal  CertificateStatusType
	Error    *Error
}

CertificateStatus indicates the status of a managed certificate.

func (*CertificateStatus) IsFailed

func (st *CertificateStatus) IsFailed() bool

IsFailed returns true if either the Issuance or the Renewal of a certificate failed. In this case the FailureReason field details the nature of the failure.

type CertificateStatusType

type CertificateStatusType string

CertificateStatusType is defines the type for the various managed certificate status.

const (
	CertificateStatusTypePending CertificateStatusType = "pending"
	CertificateStatusTypeFailed  CertificateStatusType = "failed"

	// only in issuance.
	CertificateStatusTypeCompleted CertificateStatusType = "completed"

	// only in renewal.
	CertificateStatusTypeScheduled   CertificateStatusType = "scheduled"
	CertificateStatusTypeUnavailable CertificateStatusType = "unavailable"
)

Possible certificate status.

type CertificateType

type CertificateType string

CertificateType is the type of available certificate types.

const (
	CertificateTypeUploaded CertificateType = "uploaded"
	CertificateTypeManaged  CertificateType = "managed"
)

Available certificate types.

type CertificateUpdateOpts

type CertificateUpdateOpts struct {
	Name   string
	Labels map[string]string
}

CertificateUpdateOpts specifies options for updating a Certificate.

type CertificateUsedByRef

type CertificateUsedByRef struct {
	ID   int64
	Type CertificateUsedByRefType
}

CertificateUsedByRef points to a resource that uses this certificate.

type CertificateUsedByRefType

type CertificateUsedByRefType string

CertificateUsedByRefType is the type of used by references for certificates.

const (
	CertificateUsedByRefTypeLoadBalancer CertificateUsedByRefType = "load_balancer"
)

Possible users of certificates.

type Client

type Client struct {
	Action           ActionClient
	Certificate      CertificateClient
	Datacenter       DatacenterClient
	Firewall         FirewallClient
	FloatingIP       FloatingIPClient
	Image            ImageClient
	ISO              ISOClient
	LoadBalancer     LoadBalancerClient
	LoadBalancerType LoadBalancerTypeClient
	Location         LocationClient
	Network          NetworkClient
	Pricing          PricingClient
	Server           ServerClient
	ServerType       ServerTypeClient
	SSHKey           SSHKeyClient
	Volume           VolumeClient
	PlacementGroup   PlacementGroupClient
	RDNS             RDNSClient
	PrimaryIP        PrimaryIPClient
	// contains filtered or unexported fields
}

Client is a client for the Hetzner Cloud API.

func NewClient

func NewClient(options ...ClientOption) *Client

NewClient creates a new client.

func (*Client) Do

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

Do performs an HTTP request against the API. v can be nil, an io.Writer to write the response body to or a pointer to a struct to json.Unmarshal the response to.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)

NewRequest creates an HTTP request against the API. The returned request is assigned with ctx and has all necessary headers set (auth, user agent, etc.).

type ClientOption

type ClientOption func(*Client)

A ClientOption is used to configure a Client.

func WithApplication

func WithApplication(name, version string) ClientOption

WithApplication configures a Client with the given application name and application version. The version may be blank. Programs are encouraged to at least set an application name.

func WithBackoffFunc

func WithBackoffFunc(f BackoffFunc) ClientOption

WithBackoffFunc configures a Client to use the specified backoff function. The backoff function is used for retrying HTTP requests.

func WithDebugWriter

func WithDebugWriter(debugWriter io.Writer) ClientOption

WithDebugWriter configures a Client to print debug information to the given writer. To, for example, print debug information on stderr, set it to os.Stderr.

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint configures a Client to use the specified API endpoint.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient configures a Client to perform HTTP requests with httpClient.

func WithInstrumentation

func WithInstrumentation(registry prometheus.Registerer) ClientOption

WithInstrumentation configures a Client to collect metrics about the performed HTTP requests.

func WithPollBackoffFunc

func WithPollBackoffFunc(f BackoffFunc) ClientOption

WithPollBackoffFunc configures a Client to use the specified backoff function when polling from the API.

func WithPollInterval deprecated

func WithPollInterval(pollInterval time.Duration) ClientOption

WithPollInterval configures a Client to use the specified interval when polling from the API.

Deprecated: Setting the poll interval is deprecated, you can now configure WithPollBackoffFunc with a ConstantBackoff to get the same results. To migrate your code, replace your usage like this:

// before
hcloud.WithPollInterval(2 * time.Second)
// now
hcloud.WithPollBackoffFunc(hcloud.ConstantBackoff(2 * time.Second))

func WithToken

func WithToken(token string) ClientOption

WithToken configures a Client to use the specified token for authentication.

type DNSNotFoundError

type DNSNotFoundError struct {
	IP net.IP
}

func (DNSNotFoundError) Error

func (e DNSNotFoundError) Error() string

type Datacenter

type Datacenter struct {
	ID          int64
	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) AllWithOpts

func (c *DatacenterClient) AllWithOpts(ctx context.Context, opts DatacenterListOpts) ([]*Datacenter, error)

AllWithOpts returns all datacenters for the given options.

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. If the datacenter does not exist, nil is returned.

func (*DatacenterClient) GetByID

func (c *DatacenterClient) GetByID(ctx context.Context, id int64) (*Datacenter, *Response, error)

GetByID retrieves a datacenter by its ID. If the datacenter does not exist, nil is returned.

func (*DatacenterClient) GetByName

func (c *DatacenterClient) GetByName(ctx context.Context, name string) (*Datacenter, *Response, error)

GetByName retrieves a datacenter by its name. If the datacenter does not exist, nil is returned.

func (*DatacenterClient) List

List returns a list of datacenters for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

type DatacenterListOpts

type DatacenterListOpts struct {
	ListOpts
	Name string
	Sort []string
}

DatacenterListOpts specifies options for listing datacenters.

type DatacenterServerTypes

type DatacenterServerTypes struct {
	Supported             []*ServerType
	AvailableForMigration []*ServerType
	Available             []*ServerType
}

DatacenterServerTypes represents the server types available and supported in a datacenter.

type Deprecatable

type Deprecatable interface {
	// IsDeprecated returns true if the resource is marked as deprecated.
	IsDeprecated() bool

	// UnavailableAfter returns the time that the deprecated resource will be removed from the API.
	// This only returns a valid value if [Deprecatable.IsDeprecated] returned true.
	UnavailableAfter() time.Time

	// DeprecationAnnounced returns the time that the deprecation of this resource was announced.
	// This only returns a valid value if [Deprecatable.IsDeprecated] returned true.
	DeprecationAnnounced() time.Time
}

Deprecatable is a shared interface implemented by all Resources that have a defined deprecation workflow.

type DeprecatableResource

type DeprecatableResource struct {
	Deprecation *DeprecationInfo
}

DeprecatableResource implements the Deprecatable interface and can be embedded in structs for Resources that can be deprecated.

func (DeprecatableResource) DeprecationAnnounced

func (d DeprecatableResource) DeprecationAnnounced() time.Time

DeprecationAnnounced returns the time that the deprecation of this resource was announced. This only returns a valid value if [Deprecatable.IsDeprecated] returned true.

func (DeprecatableResource) IsDeprecated

func (d DeprecatableResource) IsDeprecated() bool

IsDeprecated returns true if the resource is marked as deprecated.

func (DeprecatableResource) UnavailableAfter

func (d DeprecatableResource) UnavailableAfter() time.Time

UnavailableAfter returns the time that the deprecated resource will be removed from the API. This only returns a valid value if [Deprecatable.IsDeprecated] returned true.

type DeprecationInfo

type DeprecationInfo struct {
	Announced        time.Time
	UnavailableAfter time.Time
}

DeprecationInfo contains the information published when a resource is actually deprecated.

func DeprecationFromSchema

func DeprecationFromSchema(s *schema.DeprecationInfo) *DeprecationInfo

DeprecationFromSchema converts a schema.DeprecationInfo to a DeprecationInfo.

type Error

type Error struct {
	Code    ErrorCode
	Message string
	Details interface{}
	// contains filtered or unexported fields
}

Error is an error returned from the API.

func ErrorFromSchema

func ErrorFromSchema(s schema.Error) Error

ErrorFromSchema converts a schema.Error to an Error.

func (Error) Error

func (e Error) Error() string

func (Error) Response

func (e Error) Response() *Response

Response returns the Response that contained the error if available.

type ErrorCode

type ErrorCode string

ErrorCode represents an error code returned from the API.

const (
	ErrorCodeServiceError          ErrorCode = "service_error"           // Generic service error
	ErrorCodeRateLimitExceeded     ErrorCode = "rate_limit_exceeded"     // Rate limit exceeded
	ErrorCodeUnknownError          ErrorCode = "unknown_error"           // Unknown error
	ErrorCodeNotFound              ErrorCode = "not_found"               // Resource not found
	ErrorCodeInvalidInput          ErrorCode = "invalid_input"           // Validation error
	ErrorCodeForbidden             ErrorCode = "forbidden"               // Insufficient permissions
	ErrorCodeUnauthorized          ErrorCode = "unauthorized"            // Request was made with an invalid or unknown token
	ErrorCodeJSONError             ErrorCode = "json_error"              // Invalid JSON in request
	ErrorCodeLocked                ErrorCode = "locked"                  // Item is locked (Another action is running)
	ErrorCodeResourceLimitExceeded ErrorCode = "resource_limit_exceeded" // Resource limit exceeded
	ErrorCodeResourceUnavailable   ErrorCode = "resource_unavailable"    // Resource currently unavailable
	ErrorCodeUniquenessError       ErrorCode = "uniqueness_error"        // One or more fields must be unique
	ErrorCodeProtected             ErrorCode = "protected"               // The actions you are trying is protected
	ErrorCodeMaintenance           ErrorCode = "maintenance"             // Cannot perform operation due to maintenance
	ErrorCodeConflict              ErrorCode = "conflict"                // The resource has changed during the request, please retry
	ErrorCodeRobotUnavailable      ErrorCode = "robot_unavailable"       // Robot was not available. The caller may retry the operation after a short delay
	ErrorCodeResourceLocked        ErrorCode = "resource_locked"         // The resource is locked. The caller should contact support
	ErrorUnsupportedError          ErrorCode = "unsupported_error"       // The given resource does not support this

	ErrorCodeInvalidServerType     ErrorCode = "invalid_server_type"     // The server type does not fit for the given server or is deprecated
	ErrorCodeServerNotStopped      ErrorCode = "server_not_stopped"      // The action requires a stopped server
	ErrorCodeNetworksOverlap       ErrorCode = "networks_overlap"        // The network IP range overlaps with one of the server networks
	ErrorCodePlacementError        ErrorCode = "placement_error"         // An error during the placement occurred
	ErrorCodeServerAlreadyAttached ErrorCode = "server_already_attached" // The server is already attached to the resource

	ErrorCodeIPNotOwned                       ErrorCode = "ip_not_owned"                          // The IP you are trying to add as a target is not owned by the Project owner
	ErrorCodeSourcePortAlreadyUsed            ErrorCode = "source_port_already_used"              // The source port you are trying to add is already in use
	ErrorCodeCloudResourceIPNotAllowed        ErrorCode = "cloud_resource_ip_not_allowed"         // The IP you are trying to add as a target belongs to a Hetzner Cloud resource
	ErrorCodeServerNotAttachedToNetwork       ErrorCode = "server_not_attached_to_network"        // The server you are trying to add as a target is not attached to the same network as the Load Balancer
	ErrorCodeTargetAlreadyDefined             ErrorCode = "target_already_defined"                // The Load Balancer target you are trying to define is already defined
	ErrorCodeInvalidLoadBalancerType          ErrorCode = "invalid_load_balancer_type"            // The Load Balancer type does not fit for the given Load Balancer
	ErrorCodeLoadBalancerAlreadyAttached      ErrorCode = "load_balancer_already_attached"        // The Load Balancer is already attached to a network
	ErrorCodeTargetsWithoutUsePrivateIP       ErrorCode = "targets_without_use_private_ip"        // The Load Balancer has targets that use the public IP instead of the private IP
	ErrorCodeLoadBalancerNotAttachedToNetwork ErrorCode = "load_balancer_not_attached_to_network" // The Load Balancer is not attached to a network

	ErrorCodeIPNotAvailable     ErrorCode = "ip_not_available"        // The provided Network IP is not available
	ErrorCodeNoSubnetAvailable  ErrorCode = "no_subnet_available"     // No Subnet or IP is available for the Load Balancer/Server within the network
	ErrorCodeVSwitchAlreadyUsed ErrorCode = "vswitch_id_already_used" // The given Robot vSwitch ID is already registered in another network

	ErrorCodeNoSpaceLeftInLocation ErrorCode = "no_space_left_in_location" // There is no volume space left in the given location
	ErrorCodeVolumeAlreadyAttached ErrorCode = "volume_already_attached"   // Volume is already attached to a server, detach first

	ErrorCodeFirewallAlreadyApplied   ErrorCode = "firewall_already_applied"    // Firewall was already applied on resource
	ErrorCodeFirewallAlreadyRemoved   ErrorCode = "firewall_already_removed"    // Firewall was already removed from the resource
	ErrorCodeIncompatibleNetworkType  ErrorCode = "incompatible_network_type"   // The Network type is incompatible for the given resource
	ErrorCodeResourceInUse            ErrorCode = "resource_in_use"             // Firewall must not be in use to be deleted
	ErrorCodeServerAlreadyAdded       ErrorCode = "server_already_added"        // Server added more than one time to resource
	ErrorCodeFirewallResourceNotFound ErrorCode = "firewall_resource_not_found" // Resource a firewall should be attached to / detached from not found

	ErrorCodeCAARecordDoesNotAllowCA                        ErrorCode = "caa_record_does_not_allow_ca"                          // CAA record does not allow certificate authority
	ErrorCodeCADNSValidationFailed                          ErrorCode = "ca_dns_validation_failed"                              // Certificate Authority: DNS validation failed
	ErrorCodeCATooManyAuthorizationsFailedRecently          ErrorCode = "ca_too_many_authorizations_failed_recently"            // Certificate Authority: Too many authorizations failed recently
	ErrorCodeCATooManyCertificatedIssuedForRegisteredDomain ErrorCode = "ca_too_many_certificates_issued_for_registered_domain" // Certificate Authority: Too many certificates issued for registered domain
	ErrorCodeCATooManyDuplicateCertificates                 ErrorCode = "ca_too_many_duplicate_certificates"                    // Certificate Authority: Too many duplicate certificates
	ErrorCodeCloudNotVerifyDomainDelegatedToZone            ErrorCode = "could_not_verify_domain_delegated_to_zone"             // Could not verify domain delegated to zone
	ErrorCodeDNSZoneNotFound                                ErrorCode = "dns_zone_not_found"                                    // DNS zone not found

	// Deprecated: The actual value of this error code is limit_reached. The
	// new error code rate_limit_exceeded for rate limiting was introduced
	// before Hetzner Cloud launched into the public. To make clients using the
	// old error code still work as expected, we set the value of the old error
	// code to that of the new error code.
	ErrorCodeLimitReached = ErrorCodeRateLimitExceeded
)

Error codes returned from the API.

type ErrorDetailsInvalidInput

type ErrorDetailsInvalidInput struct {
	Fields []ErrorDetailsInvalidInputField
}

ErrorDetailsInvalidInput contains the details of an 'invalid_input' error.

type ErrorDetailsInvalidInputField

type ErrorDetailsInvalidInputField struct {
	Name     string
	Messages []string
}

ErrorDetailsInvalidInputField contains the validation errors reported on a field.

type Firewall

type Firewall struct {
	ID        int64
	Name      string
	Labels    map[string]string
	Created   time.Time
	Rules     []FirewallRule
	AppliedTo []FirewallResource
}

Firewall represents a Firewall in the Hetzner Cloud.

func FirewallFromSchema

func FirewallFromSchema(s schema.Firewall) *Firewall

FirewallFromSchema converts a schema.Firewall to a Firewall.

type FirewallClient

type FirewallClient struct {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

FirewallClient is a client for the Firewalls API.

func (*FirewallClient) All

func (c *FirewallClient) All(ctx context.Context) ([]*Firewall, error)

All returns all Firewalls.

func (*FirewallClient) AllWithOpts

func (c *FirewallClient) AllWithOpts(ctx context.Context, opts FirewallListOpts) ([]*Firewall, error)

AllWithOpts returns all Firewalls for the given options.

func (*FirewallClient) ApplyResources

func (c *FirewallClient) ApplyResources(ctx context.Context, firewall *Firewall, resources []FirewallResource) ([]*Action, *Response, error)

func (*FirewallClient) Create

Create creates a new Firewall.

func (*FirewallClient) Delete

func (c *FirewallClient) Delete(ctx context.Context, firewall *Firewall) (*Response, error)

Delete deletes a Firewall.

func (*FirewallClient) Get

func (c *FirewallClient) Get(ctx context.Context, idOrName string) (*Firewall, *Response, error)

Get retrieves a Firewall by its ID if the input can be parsed as an integer, otherwise it retrieves a Firewall by its name. If the Firewall does not exist, nil is returned.

func (*FirewallClient) GetByID

func (c *FirewallClient) GetByID(ctx context.Context, id int64) (*Firewall, *Response, error)

GetByID retrieves a Firewall by its ID. If the Firewall does not exist, nil is returned.

func (*FirewallClient) GetByName

func (c *FirewallClient) GetByName(ctx context.Context, name string) (*Firewall, *Response, error)

GetByName retrieves a Firewall by its name. If the Firewall does not exist, nil is returned.

func (*FirewallClient) List

List returns a list of Firewalls for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*FirewallClient) RemoveResources

func (c *FirewallClient) RemoveResources(ctx context.Context, firewall *Firewall, resources []FirewallResource) ([]*Action, *Response, error)

func (*FirewallClient) SetRules

func (c *FirewallClient) SetRules(ctx context.Context, firewall *Firewall, opts FirewallSetRulesOpts) ([]*Action, *Response, error)

SetRules sets the rules of a Firewall.

func (*FirewallClient) Update

func (c *FirewallClient) Update(ctx context.Context, firewall *Firewall, opts FirewallUpdateOpts) (*Firewall, *Response, error)

Update updates a Firewall.

type FirewallCreateOpts

type FirewallCreateOpts struct {
	Name    string
	Labels  map[string]string
	Rules   []FirewallRule
	ApplyTo []FirewallResource
}

FirewallCreateOpts specifies options for creating a new Firewall.

func (FirewallCreateOpts) Validate

func (o FirewallCreateOpts) Validate() error

Validate checks if options are valid.

type FirewallCreateResult

type FirewallCreateResult struct {
	Firewall *Firewall
	Actions  []*Action
}

FirewallCreateResult is the result of a create Firewall call.

type FirewallListOpts

type FirewallListOpts struct {
	ListOpts
	Name string
	Sort []string
}

FirewallListOpts specifies options for listing Firewalls.

type FirewallResource

type FirewallResource struct {
	Type          FirewallResourceType
	Server        *FirewallResourceServer
	LabelSelector *FirewallResourceLabelSelector
}

FirewallResource represents a resource to apply the new Firewall on.

type FirewallResourceLabelSelector

type FirewallResourceLabelSelector struct {
	Selector string
}

FirewallResourceLabelSelector represents a LabelSelector to apply a Firewall on.

type FirewallResourceServer

type FirewallResourceServer struct {
	ID int64
}

FirewallResourceServer represents a Server to apply a Firewall on.

type FirewallResourceType

type FirewallResourceType string

FirewallResourceType specifies the resource to apply a Firewall on.

const (
	// FirewallResourceTypeServer specifies a Server.
	FirewallResourceTypeServer FirewallResourceType = "server"
	// FirewallResourceTypeLabelSelector specifies a LabelSelector.
	FirewallResourceTypeLabelSelector FirewallResourceType = "label_selector"
)

type FirewallRule

type FirewallRule struct {
	Direction      FirewallRuleDirection
	SourceIPs      []net.IPNet
	DestinationIPs []net.IPNet
	Protocol       FirewallRuleProtocol
	Port           *string
	Description    *string
}

FirewallRule represents a Firewall's rules.

type FirewallRuleDirection

type FirewallRuleDirection string

FirewallRuleDirection specifies the direction of a Firewall rule.

const (
	// FirewallRuleDirectionIn specifies a rule for inbound traffic.
	FirewallRuleDirectionIn FirewallRuleDirection = "in"

	// FirewallRuleDirectionOut specifies a rule for outbound traffic.
	FirewallRuleDirectionOut FirewallRuleDirection = "out"
)

type FirewallRuleProtocol

type FirewallRuleProtocol string

FirewallRuleProtocol specifies the protocol of a Firewall rule.

const (
	// FirewallRuleProtocolTCP specifies a TCP rule.
	FirewallRuleProtocolTCP FirewallRuleProtocol = "tcp"
	// FirewallRuleProtocolUDP specifies a UDP rule.
	FirewallRuleProtocolUDP FirewallRuleProtocol = "udp"
	// FirewallRuleProtocolICMP specifies an ICMP rule.
	FirewallRuleProtocolICMP FirewallRuleProtocol = "icmp"
	// FirewallRuleProtocolESP specifies an esp rule.
	FirewallRuleProtocolESP FirewallRuleProtocol = "esp"
	// FirewallRuleProtocolGRE specifies an gre rule.
	FirewallRuleProtocolGRE FirewallRuleProtocol = "gre"
)

type FirewallSetRulesOpts

type FirewallSetRulesOpts struct {
	Rules []FirewallRule
}

FirewallSetRulesOpts specifies options for setting rules of a Firewall.

type FirewallStatus

type FirewallStatus string

FirewallStatus specifies a Firewall's status.

const (
	// FirewallStatusPending is the status when a Firewall is pending.
	FirewallStatusPending FirewallStatus = "pending"

	// FirewallStatusApplied is the status when a Firewall is applied.
	FirewallStatusApplied FirewallStatus = "applied"
)

type FirewallUpdateOpts

type FirewallUpdateOpts struct {
	Name   string
	Labels map[string]string
}

FirewallUpdateOpts specifies options for updating a Firewall.

type FloatingIP

type FloatingIP struct {
	ID           int64
	Description  string
	Created      time.Time
	IP           net.IP
	Network      *net.IPNet
	Type         FloatingIPType
	Server       *Server
	DNSPtr       map[string]string
	HomeLocation *Location
	Blocked      bool
	Protection   FloatingIPProtection
	Labels       map[string]string
	Name         string
}

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. Deprecated: Use GetDNSPtrForIP instead.

func (*FloatingIP) GetDNSPtrForIP

func (f *FloatingIP) GetDNSPtrForIP(ip net.IP) (string, error)

GetDNSPtrForIP searches for the dns assigned to the given IP address. It returns an error if there is no dns set for the given IP address.

type FloatingIPChangeProtectionOpts

type FloatingIPChangeProtectionOpts struct {
	Delete *bool
}

FloatingIPChangeProtectionOpts specifies options for changing the resource protection level of a Floating IP.

type FloatingIPClient

type FloatingIPClient struct {
	Action *ResourceActionClient
	// 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) AllWithOpts

func (c *FloatingIPClient) AllWithOpts(ctx context.Context, opts FloatingIPListOpts) ([]*FloatingIP, error)

AllWithOpts returns all Floating IPs for the given options.

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) ChangeProtection

func (c *FloatingIPClient) ChangeProtection(ctx context.Context, floatingIP *FloatingIP, opts FloatingIPChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection changes the resource protection level of a Floating IP.

func (*FloatingIPClient) Create

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) Get

func (c *FloatingIPClient) Get(ctx context.Context, idOrName string) (*FloatingIP, *Response, error)

Get retrieves a Floating IP by its ID if the input can be parsed as an integer, otherwise it retrieves a Floating IP by its name. If the Floating IP does not exist, nil is returned.

func (*FloatingIPClient) GetByID

func (c *FloatingIPClient) GetByID(ctx context.Context, id int64) (*FloatingIP, *Response, error)

GetByID retrieves a Floating IP by its ID. If the Floating IP does not exist, nil is returned.

func (*FloatingIPClient) GetByName

func (c *FloatingIPClient) GetByName(ctx context.Context, name string) (*FloatingIP, *Response, error)

GetByName retrieves a Floating IP by its name. If the Floating IP does not exist, nil is returned.

func (*FloatingIPClient) List

List returns a list of Floating IPs for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

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
	Name         *string
	Labels       map[string]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
	Name string
	Sort []string
}

FloatingIPListOpts specifies options for listing Floating IPs.

type FloatingIPPricing

type FloatingIPPricing struct {
	Monthly Price
}

FloatingIPPricing provides pricing information for Floating IPs.

type FloatingIPProtection

type FloatingIPProtection struct {
	Delete bool
}

FloatingIPProtection represents the protection level of a Floating IP.

type FloatingIPType

type FloatingIPType string

FloatingIPType represents the type of Floating IP.

const (
	FloatingIPTypeIPv4 FloatingIPType = "ipv4"
	FloatingIPTypeIPv6 FloatingIPType = "ipv6"
)

Floating IP types.

type FloatingIPTypeLocationPricing

type FloatingIPTypeLocationPricing struct {
	Location *Location
	Monthly  Price
}

FloatingIPTypeLocationPricing provides pricing information for a Floating IP type at a location.

type FloatingIPTypePricing

type FloatingIPTypePricing struct {
	Type     FloatingIPType
	Pricings []FloatingIPTypeLocationPricing
}

FloatingIPTypePricing provides pricing information for Floating IPs per Type.

type FloatingIPUpdateOpts

type FloatingIPUpdateOpts struct {
	Description string
	Labels      map[string]string
	Name        string
}

FloatingIPUpdateOpts specifies options for updating a Floating IP.

type IActionClient

type IActionClient interface {
	// GetByID retrieves an action by its ID. If the action does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Action, *Response, error)
	// List returns a list of actions for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts ActionListOpts) ([]*Action, *Response, error)
	// All returns all actions.
	All(ctx context.Context) ([]*Action, error)
	// AllWithOpts returns all actions for the given options.
	AllWithOpts(ctx context.Context, opts ActionListOpts) ([]*Action, error)
	// WatchOverallProgress watches several actions' progress until they complete
	// with success or error. This watching happens in a goroutine and updates are
	// provided through the two returned channels:
	//
	//   - The first channel receives percentage updates of the progress, based on
	//     the number of completed versus total watched actions. The return value
	//     is an int between 0 and 100.
	//   - The second channel returned receives errors for actions that did not
	//     complete successfully, as well as any errors that happened while
	//     querying the API.
	//
	// By default, the method keeps watching until all actions have finished
	// processing. If you want to be able to cancel the method or configure a
	// timeout, use the [context.Context]. Once the method has stopped watching,
	// both returned channels are closed.
	//
	// WatchOverallProgress uses the [WithPollBackoffFunc] of the [Client] to wait
	// until sending the next request.
	//
	// Deprecated: WatchOverallProgress is deprecated, use [WaitForFunc] instead.
	WatchOverallProgress(ctx context.Context, actions []*Action) (<-chan int, <-chan error)
	// WatchProgress watches one action's progress until it completes with success
	// or error. This watching happens in a goroutine and updates are provided
	// through the two returned channels:
	//
	//   - The first channel receives percentage updates of the progress, based on
	//     the progress percentage indicated by the API. The return value is an int
	//     between 0 and 100.
	//   - The second channel receives any errors that happened while querying the
	//     API, as well as the error of the action if it did not complete
	//     successfully, or nil if it did.
	//
	// By default, the method keeps watching until the action has finished
	// processing. If you want to be able to cancel the method or configure a
	// timeout, use the [context.Context]. Once the method has stopped watching,
	// both returned channels are closed.
	//
	// WatchProgress uses the [WithPollBackoffFunc] of the [Client] to wait until
	// sending the next request.
	//
	// Deprecated: WatchProgress is deprecated, use [WaitForFunc] instead.
	WatchProgress(ctx context.Context, action *Action) (<-chan int, <-chan error)
	// WaitForFunc waits until all actions are completed by polling the API at the interval
	// defined by [WithPollBackoffFunc]. An action is considered as complete when its status is
	// either [ActionStatusSuccess] or [ActionStatusError].
	//
	// The handleUpdate callback is called every time an action is updated.
	WaitForFunc(ctx context.Context, handleUpdate func(update *Action) error, actions ...*Action) error
	// WaitFor waits until all actions succeed by polling the API at the interval defined by
	// [WithPollBackoffFunc]. An action is considered as succeeded when its status is either
	// [ActionStatusSuccess].
	//
	// If a single action fails, the function will stop waiting and the error set in the
	// action will be returned as an [ActionError].
	//
	// For more flexibility, see the [ActionClient.WaitForFunc] function.
	WaitFor(ctx context.Context, actions ...*Action) error
}

IActionClient ...

type ICertificateClient

type ICertificateClient interface {
	// GetByID retrieves a Certificate by its ID. If the Certificate does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Certificate, *Response, error)
	// GetByName retrieves a Certificate by its name. If the Certificate does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*Certificate, *Response, error)
	// Get retrieves a Certificate by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a Certificate by its name. If the Certificate does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Certificate, *Response, error)
	// List returns a list of Certificates for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts CertificateListOpts) ([]*Certificate, *Response, error)
	// All returns all Certificates.
	All(ctx context.Context) ([]*Certificate, error)
	// AllWithOpts returns all Certificates for the given options.
	AllWithOpts(ctx context.Context, opts CertificateListOpts) ([]*Certificate, error)
	// Create creates a new uploaded certificate.
	//
	// Create returns an error for certificates of any other type. Use
	// CreateCertificate to create such certificates.
	Create(ctx context.Context, opts CertificateCreateOpts) (*Certificate, *Response, error)
	// CreateCertificate creates a new certificate of any type.
	CreateCertificate(ctx context.Context, opts CertificateCreateOpts) (CertificateCreateResult, *Response, error)
	// Update updates a Certificate.
	Update(ctx context.Context, certificate *Certificate, opts CertificateUpdateOpts) (*Certificate, *Response, error)
	// Delete deletes a certificate.
	Delete(ctx context.Context, certificate *Certificate) (*Response, error)
	// RetryIssuance retries the issuance of a failed managed certificate.
	RetryIssuance(ctx context.Context, certificate *Certificate) (*Action, *Response, error)
}

ICertificateClient ...

type IDatacenterClient

type IDatacenterClient interface {
	// GetByID retrieves a datacenter by its ID. If the datacenter does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Datacenter, *Response, error)
	// GetByName retrieves a datacenter by its name. If the datacenter does not exist, nil is returned.
	GetByName(ctx context.Context, name 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. If the datacenter does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Datacenter, *Response, error)
	// List returns a list of datacenters for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts DatacenterListOpts) ([]*Datacenter, *Response, error)
	// All returns all datacenters.
	All(ctx context.Context) ([]*Datacenter, error)
	// AllWithOpts returns all datacenters for the given options.
	AllWithOpts(ctx context.Context, opts DatacenterListOpts) ([]*Datacenter, error)
}

IDatacenterClient ...

type IFirewallClient

type IFirewallClient interface {
	// GetByID retrieves a Firewall by its ID. If the Firewall does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Firewall, *Response, error)
	// GetByName retrieves a Firewall by its name. If the Firewall does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*Firewall, *Response, error)
	// Get retrieves a Firewall by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a Firewall by its name. If the Firewall does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Firewall, *Response, error)
	// List returns a list of Firewalls for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts FirewallListOpts) ([]*Firewall, *Response, error)
	// All returns all Firewalls.
	All(ctx context.Context) ([]*Firewall, error)
	// AllWithOpts returns all Firewalls for the given options.
	AllWithOpts(ctx context.Context, opts FirewallListOpts) ([]*Firewall, error)
	// Create creates a new Firewall.
	Create(ctx context.Context, opts FirewallCreateOpts) (FirewallCreateResult, *Response, error)
	// Update updates a Firewall.
	Update(ctx context.Context, firewall *Firewall, opts FirewallUpdateOpts) (*Firewall, *Response, error)
	// Delete deletes a Firewall.
	Delete(ctx context.Context, firewall *Firewall) (*Response, error)
	// SetRules sets the rules of a Firewall.
	SetRules(ctx context.Context, firewall *Firewall, opts FirewallSetRulesOpts) ([]*Action, *Response, error)
	ApplyResources(ctx context.Context, firewall *Firewall, resources []FirewallResource) ([]*Action, *Response, error)
	RemoveResources(ctx context.Context, firewall *Firewall, resources []FirewallResource) ([]*Action, *Response, error)
}

IFirewallClient ...

type IFloatingIPClient

type IFloatingIPClient interface {
	// GetByID retrieves a Floating IP by its ID. If the Floating IP does not exist,
	// nil is returned.
	GetByID(ctx context.Context, id int64) (*FloatingIP, *Response, error)
	// GetByName retrieves a Floating IP by its name. If the Floating IP does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*FloatingIP, *Response, error)
	// Get retrieves a Floating IP by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a Floating IP by its name. If the Floating IP does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*FloatingIP, *Response, error)
	// List returns a list of Floating IPs for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts FloatingIPListOpts) ([]*FloatingIP, *Response, error)
	// All returns all Floating IPs.
	All(ctx context.Context) ([]*FloatingIP, error)
	// AllWithOpts returns all Floating IPs for the given options.
	AllWithOpts(ctx context.Context, opts FloatingIPListOpts) ([]*FloatingIP, error)
	// Create creates a Floating IP.
	Create(ctx context.Context, opts FloatingIPCreateOpts) (FloatingIPCreateResult, *Response, error)
	// Delete deletes a Floating IP.
	Delete(ctx context.Context, floatingIP *FloatingIP) (*Response, error)
	// Update updates a Floating IP.
	Update(ctx context.Context, floatingIP *FloatingIP, opts FloatingIPUpdateOpts) (*FloatingIP, *Response, error)
	// Assign assigns a Floating IP to a server.
	Assign(ctx context.Context, floatingIP *FloatingIP, server *Server) (*Action, *Response, error)
	// Unassign unassigns a Floating IP from the currently assigned server.
	Unassign(ctx context.Context, floatingIP *FloatingIP) (*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.
	ChangeDNSPtr(ctx context.Context, floatingIP *FloatingIP, ip string, ptr *string) (*Action, *Response, error)
	// ChangeProtection changes the resource protection level of a Floating IP.
	ChangeProtection(ctx context.Context, floatingIP *FloatingIP, opts FloatingIPChangeProtectionOpts) (*Action, *Response, error)
}

IFloatingIPClient ...

type IISOClient

type IISOClient interface {
	// GetByID retrieves an ISO by its ID.
	GetByID(ctx context.Context, id int64) (*ISO, *Response, error)
	// GetByName retrieves an ISO by its name.
	GetByName(ctx context.Context, name string) (*ISO, *Response, error)
	// Get retrieves an ISO by its ID if the input can be parsed as an integer, otherwise it retrieves an ISO by its name.
	Get(ctx context.Context, idOrName string) (*ISO, *Response, error)
	// List returns a list of ISOs for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts ISOListOpts) ([]*ISO, *Response, error)
	// All returns all ISOs.
	All(ctx context.Context) ([]*ISO, error)
	// AllWithOpts returns all ISOs for the given options.
	AllWithOpts(ctx context.Context, opts ISOListOpts) ([]*ISO, error)
}

IISOClient ...

type IImageClient

type IImageClient interface {
	// GetByID retrieves an image by its ID. If the image does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Image, *Response, error)
	// GetByName retrieves an image by its name. If the image does not exist, nil is returned.
	//
	// Deprecated: Use [ImageClient.GetByNameAndArchitecture] instead.
	GetByName(ctx context.Context, name string) (*Image, *Response, error)
	// GetByNameAndArchitecture retrieves an image by its name and architecture. If the image does not exist,
	// nil is returned.
	// In contrast to [ImageClient.Get], this method also returns deprecated images. Depending on your needs you should
	// check for this in your calling method.
	GetByNameAndArchitecture(ctx context.Context, name string, architecture Architecture) (*Image, *Response, error)
	// Get retrieves an image by its ID if the input can be parsed as an integer, otherwise it
	// retrieves an image by its name. If the image does not exist, nil is returned.
	//
	// Deprecated: Use [ImageClient.GetForArchitecture] instead.
	Get(ctx context.Context, idOrName string) (*Image, *Response, error)
	// GetForArchitecture retrieves an image by its ID if the input can be parsed as an integer, otherwise it
	// retrieves an image by its name and architecture. If the image does not exist, nil is returned.
	//
	// In contrast to [ImageClient.Get], this method also returns deprecated images. Depending on your needs you should
	// check for this in your calling method.
	GetForArchitecture(ctx context.Context, idOrName string, architecture Architecture) (*Image, *Response, error)
	// List returns a list of images for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts ImageListOpts) ([]*Image, *Response, error)
	// All returns all images.
	All(ctx context.Context) ([]*Image, error)
	// AllWithOpts returns all images for the given options.
	AllWithOpts(ctx context.Context, opts ImageListOpts) ([]*Image, error)
	// Delete deletes an image.
	Delete(ctx context.Context, image *Image) (*Response, error)
	// Update updates an image.
	Update(ctx context.Context, image *Image, opts ImageUpdateOpts) (*Image, *Response, error)
	// ChangeProtection changes the resource protection level of an image.
	ChangeProtection(ctx context.Context, image *Image, opts ImageChangeProtectionOpts) (*Action, *Response, error)
}

IImageClient ...

type ILoadBalancerClient

type ILoadBalancerClient interface {
	// GetByID retrieves a Load Balancer by its ID. If the Load Balancer does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*LoadBalancer, *Response, error)
	// GetByName retrieves a Load Balancer by its name. If the Load Balancer does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*LoadBalancer, *Response, error)
	// Get retrieves a Load Balancer by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a Load Balancer by its name. If the Load Balancer does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*LoadBalancer, *Response, error)
	// List returns a list of Load Balancers for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts LoadBalancerListOpts) ([]*LoadBalancer, *Response, error)
	// All returns all Load Balancers.
	All(ctx context.Context) ([]*LoadBalancer, error)
	// AllWithOpts returns all Load Balancers for the given options.
	AllWithOpts(ctx context.Context, opts LoadBalancerListOpts) ([]*LoadBalancer, error)
	// Update updates a Load Balancer.
	Update(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerUpdateOpts) (*LoadBalancer, *Response, error)
	// Create creates a new Load Balancer.
	Create(ctx context.Context, opts LoadBalancerCreateOpts) (LoadBalancerCreateResult, *Response, error)
	// Delete deletes a Load Balancer.
	Delete(ctx context.Context, loadBalancer *LoadBalancer) (*Response, error)
	// AddServerTarget adds a server target to a Load Balancer.
	AddServerTarget(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddServerTargetOpts) (*Action, *Response, error)
	// RemoveServerTarget removes a server target from a Load Balancer.
	RemoveServerTarget(ctx context.Context, loadBalancer *LoadBalancer, server *Server) (*Action, *Response, error)
	// AddLabelSelectorTarget adds a label selector target to a Load Balancer.
	AddLabelSelectorTarget(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddLabelSelectorTargetOpts) (*Action, *Response, error)
	// RemoveLabelSelectorTarget removes a label selector target from a Load Balancer.
	RemoveLabelSelectorTarget(ctx context.Context, loadBalancer *LoadBalancer, labelSelector string) (*Action, *Response, error)
	// AddIPTarget adds an IP target to a Load Balancer.
	AddIPTarget(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddIPTargetOpts) (*Action, *Response, error)
	// RemoveIPTarget removes an IP target from a Load Balancer.
	RemoveIPTarget(ctx context.Context, loadBalancer *LoadBalancer, ip net.IP) (*Action, *Response, error)
	// AddService adds a service to a Load Balancer.
	AddService(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddServiceOpts) (*Action, *Response, error)
	// UpdateService updates a Load Balancer service.
	UpdateService(ctx context.Context, loadBalancer *LoadBalancer, listenPort int, opts LoadBalancerUpdateServiceOpts) (*Action, *Response, error)
	// DeleteService deletes a Load Balancer service.
	DeleteService(ctx context.Context, loadBalancer *LoadBalancer, listenPort int) (*Action, *Response, error)
	// ChangeProtection changes the resource protection level of a Load Balancer.
	ChangeProtection(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerChangeProtectionOpts) (*Action, *Response, error)
	// ChangeAlgorithm changes the algorithm of a Load Balancer.
	ChangeAlgorithm(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerChangeAlgorithmOpts) (*Action, *Response, error)
	// AttachToNetwork attaches a Load Balancer to a network.
	AttachToNetwork(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAttachToNetworkOpts) (*Action, *Response, error)
	// DetachFromNetwork detaches a Load Balancer from a network.
	DetachFromNetwork(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerDetachFromNetworkOpts) (*Action, *Response, error)
	// EnablePublicInterface enables the Load Balancer's public network interface.
	EnablePublicInterface(ctx context.Context, loadBalancer *LoadBalancer) (*Action, *Response, error)
	// DisablePublicInterface disables the Load Balancer's public network interface.
	DisablePublicInterface(ctx context.Context, loadBalancer *LoadBalancer) (*Action, *Response, error)
	// ChangeType changes a Load Balancer's type.
	ChangeType(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerChangeTypeOpts) (*Action, *Response, error)
	// GetMetrics obtains metrics for a Load Balancer.
	GetMetrics(ctx context.Context, lb *LoadBalancer, opts LoadBalancerGetMetricsOpts) (*LoadBalancerMetrics, *Response, error)
	// ChangeDNSPtr changes or resets the reverse DNS pointer for a Load Balancer.
	// Pass a nil ptr to reset the reverse DNS pointer to its default value.
	ChangeDNSPtr(ctx context.Context, lb *LoadBalancer, ip string, ptr *string) (*Action, *Response, error)
}

ILoadBalancerClient ...

type ILoadBalancerTypeClient

type ILoadBalancerTypeClient interface {
	// GetByID retrieves a Load Balancer type by its ID. If the Load Balancer type does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*LoadBalancerType, *Response, error)
	// GetByName retrieves a Load Balancer type by its name. If the Load Balancer type does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*LoadBalancerType, *Response, error)
	// Get retrieves a Load Balancer type by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a Load Balancer type by its name. If the Load Balancer type does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*LoadBalancerType, *Response, error)
	// List returns a list of Load Balancer types for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts LoadBalancerTypeListOpts) ([]*LoadBalancerType, *Response, error)
	// All returns all Load Balancer types.
	All(ctx context.Context) ([]*LoadBalancerType, error)
	// AllWithOpts returns all Load Balancer types for the given options.
	AllWithOpts(ctx context.Context, opts LoadBalancerTypeListOpts) ([]*LoadBalancerType, error)
}

ILoadBalancerTypeClient ...

type ILocationClient

type ILocationClient interface {
	// GetByID retrieves a location by its ID. If the location does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Location, *Response, error)
	// GetByName retrieves an location by its name. If the location does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*Location, *Response, error)
	// Get retrieves a location by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a location by its name. If the location does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Location, *Response, error)
	// List returns a list of locations for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts LocationListOpts) ([]*Location, *Response, error)
	// All returns all locations.
	All(ctx context.Context) ([]*Location, error)
	// AllWithOpts returns all locations for the given options.
	AllWithOpts(ctx context.Context, opts LocationListOpts) ([]*Location, error)
}

ILocationClient ...

type INetworkClient

type INetworkClient interface {
	// GetByID retrieves a network by its ID. If the network does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Network, *Response, error)
	// GetByName retrieves a network by its name. If the network does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*Network, *Response, error)
	// Get retrieves a network by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a network by its name. If the network does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Network, *Response, error)
	// List returns a list of networks for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts NetworkListOpts) ([]*Network, *Response, error)
	// All returns all networks.
	All(ctx context.Context) ([]*Network, error)
	// AllWithOpts returns all networks for the given options.
	AllWithOpts(ctx context.Context, opts NetworkListOpts) ([]*Network, error)
	// Delete deletes a network.
	Delete(ctx context.Context, network *Network) (*Response, error)
	// Update updates a network.
	Update(ctx context.Context, network *Network, opts NetworkUpdateOpts) (*Network, *Response, error)
	// Create creates a new network.
	Create(ctx context.Context, opts NetworkCreateOpts) (*Network, *Response, error)
	// ChangeIPRange changes the IP range of a network.
	ChangeIPRange(ctx context.Context, network *Network, opts NetworkChangeIPRangeOpts) (*Action, *Response, error)
	// AddSubnet adds a subnet to a network.
	AddSubnet(ctx context.Context, network *Network, opts NetworkAddSubnetOpts) (*Action, *Response, error)
	// DeleteSubnet deletes a subnet from a network.
	DeleteSubnet(ctx context.Context, network *Network, opts NetworkDeleteSubnetOpts) (*Action, *Response, error)
	// AddRoute adds a route to a network.
	AddRoute(ctx context.Context, network *Network, opts NetworkAddRouteOpts) (*Action, *Response, error)
	// DeleteRoute deletes a route from a network.
	DeleteRoute(ctx context.Context, network *Network, opts NetworkDeleteRouteOpts) (*Action, *Response, error)
	// ChangeProtection changes the resource protection level of a network.
	ChangeProtection(ctx context.Context, network *Network, opts NetworkChangeProtectionOpts) (*Action, *Response, error)
}

INetworkClient ...

type IPlacementGroupClient

type IPlacementGroupClient interface {
	// GetByID retrieves a PlacementGroup by its ID. If the PlacementGroup does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*PlacementGroup, *Response, error)
	// GetByName retrieves a PlacementGroup by its name. If the PlacementGroup does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*PlacementGroup, *Response, error)
	// Get retrieves a PlacementGroup by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a PlacementGroup by its name. If the PlacementGroup does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*PlacementGroup, *Response, error)
	// List returns a list of PlacementGroups for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts PlacementGroupListOpts) ([]*PlacementGroup, *Response, error)
	// All returns all PlacementGroups.
	All(ctx context.Context) ([]*PlacementGroup, error)
	// AllWithOpts returns all PlacementGroups for the given options.
	AllWithOpts(ctx context.Context, opts PlacementGroupListOpts) ([]*PlacementGroup, error)
	// Create creates a new PlacementGroup.
	Create(ctx context.Context, opts PlacementGroupCreateOpts) (PlacementGroupCreateResult, *Response, error)
	// Update updates a PlacementGroup.
	Update(ctx context.Context, placementGroup *PlacementGroup, opts PlacementGroupUpdateOpts) (*PlacementGroup, *Response, error)
	// Delete deletes a PlacementGroup.
	Delete(ctx context.Context, placementGroup *PlacementGroup) (*Response, error)
}

IPlacementGroupClient ...

type IPricingClient

type IPricingClient interface {
	// Get retrieves pricing information.
	Get(ctx context.Context) (Pricing, *Response, error)
}

IPricingClient ...

type IPrimaryIPClient

type IPrimaryIPClient interface {
	// GetByID retrieves a Primary IP by its ID. If the Primary IP does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*PrimaryIP, *Response, error)
	// GetByIP retrieves a Primary IP by its IP Address. If the Primary IP does not exist, nil is returned.
	GetByIP(ctx context.Context, ip string) (*PrimaryIP, *Response, error)
	// GetByName retrieves a Primary IP by its name. If the Primary IP does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*PrimaryIP, *Response, error)
	// Get retrieves a Primary IP by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a Primary IP by its name. If the Primary IP does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*PrimaryIP, *Response, error)
	// List returns a list of Primary IPs for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts PrimaryIPListOpts) ([]*PrimaryIP, *Response, error)
	// All returns all Primary IPs.
	All(ctx context.Context) ([]*PrimaryIP, error)
	// AllWithOpts returns all Primary IPs for the given options.
	AllWithOpts(ctx context.Context, opts PrimaryIPListOpts) ([]*PrimaryIP, error)
	// Create creates a Primary IP.
	Create(ctx context.Context, reqBody PrimaryIPCreateOpts) (*PrimaryIPCreateResult, *Response, error)
	// Delete deletes a Primary IP.
	Delete(ctx context.Context, primaryIP *PrimaryIP) (*Response, error)
	// Update updates a Primary IP.
	Update(ctx context.Context, primaryIP *PrimaryIP, reqBody PrimaryIPUpdateOpts) (*PrimaryIP, *Response, error)
	// Assign a Primary IP to a resource.
	Assign(ctx context.Context, opts PrimaryIPAssignOpts) (*Action, *Response, error)
	// Unassign a Primary IP from a resource.
	Unassign(ctx context.Context, id int64) (*Action, *Response, error)
	// ChangeDNSPtr Change the reverse DNS from a Primary IP.
	ChangeDNSPtr(ctx context.Context, opts PrimaryIPChangeDNSPtrOpts) (*Action, *Response, error)
	// ChangeProtection Changes the protection configuration of a Primary IP.
	ChangeProtection(ctx context.Context, opts PrimaryIPChangeProtectionOpts) (*Action, *Response, error)
}

IPrimaryIPClient ...

type IRDNSClient

type IRDNSClient interface {
	// ChangeDNSPtr changes or resets the reverse DNS pointer for a IP address.
	// Pass a nil ptr to reset the reverse DNS pointer to its default value.
	ChangeDNSPtr(ctx context.Context, rdns RDNSSupporter, ip net.IP, ptr *string) (*Action, *Response, error)
}

IRDNSClient ...

type IResourceActionClient

type IResourceActionClient interface {
	// GetByID retrieves an action by its ID. If the action does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Action, *Response, error)
	// List returns a list of actions for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts ActionListOpts) ([]*Action, *Response, error)
	// All returns all actions for the given options.
	All(ctx context.Context, opts ActionListOpts) ([]*Action, error)
}

IResourceActionClient ...

type ISO

type ISO struct {
	ID           int64
	Name         string
	Description  string
	Type         ISOType
	Architecture *Architecture
	// Deprecated: Use [ISO.Deprecation] instead.
	Deprecated time.Time
	DeprecatableResource
}

ISO represents an ISO image in the Hetzner Cloud.

func ISOFromSchema

func ISOFromSchema(s schema.ISO) *ISO

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) All

func (c *ISOClient) All(ctx context.Context) ([]*ISO, error)

All returns all ISOs.

func (*ISOClient) AllWithOpts

func (c *ISOClient) AllWithOpts(ctx context.Context, opts ISOListOpts) ([]*ISO, error)

AllWithOpts returns all ISOs for the given options.

func (*ISOClient) Get

func (c *ISOClient) Get(ctx context.Context, idOrName string) (*ISO, *Response, error)

Get retrieves an ISO by its ID if the input can be parsed as an integer, otherwise it retrieves an ISO by its name.

func (*ISOClient) GetByID

func (c *ISOClient) GetByID(ctx context.Context, id int64) (*ISO, *Response, error)

GetByID retrieves an ISO by its ID.

func (*ISOClient) GetByName

func (c *ISOClient) GetByName(ctx context.Context, name string) (*ISO, *Response, error)

GetByName retrieves an ISO by its name.

func (*ISOClient) List

func (c *ISOClient) List(ctx context.Context, opts ISOListOpts) ([]*ISO, *Response, error)

List returns a list of ISOs for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

type ISOListOpts

type ISOListOpts struct {
	ListOpts
	Name string
	Sort []string
	// Architecture filters the ISOs by Architecture. Note that custom ISOs do not have any architecture set, and you
	// must use IncludeWildcardArchitecture to include them.
	Architecture []Architecture
	// IncludeWildcardArchitecture must be set to also return custom ISOs that have no architecture set, if you are
	// also setting the Architecture field.
	// Deprecated: Use [ISOListOpts.IncludeArchitectureWildcard] instead.
	IncludeWildcardArchitecture bool
	// IncludeWildcardArchitecture must be set to also return custom ISOs that have no architecture set, if you are
	// also setting the Architecture field.
	IncludeArchitectureWildcard bool
}

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 ISOType = "private"
)

type ISSHKeyClient

type ISSHKeyClient interface {
	// GetByID retrieves a SSH key by its ID. If the SSH key does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*SSHKey, *Response, error)
	// GetByName retrieves a SSH key by its name. If the SSH key does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*SSHKey, *Response, error)
	// GetByFingerprint retreives a SSH key by its fingerprint. If the SSH key does not exist, nil is returned.
	GetByFingerprint(ctx context.Context, fingerprint string) (*SSHKey, *Response, error)
	// 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. If the SSH key does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*SSHKey, *Response, error)
	// List returns a list of SSH keys for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts SSHKeyListOpts) ([]*SSHKey, *Response, error)
	// All returns all SSH keys.
	All(ctx context.Context) ([]*SSHKey, error)
	// AllWithOpts returns all SSH keys with the given options.
	AllWithOpts(ctx context.Context, opts SSHKeyListOpts) ([]*SSHKey, error)
	// Create creates a new SSH key with the given options.
	Create(ctx context.Context, opts SSHKeyCreateOpts) (*SSHKey, *Response, error)
	// Delete deletes a SSH key.
	Delete(ctx context.Context, sshKey *SSHKey) (*Response, error)
	// Update updates a SSH key.
	Update(ctx context.Context, sshKey *SSHKey, opts SSHKeyUpdateOpts) (*SSHKey, *Response, error)
}

ISSHKeyClient ...

type IServerClient

type IServerClient interface {
	// GetByID retrieves a server by its ID. If the server does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Server, *Response, error)
	// GetByName retrieves a server by its name. If the server does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*Server, *Response, error)
	// Get retrieves a server by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a server by its name. If the server does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Server, *Response, error)
	// List returns a list of servers for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts ServerListOpts) ([]*Server, *Response, error)
	// All returns all servers.
	All(ctx context.Context) ([]*Server, error)
	// AllWithOpts returns all servers for the given options.
	AllWithOpts(ctx context.Context, opts ServerListOpts) ([]*Server, error)
	// Create creates a new server.
	Create(ctx context.Context, opts ServerCreateOpts) (ServerCreateResult, *Response, error)
	// Delete deletes a server.
	//
	// Deprecated: Use [ServerClient.DeleteWithResult] instead.
	Delete(ctx context.Context, server *Server) (*Response, error)
	// DeleteWithResult deletes a server and returns the parsed response containing the action.
	DeleteWithResult(ctx context.Context, server *Server) (*ServerDeleteResult, *Response, error)
	// Update updates a server.
	Update(ctx context.Context, server *Server, opts ServerUpdateOpts) (*Server, *Response, error)
	// Poweron starts a server.
	Poweron(ctx context.Context, server *Server) (*Action, *Response, error)
	// Reboot reboots a server.
	Reboot(ctx context.Context, server *Server) (*Action, *Response, error)
	// Reset resets a server.
	Reset(ctx context.Context, server *Server) (*Action, *Response, error)
	// Shutdown shuts down a server.
	Shutdown(ctx context.Context, server *Server) (*Action, *Response, error)
	// Poweroff stops a server.
	Poweroff(ctx context.Context, server *Server) (*Action, *Response, error)
	// ResetPassword resets a server's password.
	ResetPassword(ctx context.Context, server *Server) (ServerResetPasswordResult, *Response, error)
	// CreateImage creates an image from a server.
	CreateImage(ctx context.Context, server *Server, opts *ServerCreateImageOpts) (ServerCreateImageResult, *Response, error)
	// EnableRescue enables rescue mode for a server.
	EnableRescue(ctx context.Context, server *Server, opts ServerEnableRescueOpts) (ServerEnableRescueResult, *Response, error)
	// DisableRescue disables rescue mode for a server.
	DisableRescue(ctx context.Context, server *Server) (*Action, *Response, error)
	// Rebuild rebuilds a server.
	//
	// Deprecated: Use [ServerClient.RebuildWithResult] instead.
	Rebuild(ctx context.Context, server *Server, opts ServerRebuildOpts) (*Action, *Response, error)
	// RebuildWithResult rebuilds a server.
	RebuildWithResult(ctx context.Context, server *Server, opts ServerRebuildOpts) (ServerRebuildResult, *Response, error)
	// AttachISO attaches an ISO to a server.
	AttachISO(ctx context.Context, server *Server, iso *ISO) (*Action, *Response, error)
	// DetachISO detaches the currently attached ISO from a server.
	DetachISO(ctx context.Context, server *Server) (*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.
	EnableBackup(ctx context.Context, server *Server, window string) (*Action, *Response, error)
	// DisableBackup disables backup for a server.
	DisableBackup(ctx context.Context, server *Server) (*Action, *Response, error)
	// ChangeType changes a server's type.
	ChangeType(ctx context.Context, server *Server, opts ServerChangeTypeOpts) (*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.
	ChangeDNSPtr(ctx context.Context, server *Server, ip string, ptr *string) (*Action, *Response, error)
	// ChangeProtection changes the resource protection level of a server.
	ChangeProtection(ctx context.Context, server *Server, opts ServerChangeProtectionOpts) (*Action, *Response, error)
	// RequestConsole requests a WebSocket VNC console.
	RequestConsole(ctx context.Context, server *Server) (ServerRequestConsoleResult, *Response, error)
	// AttachToNetwork attaches a server to a network.
	AttachToNetwork(ctx context.Context, server *Server, opts ServerAttachToNetworkOpts) (*Action, *Response, error)
	// DetachFromNetwork detaches a server from a network.
	DetachFromNetwork(ctx context.Context, server *Server, opts ServerDetachFromNetworkOpts) (*Action, *Response, error)
	// ChangeAliasIPs changes a server's alias IPs in a network.
	ChangeAliasIPs(ctx context.Context, server *Server, opts ServerChangeAliasIPsOpts) (*Action, *Response, error)
	// GetMetrics obtains metrics for Server.
	GetMetrics(ctx context.Context, server *Server, opts ServerGetMetricsOpts) (*ServerMetrics, *Response, error)
	AddToPlacementGroup(ctx context.Context, server *Server, placementGroup *PlacementGroup) (*Action, *Response, error)
	RemoveFromPlacementGroup(ctx context.Context, server *Server) (*Action, *Response, error)
}

IServerClient ...

type IServerTypeClient

type IServerTypeClient interface {
	// GetByID retrieves a server type by its ID. If the server type does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*ServerType, *Response, error)
	// GetByName retrieves a server type by its name. If the server type does not exist, nil is returned.
	GetByName(ctx context.Context, name 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. If the server type does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*ServerType, *Response, error)
	// List returns a list of server types for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts ServerTypeListOpts) ([]*ServerType, *Response, error)
	// All returns all server types.
	All(ctx context.Context) ([]*ServerType, error)
	// AllWithOpts returns all server types for the given options.
	AllWithOpts(ctx context.Context, opts ServerTypeListOpts) ([]*ServerType, error)
}

IServerTypeClient ...

type IVolumeClient

type IVolumeClient interface {
	// GetByID retrieves a volume by its ID. If the volume does not exist, nil is returned.
	GetByID(ctx context.Context, id int64) (*Volume, *Response, error)
	// GetByName retrieves a volume by its name. If the volume does not exist, nil is returned.
	GetByName(ctx context.Context, name string) (*Volume, *Response, error)
	// Get retrieves a volume by its ID if the input can be parsed as an integer, otherwise it
	// retrieves a volume by its name. If the volume does not exist, nil is returned.
	Get(ctx context.Context, idOrName string) (*Volume, *Response, error)
	// List returns a list of volumes for a specific page.
	//
	// Please note that filters specified in opts are not taken into account
	// when their value corresponds to their zero value or when they are empty.
	List(ctx context.Context, opts VolumeListOpts) ([]*Volume, *Response, error)
	// All returns all volumes.
	All(ctx context.Context) ([]*Volume, error)
	// AllWithOpts returns all volumes with the given options.
	AllWithOpts(ctx context.Context, opts VolumeListOpts) ([]*Volume, error)
	// Create creates a new volume with the given options.
	Create(ctx context.Context, opts VolumeCreateOpts) (VolumeCreateResult, *Response, error)
	// Delete deletes a volume.
	Delete(ctx context.Context, volume *Volume) (*Response, error)
	// Update updates a volume.
	Update(ctx context.Context, volume *Volume, opts VolumeUpdateOpts) (*Volume, *Response, error)
	// AttachWithOpts attaches a volume to a server.
	AttachWithOpts(ctx context.Context, volume *Volume, opts VolumeAttachOpts) (*Action, *Response, error)
	// Attach attaches a volume to a server.
	Attach(ctx context.Context, volume *Volume, server *Server) (*Action, *Response, error)
	// Detach detaches a volume from a server.
	Detach(ctx context.Context, volume *Volume) (*Action, *Response, error)
	// ChangeProtection changes the resource protection level of a volume.
	ChangeProtection(ctx context.Context, volume *Volume, opts VolumeChangeProtectionOpts) (*Action, *Response, error)
	// Resize changes the size of a volume.
	Resize(ctx context.Context, volume *Volume, size int) (*Action, *Response, error)
}

IVolumeClient ...

type Image

type Image struct {
	ID          int64
	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
	Architecture Architecture

	Protection ImageProtection
	Deprecated time.Time // The zero value denotes the image is not deprecated.
	Labels     map[string]string
	Deleted    time.Time
}

Image represents an Image in the Hetzner Cloud.

func ImageFromSchema

func ImageFromSchema(s schema.Image) *Image

ImageFromSchema converts a schema.Image to an Image.

func (*Image) IsDeleted

func (image *Image) IsDeleted() bool

IsDeleted returns whether the image is deleted.

func (*Image) IsDeprecated

func (image *Image) IsDeprecated() bool

IsDeprecated returns whether the image is deprecated.

type ImageChangeProtectionOpts

type ImageChangeProtectionOpts struct {
	Delete *bool
}

ImageChangeProtectionOpts specifies options for changing the resource protection level of an image.

type ImageClient

type ImageClient struct {
	Action *ResourceActionClient
	// 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) AllWithOpts

func (c *ImageClient) AllWithOpts(ctx context.Context, opts ImageListOpts) ([]*Image, error)

AllWithOpts returns all images for the given options.

func (*ImageClient) ChangeProtection

func (c *ImageClient) ChangeProtection(ctx context.Context, image *Image, opts ImageChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection changes the resource protection level of an image.

func (*ImageClient) Delete

func (c *ImageClient) Delete(ctx context.Context, image *Image) (*Response, error)

Delete deletes an image.

func (*ImageClient) Get deprecated

func (c *ImageClient) Get(ctx context.Context, idOrName string) (*Image, *Response, error)

Get retrieves an image by its ID if the input can be parsed as an integer, otherwise it retrieves an image by its name. If the image does not exist, nil is returned.

Deprecated: Use ImageClient.GetForArchitecture instead.

func (*ImageClient) GetByID

func (c *ImageClient) GetByID(ctx context.Context, id int64) (*Image, *Response, error)

GetByID retrieves an image by its ID. If the image does not exist, nil is returned.

func (*ImageClient) GetByName deprecated

func (c *ImageClient) GetByName(ctx context.Context, name string) (*Image, *Response, error)

GetByName retrieves an image by its name. If the image does not exist, nil is returned.

Deprecated: Use ImageClient.GetByNameAndArchitecture instead.

func (*ImageClient) GetByNameAndArchitecture

func (c *ImageClient) GetByNameAndArchitecture(ctx context.Context, name string, architecture Architecture) (*Image, *Response, error)

GetByNameAndArchitecture retrieves an image by its name and architecture. If the image does not exist, nil is returned. In contrast to ImageClient.Get, this method also returns deprecated images. Depending on your needs you should check for this in your calling method.

func (*ImageClient) GetForArchitecture

func (c *ImageClient) GetForArchitecture(ctx context.Context, idOrName string, architecture Architecture) (*Image, *Response, error)

GetForArchitecture retrieves an image by its ID if the input can be parsed as an integer, otherwise it retrieves an image by its name and architecture. If the image does not exist, nil is returned.

In contrast to ImageClient.Get, this method also returns deprecated images. Depending on your needs you should check for this in your calling method.

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.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

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
	Type              []ImageType
	BoundTo           *Server
	Name              string
	Sort              []string
	Status            []ImageStatus
	IncludeDeprecated bool
	Architecture      []Architecture
}

ImageListOpts specifies options for listing images.

type ImagePricing

type ImagePricing struct {
	PerGBMonth Price
}

ImagePricing provides pricing information for imaegs.

type ImageProtection

type ImageProtection struct {
	Delete bool
}

ImageProtection represents the protection level of an image.

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 status when an image is available.
	ImageStatusAvailable ImageStatus = "available"
)

type ImageType

type ImageType string

ImageType specifies the type of an image.

const (
	// ImageTypeSnapshot represents a snapshot image.
	ImageTypeSnapshot ImageType = "snapshot"
	// ImageTypeBackup represents a backup image.
	ImageTypeBackup ImageType = "backup"
	// ImageTypeSystem represents a system image.
	ImageTypeSystem ImageType = "system"
	// ImageTypeApp represents a one click app image.
	ImageTypeApp ImageType = "app"
)

type ImageUpdateOpts

type ImageUpdateOpts struct {
	Description *string
	Type        ImageType
	Labels      map[string]string
}

ImageUpdateOpts specifies options for updating an image.

type InvalidIPError

type InvalidIPError struct {
	IP string
}

func (InvalidIPError) Error

func (e InvalidIPError) Error() string

type ListOpts

type ListOpts struct {
	Page          int    // Page (starting at 1)
	PerPage       int    // Items per page (0 means default)
	LabelSelector string // Label selector for filtering by labels
}

ListOpts specifies options for listing resources.

func (ListOpts) Values

func (l ListOpts) Values() url.Values

Values returns the ListOpts as URL values.

type LoadBalancer

type LoadBalancer struct {
	ID               int64
	Name             string
	PublicNet        LoadBalancerPublicNet
	PrivateNet       []LoadBalancerPrivateNet
	Location         *Location
	LoadBalancerType *LoadBalancerType
	Algorithm        LoadBalancerAlgorithm
	Services         []LoadBalancerService
	Targets          []LoadBalancerTarget
	Protection       LoadBalancerProtection
	Labels           map[string]string
	Created          time.Time
	IncludedTraffic  uint64
	OutgoingTraffic  uint64
	IngoingTraffic   uint64
}

LoadBalancer represents a Load Balancer in the Hetzner Cloud.

func LoadBalancerFromSchema

func LoadBalancerFromSchema(s schema.LoadBalancer) *LoadBalancer

LoadBalancerFromSchema converts a schema.LoadBalancer to a LoadBalancer.

func (*LoadBalancer) GetDNSPtrForIP

func (lb *LoadBalancer) GetDNSPtrForIP(ip net.IP) (string, error)

GetDNSPtrForIP searches for the dns assigned to the given IP address. It returns an error if there is no dns set for the given IP address.

type LoadBalancerAddIPTargetOpts

type LoadBalancerAddIPTargetOpts struct {
	IP net.IP
}

LoadBalancerAddIPTargetOpts specifies options for adding an IP target to a Load Balancer.

type LoadBalancerAddLabelSelectorTargetOpts

type LoadBalancerAddLabelSelectorTargetOpts struct {
	Selector     string
	UsePrivateIP *bool
}

LoadBalancerAddLabelSelectorTargetOpts specifies options for adding a label selector target to a Load Balancer.

type LoadBalancerAddServerTargetOpts

type LoadBalancerAddServerTargetOpts struct {
	Server       *Server
	UsePrivateIP *bool
}

LoadBalancerAddServerTargetOpts specifies options for adding a server target to a Load Balancer.

type LoadBalancerAddServiceOpts

type LoadBalancerAddServiceOpts struct {
	Protocol        LoadBalancerServiceProtocol
	ListenPort      *int
	DestinationPort *int
	Proxyprotocol   *bool
	HTTP            *LoadBalancerAddServiceOptsHTTP
	HealthCheck     *LoadBalancerAddServiceOptsHealthCheck
}

LoadBalancerAddServiceOpts specifies options for adding a service to a Load Balancer.

type LoadBalancerAddServiceOptsHTTP

type LoadBalancerAddServiceOptsHTTP struct {
	CookieName     *string
	CookieLifetime *time.Duration
	Certificates   []*Certificate
	RedirectHTTP   *bool
	StickySessions *bool
}

LoadBalancerAddServiceOptsHTTP holds options for specifying an HTTP service when adding a service to a Load Balancer.

type LoadBalancerAddServiceOptsHealthCheck

type LoadBalancerAddServiceOptsHealthCheck struct {
	Protocol LoadBalancerServiceProtocol
	Port     *int
	Interval *time.Duration
	Timeout  *time.Duration
	Retries  *int
	HTTP     *LoadBalancerAddServiceOptsHealthCheckHTTP
}

LoadBalancerAddServiceOptsHealthCheck holds options for specifying a health check when adding a service to a Load Balancer.

type LoadBalancerAddServiceOptsHealthCheckHTTP

type LoadBalancerAddServiceOptsHealthCheckHTTP struct {
	Domain      *string
	Path        *string
	Response    *string
	StatusCodes []string
	TLS         *bool
}

LoadBalancerAddServiceOptsHealthCheckHTTP holds options for specifying an HTTP health check when adding a service to a Load Balancer.

type LoadBalancerAlgorithm

type LoadBalancerAlgorithm struct {
	Type LoadBalancerAlgorithmType
}

LoadBalancerAlgorithm configures the algorithm a Load Balancer uses for distributing requests.

type LoadBalancerAlgorithmType

type LoadBalancerAlgorithmType string

LoadBalancerAlgorithmType specifies the algorithm type a Load Balancer uses for distributing requests.

const (
	// LoadBalancerAlgorithmTypeRoundRobin is an algorithm which distributes
	// requests to targets in a round-robin fashion.
	LoadBalancerAlgorithmTypeRoundRobin LoadBalancerAlgorithmType = "round_robin"
	// LoadBalancerAlgorithmTypeLeastConnections is an algorithm which distributes
	// requests to targets with the least number of connections.
	LoadBalancerAlgorithmTypeLeastConnections LoadBalancerAlgorithmType = "least_connections"
)

type LoadBalancerAttachToNetworkOpts

type LoadBalancerAttachToNetworkOpts struct {
	Network *Network
	IP      net.IP
}

LoadBalancerAttachToNetworkOpts specifies options for attaching a Load Balancer to a network.

type LoadBalancerChangeAlgorithmOpts

type LoadBalancerChangeAlgorithmOpts struct {
	Type LoadBalancerAlgorithmType
}

LoadBalancerChangeAlgorithmOpts specifies options for changing the algorithm of a Load Balancer.

type LoadBalancerChangeProtectionOpts

type LoadBalancerChangeProtectionOpts struct {
	Delete *bool
}

LoadBalancerChangeProtectionOpts specifies options for changing the resource protection level of a Load Balancer.

type LoadBalancerChangeTypeOpts

type LoadBalancerChangeTypeOpts struct {
	LoadBalancerType *LoadBalancerType // new Load Balancer type
}

LoadBalancerChangeTypeOpts specifies options for changing a Load Balancer's type.

type LoadBalancerClient

type LoadBalancerClient struct {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

LoadBalancerClient is a client for the Load Balancers API.

func (*LoadBalancerClient) AddIPTarget

func (c *LoadBalancerClient) AddIPTarget(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddIPTargetOpts) (*Action, *Response, error)

AddIPTarget adds an IP target to a Load Balancer.

func (*LoadBalancerClient) AddLabelSelectorTarget

func (c *LoadBalancerClient) AddLabelSelectorTarget(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddLabelSelectorTargetOpts) (*Action, *Response, error)

AddLabelSelectorTarget adds a label selector target to a Load Balancer.

func (*LoadBalancerClient) AddServerTarget

func (c *LoadBalancerClient) AddServerTarget(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddServerTargetOpts) (*Action, *Response, error)

AddServerTarget adds a server target to a Load Balancer.

func (*LoadBalancerClient) AddService

func (c *LoadBalancerClient) AddService(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAddServiceOpts) (*Action, *Response, error)

AddService adds a service to a Load Balancer.

func (*LoadBalancerClient) All

All returns all Load Balancers.

func (*LoadBalancerClient) AllWithOpts

func (c *LoadBalancerClient) AllWithOpts(ctx context.Context, opts LoadBalancerListOpts) ([]*LoadBalancer, error)

AllWithOpts returns all Load Balancers for the given options.

func (*LoadBalancerClient) AttachToNetwork

func (c *LoadBalancerClient) AttachToNetwork(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerAttachToNetworkOpts) (*Action, *Response, error)

AttachToNetwork attaches a Load Balancer to a network.

func (*LoadBalancerClient) ChangeAlgorithm

func (c *LoadBalancerClient) ChangeAlgorithm(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerChangeAlgorithmOpts) (*Action, *Response, error)

ChangeAlgorithm changes the algorithm of a Load Balancer.

func (*LoadBalancerClient) ChangeDNSPtr

func (c *LoadBalancerClient) ChangeDNSPtr(ctx context.Context, lb *LoadBalancer, ip string, ptr *string) (*Action, *Response, error)

ChangeDNSPtr changes or resets the reverse DNS pointer for a Load Balancer. Pass a nil ptr to reset the reverse DNS pointer to its default value.

func (*LoadBalancerClient) ChangeProtection

func (c *LoadBalancerClient) ChangeProtection(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection changes the resource protection level of a Load Balancer.

func (*LoadBalancerClient) ChangeType

func (c *LoadBalancerClient) ChangeType(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerChangeTypeOpts) (*Action, *Response, error)

ChangeType changes a Load Balancer's type.

func (*LoadBalancerClient) Create

Create creates a new Load Balancer.

func (*LoadBalancerClient) Delete

func (c *LoadBalancerClient) Delete(ctx context.Context, loadBalancer *LoadBalancer) (*Response, error)

Delete deletes a Load Balancer.

func (*LoadBalancerClient) DeleteService

func (c *LoadBalancerClient) DeleteService(ctx context.Context, loadBalancer *LoadBalancer, listenPort int) (*Action, *Response, error)

DeleteService deletes a Load Balancer service.

func (*LoadBalancerClient) DetachFromNetwork

func (c *LoadBalancerClient) DetachFromNetwork(ctx context.Context, loadBalancer *LoadBalancer, opts LoadBalancerDetachFromNetworkOpts) (*Action, *Response, error)

DetachFromNetwork detaches a Load Balancer from a network.

func (*LoadBalancerClient) DisablePublicInterface

func (c *LoadBalancerClient) DisablePublicInterface(ctx context.Context, loadBalancer *LoadBalancer) (*Action, *Response, error)

DisablePublicInterface disables the Load Balancer's public network interface.

func (*LoadBalancerClient) EnablePublicInterface

func (c *LoadBalancerClient) EnablePublicInterface(ctx context.Context, loadBalancer *LoadBalancer) (*Action, *Response, error)

EnablePublicInterface enables the Load Balancer's public network interface.

func (*LoadBalancerClient) Get

func (c *LoadBalancerClient) Get(ctx context.Context, idOrName string) (*LoadBalancer, *Response, error)

Get retrieves a Load Balancer by its ID if the input can be parsed as an integer, otherwise it retrieves a Load Balancer by its name. If the Load Balancer does not exist, nil is returned.

func (*LoadBalancerClient) GetByID

GetByID retrieves a Load Balancer by its ID. If the Load Balancer does not exist, nil is returned.

func (*LoadBalancerClient) GetByName

func (c *LoadBalancerClient) GetByName(ctx context.Context, name string) (*LoadBalancer, *Response, error)

GetByName retrieves a Load Balancer by its name. If the Load Balancer does not exist, nil is returned.

func (*LoadBalancerClient) GetMetrics

GetMetrics obtains metrics for a Load Balancer.

func (*LoadBalancerClient) List

List returns a list of Load Balancers for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*LoadBalancerClient) RemoveIPTarget

func (c *LoadBalancerClient) RemoveIPTarget(ctx context.Context, loadBalancer *LoadBalancer, ip net.IP) (*Action, *Response, error)

RemoveIPTarget removes an IP target from a Load Balancer.

func (*LoadBalancerClient) RemoveLabelSelectorTarget

func (c *LoadBalancerClient) RemoveLabelSelectorTarget(ctx context.Context, loadBalancer *LoadBalancer, labelSelector string) (*Action, *Response, error)

RemoveLabelSelectorTarget removes a label selector target from a Load Balancer.

func (*LoadBalancerClient) RemoveServerTarget

func (c *LoadBalancerClient) RemoveServerTarget(ctx context.Context, loadBalancer *LoadBalancer, server *Server) (*Action, *Response, error)

RemoveServerTarget removes a server target from a Load Balancer.

func (*LoadBalancerClient) Update

Update updates a Load Balancer.

func (*LoadBalancerClient) UpdateService

func (c *LoadBalancerClient) UpdateService(ctx context.Context, loadBalancer *LoadBalancer, listenPort int, opts LoadBalancerUpdateServiceOpts) (*Action, *Response, error)

UpdateService updates a Load Balancer service.

type LoadBalancerCreateOpts

type LoadBalancerCreateOpts struct {
	Name             string
	LoadBalancerType *LoadBalancerType
	Algorithm        *LoadBalancerAlgorithm
	Location         *Location
	NetworkZone      NetworkZone
	Labels           map[string]string
	Targets          []LoadBalancerCreateOptsTarget
	Services         []LoadBalancerCreateOptsService
	PublicInterface  *bool
	Network          *Network
}

LoadBalancerCreateOpts specifies options for creating a new Load Balancer.

type LoadBalancerCreateOptsService

type LoadBalancerCreateOptsService struct {
	Protocol        LoadBalancerServiceProtocol
	ListenPort      *int
	DestinationPort *int
	Proxyprotocol   *bool
	HTTP            *LoadBalancerCreateOptsServiceHTTP
	HealthCheck     *LoadBalancerCreateOptsServiceHealthCheck
}

LoadBalancerCreateOptsService holds options for specifying a service when creating a new Load Balancer.

type LoadBalancerCreateOptsServiceHTTP

type LoadBalancerCreateOptsServiceHTTP struct {
	CookieName     *string
	CookieLifetime *time.Duration
	Certificates   []*Certificate
	RedirectHTTP   *bool
	StickySessions *bool
}

LoadBalancerCreateOptsServiceHTTP holds options for specifying an HTTP service when creating a new Load Balancer.

type LoadBalancerCreateOptsServiceHealthCheck

type LoadBalancerCreateOptsServiceHealthCheck struct {
	Protocol LoadBalancerServiceProtocol
	Port     *int
	Interval *time.Duration
	Timeout  *time.Duration
	Retries  *int
	HTTP     *LoadBalancerCreateOptsServiceHealthCheckHTTP
}

LoadBalancerCreateOptsServiceHealthCheck holds options for specifying a service health check when creating a new Load Balancer.

type LoadBalancerCreateOptsServiceHealthCheckHTTP

type LoadBalancerCreateOptsServiceHealthCheckHTTP struct {
	Domain      *string
	Path        *string
	Response    *string
	StatusCodes []string
	TLS         *bool
}

LoadBalancerCreateOptsServiceHealthCheckHTTP holds options for specifying a service HTTP health check when creating a new Load Balancer.

type LoadBalancerCreateOptsTarget

type LoadBalancerCreateOptsTarget struct {
	Type          LoadBalancerTargetType
	Server        LoadBalancerCreateOptsTargetServer
	LabelSelector LoadBalancerCreateOptsTargetLabelSelector
	IP            LoadBalancerCreateOptsTargetIP
	UsePrivateIP  *bool
}

LoadBalancerCreateOptsTarget holds options for specifying a target when creating a new Load Balancer.

type LoadBalancerCreateOptsTargetIP

type LoadBalancerCreateOptsTargetIP struct {
	IP string
}

LoadBalancerCreateOptsTargetIP holds options for specifying an IP target when creating a new Load Balancer.

type LoadBalancerCreateOptsTargetLabelSelector

type LoadBalancerCreateOptsTargetLabelSelector struct {
	Selector string
}

LoadBalancerCreateOptsTargetLabelSelector holds options for specifying a label selector target when creating a new Load Balancer.

type LoadBalancerCreateOptsTargetServer

type LoadBalancerCreateOptsTargetServer struct {
	Server *Server
}

LoadBalancerCreateOptsTargetServer holds options for specifying a server target when creating a new Load Balancer.

type LoadBalancerCreateResult

type LoadBalancerCreateResult struct {
	LoadBalancer *LoadBalancer
	Action       *Action
}

LoadBalancerCreateResult is the result of a create Load Balancer call.

type LoadBalancerDetachFromNetworkOpts

type LoadBalancerDetachFromNetworkOpts struct {
	Network *Network
}

LoadBalancerDetachFromNetworkOpts specifies options for detaching a Load Balancer from a network.

type LoadBalancerGetMetricsOpts

type LoadBalancerGetMetricsOpts struct {
	Types []LoadBalancerMetricType
	Start time.Time
	End   time.Time
	Step  int
}

LoadBalancerGetMetricsOpts configures the call to get metrics for a Load Balancer.

type LoadBalancerListOpts

type LoadBalancerListOpts struct {
	ListOpts
	Name string
	Sort []string
}

LoadBalancerListOpts specifies options for listing Load Balancers.

type LoadBalancerMetricType

type LoadBalancerMetricType string

LoadBalancerMetricType is the type of available metrics for Load Balancers.

const (
	LoadBalancerMetricOpenConnections      LoadBalancerMetricType = "open_connections"
	LoadBalancerMetricConnectionsPerSecond LoadBalancerMetricType = "connections_per_second"
	LoadBalancerMetricRequestsPerSecond    LoadBalancerMetricType = "requests_per_second"
	LoadBalancerMetricBandwidth            LoadBalancerMetricType = "bandwidth"
)

Available types of Load Balancer metrics. See Hetzner Cloud API documentation for details.

type LoadBalancerMetrics

type LoadBalancerMetrics struct {
	Start      time.Time
	End        time.Time
	Step       float64
	TimeSeries map[string][]LoadBalancerMetricsValue
}

LoadBalancerMetrics contains the metrics requested for a Load Balancer.

type LoadBalancerMetricsValue

type LoadBalancerMetricsValue struct {
	Timestamp float64
	Value     string
}

LoadBalancerMetricsValue represents a single value in a time series of metrics.

type LoadBalancerPrivateNet

type LoadBalancerPrivateNet struct {
	Network *Network
	IP      net.IP
}

LoadBalancerPrivateNet represents a Load Balancer's private network.

type LoadBalancerProtection

type LoadBalancerProtection struct {
	Delete bool
}

LoadBalancerProtection represents the protection level of a Load Balancer.

type LoadBalancerPublicNet

type LoadBalancerPublicNet struct {
	Enabled bool
	IPv4    LoadBalancerPublicNetIPv4
	IPv6    LoadBalancerPublicNetIPv6
}

LoadBalancerPublicNet represents a Load Balancer's public network.

type LoadBalancerPublicNetIPv4

type LoadBalancerPublicNetIPv4 struct {
	IP     net.IP
	DNSPtr string
}

LoadBalancerPublicNetIPv4 represents a Load Balancer's public IPv4 address.

type LoadBalancerPublicNetIPv6

type LoadBalancerPublicNetIPv6 struct {
	IP     net.IP
	DNSPtr string
}

LoadBalancerPublicNetIPv6 represents a Load Balancer's public IPv6 address.

type LoadBalancerService

type LoadBalancerService struct {
	Protocol        LoadBalancerServiceProtocol
	ListenPort      int
	DestinationPort int
	Proxyprotocol   bool
	HTTP            LoadBalancerServiceHTTP
	HealthCheck     LoadBalancerServiceHealthCheck
}

LoadBalancerService represents a Load Balancer service.

func LoadBalancerServiceFromSchema

func LoadBalancerServiceFromSchema(s schema.LoadBalancerService) LoadBalancerService

LoadBalancerServiceFromSchema converts a schema.LoadBalancerService to a LoadBalancerService.

type LoadBalancerServiceHTTP

type LoadBalancerServiceHTTP struct {
	CookieName     string
	CookieLifetime time.Duration
	Certificates   []*Certificate
	RedirectHTTP   bool
	StickySessions bool
}

LoadBalancerServiceHTTP stores configuration for a service using the HTTP protocol.

type LoadBalancerServiceHealthCheck

type LoadBalancerServiceHealthCheck struct {
	Protocol LoadBalancerServiceProtocol
	Port     int
	Interval time.Duration
	Timeout  time.Duration
	Retries  int
	HTTP     *LoadBalancerServiceHealthCheckHTTP
}

LoadBalancerServiceHealthCheck stores configuration for a service health check.

func LoadBalancerServiceHealthCheckFromSchema

func LoadBalancerServiceHealthCheckFromSchema(s *schema.LoadBalancerServiceHealthCheck) LoadBalancerServiceHealthCheck

LoadBalancerServiceHealthCheckFromSchema converts a schema.LoadBalancerServiceHealthCheck to a LoadBalancerServiceHealthCheck.

type LoadBalancerServiceHealthCheckHTTP

type LoadBalancerServiceHealthCheckHTTP struct {
	Domain      string
	Path        string
	Response    string
	StatusCodes []string
	TLS         bool
}

LoadBalancerServiceHealthCheckHTTP stores configuration for a service health check using the HTTP protocol.

type LoadBalancerServiceProtocol

type LoadBalancerServiceProtocol string

LoadBalancerServiceProtocol specifies the protocol of a Load Balancer service.

const (
	// LoadBalancerServiceProtocolTCP specifies a TCP service.
	LoadBalancerServiceProtocolTCP LoadBalancerServiceProtocol = "tcp"
	// LoadBalancerServiceProtocolHTTP specifies an HTTP service.
	LoadBalancerServiceProtocolHTTP LoadBalancerServiceProtocol = "http"
	// LoadBalancerServiceProtocolHTTPS specifies an HTTPS service.
	LoadBalancerServiceProtocolHTTPS LoadBalancerServiceProtocol = "https"
)

type LoadBalancerTarget

type LoadBalancerTarget struct {
	Type          LoadBalancerTargetType
	Server        *LoadBalancerTargetServer
	LabelSelector *LoadBalancerTargetLabelSelector
	IP            *LoadBalancerTargetIP
	HealthStatus  []LoadBalancerTargetHealthStatus
	Targets       []LoadBalancerTarget
	UsePrivateIP  bool
}

LoadBalancerTarget represents a Load Balancer target.

func LoadBalancerTargetFromSchema

func LoadBalancerTargetFromSchema(s schema.LoadBalancerTarget) LoadBalancerTarget

LoadBalancerTargetFromSchema converts a schema.LoadBalancerTarget to a LoadBalancerTarget.

type LoadBalancerTargetHealthStatus

type LoadBalancerTargetHealthStatus struct {
	ListenPort int
	Status     LoadBalancerTargetHealthStatusStatus
}

LoadBalancerTargetHealthStatus describes a target's health for a specific service.

func LoadBalancerTargetHealthStatusFromSchema

func LoadBalancerTargetHealthStatusFromSchema(s schema.LoadBalancerTargetHealthStatus) LoadBalancerTargetHealthStatus

LoadBalancerTargetHealthStatusFromSchema converts a schema.LoadBalancerTarget to a LoadBalancerTarget.

type LoadBalancerTargetHealthStatusStatus

type LoadBalancerTargetHealthStatusStatus string

LoadBalancerTargetHealthStatusStatus describes a target's health status.

const (
	// LoadBalancerTargetHealthStatusStatusUnknown denotes that the health status is unknown.
	LoadBalancerTargetHealthStatusStatusUnknown LoadBalancerTargetHealthStatusStatus = "unknown"
	// LoadBalancerTargetHealthStatusStatusHealthy denotes a healthy target.
	LoadBalancerTargetHealthStatusStatusHealthy LoadBalancerTargetHealthStatusStatus = "healthy"
	// LoadBalancerTargetHealthStatusStatusUnhealthy denotes an unhealthy target.
	LoadBalancerTargetHealthStatusStatusUnhealthy LoadBalancerTargetHealthStatusStatus = "unhealthy"
)

type LoadBalancerTargetIP

type LoadBalancerTargetIP struct {
	IP string
}

LoadBalancerTargetIP configures a Load Balancer target pointing to a Hetzner Online IP address.

type LoadBalancerTargetLabelSelector

type LoadBalancerTargetLabelSelector struct {
	Selector string
}

LoadBalancerTargetLabelSelector configures a Load Balancer target pointing at the servers matching the selector. This includes the target pointing at nothing, if no servers match the Selector.

type LoadBalancerTargetServer

type LoadBalancerTargetServer struct {
	Server *Server
}

LoadBalancerTargetServer configures a Load Balancer target pointing at a specific server.

type LoadBalancerTargetType

type LoadBalancerTargetType string

LoadBalancerTargetType specifies the type of Load Balancer target.

const (
	// LoadBalancerTargetTypeServer is a target type which points to a specific
	// server.
	LoadBalancerTargetTypeServer LoadBalancerTargetType = "server"

	// LoadBalancerTargetTypeLabelSelector is a target type which selects the
	// servers a Load Balancer points to using labels assigned to the servers.
	LoadBalancerTargetTypeLabelSelector LoadBalancerTargetType = "label_selector"

	// LoadBalancerTargetTypeIP is a target type which points to an IP.
	LoadBalancerTargetTypeIP LoadBalancerTargetType = "ip"
)

type LoadBalancerType

type LoadBalancerType struct {
	ID                      int64
	Name                    string
	Description             string
	MaxConnections          int
	MaxServices             int
	MaxTargets              int
	MaxAssignedCertificates int
	Pricings                []LoadBalancerTypeLocationPricing
	Deprecated              *string
}

LoadBalancerType represents a LoadBalancer type in the Hetzner Cloud.

func LoadBalancerTypeFromSchema

func LoadBalancerTypeFromSchema(s schema.LoadBalancerType) *LoadBalancerType

LoadBalancerTypeFromSchema converts a schema.LoadBalancerType to a LoadBalancerType.

type LoadBalancerTypeClient

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

LoadBalancerTypeClient is a client for the Load Balancer types API.

func (*LoadBalancerTypeClient) All

All returns all Load Balancer types.

func (*LoadBalancerTypeClient) AllWithOpts

AllWithOpts returns all Load Balancer types for the given options.

func (*LoadBalancerTypeClient) Get

Get retrieves a Load Balancer type by its ID if the input can be parsed as an integer, otherwise it retrieves a Load Balancer type by its name. If the Load Balancer type does not exist, nil is returned.

func (*LoadBalancerTypeClient) GetByID

GetByID retrieves a Load Balancer type by its ID. If the Load Balancer type does not exist, nil is returned.

func (*LoadBalancerTypeClient) GetByName

GetByName retrieves a Load Balancer type by its name. If the Load Balancer type does not exist, nil is returned.

func (*LoadBalancerTypeClient) List

List returns a list of Load Balancer types for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

type LoadBalancerTypeListOpts

type LoadBalancerTypeListOpts struct {
	ListOpts
	Name string
	Sort []string
}

LoadBalancerTypeListOpts specifies options for listing Load Balancer types.

type LoadBalancerTypeLocationPricing

type LoadBalancerTypeLocationPricing struct {
	Location *Location
	Hourly   Price
	Monthly  Price
}

LoadBalancerTypeLocationPricing provides pricing information for a Load Balancer type at a location.

type LoadBalancerTypePricing

type LoadBalancerTypePricing struct {
	LoadBalancerType *LoadBalancerType
	Pricings         []LoadBalancerTypeLocationPricing
}

LoadBalancerTypePricing provides pricing information for a Load Balancer type.

type LoadBalancerUpdateOpts

type LoadBalancerUpdateOpts struct {
	Name   string
	Labels map[string]string
}

LoadBalancerUpdateOpts specifies options for updating a Load Balancer.

type LoadBalancerUpdateServiceOpts

type LoadBalancerUpdateServiceOpts struct {
	Protocol        LoadBalancerServiceProtocol
	DestinationPort *int
	Proxyprotocol   *bool
	HTTP            *LoadBalancerUpdateServiceOptsHTTP
	HealthCheck     *LoadBalancerUpdateServiceOptsHealthCheck
}

LoadBalancerUpdateServiceOpts specifies options for updating a service.

type LoadBalancerUpdateServiceOptsHTTP

type LoadBalancerUpdateServiceOptsHTTP struct {
	CookieName     *string
	CookieLifetime *time.Duration
	Certificates   []*Certificate
	RedirectHTTP   *bool
	StickySessions *bool
}

LoadBalancerUpdateServiceOptsHTTP specifies options for updating an HTTP(S) service.

type LoadBalancerUpdateServiceOptsHealthCheck

type LoadBalancerUpdateServiceOptsHealthCheck struct {
	Protocol LoadBalancerServiceProtocol
	Port     *int
	Interval *time.Duration
	Timeout  *time.Duration
	Retries  *int
	HTTP     *LoadBalancerUpdateServiceOptsHealthCheckHTTP
}

LoadBalancerUpdateServiceOptsHealthCheck specifies options for updating a service's health check.

type LoadBalancerUpdateServiceOptsHealthCheckHTTP

type LoadBalancerUpdateServiceOptsHealthCheckHTTP struct {
	Domain      *string
	Path        *string
	Response    *string
	StatusCodes []string
	TLS         *bool
}

LoadBalancerUpdateServiceOptsHealthCheckHTTP specifies options for updating the HTTP-specific settings of a service's health check.

type Location

type Location struct {
	ID          int64
	Name        string
	Description string
	Country     string
	City        string
	Latitude    float64
	Longitude   float64
	NetworkZone NetworkZone
}

Location represents a location in the Hetzner Cloud.

func LocationFromSchema

func LocationFromSchema(s schema.Location) *Location

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) AllWithOpts

func (c *LocationClient) AllWithOpts(ctx context.Context, opts LocationListOpts) ([]*Location, error)

AllWithOpts returns all locations for the given options.

func (*LocationClient) Get

func (c *LocationClient) Get(ctx context.Context, idOrName string) (*Location, *Response, error)

Get retrieves a location by its ID if the input can be parsed as an integer, otherwise it retrieves a location by its name. If the location does not exist, nil is returned.

func (*LocationClient) GetByID

func (c *LocationClient) GetByID(ctx context.Context, id int64) (*Location, *Response, error)

GetByID retrieves a location by its ID. If the location does not exist, nil is returned.

func (*LocationClient) GetByName

func (c *LocationClient) GetByName(ctx context.Context, name string) (*Location, *Response, error)

GetByName retrieves an location by its name. If the location does not exist, nil is returned.

func (*LocationClient) List

List returns a list of locations for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

type LocationListOpts

type LocationListOpts struct {
	ListOpts
	Name string
	Sort []string
}

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 Network

type Network struct {
	ID         int64
	Name       string
	Created    time.Time
	IPRange    *net.IPNet
	Subnets    []NetworkSubnet
	Routes     []NetworkRoute
	Servers    []*Server
	Protection NetworkProtection
	Labels     map[string]string

	// ExposeRoutesToVSwitch indicates if the routes from this network should be exposed to the vSwitch connection.
	ExposeRoutesToVSwitch bool
}

Network represents a network in the Hetzner Cloud.

func NetworkFromSchema

func NetworkFromSchema(s schema.Network) *Network

NetworkFromSchema converts a schema.Network to a Network.

type NetworkAddRouteOpts

type NetworkAddRouteOpts struct {
	Route NetworkRoute
}

NetworkAddRouteOpts specifies options for adding a route to a network.

type NetworkAddSubnetOpts

type NetworkAddSubnetOpts struct {
	Subnet NetworkSubnet
}

NetworkAddSubnetOpts specifies options for adding a subnet to a network.

type NetworkChangeIPRangeOpts

type NetworkChangeIPRangeOpts struct {
	IPRange *net.IPNet
}

NetworkChangeIPRangeOpts specifies options for changing the IP range of a network.

type NetworkChangeProtectionOpts

type NetworkChangeProtectionOpts struct {
	Delete *bool
}

NetworkChangeProtectionOpts specifies options for changing the resource protection level of a network.

type NetworkClient

type NetworkClient struct {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

NetworkClient is a client for the network API.

func (*NetworkClient) AddRoute

func (c *NetworkClient) AddRoute(ctx context.Context, network *Network, opts NetworkAddRouteOpts) (*Action, *Response, error)

AddRoute adds a route to a network.

func (*NetworkClient) AddSubnet

func (c *NetworkClient) AddSubnet(ctx context.Context, network *Network, opts NetworkAddSubnetOpts) (*Action, *Response, error)

AddSubnet adds a subnet to a network.

func (*NetworkClient) All

func (c *NetworkClient) All(ctx context.Context) ([]*Network, error)

All returns all networks.

func (*NetworkClient) AllWithOpts

func (c *NetworkClient) AllWithOpts(ctx context.Context, opts NetworkListOpts) ([]*Network, error)

AllWithOpts returns all networks for the given options.

func (*NetworkClient) ChangeIPRange

func (c *NetworkClient) ChangeIPRange(ctx context.Context, network *Network, opts NetworkChangeIPRangeOpts) (*Action, *Response, error)

ChangeIPRange changes the IP range of a network.

func (*NetworkClient) ChangeProtection

func (c *NetworkClient) ChangeProtection(ctx context.Context, network *Network, opts NetworkChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection changes the resource protection level of a network.

func (*NetworkClient) Create

Create creates a new network.

func (*NetworkClient) Delete

func (c *NetworkClient) Delete(ctx context.Context, network *Network) (*Response, error)

Delete deletes a network.

func (*NetworkClient) DeleteRoute

func (c *NetworkClient) DeleteRoute(ctx context.Context, network *Network, opts NetworkDeleteRouteOpts) (*Action, *Response, error)

DeleteRoute deletes a route from a network.

func (*NetworkClient) DeleteSubnet

func (c *NetworkClient) DeleteSubnet(ctx context.Context, network *Network, opts NetworkDeleteSubnetOpts) (*Action, *Response, error)

DeleteSubnet deletes a subnet from a network.

func (*NetworkClient) Get

func (c *NetworkClient) Get(ctx context.Context, idOrName string) (*Network, *Response, error)

Get retrieves a network by its ID if the input can be parsed as an integer, otherwise it retrieves a network by its name. If the network does not exist, nil is returned.

func (*NetworkClient) GetByID

func (c *NetworkClient) GetByID(ctx context.Context, id int64) (*Network, *Response, error)

GetByID retrieves a network by its ID. If the network does not exist, nil is returned.

func (*NetworkClient) GetByName

func (c *NetworkClient) GetByName(ctx context.Context, name string) (*Network, *Response, error)

GetByName retrieves a network by its name. If the network does not exist, nil is returned.

func (*NetworkClient) List

func (c *NetworkClient) List(ctx context.Context, opts NetworkListOpts) ([]*Network, *Response, error)

List returns a list of networks for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*NetworkClient) Update

func (c *NetworkClient) Update(ctx context.Context, network *Network, opts NetworkUpdateOpts) (*Network, *Response, error)

Update updates a network.

type NetworkCreateOpts

type NetworkCreateOpts struct {
	Name    string
	IPRange *net.IPNet
	Subnets []NetworkSubnet
	Routes  []NetworkRoute
	Labels  map[string]string
	// ExposeRoutesToVSwitch indicates if the routes from this network should be exposed to the vSwitch connection.
	// The exposing only takes effect if a vSwitch connection is active.
	ExposeRoutesToVSwitch bool
}

NetworkCreateOpts specifies options for creating a new network.

func (NetworkCreateOpts) Validate

func (o NetworkCreateOpts) Validate() error

Validate checks if options are valid.

type NetworkDeleteRouteOpts

type NetworkDeleteRouteOpts struct {
	Route NetworkRoute
}

NetworkDeleteRouteOpts specifies options for deleting a route from a network.

type NetworkDeleteSubnetOpts

type NetworkDeleteSubnetOpts struct {
	Subnet NetworkSubnet
}

NetworkDeleteSubnetOpts specifies options for deleting a subnet from a network.

type NetworkListOpts

type NetworkListOpts struct {
	ListOpts
	Name string
	Sort []string
}

NetworkListOpts specifies options for listing networks.

type NetworkProtection

type NetworkProtection struct {
	Delete bool
}

NetworkProtection represents the protection level of a network.

type NetworkRoute

type NetworkRoute struct {
	Destination *net.IPNet
	Gateway     net.IP
}

NetworkRoute represents a route of a network.

func NetworkRouteFromSchema

func NetworkRouteFromSchema(s schema.NetworkRoute) NetworkRoute

NetworkRouteFromSchema converts a schema.NetworkRoute to a NetworkRoute.

type NetworkSubnet

type NetworkSubnet struct {
	Type        NetworkSubnetType
	IPRange     *net.IPNet
	NetworkZone NetworkZone
	Gateway     net.IP
	VSwitchID   int64
}

NetworkSubnet represents a subnet of a network in the Hetzner Cloud.

func NetworkSubnetFromSchema

func NetworkSubnetFromSchema(s schema.NetworkSubnet) NetworkSubnet

NetworkSubnetFromSchema converts a schema.NetworkSubnet to a NetworkSubnet.

type NetworkSubnetType

type NetworkSubnetType string

NetworkSubnetType specifies a type of a subnet.

const (
	NetworkSubnetTypeCloud   NetworkSubnetType = "cloud"
	NetworkSubnetTypeServer  NetworkSubnetType = "server"
	NetworkSubnetTypeVSwitch NetworkSubnetType = "vswitch"
)

List of available network subnet types.

type NetworkUpdateOpts

type NetworkUpdateOpts struct {
	Name   string
	Labels map[string]string
	// ExposeRoutesToVSwitch indicates if the routes from this network should be exposed to the vSwitch connection.
	// The exposing only takes effect if a vSwitch connection is active.
	ExposeRoutesToVSwitch *bool
}

NetworkUpdateOpts specifies options for updating a network.

type NetworkZone

type NetworkZone string

NetworkZone specifies a network zone.

const (
	NetworkZoneEUCentral NetworkZone = "eu-central"
	NetworkZoneUSEast    NetworkZone = "us-east"
	NetworkZoneUSWest    NetworkZone = "us-west"
)

List of available Network Zones.

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 PlacementGroup

type PlacementGroup struct {
	ID      int64
	Name    string
	Labels  map[string]string
	Created time.Time
	Servers []int64
	Type    PlacementGroupType
}

PlacementGroup represents a Placement Group in the Hetzner Cloud.

func PlacementGroupFromSchema

func PlacementGroupFromSchema(s schema.PlacementGroup) *PlacementGroup

PlacementGroupFromSchema converts a schema.PlacementGroup to a PlacementGroup.

type PlacementGroupClient

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

PlacementGroupClient is a client for the Placement Groups API.

func (*PlacementGroupClient) All

All returns all PlacementGroups.

func (*PlacementGroupClient) AllWithOpts

AllWithOpts returns all PlacementGroups for the given options.

func (*PlacementGroupClient) Create

Create creates a new PlacementGroup.

func (*PlacementGroupClient) Delete

func (c *PlacementGroupClient) Delete(ctx context.Context, placementGroup *PlacementGroup) (*Response, error)

Delete deletes a PlacementGroup.

func (*PlacementGroupClient) Get

Get retrieves a PlacementGroup by its ID if the input can be parsed as an integer, otherwise it retrieves a PlacementGroup by its name. If the PlacementGroup does not exist, nil is returned.

func (*PlacementGroupClient) GetByID

GetByID retrieves a PlacementGroup by its ID. If the PlacementGroup does not exist, nil is returned.

func (*PlacementGroupClient) GetByName

func (c *PlacementGroupClient) GetByName(ctx context.Context, name string) (*PlacementGroup, *Response, error)

GetByName retrieves a PlacementGroup by its name. If the PlacementGroup does not exist, nil is returned.

func (*PlacementGroupClient) List

List returns a list of PlacementGroups for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*PlacementGroupClient) Update

Update updates a PlacementGroup.

type PlacementGroupCreateOpts

type PlacementGroupCreateOpts struct {
	Name   string
	Labels map[string]string
	Type   PlacementGroupType
}

PlacementGroupCreateOpts specifies options for creating a new PlacementGroup.

func (PlacementGroupCreateOpts) Validate

func (o PlacementGroupCreateOpts) Validate() error

Validate checks if options are valid.

type PlacementGroupCreateResult

type PlacementGroupCreateResult struct {
	PlacementGroup *PlacementGroup
	Action         *Action
}

PlacementGroupCreateResult is the result of a create PlacementGroup call.

type PlacementGroupListOpts

type PlacementGroupListOpts struct {
	ListOpts
	Name string
	Type PlacementGroupType
	Sort []string
}

PlacementGroupListOpts specifies options for listing PlacementGroup.

type PlacementGroupType

type PlacementGroupType string

PlacementGroupType specifies the type of a Placement Group.

const (
	// PlacementGroupTypeSpread spreads all servers in the group on different vhosts.
	PlacementGroupTypeSpread PlacementGroupType = "spread"
)

type PlacementGroupUpdateOpts

type PlacementGroupUpdateOpts struct {
	Name   string
	Labels map[string]string
}

PlacementGroupUpdateOpts specifies options for updating a PlacementGroup.

type Price

type Price struct {
	Currency string
	VATRate  string
	Net      string
	Gross    string
}

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
	FloatingIPs       []FloatingIPTypePricing
	PrimaryIPs        []PrimaryIPPricing
	Traffic           TrafficPricing
	ServerBackup      ServerBackupPricing
	ServerTypes       []ServerTypePricing
	LoadBalancerTypes []LoadBalancerTypePricing
	Volume            VolumePricing
}

Pricing specifies pricing information for various resources.

func PricingFromSchema

func PricingFromSchema(s schema.Pricing) Pricing

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.

func (*PricingClient) Get

Get retrieves pricing information.

type PrimaryIP

type PrimaryIP struct {
	ID           int64
	IP           net.IP
	Network      *net.IPNet
	Labels       map[string]string
	Name         string
	Type         PrimaryIPType
	Protection   PrimaryIPProtection
	DNSPtr       map[string]string
	AssigneeID   int64
	AssigneeType string
	AutoDelete   bool
	Blocked      bool
	Created      time.Time
	Datacenter   *Datacenter
}

PrimaryIP defines a Primary IP.

func PrimaryIPFromSchema

func PrimaryIPFromSchema(s schema.PrimaryIP) *PrimaryIP

PrimaryIPFromSchema converts a schema.PrimaryIP to a PrimaryIP.

func (*PrimaryIP) GetDNSPtrForIP

func (p *PrimaryIP) GetDNSPtrForIP(ip net.IP) (string, error)

GetDNSPtrForIP searches for the dns assigned to the given IP address. It returns an error if there is no dns set for the given IP address.

type PrimaryIPAssignOpts

type PrimaryIPAssignOpts struct {
	ID           int64
	AssigneeID   int64  `json:"assignee_id"`
	AssigneeType string `json:"assignee_type"`
}

PrimaryIPAssignOpts defines the request to assign a Primary IP to an assignee (usually a server).

type PrimaryIPAssignResult

type PrimaryIPAssignResult struct {
	Action schema.Action `json:"action"`
}

PrimaryIPAssignResult defines the response when assigning a Primary IP to a assignee.

type PrimaryIPChangeDNSPtrOpts

type PrimaryIPChangeDNSPtrOpts struct {
	ID     int64
	DNSPtr string `json:"dns_ptr"`
	IP     string `json:"ip"`
}

PrimaryIPChangeDNSPtrOpts defines the request to change a DNS PTR entry from a Primary IP.

type PrimaryIPChangeDNSPtrResult

type PrimaryIPChangeDNSPtrResult struct {
	Action schema.Action `json:"action"`
}

PrimaryIPChangeDNSPtrResult defines the response when assigning a Primary IP to a assignee.

type PrimaryIPChangeProtectionOpts

type PrimaryIPChangeProtectionOpts struct {
	ID     int64
	Delete bool `json:"delete"`
}

PrimaryIPChangeProtectionOpts defines the request to change protection configuration of a Primary IP.

type PrimaryIPChangeProtectionResult

type PrimaryIPChangeProtectionResult struct {
	Action schema.Action `json:"action"`
}

PrimaryIPChangeProtectionResult defines the response when changing a protection of a PrimaryIP.

type PrimaryIPClient

type PrimaryIPClient struct {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

PrimaryIPClient is a client for the Primary IP API.

func (*PrimaryIPClient) All

func (c *PrimaryIPClient) All(ctx context.Context) ([]*PrimaryIP, error)

All returns all Primary IPs.

func (*PrimaryIPClient) AllWithOpts

func (c *PrimaryIPClient) AllWithOpts(ctx context.Context, opts PrimaryIPListOpts) ([]*PrimaryIP, error)

AllWithOpts returns all Primary IPs for the given options.

func (*PrimaryIPClient) Assign

Assign a Primary IP to a resource.

func (*PrimaryIPClient) ChangeDNSPtr

ChangeDNSPtr Change the reverse DNS from a Primary IP.

func (*PrimaryIPClient) ChangeProtection

func (c *PrimaryIPClient) ChangeProtection(ctx context.Context, opts PrimaryIPChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection Changes the protection configuration of a Primary IP.

func (*PrimaryIPClient) Create

Create creates a Primary IP.

func (*PrimaryIPClient) Delete

func (c *PrimaryIPClient) Delete(ctx context.Context, primaryIP *PrimaryIP) (*Response, error)

Delete deletes a Primary IP.

func (*PrimaryIPClient) Get

func (c *PrimaryIPClient) Get(ctx context.Context, idOrName string) (*PrimaryIP, *Response, error)

Get retrieves a Primary IP by its ID if the input can be parsed as an integer, otherwise it retrieves a Primary IP by its name. If the Primary IP does not exist, nil is returned.

func (*PrimaryIPClient) GetByID

func (c *PrimaryIPClient) GetByID(ctx context.Context, id int64) (*PrimaryIP, *Response, error)

GetByID retrieves a Primary IP by its ID. If the Primary IP does not exist, nil is returned.

func (*PrimaryIPClient) GetByIP

func (c *PrimaryIPClient) GetByIP(ctx context.Context, ip string) (*PrimaryIP, *Response, error)

GetByIP retrieves a Primary IP by its IP Address. If the Primary IP does not exist, nil is returned.

func (*PrimaryIPClient) GetByName

func (c *PrimaryIPClient) GetByName(ctx context.Context, name string) (*PrimaryIP, *Response, error)

GetByName retrieves a Primary IP by its name. If the Primary IP does not exist, nil is returned.

func (*PrimaryIPClient) List

List returns a list of Primary IPs for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*PrimaryIPClient) Unassign

func (c *PrimaryIPClient) Unassign(ctx context.Context, id int64) (*Action, *Response, error)

Unassign a Primary IP from a resource.

func (*PrimaryIPClient) Update

func (c *PrimaryIPClient) Update(ctx context.Context, primaryIP *PrimaryIP, reqBody PrimaryIPUpdateOpts) (*PrimaryIP, *Response, error)

Update updates a Primary IP.

type PrimaryIPCreateOpts

type PrimaryIPCreateOpts struct {
	AssigneeID   *int64            `json:"assignee_id,omitempty"`
	AssigneeType string            `json:"assignee_type"`
	AutoDelete   *bool             `json:"auto_delete,omitempty"`
	Datacenter   string            `json:"datacenter,omitempty"`
	Labels       map[string]string `json:"labels,omitempty"`
	Name         string            `json:"name"`
	Type         PrimaryIPType     `json:"type"`
}

PrimaryIPCreateOpts defines the request to create a Primary IP.

type PrimaryIPCreateResult

type PrimaryIPCreateResult struct {
	PrimaryIP *PrimaryIP
	Action    *Action
}

PrimaryIPCreateResult defines the response when creating a Primary IP.

type PrimaryIPDNSPTR

type PrimaryIPDNSPTR struct {
	DNSPtr string
	IP     string
}

PrimaryIPDNSPTR contains reverse DNS information for a IPv4 or IPv6 Primary IP.

type PrimaryIPListOpts

type PrimaryIPListOpts struct {
	ListOpts
	Name string
	IP   string
	Sort []string
}

PrimaryIPListOpts specifies options for listing Primary IPs.

type PrimaryIPPrice

type PrimaryIPPrice struct {
	Net   string
	Gross string
}

PrimaryIPPrice represents a price. Net amount and gross amount are specified as strings and it is the user's responsibility to convert them to appropriate types for calculations.

type PrimaryIPPricing

type PrimaryIPPricing struct {
	Type     string
	Pricings []PrimaryIPTypePricing
}

PrimaryIPTypePricing provides pricing information for PrimaryIPs.

type PrimaryIPProtection

type PrimaryIPProtection struct {
	Delete bool
}

PrimaryIPProtection represents the protection level of a Primary IP.

type PrimaryIPType

type PrimaryIPType string

PrimaryIPType represents the type of Primary IP.

const (
	PrimaryIPTypeIPv4 PrimaryIPType = "ipv4"
	PrimaryIPTypeIPv6 PrimaryIPType = "ipv6"
)

PrimaryIPType Primary IP types.

type PrimaryIPTypePricing

type PrimaryIPTypePricing struct {
	Datacenter string // Deprecated: the API does not return pricing for the individual DCs anymore
	Location   string
	Hourly     PrimaryIPPrice
	Monthly    PrimaryIPPrice
}

PrimaryIPTypePricing defines the schema of pricing information for a primary IP type at a datacenter.

type PrimaryIPUpdateOpts

type PrimaryIPUpdateOpts struct {
	AutoDelete *bool              `json:"auto_delete,omitempty"`
	Labels     *map[string]string `json:"labels,omitempty"`
	Name       string             `json:"name,omitempty"`
}

PrimaryIPUpdateOpts defines the request to update a Primary IP.

type RDNSClient

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

RDNSClient simplifies the handling objects which support reverse dns entries.

func (*RDNSClient) ChangeDNSPtr

func (c *RDNSClient) ChangeDNSPtr(ctx context.Context, rdns RDNSSupporter, ip net.IP, ptr *string) (*Action, *Response, error)

ChangeDNSPtr changes or resets the reverse DNS pointer for a IP address. Pass a nil ptr to reset the reverse DNS pointer to its default value.

type RDNSSupporter

type RDNSSupporter interface {

	// GetDNSPtrForIP searches for the dns assigned to the given IP address.
	// It returns an error if there is no dns set for the given IP address.
	GetDNSPtrForIP(ip net.IP) (string, error)
	// contains filtered or unexported methods
}

RDNSSupporter defines functions to change and lookup reverse dns entries. currently implemented by Server, FloatingIP, PrimaryIP and LoadBalancer.

type Ratelimit

type Ratelimit struct {
	Limit     int
	Remaining int
	Reset     time.Time
}

Ratelimit represents ratelimit information.

type Resource

type Resource struct {
	ID   int64
	Type string
}

Resource defines the schema of a resource.

type ResourceActionClient

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

ResourceActionClient is a client for the actions API exposed by the resource.

func (*ResourceActionClient) All

All returns all actions for the given options.

func (*ResourceActionClient) GetByID

func (c *ResourceActionClient) GetByID(ctx context.Context, id int64) (*Action, *Response, error)

GetByID retrieves an action by its ID. If the action does not exist, nil is returned.

func (*ResourceActionClient) List

List returns a list of actions for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

type Response

type Response struct {
	*http.Response
	Meta Meta
}

Response represents a response from the API. It embeds http.Response.

type SSHKey

type SSHKey struct {
	ID          int64
	Name        string
	Fingerprint string
	PublicKey   string
	Labels      map[string]string
	Created     time.Time
}

SSHKey represents a SSH key in the Hetzner Cloud.

func SSHKeyFromSchema

func SSHKeyFromSchema(s schema.SSHKey) *SSHKey

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) AllWithOpts

func (c *SSHKeyClient) AllWithOpts(ctx context.Context, opts SSHKeyListOpts) ([]*SSHKey, error)

AllWithOpts returns all SSH keys with the given options.

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) Delete

func (c *SSHKeyClient) Delete(ctx context.Context, sshKey *SSHKey) (*Response, error)

Delete deletes a SSH key.

func (*SSHKeyClient) Get

func (c *SSHKeyClient) Get(ctx context.Context, idOrName string) (*SSHKey, *Response, error)

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. If the SSH key does not exist, nil is returned.

func (*SSHKeyClient) GetByFingerprint

func (c *SSHKeyClient) GetByFingerprint(ctx context.Context, fingerprint string) (*SSHKey, *Response, error)

GetByFingerprint retreives a SSH key by its fingerprint. If the SSH key does not exist, nil is returned.

func (*SSHKeyClient) GetByID

func (c *SSHKeyClient) GetByID(ctx context.Context, id int64) (*SSHKey, *Response, error)

GetByID retrieves a SSH key by its ID. If the SSH key does not exist, nil is returned.

func (*SSHKeyClient) GetByName

func (c *SSHKeyClient) GetByName(ctx context.Context, name string) (*SSHKey, *Response, error)

GetByName retrieves a SSH key by its name. If the SSH key does not exist, nil is returned.

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.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*SSHKeyClient) Update

func (c *SSHKeyClient) Update(ctx context.Context, sshKey *SSHKey, opts SSHKeyUpdateOpts) (*SSHKey, *Response, error)

Update updates a SSH key.

type SSHKeyCreateOpts

type SSHKeyCreateOpts struct {
	Name      string
	PublicKey string
	Labels    map[string]string
}

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
	Name        string
	Fingerprint string
	Sort        []string
}

SSHKeyListOpts specifies options for listing SSH keys.

type SSHKeyUpdateOpts

type SSHKeyUpdateOpts struct {
	Name   string
	Labels map[string]string
}

SSHKeyUpdateOpts specifies options for updating a SSH key.

type Server

type Server struct {
	ID              int64
	Name            string
	Status          ServerStatus
	Created         time.Time
	PublicNet       ServerPublicNet
	PrivateNet      []ServerPrivateNet
	ServerType      *ServerType
	Datacenter      *Datacenter
	IncludedTraffic uint64
	OutgoingTraffic uint64
	IngoingTraffic  uint64
	BackupWindow    string
	RescueEnabled   bool
	Locked          bool
	ISO             *ISO
	Image           *Image
	Protection      ServerProtection
	Labels          map[string]string
	Volumes         []*Volume
	PrimaryDiskSize int
	PlacementGroup  *PlacementGroup
	LoadBalancers   []*LoadBalancer
}

Server represents a server in the Hetzner Cloud.

func ServerFromSchema

func ServerFromSchema(s schema.Server) *Server

ServerFromSchema converts a schema.Server to a Server.

func (*Server) GetDNSPtrForIP

func (s *Server) GetDNSPtrForIP(ip net.IP) (string, error)

GetDNSPtrForIP searches for the dns assigned to the given IP address. It returns an error if there is no dns set for the given IP address.

type ServerAttachToNetworkOpts

type ServerAttachToNetworkOpts struct {
	Network  *Network
	IP       net.IP
	AliasIPs []net.IP
}

ServerAttachToNetworkOpts specifies options for attaching a server to a network.

type ServerBackupPricing

type ServerBackupPricing struct {
	Percentage string
}

ServerBackupPricing provides pricing information for server backups.

type ServerChangeAliasIPsOpts

type ServerChangeAliasIPsOpts struct {
	Network  *Network
	AliasIPs []net.IP
}

ServerChangeAliasIPsOpts specifies options for changing the alias ips of an already attached network.

type ServerChangeProtectionOpts

type ServerChangeProtectionOpts struct {
	Rebuild *bool
	Delete  *bool
}

ServerChangeProtectionOpts specifies options for changing the resource protection level of a server.

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 {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

ServerClient is a client for the servers API.

func (*ServerClient) AddToPlacementGroup

func (c *ServerClient) AddToPlacementGroup(ctx context.Context, server *Server, placementGroup *PlacementGroup) (*Action, *Response, error)

func (*ServerClient) All

func (c *ServerClient) All(ctx context.Context) ([]*Server, error)

All returns all servers.

func (*ServerClient) AllWithOpts

func (c *ServerClient) AllWithOpts(ctx context.Context, opts ServerListOpts) ([]*Server, error)

AllWithOpts returns all servers for the given options.

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) AttachToNetwork

func (c *ServerClient) AttachToNetwork(ctx context.Context, server *Server, opts ServerAttachToNetworkOpts) (*Action, *Response, error)

AttachToNetwork attaches a server to a network.

func (*ServerClient) ChangeAliasIPs

func (c *ServerClient) ChangeAliasIPs(ctx context.Context, server *Server, opts ServerChangeAliasIPsOpts) (*Action, *Response, error)

ChangeAliasIPs changes a server's alias IPs in a network.

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) ChangeProtection

func (c *ServerClient) ChangeProtection(ctx context.Context, server *Server, opts ServerChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection changes the resource protection level of a server.

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

Create creates a new server.

func (*ServerClient) CreateImage

CreateImage creates an image from a server.

func (*ServerClient) Delete deprecated

func (c *ServerClient) Delete(ctx context.Context, server *Server) (*Response, error)

Delete deletes a server.

Deprecated: Use ServerClient.DeleteWithResult instead.

func (*ServerClient) DeleteWithResult

func (c *ServerClient) DeleteWithResult(ctx context.Context, server *Server) (*ServerDeleteResult, *Response, error)

DeleteWithResult deletes a server and returns the parsed response containing the action.

func (*ServerClient) DetachFromNetwork

func (c *ServerClient) DetachFromNetwork(ctx context.Context, server *Server, opts ServerDetachFromNetworkOpts) (*Action, *Response, error)

DetachFromNetwork detaches a server from a network.

func (*ServerClient) DetachISO

func (c *ServerClient) DetachISO(ctx context.Context, server *Server) (*Action, *Response, error)

DetachISO detaches the currently attached ISO 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

EnableRescue enables rescue mode for a server.

func (*ServerClient) Get

func (c *ServerClient) Get(ctx context.Context, idOrName string) (*Server, *Response, error)

Get retrieves a server by its ID if the input can be parsed as an integer, otherwise it retrieves a server by its name. If the server does not exist, nil is returned.

func (*ServerClient) GetByID

func (c *ServerClient) GetByID(ctx context.Context, id int64) (*Server, *Response, error)

GetByID retrieves a server by its ID. If the server does not exist, nil is returned.

func (*ServerClient) GetByName

func (c *ServerClient) GetByName(ctx context.Context, name string) (*Server, *Response, error)

GetByName retrieves a server by its name. If the server does not exist, nil is returned.

func (*ServerClient) GetMetrics

func (c *ServerClient) GetMetrics(ctx context.Context, server *Server, opts ServerGetMetricsOpts) (*ServerMetrics, *Response, error)

GetMetrics obtains metrics for Server.

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.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*ServerClient) Poweroff

func (c *ServerClient) Poweroff(ctx context.Context, server *Server) (*Action, *Response, error)

Poweroff stops a server.

func (*ServerClient) Poweron

func (c *ServerClient) Poweron(ctx context.Context, server *Server) (*Action, *Response, error)

Poweron starts a server.

func (*ServerClient) Reboot

func (c *ServerClient) Reboot(ctx context.Context, server *Server) (*Action, *Response, error)

Reboot reboots a server.

func (*ServerClient) Rebuild deprecated

func (c *ServerClient) Rebuild(ctx context.Context, server *Server, opts ServerRebuildOpts) (*Action, *Response, error)

Rebuild rebuilds a server.

Deprecated: Use ServerClient.RebuildWithResult instead.

func (*ServerClient) RebuildWithResult

func (c *ServerClient) RebuildWithResult(ctx context.Context, server *Server, opts ServerRebuildOpts) (ServerRebuildResult, *Response, error)

RebuildWithResult rebuilds a server.

func (*ServerClient) RemoveFromPlacementGroup

func (c *ServerClient) RemoveFromPlacementGroup(ctx context.Context, server *Server) (*Action, *Response, error)

func (*ServerClient) RequestConsole

func (c *ServerClient) RequestConsole(ctx context.Context, server *Server) (ServerRequestConsoleResult, *Response, error)

RequestConsole requests a WebSocket VNC console.

func (*ServerClient) Reset

func (c *ServerClient) Reset(ctx context.Context, server *Server) (*Action, *Response, error)

Reset resets 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) Shutdown

func (c *ServerClient) Shutdown(ctx context.Context, server *Server) (*Action, *Response, error)

Shutdown shuts down a server.

func (*ServerClient) Update

func (c *ServerClient) Update(ctx context.Context, server *Server, opts ServerUpdateOpts) (*Server, *Response, error)

Update updates a server.

type ServerCreateFirewall

type ServerCreateFirewall struct {
	Firewall Firewall
}

ServerCreateFirewall defines which Firewalls to apply when creating a Server.

type ServerCreateImageOpts

type ServerCreateImageOpts struct {
	Type        ImageType
	Description *string
	Labels      map[string]string
}

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

type ServerCreateImageResult struct {
	Action *Action
	Image  *Image
}

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
	UserData         string
	StartAfterCreate *bool
	Labels           map[string]string
	Automount        *bool
	Volumes          []*Volume
	Networks         []*Network
	Firewalls        []*ServerCreateFirewall
	PlacementGroup   *PlacementGroup
	PublicNet        *ServerCreatePublicNet
}

ServerCreateOpts specifies options for creating a new server.

func (ServerCreateOpts) Validate

func (o ServerCreateOpts) Validate() error

Validate checks if options are valid.

type ServerCreatePublicNet

type ServerCreatePublicNet struct {
	EnableIPv4 bool
	EnableIPv6 bool
	IPv4       *PrimaryIP
	IPv6       *PrimaryIP
}

type ServerCreateResult

type ServerCreateResult struct {
	Server       *Server
	Action       *Action
	RootPassword string
	NextActions  []*Action
}

ServerCreateResult is the result of a create server call.

type ServerDeleteResult

type ServerDeleteResult struct {
	Action *Action
}

ServerDeleteResult is the result of a delete server call.

type ServerDetachFromNetworkOpts

type ServerDetachFromNetworkOpts struct {
	Network *Network
}

ServerDetachFromNetworkOpts specifies options for detaching a server from a network.

type ServerEnableRescueOpts

type ServerEnableRescueOpts struct {
	Type    ServerRescueType
	SSHKeys []*SSHKey
}

ServerEnableRescueOpts specifies options for enabling rescue mode for a server.

type ServerEnableRescueResult

type ServerEnableRescueResult struct {
	Action       *Action
	RootPassword string
}

ServerEnableRescueResult is the result of enabling rescue mode for a server.

type ServerFirewallStatus

type ServerFirewallStatus struct {
	Firewall Firewall
	Status   FirewallStatus
}

ServerFirewallStatus represents a Firewall and its status on a Server's network interface.

type ServerGetMetricsOpts

type ServerGetMetricsOpts struct {
	Types []ServerMetricType
	Start time.Time
	End   time.Time
	Step  int
}

ServerGetMetricsOpts configures the call to get metrics for a Server.

type ServerListOpts

type ServerListOpts struct {
	ListOpts
	Name   string
	Status []ServerStatus
	Sort   []string
}

ServerListOpts specifies options for listing servers.

type ServerMetricType

type ServerMetricType string

ServerMetricType is the type of available metrics for servers.

const (
	ServerMetricCPU     ServerMetricType = "cpu"
	ServerMetricDisk    ServerMetricType = "disk"
	ServerMetricNetwork ServerMetricType = "network"
)

Available types of server metrics. See Hetzner Cloud API documentation for details.

type ServerMetrics

type ServerMetrics struct {
	Start      time.Time
	End        time.Time
	Step       float64
	TimeSeries map[string][]ServerMetricsValue
}

ServerMetrics contains the metrics requested for a Server.

type ServerMetricsValue

type ServerMetricsValue struct {
	Timestamp float64
	Value     string
}

ServerMetricsValue represents a single value in a time series of metrics.

type ServerPrivateNet

type ServerPrivateNet struct {
	Network    *Network
	IP         net.IP
	Aliases    []net.IP
	MACAddress string
}

ServerPrivateNet defines the schema of a Server's private network information.

func ServerPrivateNetFromSchema

func ServerPrivateNetFromSchema(s schema.ServerPrivateNet) ServerPrivateNet

ServerPrivateNetFromSchema converts a schema.ServerPrivateNet to a ServerPrivateNet.

type ServerProtection

type ServerProtection struct {
	Delete, Rebuild bool
}

ServerProtection represents the protection level of a server.

type ServerPublicNet

type ServerPublicNet struct {
	IPv4        ServerPublicNetIPv4
	IPv6        ServerPublicNetIPv6
	FloatingIPs []*FloatingIP
	Firewalls   []*ServerFirewallStatus
}

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

type ServerPublicNetIPv4 struct {
	ID      int64
	IP      net.IP
	Blocked bool
	DNSPtr  string
}

ServerPublicNetIPv4 represents a server's public IPv4 address.

func ServerPublicNetIPv4FromSchema

func ServerPublicNetIPv4FromSchema(s schema.ServerPublicNetIPv4) ServerPublicNetIPv4

ServerPublicNetIPv4FromSchema converts a schema.ServerPublicNetIPv4 to a ServerPublicNetIPv4.

func (*ServerPublicNetIPv4) IsUnspecified

func (n *ServerPublicNetIPv4) IsUnspecified() bool

type ServerPublicNetIPv6

type ServerPublicNetIPv6 struct {
	ID      int64
	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 (n *ServerPublicNetIPv6) DNSPtrForIP(ip net.IP) string

DNSPtrForIP returns the reverse dns pointer of the ip address.

func (*ServerPublicNetIPv6) IsUnspecified

func (n *ServerPublicNetIPv6) IsUnspecified() bool

type ServerRebuildOpts

type ServerRebuildOpts struct {
	Image *Image
}

ServerRebuildOpts specifies options for rebuilding a server.

type ServerRebuildResult

type ServerRebuildResult struct {
	Action       *Action
	RootPassword string
}

ServerRebuildResult is the result of a create server call.

type ServerRequestConsoleResult

type ServerRequestConsoleResult struct {
	Action   *Action
	WSSURL   string
	Password string
}

ServerRequestConsoleResult is the result of requesting a WebSocket VNC console.

type ServerRescueType

type ServerRescueType string

ServerRescueType represents rescue types.

const (
	// Deprecated: Use ServerRescueTypeLinux64 instead.
	ServerRescueTypeLinux32 ServerRescueType = "linux32"
	ServerRescueTypeLinux64 ServerRescueType = "linux64"
)

List of rescue types.

type ServerResetPasswordResult

type ServerResetPasswordResult struct {
	Action       *Action
	RootPassword string
}

ServerResetPasswordResult is the result of resetting a server's password.

type ServerStatus

type ServerStatus string

ServerStatus specifies a server's status.

const (
	// ServerStatusInitializing is the status when a server is initializing.
	ServerStatusInitializing ServerStatus = "initializing"

	// ServerStatusOff is the status when a server is off.
	ServerStatusOff ServerStatus = "off"

	// ServerStatusRunning is the status when a server is running.
	ServerStatusRunning ServerStatus = "running"

	// ServerStatusStarting is the status when a server is being started.
	ServerStatusStarting ServerStatus = "starting"

	// ServerStatusStopping is the status when a server is being stopped.
	ServerStatusStopping ServerStatus = "stopping"

	// ServerStatusMigrating is the status when a server is being migrated.
	ServerStatusMigrating ServerStatus = "migrating"

	// ServerStatusRebuilding is the status when a server is being rebuilt.
	ServerStatusRebuilding ServerStatus = "rebuilding"

	// ServerStatusDeleting is the status when a server is being deleted.
	ServerStatusDeleting ServerStatus = "deleting"

	// ServerStatusUnknown is the status when a server's state is unknown.
	ServerStatusUnknown ServerStatus = "unknown"
)

type ServerType

type ServerType struct {
	ID           int64
	Name         string
	Description  string
	Cores        int
	Memory       float32
	Disk         int
	StorageType  StorageType
	CPUType      CPUType
	Architecture Architecture
	// IncludedTraffic is the free traffic per month in bytes
	IncludedTraffic int64
	Pricings        []ServerTypeLocationPricing
	DeprecatableResource
}

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) AllWithOpts

func (c *ServerTypeClient) AllWithOpts(ctx context.Context, opts ServerTypeListOpts) ([]*ServerType, error)

AllWithOpts returns all server types for the given options.

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. If the server type does not exist, nil is returned.

func (*ServerTypeClient) GetByID

func (c *ServerTypeClient) GetByID(ctx context.Context, id int64) (*ServerType, *Response, error)

GetByID retrieves a server type by its ID. If the server type does not exist, nil is returned.

func (*ServerTypeClient) GetByName

func (c *ServerTypeClient) GetByName(ctx context.Context, name string) (*ServerType, *Response, error)

GetByName retrieves a server type by its name. If the server type does not exist, nil is returned.

func (*ServerTypeClient) List

List returns a list of server types for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

type ServerTypeListOpts

type ServerTypeListOpts struct {
	ListOpts
	Name string
	Sort []string
}

ServerTypeListOpts specifies options for listing server types.

type ServerTypeLocationPricing

type ServerTypeLocationPricing struct {
	Location *Location
	Hourly   Price
	Monthly  Price
}

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
	Labels map[string]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 StorageType = "ceph"
)

type TrafficPricing

type TrafficPricing struct {
	PerTB Price
}

TrafficPricing provides pricing information for traffic.

type Volume

type Volume struct {
	ID          int64
	Name        string
	Status      VolumeStatus
	Server      *Server
	Location    *Location
	Size        int
	Format      *string
	Protection  VolumeProtection
	Labels      map[string]string
	LinuxDevice string
	Created     time.Time
}

Volume represents a volume in the Hetzner Cloud.

func VolumeFromSchema

func VolumeFromSchema(s schema.Volume) *Volume

VolumeFromSchema converts a schema.Volume to a Volume.

type VolumeAttachOpts

type VolumeAttachOpts struct {
	Server    *Server
	Automount *bool
}

VolumeAttachOpts specifies options for attaching a volume.

type VolumeChangeProtectionOpts

type VolumeChangeProtectionOpts struct {
	Delete *bool
}

VolumeChangeProtectionOpts specifies options for changing the resource protection level of a volume.

type VolumeClient

type VolumeClient struct {
	Action *ResourceActionClient
	// contains filtered or unexported fields
}

VolumeClient is a client for the volume API.

func (*VolumeClient) All

func (c *VolumeClient) All(ctx context.Context) ([]*Volume, error)

All returns all volumes.

func (*VolumeClient) AllWithOpts

func (c *VolumeClient) AllWithOpts(ctx context.Context, opts VolumeListOpts) ([]*Volume, error)

AllWithOpts returns all volumes with the given options.

func (*VolumeClient) Attach

func (c *VolumeClient) Attach(ctx context.Context, volume *Volume, server *Server) (*Action, *Response, error)

Attach attaches a volume to a server.

func (*VolumeClient) AttachWithOpts

func (c *VolumeClient) AttachWithOpts(ctx context.Context, volume *Volume, opts VolumeAttachOpts) (*Action, *Response, error)

AttachWithOpts attaches a volume to a server.

func (*VolumeClient) ChangeProtection

func (c *VolumeClient) ChangeProtection(ctx context.Context, volume *Volume, opts VolumeChangeProtectionOpts) (*Action, *Response, error)

ChangeProtection changes the resource protection level of a volume.

func (*VolumeClient) Create

Create creates a new volume with the given options.

func (*VolumeClient) Delete

func (c *VolumeClient) Delete(ctx context.Context, volume *Volume) (*Response, error)

Delete deletes a volume.

func (*VolumeClient) Detach

func (c *VolumeClient) Detach(ctx context.Context, volume *Volume) (*Action, *Response, error)

Detach detaches a volume from a server.

func (*VolumeClient) Get

func (c *VolumeClient) Get(ctx context.Context, idOrName string) (*Volume, *Response, error)

Get retrieves a volume by its ID if the input can be parsed as an integer, otherwise it retrieves a volume by its name. If the volume does not exist, nil is returned.

func (*VolumeClient) GetByID

func (c *VolumeClient) GetByID(ctx context.Context, id int64) (*Volume, *Response, error)

GetByID retrieves a volume by its ID. If the volume does not exist, nil is returned.

func (*VolumeClient) GetByName

func (c *VolumeClient) GetByName(ctx context.Context, name string) (*Volume, *Response, error)

GetByName retrieves a volume by its name. If the volume does not exist, nil is returned.

func (*VolumeClient) List

func (c *VolumeClient) List(ctx context.Context, opts VolumeListOpts) ([]*Volume, *Response, error)

List returns a list of volumes for a specific page.

Please note that filters specified in opts are not taken into account when their value corresponds to their zero value or when they are empty.

func (*VolumeClient) Resize

func (c *VolumeClient) Resize(ctx context.Context, volume *Volume, size int) (*Action, *Response, error)

Resize changes the size of a volume.

func (*VolumeClient) Update

func (c *VolumeClient) Update(ctx context.Context, volume *Volume, opts VolumeUpdateOpts) (*Volume, *Response, error)

Update updates a volume.

type VolumeCreateOpts

type VolumeCreateOpts struct {
	Name      string
	Size      int
	Server    *Server
	Location  *Location
	Labels    map[string]string
	Automount *bool
	Format    *string
}

VolumeCreateOpts specifies parameters for creating a volume.

func (VolumeCreateOpts) Validate

func (o VolumeCreateOpts) Validate() error

Validate checks if options are valid.

type VolumeCreateResult

type VolumeCreateResult struct {
	Volume      *Volume
	Action      *Action
	NextActions []*Action
}

VolumeCreateResult is the result of creating a volume.

type VolumeListOpts

type VolumeListOpts struct {
	ListOpts
	Name   string
	Status []VolumeStatus
	Sort   []string
}

VolumeListOpts specifies options for listing volumes.

type VolumePricing

type VolumePricing struct {
	PerGBMonthly Price
}

VolumePricing provides pricing information for a Volume.

type VolumeProtection

type VolumeProtection struct {
	Delete bool
}

VolumeProtection represents the protection level of a volume.

type VolumeStatus

type VolumeStatus string

VolumeStatus specifies a volume's status.

const (
	// VolumeStatusCreating is the status when a volume is being created.
	VolumeStatusCreating VolumeStatus = "creating"

	// VolumeStatusAvailable is the status when a volume is available.
	VolumeStatusAvailable VolumeStatus = "available"
)

type VolumeUpdateOpts

type VolumeUpdateOpts struct {
	Name   string
	Labels map[string]string
}

VolumeUpdateOpts specifies options for updating a volume.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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