1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

chore(deps): update dependency hcloud to v2.6.0 (#686)

This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [hcloud](https://redirect.github.com/hetznercloud/hcloud-python)
([changelog](https://redirect.github.com/hetznercloud/hcloud-python/blob/main/CHANGELOG.md))
| `2.5.4` -> `2.6.0` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/hcloud/2.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/hcloud/2.5.4/2.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>hetznercloud/hcloud-python (hcloud)</summary>

###
[`v2.6.0`](https://redirect.github.com/hetznercloud/hcloud-python/blob/HEAD/CHANGELOG.md#v260)

[Compare
Source](https://redirect.github.com/hetznercloud/hcloud-python/compare/v2.5.4...v2.6.0)

##### Features

- add category property to server type
([#&#8203;549](https://redirect.github.com/hetznercloud/hcloud-python/issues/549))

##### Bug Fixes

- rename `ClientEntityBase` to `ResourceClientBase`
([#&#8203;532](https://redirect.github.com/hetznercloud/hcloud-python/issues/532))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/ansible-collections/hetzner.hcloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45MS4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTEuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
This commit is contained in:
renovate[bot] 2025-09-08 12:44:47 +02:00 committed by GitHub
parent f2983603af
commit 923057c7b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 451 additions and 411 deletions

View file

@ -81,6 +81,25 @@ def exponential_backoff_function(
return func
def _build_user_agent(
application_name: str | None,
application_version: str | None,
) -> str:
"""Build the user agent of the hcloud-python instance with the user application name (if specified)
:return: The user agent of this hcloud-python instance
"""
parts = []
for name, version in [
(application_name, application_version),
("hcloud-python", __version__),
]:
if name is not None:
parts.append(name if version is None else f"{name}/{version}")
return " ".join(parts)
class Client:
"""
Client for the Hetzner Cloud API.
@ -115,14 +134,6 @@ class Client:
breaking changes.
"""
_version = __version__
__user_agent_prefix = "hcloud-python"
_retry_interval = staticmethod(
exponential_backoff_function(base=1.0, multiplier=2, cap=60.0, jitter=True)
)
_retry_max_retries = 5
def __init__(
self,
token: str,
@ -146,18 +157,15 @@ class Client:
Max retries before timeout when polling actions from the API.
:param timeout: Requests timeout in seconds
"""
self.token = token
self._api_endpoint = api_endpoint
self._application_name = application_name
self._application_version = application_version
self._requests_session = requests.Session()
self._requests_timeout = timeout
if isinstance(poll_interval, (int, float)):
self._poll_interval_func = constant_backoff_function(poll_interval)
else:
self._poll_interval_func = poll_interval
self._poll_max_retries = poll_max_retries
self._client = ClientBase(
token=token,
endpoint=api_endpoint,
application_name=application_name,
application_version=application_version,
poll_interval=poll_interval,
poll_max_retries=poll_max_retries,
timeout=timeout,
)
self.datacenters = DatacentersClient(self)
"""DatacentersClient Instance
@ -249,27 +257,58 @@ class Client:
:type: :class:`PlacementGroupsClient <hcloud.placement_groups.client.PlacementGroupsClient>`
"""
def _get_user_agent(self) -> str:
"""Get the user agent of the hcloud-python instance with the user application name (if specified)
def request( # type: ignore[no-untyped-def]
self,
method: str,
url: str,
**kwargs,
) -> dict:
"""Perform a request to the Hetzner Cloud API.
:return: The user agent of this hcloud-python instance
:param method: Method to perform the request.
:param url: URL to perform the request.
:param timeout: Requests timeout in seconds.
"""
user_agents = []
for name, version in [
(self._application_name, self._application_version),
(self.__user_agent_prefix, self._version),
]:
if name is not None:
user_agents.append(name if version is None else f"{name}/{version}")
return self._client.request(method, url, **kwargs)
return " ".join(user_agents)
def _get_headers(self) -> dict:
headers = {
"User-Agent": self._get_user_agent(),
"Authorization": f"Bearer {self.token}",
class ClientBase:
def __init__(
self,
token: str,
*,
endpoint: str,
application_name: str | None = None,
application_version: str | None = None,
poll_interval: int | float | BackoffFunction = 1.0,
poll_max_retries: int = 120,
timeout: float | tuple[float, float] | None = None,
):
self._token = token
self._endpoint = endpoint
self._user_agent = _build_user_agent(application_name, application_version)
self._headers = {
"User-Agent": self._user_agent,
"Authorization": f"Bearer {self._token}",
"Accept": "application/json",
}
return headers
if isinstance(poll_interval, (int, float)):
poll_interval_func = constant_backoff_function(poll_interval)
else:
poll_interval_func = poll_interval
self._poll_interval_func = poll_interval_func
self._poll_max_retries = poll_max_retries
self._retry_interval_func = exponential_backoff_function(
base=1.0, multiplier=2, cap=60.0, jitter=True
)
self._retry_max_retries = 5
self._timeout = timeout
self._session = requests.Session()
def request( # type: ignore[no-untyped-def]
self,
@ -277,22 +316,22 @@ class Client:
url: str,
**kwargs,
) -> dict:
"""Perform a request to the Hetzner Cloud API, wrapper around requests.request
"""Perform a request to the provided URL.
:param method: HTTP Method to perform the Request
:param url: URL of the Endpoint
:param timeout: Requests timeout in seconds
:param method: Method to perform the request.
:param url: URL to perform the request.
:param timeout: Requests timeout in seconds.
:return: Response
"""
kwargs.setdefault("timeout", self._requests_timeout)
kwargs.setdefault("timeout", self._timeout)
url = self._api_endpoint + url
headers = self._get_headers()
url = self._endpoint + url
headers = self._headers
retries = 0
while True:
try:
response = self._requests_session.request(
response = self._session.request(
method=method,
url=url,
headers=headers,
@ -301,13 +340,13 @@ class Client:
return self._read_response(response)
except APIException as exception:
if retries < self._retry_max_retries and self._retry_policy(exception):
time.sleep(self._retry_interval(retries))
time.sleep(self._retry_interval_func(retries))
retries += 1
continue
raise
except requests.exceptions.Timeout:
if retries < self._retry_max_retries:
time.sleep(self._retry_interval(retries))
time.sleep(self._retry_interval_func(retries))
retries += 1
continue
raise