hetzner

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SSHKeyURL defines the SSH key API endpoint.
	SSHKeyURL = "https://robot-ws.your-server.de/key"
)
View Source
const (
	// ServerURL defines the server API endpoint.
	ServerURL = "https://robot-ws.your-server.de/server"
)
View Source
const (
	// StorageboxURL defines the storagebox API endpoint.
	StorageboxURL = "https://robot-ws.your-server.de/storagebox"
)

Variables

View Source
var (
	// UserAgent defines the used user ganet for request.
	UserAgent = fmt.Sprintf("hetzner_export/%s", version.String)
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Server     ServerClient
	SSHKey     SSHKeyClient
	Storagebox StorageboxClient
	// contains filtered or unexported fields
}

Client is a client for the DockerHub API.

func NewClient

func NewClient(options ...ClientOption) *Client

NewClient creates a new client.

func (*Client) Do

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

Do performs an HTTP request against the DockerHub.

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 DockerHub.

type ClientOption

type ClientOption func(*Client)

A ClientOption is used to configure a Client.

func WithHTTPClient

func WithHTTPClient(value *http.Client) ClientOption

WithHTTPClient configures a Client to use the specified HTTP client.

func WithHTTPDumper

func WithHTTPDumper(value Dumper) ClientOption

WithHTTPDumper configures a Client to use the specified debug dumper.

func WithPassword

func WithPassword(value string) ClientOption

WithPassword configures a Client to use the specified password for authentication.

func WithUsername

func WithUsername(value string) ClientOption

WithUsername configures a Client to use the specified username for authentication.

type Dumper

type Dumper interface {
	DumpRequest(*http.Request)
	DumpResponse(*http.Response)
}

Dumper dumps the http.Request and http.Response message payload for debugging.

func DiscardDumper

func DiscardDumper() Dumper

DiscardDumper returns a no-op dumper.

func StandardDumper

func StandardDumper(body bool) Dumper

StandardDumper returns a standard dumper.

type Response

type Response struct {
	*http.Response
}

Response simply wraps the standard response type.

type SSHKey

type SSHKey struct {
	Name        string
	Type        string
	Size        string
	Fingerprint string
}

SSHKey represents a SSH key record prepared for the exporter.

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 fetches all available SSH keys from API.

type Server

type Server struct {
	Number     string
	Name       string
	Type       string
	Datacenter string
	Status     float64
	Traffic    float64
	Flatrate   float64
	Cancelled  float64
	Paid       float64
}

Server represents a server record prepared for the exporter.

type ServerClient

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

ServerClient is a client for the servers API.

func (*ServerClient) All

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

All fetches all available servers from API.

type Storagebox

type Storagebox struct {
	Number    string
	Name      string
	Type      string
	Location  string
	Login     string
	Cancelled float64
	Locked    float64
	Paid      float64
	Quota     float64
	Usage     float64
	Data      float64
	Snapshots float64
	Webdav    float64
	ZFS       float64
	Samba     float64
	SSH       float64
	External  float64
}

Storagebox represents a storagebox record prepared for the exporter.

type StorageboxClient

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

StorageboxClient is a client for the storageboxes API.

func (*StorageboxClient) All

func (c *StorageboxClient) All(ctx context.Context) ([]*Storagebox, error)

All fetches all available storageboxes from API.

func (*StorageboxClient) Get

func (c *StorageboxClient) Get(ctx context.Context, number string) (*Storagebox, error)

Get fetches a specific storagebox from API.

Jump to

Keyboard shortcuts

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