| 1 |
Metadata-Version: 2.4 |
| 2 |
Name: hcloud |
| 3 |
Version: 2.17.0 |
| 4 |
Summary: Official Hetzner Cloud python library |
| 5 |
Home-page: https://github.com/hetznercloud/hcloud-python |
| 6 |
Author: Hetzner Cloud GmbH |
| 7 |
Author-email: [email protected] |
| 8 |
License: MIT |
| 9 |
Project-URL: Bug Tracker, https://github.com/hetznercloud/hcloud-python/issues |
| 10 |
Project-URL: Documentation, https://hcloud-python.readthedocs.io/en/stable/ |
| 11 |
Project-URL: Changelog, https://github.com/hetznercloud/hcloud-python/blob/main/CHANGELOG.md |
| 12 |
Project-URL: Source Code, https://github.com/hetznercloud/hcloud-python |
| 13 |
Keywords: hcloud hetzner cloud |
| 14 |
Classifier: Development Status :: 5 - Production/Stable |
| 15 |
Classifier: Intended Audience :: Developers |
| 16 |
Classifier: Natural Language :: English |
| 17 |
Classifier: Programming Language :: Python :: 3 |
| 18 |
Classifier: Programming Language :: Python :: 3.10 |
| 19 |
Classifier: Programming Language :: Python :: 3.11 |
| 20 |
Classifier: Programming Language :: Python :: 3.12 |
| 21 |
Classifier: Programming Language :: Python :: 3.13 |
| 22 |
Classifier: Programming Language :: Python :: 3.14 |
| 23 |
Requires-Python: >=3.10 |
| 24 |
Description-Content-Type: text/markdown |
| 25 |
License-File: LICENSE |
| 26 |
Requires-Dist: python-dateutil>=2.7.5 |
| 27 |
Requires-Dist: requests>=2.20 |
| 28 |
Provides-Extra: docs |
| 29 |
Requires-Dist: sphinx<9.2,>=9; extra == "docs" |
| 30 |
Requires-Dist: sphinx-rtd-theme<3.2,>=3; extra == "docs" |
| 31 |
Requires-Dist: myst-parser<5.1,>=5; extra == "docs" |
| 32 |
Requires-Dist: watchdog<6.1,>=6; extra == "docs" |
| 33 |
Provides-Extra: test |
| 34 |
Requires-Dist: coverage<7.14,>=7.13; extra == "test" |
| 35 |
Requires-Dist: pylint<4.1,>=4; extra == "test" |
| 36 |
Requires-Dist: pytest<9.1,>=9; extra == "test" |
| 37 |
Requires-Dist: pytest-cov<7.1,>=7; extra == "test" |
| 38 |
Requires-Dist: mypy<1.20,>=1.19; extra == "test" |
| 39 |
Requires-Dist: types-python-dateutil; extra == "test" |
| 40 |
Requires-Dist: types-requests; extra == "test" |
| 41 |
Dynamic: author |
| 42 |
Dynamic: author-email |
| 43 |
Dynamic: classifier |
| 44 |
Dynamic: description |
| 45 |
Dynamic: description-content-type |
| 46 |
Dynamic: home-page |
| 47 |
Dynamic: keywords |
| 48 |
Dynamic: license |
| 49 |
Dynamic: license-file |
| 50 |
Dynamic: project-url |
| 51 |
Dynamic: provides-extra |
| 52 |
Dynamic: requires-dist |
| 53 |
Dynamic: requires-python |
| 54 |
Dynamic: summary |
| 55 |
|
| 56 |
# Hetzner Cloud Python |
| 57 |
|
| 58 |
[](https://github.com/hetznercloud/hcloud-python/actions/workflows/test.yml) |
| 59 |
[](https://github.com/hetznercloud/hcloud-python/actions/workflows/lint.yml) |
| 60 |
[](https://codecov.io/github/hetznercloud/hcloud-python/tree/main) |
| 61 |
[](https://hcloud-python.readthedocs.io/en/stable/) |
| 62 |
[](https://pypi.org/project/hcloud/) |
| 63 |
|
| 64 |
Official Hetzner Cloud python library. |
| 65 |
|
| 66 |
The library's documentation is available at [hcloud-python.readthedocs.io](https://hcloud-python.readthedocs.io/en/stable/), the public API documentation is available at [docs.hetzner.cloud](https://docs.hetzner.cloud). |
| 67 |
|
| 68 |
> [!IMPORTANT] |
| 69 |
> Make sure to follow our API changelog available at |
| 70 |
> [docs.hetzner.cloud/changelog](https://docs.hetzner.cloud/changelog) (or the RSS feed |
| 71 |
> available at |
| 72 |
> [docs.hetzner.cloud/changelog/feed.rss](https://docs.hetzner.cloud/changelog/feed.rss)) |
| 73 |
> to be notified about additions, deprecations and removals. |
| 74 |
|
| 75 |
## Usage |
| 76 |
|
| 77 |
Install the `hcloud` library: |
| 78 |
|
| 79 |
```sh |
| 80 |
pip install hcloud |
| 81 |
``` |
| 82 |
|
| 83 |
For more installation details, please see the [installation docs](https://hcloud-python.readthedocs.io/en/stable/installation.html). |
| 84 |
|
| 85 |
Here is an example that creates a server and list them: |
| 86 |
|
| 87 |
```python |
| 88 |
from hcloud import Client |
| 89 |
from hcloud.images import Image |
| 90 |
from hcloud.server_types import ServerType |
| 91 |
|
| 92 |
client = Client( |
| 93 |
token="{YOUR_API_TOKEN}", # Please paste your API token here |
| 94 |
application_name="my-app", |
| 95 |
application_version="v1.0.0", |
| 96 |
) |
| 97 |
|
| 98 |
# Create a server named my-server |
| 99 |
response = client.servers.create( |
| 100 |
name="my-server", |
| 101 |
server_type=ServerType(name="cx23"), |
| 102 |
image=Image(name="ubuntu-22.04"), |
| 103 |
) |
| 104 |
server = response.server |
| 105 |
print(f"{server.id=} {server.name=} {server.status=}") |
| 106 |
print(f"root password: {response.root_password}") |
| 107 |
|
| 108 |
# List your servers |
| 109 |
servers = client.servers.get_all() |
| 110 |
for server in servers: |
| 111 |
print(f"{server.id=} {server.name=} {server.status=}") |
| 112 |
``` |
| 113 |
|
| 114 |
- To upgrade the package, please read the [instructions available in the documentation](https://hcloud-python.readthedocs.io/en/stable/upgrading.html). |
| 115 |
- For more details on the API, please see the [API reference](https://hcloud-python.readthedocs.io/en/stable/api.html). |
| 116 |
- You can find some more examples under the [`examples/`](https://github.com/hetznercloud/hcloud-python/tree/main/examples) directory. |
| 117 |
|
| 118 |
## Supported Python versions |
| 119 |
|
| 120 |
We support python versions until [`end-of-life`](https://devguide.python.org/versions/#status-of-python-versions). |
| 121 |
|
| 122 |
## Experimental features |
| 123 |
|
| 124 |
Experimental features are published as part of our regular releases (e.g. a product |
| 125 |
public beta). During an experimental phase, breaking changes on those features may occur |
| 126 |
within minor releases. |
| 127 |
|
| 128 |
The stability of experimental features is not related to the stability of its upstream API. |
| 129 |
|
| 130 |
Experimental features have different levels of maturity (e.g. experimental, alpha, beta) |
| 131 |
based on the maturity of the upstream API. |
| 132 |
|
| 133 |
While experimental features will be announced in the release notes, you can also find |
| 134 |
whether a python class or function is experimental in its docstring: |
| 135 |
|
| 136 |
``` |
| 137 |
Experimental: |
| 138 |
$PRODUCT is $MATURITY, breaking changes may occur within minor releases. |
| 139 |
See https://docs.hetzner.cloud/changelog#$SLUG for more details. |
| 140 |
``` |
| 141 |
|
| 142 |
## Development |
| 143 |
|
| 144 |
First, create a virtual environment and activate it: |
| 145 |
|
| 146 |
```sh |
| 147 |
make venv |
| 148 |
source venv/bin/activate |
| 149 |
``` |
| 150 |
|
| 151 |
You may setup [`pre-commit`](https://pre-commit.com/) to run before you commit changes, this removes the need to run it manually afterwards: |
| 152 |
|
| 153 |
```sh |
| 154 |
pre-commit install |
| 155 |
``` |
| 156 |
|
| 157 |
You can then run different tasks defined in the `Makefile`, below are the most important ones: |
| 158 |
|
| 159 |
Build the documentation and open it in your browser: |
| 160 |
|
| 161 |
```sh |
| 162 |
make docs |
| 163 |
``` |
| 164 |
|
| 165 |
Lint the code: |
| 166 |
|
| 167 |
```sh |
| 168 |
make lint |
| 169 |
``` |
| 170 |
|
| 171 |
Run tests using the current `python3` version: |
| 172 |
|
| 173 |
```sh |
| 174 |
make test |
| 175 |
``` |
| 176 |
|
| 177 |
You may also run the tests for multiple `python3` versions using `tox`: |
| 178 |
|
| 179 |
```sh |
| 180 |
tox . |
| 181 |
``` |
| 182 |
|
| 183 |
### Deprecations implementation |
| 184 |
|
| 185 |
When deprecating a module or a function, you must: |
| 186 |
|
| 187 |
- Update the docstring with a `deprecated` notice: |
| 188 |
|
| 189 |
```py |
| 190 |
"""Get image by name |
| 191 |
|
| 192 |
.. deprecated:: 1.19 |
| 193 |
Use :func:`hcloud.images.client.ImagesClient.get_by_name_and_architecture` instead. |
| 194 |
""" |
| 195 |
``` |
| 196 |
|
| 197 |
- Raise a warning when the deprecated module or function is being used: |
| 198 |
|
| 199 |
```py |
| 200 |
warnings.warn( |
| 201 |
"The 'hcloud.images.client.ImagesClient.get_by_name' method is deprecated, please use the " |
| 202 |
"'hcloud.images.client.ImagesClient.get_by_name_and_architecture' method instead.", |
| 203 |
DeprecationWarning, |
| 204 |
stacklevel=2, |
| 205 |
) |
| 206 |
``` |
| 207 |
|
| 208 |
### Releasing experimental features |
| 209 |
|
| 210 |
To publish experimental features as part of regular releases: |
| 211 |
|
| 212 |
- an announcement, including a link to a changelog entry, must be added to the release notes. |
| 213 |
- an `Experimental` notice, including a link to a changelog entry, must be added to the python classes and functions that are experimental: |
| 214 |
|
| 215 |
```py |
| 216 |
""" |
| 217 |
Experimental: |
| 218 |
$PRODUCT is $MATURITY, breaking changes may occur within minor releases. |
| 219 |
See https://docs.hetzner.cloud/changelog#$SLUG for more details. |
| 220 |
""" |
| 221 |
``` |
| 222 |
|
| 223 |
## License |
| 224 |
|
| 225 |
The MIT License (MIT). Please see [`License File`](https://github.com/hetznercloud/hcloud-python/blob/main/LICENSE) for more information. |