Liking cljdoc? Tell your friends :D

hcloud.core

Hetzner Cloud API functions.

Auth Token

All calls to the Hetzner API must be authenticated. For that, you need an Authentication Token which you can generate online in your Hetzner Cloud Account. The token is a string and could look like this:

(def my-token "FOOBAR123")

Each function takes this token as its first argument. An example call to get-prices would look like this:

(get-prices my-token)

IDs

Furthermore, some functions take an id as an argument. The id is a string and refers to the resource which the API call is referring to (e.g., a server). An example call to get-server would look like this:

(get-server my-token "SERVER-ID-123")

Query Parameters

Some functions take query string parameters. These are appended to the API url, i.e. in the url https://api.hetzner.cloud/v1/servers?name=cx11, there is the query parameter name with the value of cx11.

In our functions, these query string parameters can be set in the query-m map. For example, the API call above is equivalent to this function call:

(get-servers my-token {:name "cx11"})

Pagination is also handled via the query parameters (and therefore the query-m map). Say we want to retrieve page 2 of our servers:

(get-servers my-token {:page 2})

An important note on kebab-case

Note that these are converted from kebab-cased keywords to snake-cased strings. So if the Hetzner API would be expecting a query parameter called "foo_bar", we would set it by providing {:foo-bar "some-value"} in our map. Dashes are converted to underscores.

This is also true for the replies from the Hetzner API, this time the other way round: The keys are snake-cased strings and will be converted to kebab-cased keywords. So if the reply json has a key "time_series", you'll find it in a Clojure map under the value :time-series.

Body Parameters

Some functions take (json) body parameters. In our functions, these can be set in the body-m map. Let's say we want to create a server with the name "HAL", this is how we would do it:

(create-server my-token {:name "HAL"})

Note that keywords will be converted from kebab-case to snake-case again, so if you would also want to set the start_after_create value, you would do this:

(create-server my-token {:name               "HAL"
                         :start-after-create true})

Metadata of public functions

Public functions in this namespace have two keys in their metadata: :api-category and :order. These are used to auto-generate docs in the README (check dev/readme.clj). The idea is to have the documentation of the functions in the same order as in the Hetzner docs. Therefore :api-category refers to the endpoint (and the title of the section in the docs) and :order is the position at which it appears in the docs.

If you didn't understand any of this, don't worry. As long as you understand the README, you're fine!

Hetzner Cloud API functions.

## Auth Token

All calls to the Hetzner API must be authenticated. For that, you
need an Authentication Token which you can generate online in your
Hetzner Cloud Account. The token is a string and could look like
this:

```
(def my-token "FOOBAR123")
```

Each function takes this token as its first argument. An example
call to `get-prices` would look like this:

```
(get-prices my-token)
```

## IDs

Furthermore, some functions take an `id` as an argument. The `id` is
a string and refers to the resource which the API call is referring
to (e.g., a server). An example call to `get-server` would look like
this:

```
(get-server my-token "SERVER-ID-123")
```

## Query Parameters

Some functions take query string parameters. These are appended to
the API url, i.e. in the url
`https://api.hetzner.cloud/v1/servers?name=cx11`, there is the query
parameter `name` with the value of `cx11`.

In our functions, these query string parameters can be set in the
`query-m` map. For example, the API call above is equivalent to this
function call:

```
(get-servers my-token {:name "cx11"})
```

Pagination is also handled via the query parameters (and therefore
the `query-m` map). Say we want to retrieve page 2 of our servers:

```
(get-servers my-token {:page 2})
```

### An important note on kebab-case

Note that these are converted from kebab-cased keywords to
snake-cased strings. So if the Hetzner API would be expecting a
query parameter called "foo_bar", we would set it by providing
`{:foo-bar "some-value"}` in our map. Dashes are converted to
underscores.

This is also true for the replies from the Hetzner API, this time
the other way round: The keys are snake-cased strings and will be
converted to kebab-cased keywords. So if the reply json has a key
"time_series", you'll find it in a Clojure map under the value
`:time-series`.

## Body Parameters

Some functions take (json) body parameters. In our functions, these
can be set in the `body-m` map. Let's say we want to create a server
with the name "HAL", this is how we would do it:

```
(create-server my-token {:name "HAL"})
```

Note that keywords will be converted from kebab-case to snake-case
again, so if you would also want to set the `start_after_create`
value, you would do this:

```
(create-server my-token {:name               "HAL"
                         :start-after-create true})
```

## Metadata of public functions

Public functions in this namespace have two keys in their metadata:
`:api-category` and `:order`. These are used to auto-generate docs
in the README (check `dev/readme.clj`). The idea is to have the
documentation of the functions in the same order as in the [Hetzner
docs](https://docs.hetzner.cloud). Therefore `:api-category` refers
to the endpoint (and the title of the section in the docs) and
`:order` is the position at which it appears in the docs.

If you didn't understand any of this, don't worry. As long as you
understand the README, you're fine!
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close