Skip to content

Commit

Permalink
deps: update dependency hcloud to v1.29.0 (#334)
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.28.0` -> `1.29.0` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/hcloud/1.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/hcloud/1.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/hcloud/1.28.0/1.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/hcloud/1.28.0/1.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

###
[`v1.29.0`](https://togithub.com/hetznercloud/hcloud-python/blob/HEAD/CHANGELOG.md#1290-2023-09-25)

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

##### Features

- add domain attribute type hints to bound models
([#&#8203;300](https://togithub.com/hetznercloud/hcloud-python/issues/300))
([6d46d06](https://togithub.com/hetznercloud/hcloud-python/commit/6d46d06c42e2e86e88b32a74d7fbd588911cc8ad))
- **firewalls:** add `applied_to_resources` to `FirewallResource`
([#&#8203;297](https://togithub.com/hetznercloud/hcloud-python/issues/297))
([55d2b20](https://togithub.com/hetznercloud/hcloud-python/commit/55d2b2043ec1e3a040eb9e360ca0dc0c299ad60f))

##### Bug Fixes

- missing BaseDomain base class inheritance
([#&#8203;303](https://togithub.com/hetznercloud/hcloud-python/issues/303))
([0ee7598](https://togithub.com/hetznercloud/hcloud-python/commit/0ee759856cb1352f6cc538b7ef86a91cd20380f2))

##### Dependencies

- update actions/checkout action to v4
([#&#8203;295](https://togithub.com/hetznercloud/hcloud-python/issues/295))
([c02b446](https://togithub.com/hetznercloud/hcloud-python/commit/c02b4468f0e499791bbee8fe48fe7a737985df1f))
- update dependency sphinx to >=7.2.2,<7.3
([#&#8203;291](https://togithub.com/hetznercloud/hcloud-python/issues/291))
([10234ea](https://togithub.com/hetznercloud/hcloud-python/commit/10234ea7bf51a427b18f2b5605d9ffa7ac5f5ee8))
- update dependency sphinx to v7
([#&#8203;211](https://togithub.com/hetznercloud/hcloud-python/issues/211))
([f635c94](https://togithub.com/hetznercloud/hcloud-python/commit/f635c94c23b8ae49283b9b7fcb4fe7b948b203b9))
- update pre-commit hook asottile/pyupgrade to v3.11.0
([#&#8203;298](https://togithub.com/hetznercloud/hcloud-python/issues/298))
([4bbd0cc](https://togithub.com/hetznercloud/hcloud-python/commit/4bbd0ccb0f606e2f90f8242951d3f4d9b86d7aea))
- update pre-commit hook asottile/pyupgrade to v3.11.1
([#&#8203;299](https://togithub.com/hetznercloud/hcloud-python/issues/299))
([2f9fcd7](https://togithub.com/hetznercloud/hcloud-python/commit/2f9fcd7bb80efb8da6eafab0ee70a8dda93eb6f1))
- update pre-commit hook asottile/pyupgrade to v3.13.0
([#&#8203;301](https://togithub.com/hetznercloud/hcloud-python/issues/301))
([951dbf3](https://togithub.com/hetznercloud/hcloud-python/commit/951dbf3e3b3816ffaeb44a583251a5a3a4b90b70))
- update pre-commit hook pre-commit/mirrors-prettier to v3.0.3
([#&#8203;294](https://togithub.com/hetznercloud/hcloud-python/issues/294))
([381e336](https://togithub.com/hetznercloud/hcloud-python/commit/381e336ff1259fa26cb6abae3b7341cb16229a4b))
- update pre-commit hook psf/black to v23.9.1
([#&#8203;296](https://togithub.com/hetznercloud/hcloud-python/issues/296))
([4374a7b](https://togithub.com/hetznercloud/hcloud-python/commit/4374a7be9f244a72f1fc0c2dd76357cf63f19bfd))

##### Documentation

- load token from env in examples scripts
([#&#8203;302](https://togithub.com/hetznercloud/hcloud-python/issues/302))
([f18c9a6](https://togithub.com/hetznercloud/hcloud-python/commit/f18c9a60e045743b26892eeb1fe9e5737a63c11f))

</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:eyJjcmVhdGVkSW5WZXIiOiIzNi45Ny4xIiwidXBkYXRlZEluVmVyIjoiMzYuOTcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: jo <[email protected]>
  • Loading branch information
renovate[bot] and jooola authored Sep 25, 2023
1 parent 5767219 commit 4ae557c
Show file tree
Hide file tree
Showing 30 changed files with 136 additions and 47 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/vendor/hcloud/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
poll_interval: int = 1,
timeout: float | tuple[float, float] | None = None,
):
"""Create an new Client instance
"""Create a new Client instance
:param token: Hetzner Cloud API token
:param api_endpoint: Hetzner Cloud API endpoint
Expand Down
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.28.0" # x-release-please-version
VERSION = "1.29.0" # x-release-please-version
3 changes: 2 additions & 1 deletion plugins/module_utils/vendor/hcloud/actions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .._client import Client


class BoundAction(BoundModelBase):
class BoundAction(BoundModelBase, Action):
_client: ActionsClient

model = Action
Expand All @@ -27,6 +27,7 @@ def wait_until_finished(self, max_retries: int = 100) -> None:
while self.status == Action.STATUS_RUNNING:
if max_retries > 0:
self.reload()
# pylint: disable=protected-access
time.sleep(self._client._client.poll_interval)
max_retries = max_retries - 1
else:
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/vendor/hcloud/certificates/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .._client import Client


class BoundCertificate(BoundModelBase):
class BoundCertificate(BoundModelBase, Certificate):
_client: CertificatesClient

model = Certificate
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/vendor/hcloud/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def _iter_pages( # type: ignore[no-untyped-def]

def _get_first_by(self, **kwargs): # type: ignore[no-untyped-def]
assert hasattr(self, "get_list")
# pylint: disable=no-member
entities, _ = self.get_list(**kwargs)
return entities[0] if entities else None

Expand Down
14 changes: 11 additions & 3 deletions plugins/module_utils/vendor/hcloud/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class BaseDomain:

@classmethod
def from_dict(cls, data: dict): # type: ignore[no-untyped-def]
"""
Build the domain object from the data dict.
"""
supported_data = {k: v for k, v in data.items() if k in cls.__slots__}
return cls(**supported_data)

Expand All @@ -22,12 +25,14 @@ class DomainIdentityMixin:

@property
def id_or_name(self) -> int | str:
"""
Return the first defined value, and fails if none is defined.
"""
if self.id is not None:
return self.id
elif self.name is not None:
if self.name is not None:
return self.name
else:
raise ValueError("id or name must be set")
raise ValueError("id or name must be set")


class Pagination(BaseDomain):
Expand Down Expand Up @@ -65,6 +70,9 @@ def __init__(self, pagination: Pagination | None = None):

@classmethod
def parse_meta(cls, response: dict) -> Meta | None:
"""
If present, extract the meta details from the response and return a meta object.
"""
meta = None
if response and "meta" in response:
meta = cls()
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/vendor/hcloud/datacenters/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .._client import Client


class BoundDatacenter(BoundModelBase):
class BoundDatacenter(BoundModelBase, Datacenter):
_client: DatacentersClient

model = Datacenter
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/vendor/hcloud/datacenters/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
self.server_types = server_types


class DatacenterServerTypes:
class DatacenterServerTypes(BaseDomain):
"""DatacenterServerTypes Domain
:param available: List[:class:`BoundServerTypes <hcloud.server_types.client.BoundServerTypes>`]
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/vendor/hcloud/firewalls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
CreateFirewallResponse,
Firewall,
FirewallResource,
FirewallResourceAppliedToResources,
FirewallResourceLabelSelector,
FirewallRule,
)
49 changes: 37 additions & 12 deletions plugins/module_utils/vendor/hcloud/firewalls/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
CreateFirewallResponse,
Firewall,
FirewallResource,
FirewallResourceAppliedToResources,
FirewallResourceLabelSelector,
FirewallRule,
)
Expand All @@ -16,7 +17,7 @@
from .._client import Client


class BoundFirewall(BoundModelBase):
class BoundFirewall(BoundModelBase, Firewall):
_client: FirewallsClient

model = Firewall
Expand All @@ -39,29 +40,53 @@ def __init__(self, client: FirewallsClient, data: dict, complete: bool = True):

applied_to = data.get("applied_to", [])
if applied_to:
# pylint: disable=import-outside-toplevel
from ..servers import BoundServer

ats = []
for a in applied_to:
if a["type"] == FirewallResource.TYPE_SERVER:
ats.append(
data_applied_to = []
for firewall_resource in applied_to:
applied_to_resources = None
if firewall_resource.get("applied_to_resources"):
applied_to_resources = [
FirewallResourceAppliedToResources(
type=resource["type"],
server=(
BoundServer(
client._client.servers,
resource.get("server"),
complete=False,
)
if resource.get("server") is not None
else None
),
)
for resource in firewall_resource.get("applied_to_resources")
]

if firewall_resource["type"] == FirewallResource.TYPE_SERVER:
data_applied_to.append(
FirewallResource(
type=a["type"],
type=firewall_resource["type"],
server=BoundServer(
client._client.servers, a["server"], complete=False
client._client.servers,
firewall_resource["server"],
complete=False,
),
applied_to_resources=applied_to_resources,
)
)
elif a["type"] == FirewallResource.TYPE_LABEL_SELECTOR:
ats.append(
elif firewall_resource["type"] == FirewallResource.TYPE_LABEL_SELECTOR:
data_applied_to.append(
FirewallResource(
type=a["type"],
type=firewall_resource["type"],
label_selector=FirewallResourceLabelSelector(
selector=a["label_selector"]["selector"]
selector=firewall_resource["label_selector"]["selector"]
),
applied_to_resources=applied_to_resources,
)
)
data["applied_to"] = ats

data["applied_to"] = data_applied_to

super().__init__(client, data, complete)

Expand Down
34 changes: 31 additions & 3 deletions plugins/module_utils/vendor/hcloud/firewalls/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
self.created = isoparse(created) if created else None


class FirewallRule:
class FirewallRule(BaseDomain):
"""Firewall Rule Domain
:param direction: str
Expand Down Expand Up @@ -111,6 +111,9 @@ def __init__(
self.description = description

def to_payload(self) -> dict[str, Any]:
"""
Generates the request payload from this domain object.
"""
payload: dict[str, Any] = {
"direction": self.direction,
"protocol": self.protocol,
Expand All @@ -125,7 +128,7 @@ def to_payload(self) -> dict[str, Any]:
return payload


class FirewallResource:
class FirewallResource(BaseDomain):
"""Firewall Used By Domain
:param type: str
Expand All @@ -134,9 +137,11 @@ class FirewallResource:
Server the Firewall is applied to
:param label_selector: Optional[FirewallResourceLabelSelector]
Label Selector for Servers the Firewall should be applied to
:param applied_to_resources: (read-only) List of effective resources the firewall is
applied to.
"""

__slots__ = ("type", "server", "label_selector")
__slots__ = ("type", "server", "label_selector", "applied_to_resources")

TYPE_SERVER = "server"
"""Firewall Used By Type Server"""
Expand All @@ -148,12 +153,17 @@ def __init__(
type: str,
server: Server | BoundServer | None = None,
label_selector: FirewallResourceLabelSelector | None = None,
applied_to_resources: list[FirewallResourceAppliedToResources] | None = None,
):
self.type = type
self.server = server
self.label_selector = label_selector
self.applied_to_resources = applied_to_resources

def to_payload(self) -> dict[str, Any]:
"""
Generates the request payload from this domain object.
"""
payload: dict[str, Any] = {"type": self.type}
if self.server is not None:
payload["server"] = {"id": self.server.id}
Expand All @@ -163,6 +173,24 @@ def to_payload(self) -> dict[str, Any]:
return payload


class FirewallResourceAppliedToResources(BaseDomain):
"""Firewall Resource applied to Domain
:param type: Type of resource referenced
:param server: Server the Firewall is applied to
"""

__slots__ = ("type", "server")

def __init__(
self,
type: str,
server: BoundServer | None = None,
):
self.type = type
self.server = server


class FirewallResourceLabelSelector(BaseDomain):
"""FirewallResourceLabelSelector Domain
Expand Down
3 changes: 2 additions & 1 deletion plugins/module_utils/vendor/hcloud/floating_ips/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
from ..servers import BoundServer, Server


class BoundFloatingIP(BoundModelBase):
class BoundFloatingIP(BoundModelBase, FloatingIP):
_client: FloatingIPsClient

model = FloatingIP

def __init__(self, client: FloatingIPsClient, data: dict, complete: bool = True):
# pylint: disable=import-outside-toplevel
from ..servers import BoundServer

server = data.get("server")
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/vendor/hcloud/hcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
stacklevel=2,
)

# pylint: disable=wildcard-import,wrong-import-position,unused-wildcard-import
from ._client import * # noqa
22 changes: 14 additions & 8 deletions plugins/module_utils/vendor/hcloud/helpers/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def validate(labels: dict[str, str]) -> bool:
:return: bool
"""
for k, v in labels.items():
if LabelValidator.KEY_REGEX.match(k) is None:
for key, value in labels.items():
if LabelValidator.KEY_REGEX.match(key) is None:
return False
if LabelValidator.VALUE_REGEX.match(v) is None:
if LabelValidator.VALUE_REGEX.match(value) is None:
return False
return True

Expand All @@ -32,9 +32,15 @@ def validate_verbose(labels: dict[str, str]) -> tuple[bool, str]:
:return: bool, str
"""
for k, v in labels.items():
if LabelValidator.KEY_REGEX.match(k) is None:
return False, f"label key {k} is not correctly formatted"
if LabelValidator.VALUE_REGEX.match(v) is None:
return False, f"label value {v} (key: {k}) is not correctly formatted"
for key, value in labels.items():
if LabelValidator.KEY_REGEX.match(key) is None:
return (
False,
f"label key {key} is not correctly formatted",
)
if LabelValidator.VALUE_REGEX.match(value) is None:
return (
False,
f"label value {value} (key: {key}) is not correctly formatted",
)
return True, ""
3 changes: 2 additions & 1 deletion plugins/module_utils/vendor/hcloud/images/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
from .._client import Client


class BoundImage(BoundModelBase):
class BoundImage(BoundModelBase, Image):
_client: ImagesClient

model = Image

def __init__(self, client: ImagesClient, data: dict):
# pylint: disable=import-outside-toplevel
from ..servers import BoundServer

created_from = data.get("created_from")
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/vendor/hcloud/images/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Image(BaseDomain, DomainIdentityMixin):
"deprecated",
)

# pylint: disable=too-many-locals
def __init__(
self,
id: int | None = None,
Expand Down
2 changes: 1 addition & 1 deletion plugins/module_utils/vendor/hcloud/isos/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .._client import Client


class BoundIso(BoundModelBase):
class BoundIso(BoundModelBase, Iso):
_client: IsosClient

model = Iso
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .._client import Client


class BoundLoadBalancerType(BoundModelBase):
class BoundLoadBalancerType(BoundModelBase, LoadBalancerType):
_client: LoadBalancerTypesClient

model = LoadBalancerType
Expand Down
3 changes: 2 additions & 1 deletion plugins/module_utils/vendor/hcloud/load_balancers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
from ..networks import Network


class BoundLoadBalancer(BoundModelBase):
class BoundLoadBalancer(BoundModelBase, LoadBalancer):
_client: LoadBalancersClient

model = LoadBalancer

# pylint: disable=too-many-branches,too-many-locals
def __init__(self, client: LoadBalancersClient, data: dict, complete: bool = True):
algorithm = data.get("algorithm")
if algorithm:
Expand Down
Loading

0 comments on commit 4ae557c

Please sign in to comment.