Giter VIP home page Giter VIP logo

hetzner-api-client's Introduction

hetzner-api-client Build status

A nodeJS client for the Hetzner Robot API

Please note: I am in no way affiliated with Hetzner Online GmbH. I am just a developer trying to ease his work with a flexible API client.

Installation

Install using NPM:

npm i --save hetzner-api-client

Usage

First off, create a new API client instance:

var APIClient = require('hetzner-api-client'),
    robot = new APIClient({
      username: '<your Robot username>',
      password: '<your Robot password>'
    });

The client is all ready now and you can start using its methods:

robot.queryReverseDns('123.123.123.123').then(
  response => console.log(response),
  error => console.error(error)
);

Sample response for a valid IP address:

{
  "rdns": {
    "ip": "123.123.123.123",
    "ptr": "sub.domain.tld"
  }
}

Sample response for an invalid IP address:

IP_NOT_FOUND: ip not found

Error messages are structured like so:

<ERROR_CODE>: <error message>

Oh. Did I mention the client is completely promise-based? It will always return a promise to your requests.

Custom server proxies

Say you own one or two servers and want to execute multiple methods on them. Kind of enervating to have to specify the server IP each time, isn't it? Therefore, you can (since 0.0.5) create a proxy:

var thanos = robot.registerServer('123.123.123.123');

// see? no additional IP parameter necessary.
thanos.queryReverseDns().then( /* ... */ )
thanos.updateReverseDns('new.pointer.record.tld').then( /* ... */ )

Current status

I'm still in the process of adding API methods. Currently, around 40% are implemented, some need a final naming scheme and if necessary, some more will be rewritten. So even if the current version works as is, you should not rely on this in production. Though of course you can speed this up by committing :)

A word on tests

To start the tests, simply use npm test.
Obviously many API methods are pretty destructive, so in order to be able to test everything thoroughly, I decided to implement a simple pseudo-Hetzner API webserver based on restify. You can find it in the test folder as apiServer.js. It starts on port 8080 and tries to behave as exactly as possible as the original Hetzner API. That way, I can test the client safely and you can test the scripts you'll use it for. This is a freaking load of additional work though, so I'd appreciate some help here.

API Documentation

Official API docs can be found here.

hetzner-api-client's People

Contributors

radiergummi avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

hetzner-api-client's Issues

Add object to permanently address one IP

Sometimes you just want to apply multiple commands to a single server, though you have to add the IP address to each command again and again.
Therefore an option should exist to create a new server object like this:

var robot = new Robot(config),
    myServer = robot.use('123.123.123.123');

myServer.robotMethodX().then(/* ... */);

Implement all tests

Currently, not all client methods are being tested in the tests. They should be, though.

Optional error parser

Error parsing should be an optional possibility, selectable via an options object. I'm thinking of something like this:

robot = new APIClient(config, {
  parseErrors: true
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.