Skip to content

Commit

Permalink
deps: update dependency hcloud to v1.33.0 (#430)
Browse files Browse the repository at this point in the history
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [hcloud](https://togithub.com/hetznercloud/hcloud-python)
([changelog](https://togithub.com/hetznercloud/hcloud-python/blob/main/CHANGELOG.md))
| `1.32.0` -> `1.33.0` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/hcloud/1.33.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/hcloud/1.33.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/hcloud/1.32.0/1.33.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/hcloud/1.32.0/1.33.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

###
[`v1.33.0`](https://togithub.com/hetznercloud/hcloud-python/blob/HEAD/CHANGELOG.md#1330-2023-12-19)

[Compare
Source](https://togithub.com/hetznercloud/hcloud-python/compare/v1.32.0...v1.33.0)

##### Features

- add metrics endpoint for load balancers and servers
([#&#8203;331](https://togithub.com/hetznercloud/hcloud-python/issues/331))
([ee3c54f](https://togithub.com/hetznercloud/hcloud-python/commit/ee3c54fd1b6963533bc9d1e1f9ff57f6c5872cd5))

##### Bug Fixes

- fallback to error code when message is unset
([#&#8203;328](https://togithub.com/hetznercloud/hcloud-python/issues/328))
([1c94153](https://togithub.com/hetznercloud/hcloud-python/commit/1c94153d93acd567548604b08b5fabeabd8d33d9))

##### Dependencies

- update actions/setup-python action to v5
([#&#8203;335](https://togithub.com/hetznercloud/hcloud-python/issues/335))
([2ac252d](https://togithub.com/hetznercloud/hcloud-python/commit/2ac252d18ba6079d5372c6ab9e3f67b4740db465))
- update dependency sphinx-rtd-theme to v2
([#&#8203;330](https://togithub.com/hetznercloud/hcloud-python/issues/330))
([7cc4335](https://togithub.com/hetznercloud/hcloud-python/commit/7cc4335cacab6073cf39a0ecbecf8890903d5bca))
- update pre-commit hook psf/black-pre-commit-mirror to v23.12.0
([#&#8203;338](https://togithub.com/hetznercloud/hcloud-python/issues/338))
([38e4748](https://togithub.com/hetznercloud/hcloud-python/commit/38e4748d3d194d37ea3d0c63683609f5db432e0d))
- update pre-commit hook pycqa/isort to v5.13.0
([#&#8203;336](https://togithub.com/hetznercloud/hcloud-python/issues/336))
([3244cfe](https://togithub.com/hetznercloud/hcloud-python/commit/3244cfef2f90ef52d0fb791d514d6afe481aa4d7))
- update pre-commit hook pycqa/isort to v5.13.1
([#&#8203;337](https://togithub.com/hetznercloud/hcloud-python/issues/337))
([020a0ef](https://togithub.com/hetznercloud/hcloud-python/commit/020a0eff6bc2b63d16b339fd5d4c3ea3610c0509))
- update pre-commit hook pycqa/isort to v5.13.2
([#&#8203;339](https://togithub.com/hetznercloud/hcloud-python/issues/339))
([b46df8c](https://togithub.com/hetznercloud/hcloud-python/commit/b46df8cbb263945c59ce4408e0a7189d19d9c597))

</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 has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ansible-collections/hetzner.hcloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <ljonas@riseup.net>
  • Loading branch information
renovate[bot] and jooola committed Dec 19, 2023
1 parent 1e6e3a0 commit b7beb09
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 6 deletions.
4 changes: 2 additions & 2 deletions plugins/module_utils/vendor/hcloud/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class HCloudException(Exception):
class APIException(HCloudException):
"""There was an error while performing an API Request"""

def __init__(self, code: int | str, message: str, details: Any):
super().__init__(message)
def __init__(self, code: int | str, message: str | None, details: Any):
super().__init__(code if message is None and isinstance(code, str) else message)
self.code = code
self.message = message
self.details = details
2 changes: 1 addition & 1 deletion plugins/module_utils/vendor/hcloud/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import annotations

VERSION = "1.32.0" # x-release-please-version
VERSION = "1.33.0" # x-release-please-version
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)
from .domain import ( # noqa: F401
CreateLoadBalancerResponse,
GetMetricsResponse,
IPv4Address,
IPv6Network,
LoadBalancer,
Expand Down
71 changes: 71 additions & 0 deletions plugins/module_utils/vendor/hcloud/load_balancers/client.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
from __future__ import annotations

from datetime import datetime
from typing import TYPE_CHECKING, Any, NamedTuple

try:
from dateutil.parser import isoparse
except ImportError:
isoparse = None

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..certificates import BoundCertificate
from ..core import BoundModelBase, ClientEntityBase, Meta
from ..load_balancer_types import BoundLoadBalancerType
from ..locations import BoundLocation
from ..metrics import Metrics
from ..networks import BoundNetwork
from ..servers import BoundServer
from .domain import (
CreateLoadBalancerResponse,
GetMetricsResponse,
IPv4Address,
IPv6Network,
LoadBalancer,
Expand All @@ -23,6 +31,7 @@
LoadBalancerTargetHealthStatus,
LoadBalancerTargetIP,
LoadBalancerTargetLabelSelector,
MetricsType,
PrivateNet,
PublicNetwork,
)
Expand Down Expand Up @@ -177,6 +186,28 @@ def delete(self) -> bool:
"""
return self._client.delete(self)

def get_metrics(
self,
type: MetricsType,
start: datetime | str,
end: datetime | str,
step: float | None = None,
) -> GetMetricsResponse:
"""Get Metrics for a LoadBalancer.
:param type: Type of metrics to get.
:param start: Start of period to get Metrics for (in ISO-8601 format).
:param end: End of period to get Metrics for (in ISO-8601 format).
:param step: Resolution of results in seconds.
"""
return self._client.get_metrics(
self,
type=type,
start=start,
end=end,
step=step,
)

def get_actions_list(
self,
status: list[str] | None = None,
Expand Down Expand Up @@ -533,6 +564,46 @@ def delete(self, load_balancer: LoadBalancer | BoundLoadBalancer) -> bool:
)
return True

def get_metrics(
self,
load_balancer: LoadBalancer | BoundLoadBalancer,
type: MetricsType | list[MetricsType],
start: datetime | str,
end: datetime | str,
step: float | None = None,
) -> GetMetricsResponse:
"""Get Metrics for a LoadBalancer.
:param load_balancer: The Load Balancer to get the metrics for.
:param type: Type of metrics to get.
:param start: Start of period to get Metrics for (in ISO-8601 format).
:param end: End of period to get Metrics for (in ISO-8601 format).
:param step: Resolution of results in seconds.
"""
if not isinstance(type, list):
type = [type]
if isinstance(start, str):
start = isoparse(start)
if isinstance(end, str):
end = isoparse(end)

params: dict[str, Any] = {
"type": ",".join(type),
"start": start.isoformat(),
"end": end.isoformat(),
}
if step is not None:
params["step"] = step

response = self._client.request(
url=f"/load_balancers/{load_balancer.id}/metrics",
method="GET",
params=params,
)
return GetMetricsResponse(
metrics=Metrics(**response["metrics"]),
)

def get_actions_list(
self,
load_balancer: LoadBalancer | BoundLoadBalancer,
Expand Down
26 changes: 25 additions & 1 deletion plugins/module_utils/vendor/hcloud/load_balancers/domain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Literal

try:
from dateutil.parser import isoparse
Expand All @@ -14,6 +14,7 @@
from ..certificates import BoundCertificate
from ..load_balancer_types import BoundLoadBalancerType
from ..locations import BoundLocation
from ..metrics import Metrics
from ..networks import BoundNetwork
from ..servers import BoundServer
from .client import BoundLoadBalancer
Expand Down Expand Up @@ -511,3 +512,26 @@ def __init__(
):
self.load_balancer = load_balancer
self.action = action


MetricsType = Literal[
"open_connections",
"connections_per_second",
"requests_per_second",
"bandwidth",
]


class GetMetricsResponse(BaseDomain):
"""Get a Load Balancer Metrics Response Domain
:param metrics: The Load Balancer metrics
"""

__slots__ = ("metrics",)

def __init__(
self,
metrics: Metrics,
):
self.metrics = metrics
3 changes: 3 additions & 0 deletions plugins/module_utils/vendor/hcloud/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from __future__ import annotations

from .domain import Metrics, TimeSeries # noqa: F401
49 changes: 49 additions & 0 deletions plugins/module_utils/vendor/hcloud/metrics/domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from __future__ import annotations

from datetime import datetime
from typing import Dict, List, Literal, Tuple

try:
from dateutil.parser import isoparse
except ImportError:
isoparse = None

from ..core import BaseDomain

TimeSeries = Dict[str, Dict[Literal["values"], List[Tuple[float, str]]]]


class Metrics(BaseDomain):
"""Metrics Domain
:param start: Start of period of metrics reported.
:param end: End of period of metrics reported.
:param step: Resolution of results in seconds.
:param time_series: Dict with time series data, using the name of the time series as
key. The metrics timestamps and values are stored in a list of tuples
``[(timestamp, value), ...]``.
"""

start: datetime
end: datetime
step: float
time_series: TimeSeries

__slots__ = (
"start",
"end",
"step",
"time_series",
)

def __init__(
self,
start: str,
end: str,
step: float,
time_series: TimeSeries,
):
self.start = isoparse(start)
self.end = isoparse(end)
self.step = step
self.time_series = time_series
1 change: 1 addition & 0 deletions plugins/module_utils/vendor/hcloud/servers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .domain import ( # noqa: F401
CreateServerResponse,
EnableRescueResponse,
GetMetricsResponse,
IPv4Address,
IPv6Network,
PrivateNet,
Expand Down
72 changes: 72 additions & 0 deletions plugins/module_utils/vendor/hcloud/servers/client.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
from __future__ import annotations

import warnings
from datetime import datetime
from typing import TYPE_CHECKING, Any, NamedTuple

try:
from dateutil.parser import isoparse
except ImportError:
isoparse = None

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BoundModelBase, ClientEntityBase, Meta
from ..datacenters import BoundDatacenter
from ..firewalls import BoundFirewall
from ..floating_ips import BoundFloatingIP
from ..images import BoundImage, CreateImageResponse
from ..isos import BoundIso
from ..metrics import Metrics
from ..placement_groups import BoundPlacementGroup
from ..primary_ips import BoundPrimaryIP
from ..server_types import BoundServerType
from ..volumes import BoundVolume
from .domain import (
CreateServerResponse,
EnableRescueResponse,
GetMetricsResponse,
IPv4Address,
IPv6Network,
MetricsType,
PrivateNet,
PublicNetwork,
PublicNetworkFirewall,
Expand Down Expand Up @@ -210,6 +219,29 @@ def update(
"""
return self._client.update(self, name, labels)

def get_metrics(
self,
type: MetricsType | list[MetricsType],
start: datetime | str,
end: datetime | str,
step: float | None = None,
) -> GetMetricsResponse:
"""Get Metrics for a Server.
:param server: The Server to get the metrics for.
:param type: Type of metrics to get.
:param start: Start of period to get Metrics for (in ISO-8601 format).
:param end: End of period to get Metrics for (in ISO-8601 format).
:param step: Resolution of results in seconds.
"""
return self._client.get_metrics(
self,
type=type,
start=start,
end=end,
step=step,
)

def delete(self) -> BoundAction:
"""Deletes a server. This immediately removes the server from your account, and it is no longer accessible.
Expand Down Expand Up @@ -742,6 +774,46 @@ def update(
)
return BoundServer(self, response["server"])

def get_metrics(
self,
server: Server | BoundServer,
type: MetricsType | list[MetricsType],
start: datetime | str,
end: datetime | str,
step: float | None = None,
) -> GetMetricsResponse:
"""Get Metrics for a Server.
:param server: The Server to get the metrics for.
:param type: Type of metrics to get.
:param start: Start of period to get Metrics for (in ISO-8601 format).
:param end: End of period to get Metrics for (in ISO-8601 format).
:param step: Resolution of results in seconds.
"""
if not isinstance(type, list):
type = [type]
if isinstance(start, str):
start = isoparse(start)
if isinstance(end, str):
end = isoparse(end)

params: dict[str, Any] = {
"type": ",".join(type),
"start": start.isoformat(),
"end": end.isoformat(),
}
if step is not None:
params["step"] = step

response = self._client.request(
url=f"/servers/{server.id}/metrics",
method="GET",
params=params,
)
return GetMetricsResponse(
metrics=Metrics(**response["metrics"]),
)

def delete(self, server: Server | BoundServer) -> BoundAction:
"""Deletes a server. This immediately removes the server from your account, and it is no longer accessible.
Expand Down
25 changes: 24 additions & 1 deletion plugins/module_utils/vendor/hcloud/servers/domain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Literal

try:
from dateutil.parser import isoparse
Expand All @@ -16,6 +16,7 @@
from ..floating_ips import BoundFloatingIP
from ..images import BoundImage
from ..isos import BoundIso
from ..metrics import Metrics
from ..networks import BoundNetwork
from ..placement_groups import BoundPlacementGroup
from ..primary_ips import BoundPrimaryIP, PrimaryIP
Expand Down Expand Up @@ -430,3 +431,25 @@ def __init__(
self.ipv6 = ipv6
self.enable_ipv4 = enable_ipv4
self.enable_ipv6 = enable_ipv6


MetricsType = Literal[
"cpu",
"disk",
"network",
]


class GetMetricsResponse(BaseDomain):
"""Get a Server Metrics Response Domain
:param metrics: The Server metrics
"""

__slots__ = ("metrics",)

def __init__(
self,
metrics: Metrics,
):
self.metrics = metrics
2 changes: 1 addition & 1 deletion scripts/vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
logger = logging.getLogger("vendor")

HCLOUD_SOURCE_URL = "https://github.com/hetznercloud/hcloud-python"
HCLOUD_VERSION = "v1.32.0"
HCLOUD_VERSION = "v1.33.0"
HCLOUD_VENDOR_PATH = "plugins/module_utils/vendor/hcloud"


Expand Down

0 comments on commit b7beb09

Please sign in to comment.