Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) AvailabilityZone() (string, error)deprecated
- func (c *Client) AvailabilityZoneWithContext(ctx context.Context) (string, error)
- func (c *Client) Hostname() (string, error)deprecated
- func (c *Client) HostnameWithContext(ctx context.Context) (string, error)
- func (c *Client) InstanceID() (int64, error)deprecated
- func (c *Client) InstanceIDWithContext(ctx context.Context) (int64, error)
- func (c *Client) IsHcloudServer() booldeprecated
- func (c *Client) IsHcloudServerWithContext(ctx context.Context) bool
- func (c *Client) PrivateNetworks() (string, error)deprecated
- func (c *Client) PrivateNetworksWithContext(ctx context.Context) (string, error)
- func (c *Client) PublicIPv4() (net.IP, error)deprecated
- func (c *Client) PublicIPv4WithContext(ctx context.Context) (net.IP, error)
- func (c *Client) Region() (string, error)deprecated
- func (c *Client) RegionWithContext(ctx context.Context) (string, error)
- type ClientOption
Constants ¶
const Endpoint = "http://169.254.169.254/hetzner/v1/metadata"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the Hetzner Cloud Server Metadata Endpoints.
func NewClient ¶
func NewClient(options ...ClientOption) *Client
NewClient creates a new Client with the options applied.
func (*Client) AvailabilityZone
deprecated
AvailabilityZone returns the datacenter of the server that did the request to the Metadata server.
Deprecated: Use Client.AvailabilityZoneWithContext instead so callers can control the request lifecycle.
func (*Client) AvailabilityZoneWithContext ¶ added in v2.41.0
AvailabilityZoneWithContext returns the datacenter of the server that did the request to the Metadata server.
func (*Client) Hostname
deprecated
Hostname returns the hostname of the server that did the request to the Metadata server.
Deprecated: Use Client.HostnameWithContext instead so callers can control the request lifecycle.
func (*Client) HostnameWithContext ¶ added in v2.41.0
HostnameWithContext returns the hostname of the server that did the request to the Metadata server.
func (*Client) InstanceID
deprecated
InstanceID returns the ID of the server that did the request to the Metadata server.
Deprecated: Use Client.InstanceIDWithContext instead so callers can control the request lifecycle.
func (*Client) InstanceIDWithContext ¶ added in v2.41.0
InstanceIDWithContext returns the ID of the server that did the request to the Metadata server.
func (*Client) IsHcloudServer
deprecated
IsHcloudServer checks if the currently called server is a hcloud server by calling a metadata endpoint if the endpoint answers with a non-empty value this method returns true, otherwise false.
Deprecated: Use Client.IsHcloudServerWithContext instead so callers can control the request lifecycle.
func (*Client) IsHcloudServerWithContext ¶ added in v2.41.0
IsHcloudServerWithContext checks if the currently called server is a hcloud server by calling a metadata endpoint. If the endpoint answers with a non-empty value this method returns true, otherwise false.
func (*Client) PrivateNetworks
deprecated
PrivateNetworks returns details about the private networks the server is attached to. Returns YAML (unparsed).
Deprecated: Use Client.PrivateNetworksWithContext instead so callers can control the request lifecycle.
func (*Client) PrivateNetworksWithContext ¶ added in v2.41.0
PrivateNetworksWithContext returns details about the private networks the server is attached to. Returns YAML (unparsed).
func (*Client) PublicIPv4
deprecated
PublicIPv4 returns the Public IPv4 of the server that did the request to the Metadata server.
Deprecated: Use Client.PublicIPv4WithContext instead so callers can control the request lifecycle.
func (*Client) PublicIPv4WithContext ¶ added in v2.41.0
PublicIPv4WithContext returns the Public IPv4 of the server that did the request to the Metadata server.
func (*Client) Region
deprecated
Region returns the Network Zone of the server that did the request to the Metadata server.
Deprecated: Use Client.RegionWithContext instead so callers can control the request lifecycle.
type ClientOption ¶
type ClientOption func(*Client)
A ClientOption is used to configure a Client.
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientOption
WithEndpoint configures a Client to use the specified Metadata 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 WithTimeout ¶ added in v2.1.0
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout specifies a time limit for requests made by this Client. Defaults to 5 seconds.