client

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 8 Imported by: 3

README

hrobot-go: A Go library for the Hetzner Robot Webservice

Package hrobot-go is a library for the Hetzner Robot Webservice.

The library’s documentation is available at GoDoc, the public API documentation is available at robot.your-server.de.

Infos about fork

This fork is based on the repo of nl2go. The original repo implemented the important parts of Hetzner Robot API, but has not been updated since 2019. This work has the goal to keep up with API changes on Hetzner side and to implement additional functions that Hetzner Robot offers.

Contributions and feature requests are very welcome!

Example

package main

import (
    "fmt"
    "log"

    client "github.com/syself/hrobot-go"
)

func main() {
    robotClient := client.NewBasicAuthClient("user", "pass")

    servers, err := robotClient.ServerGetList()
    if err != nil {
        log.Fatalf("error while retrieving server list: %s\n", err)
    }

    fmt.Println(servers)
}

If you want to add instrumentation (for example to debug why you hit rate-limits of the Hetzner API) you can use NewBasicAuthClientWithCustomHttpClient() to use your own httpClient.

Releasing

Update version number in client.go

make test

export RELEASE_TAG=vX.Y.Z

git tag -a ${RELEASE_TAG} -m ${RELEASE_TAG}

git push origin $RELEASE_TAG

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Username string
	Password string
	// contains filtered or unexported fields
}

func (*Client) BootLinuxDelete added in v0.2.0

func (c *Client) BootLinuxDelete(id int) (*models.Linux, error)

func (*Client) BootLinuxGet added in v0.2.0

func (c *Client) BootLinuxGet(id int) (*models.Linux, error)

func (*Client) BootLinuxSet added in v0.2.0

func (c *Client) BootLinuxSet(id int, input *models.LinuxSetInput) (*models.Linux, error)

func (*Client) BootRescueDelete added in v0.2.0

func (c *Client) BootRescueDelete(id int) (*models.Rescue, error)

func (*Client) BootRescueGet

func (c *Client) BootRescueGet(id int) (*models.Rescue, error)

func (*Client) BootRescueSet

func (c *Client) BootRescueSet(id int, input *models.RescueSetInput) (*models.Rescue, error)

func (*Client) FailoverGet

func (c *Client) FailoverGet(ip string) (*models.Failover, error)

func (*Client) FailoverGetList

func (c *Client) FailoverGetList() ([]models.Failover, error)

func (*Client) GetVersion

func (c *Client) GetVersion() string

func (*Client) IPGetList

func (c *Client) IPGetList() ([]models.IP, error)

func (*Client) KeyGetList

func (c *Client) KeyGetList() ([]models.Key, error)

func (*Client) KeySet added in v0.2.0

func (c *Client) KeySet(input *models.KeySetInput) (*models.Key, error)

func (*Client) RDnsGet

func (c *Client) RDnsGet(ip string) (*models.Rdns, error)

func (*Client) RDnsGetList

func (c *Client) RDnsGetList() ([]models.Rdns, error)

func (*Client) ResetGet

func (c *Client) ResetGet(id int) (*models.Reset, error)

func (*Client) ResetSet

func (c *Client) ResetSet(id int, input *models.ResetSetInput) (*models.ResetPost, error)

func (*Client) ServerGet

func (c *Client) ServerGet(id int) (*models.Server, error)

func (*Client) ServerGetList

func (c *Client) ServerGetList() ([]models.Server, error)

func (*Client) ServerReverse

func (c *Client) ServerReverse(id int) (*models.Cancellation, error)

func (*Client) ServerSetName

func (c *Client) ServerSetName(id int, input *models.ServerSetNameInput) (*models.Server, error)

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string)

func (*Client) SetCredentials added in v0.2.6

func (c *Client) SetCredentials(username, password string) error

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(userAgent string)

func (*Client) ValidateCredentials added in v0.2.4

func (c *Client) ValidateCredentials() error

type RobotClient

type RobotClient interface {
	SetBaseURL(baseURL string)
	SetUserAgent(userAgent string)
	GetVersion() string
	SetCredentials(username, password string) error
	ValidateCredentials() error

	ServerGetList() ([]models.Server, error)
	ServerGet(id int) (*models.Server, error)
	ServerSetName(id int, input *models.ServerSetNameInput) (*models.Server, error)
	ServerReverse(id int) (*models.Cancellation, error)
	KeyGetList() ([]models.Key, error)
	KeySet(input *models.KeySetInput) (*models.Key, error)
	IPGetList() ([]models.IP, error)
	RDnsGetList() ([]models.Rdns, error)
	RDnsGet(ip string) (*models.Rdns, error)
	BootLinuxGet(id int) (*models.Linux, error)
	BootLinuxDelete(id int) (*models.Linux, error)
	BootLinuxSet(id int, input *models.LinuxSetInput) (*models.Linux, error)
	BootRescueGet(id int) (*models.Rescue, error)
	BootRescueDelete(id int) (*models.Rescue, error)
	BootRescueSet(id int, input *models.RescueSetInput) (*models.Rescue, error)
	ResetGet(id int) (*models.Reset, error)
	ResetSet(id int, input *models.ResetSetInput) (*models.ResetPost, error)
	FailoverGetList() ([]models.Failover, error)
	FailoverGet(ip string) (*models.Failover, error)
}

func NewBasicAuthClient

func NewBasicAuthClient(username, password string) RobotClient

func NewBasicAuthClientWithCustomHttpClient added in v0.2.5

func NewBasicAuthClientWithCustomHttpClient(username, password string, httpClient *http.Client) RobotClient

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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