summaryrefslogtreecommitdiffstats
path: root/ansible_collections/hetzner/hcloud/plugins/module_utils
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:18:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:18:34 +0000
commit3667197efb7b18ec842efd504785965911f8ac4b (patch)
tree0b986a4bc6879d080b100666a97cdabbc9ca1f28 /ansible_collections/hetzner/hcloud/plugins/module_utils
parentAdding upstream version 9.5.1+dfsg. (diff)
downloadansible-3667197efb7b18ec842efd504785965911f8ac4b.tar.xz
ansible-3667197efb7b18ec842efd504785965911f8ac4b.zip
Adding upstream version 10.0.0+dfsg.upstream/10.0.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/hetzner/hcloud/plugins/module_utils')
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/hcloud.py27
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/_version.py2
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/domain.py18
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/firewalls/domain.py4
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/floating_ips/domain.py4
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/client.py22
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/load_balancers/domain.py12
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/networks/domain.py4
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/placement_groups/domain.py4
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/primary_ips/domain.py4
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/domain.py4
-rw-r--r--ansible_collections/hetzner/hcloud/plugins/module_utils/version.py2
12 files changed, 84 insertions, 23 deletions
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/hcloud.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/hcloud.py
index eab0aef59..60391308a 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/hcloud.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/hcloud.py
@@ -10,6 +10,10 @@ from typing import Any, NoReturn
from ansible.module_utils.basic import AnsibleModule as AnsibleModuleBase, env_fallback
from ansible.module_utils.common.text.converters import to_native
+from ansible.module_utils.common.validation import (
+ check_missing_parameters,
+ check_required_one_of,
+)
from .client import ClientException, client_check_required_lib, client_get_by_name_or_id
from .vendor.hcloud import APIException, Client, HCloudException
@@ -94,6 +98,29 @@ class AnsibleHCloud:
def _mark_as_changed(self) -> None:
self.result["changed"] = True
+ def fail_on_invalid_params(
+ self,
+ *,
+ required: list[str] | None = None,
+ required_one_of: list[list[str]] | None = None,
+ ) -> None:
+ """
+ Run additional validation that cannot be done in the argument spec validation.
+
+ :param required_params: Check that terms exists in the module params.
+ :param required_one_of: Check each list of terms to ensure at least one exists in the module parameters.
+ """
+ try:
+ if required:
+ check_missing_parameters(self.module.params, required)
+
+ if required_one_of:
+ params_without_nones = {k: v for k, v in self.module.params.items() if v is not None}
+ check_required_one_of(required_one_of, params_without_nones)
+
+ except TypeError as e:
+ self.module.fail_json(msg=to_native(e))
+
@classmethod
def base_module_arguments(cls):
return {
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/_version.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/_version.py
index e03c1b434..d350d7138 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/_version.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/_version.py
@@ -1,3 +1,3 @@
from __future__ import annotations
-VERSION = "1.33.2" # x-release-please-version
+VERSION = "1.35.0" # x-release-please-version
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/domain.py
index 692f7488b..bba954fe2 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/core/domain.py
@@ -34,6 +34,24 @@ class DomainIdentityMixin:
return self.name
raise ValueError("id or name must be set")
+ def has_id_or_name(self, id_or_name: int | str) -> bool:
+ """
+ Return whether this domain has the same id or same name as the other.
+
+ The domain calling this method MUST be a bound domain or be populated, otherwise
+ the comparison will not work as expected (e.g. the domains are the same but
+ cannot be equal, if one provides an id and the other the name).
+ """
+ values: list[int | str] = []
+ if self.id is not None:
+ values.append(self.id)
+ if self.name is not None:
+ values.append(self.name)
+ if not values:
+ raise ValueError("id or name must be set")
+
+ return id_or_name in values
+
class Pagination(BaseDomain):
__slots__ = (
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/firewalls/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/firewalls/domain.py
index 5ce9281d9..d637231d6 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/firewalls/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/firewalls/domain.py
@@ -7,7 +7,7 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
from .client import BoundFirewall
-class Firewall(BaseDomain):
+class Firewall(BaseDomain, DomainIdentityMixin):
"""Firewall Domain
:param id: int
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/floating_ips/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/floating_ips/domain.py
index e1f295bd6..abd2c13cc 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/floating_ips/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/floating_ips/domain.py
@@ -7,7 +7,7 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
from .client import BoundFloatingIP
-class FloatingIP(BaseDomain):
+class FloatingIP(BaseDomain, DomainIdentityMixin):
"""Floating IP Domain
:param id: int
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/client.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/client.py
index 65b7546a8..a7d41e01b 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/client.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/images/client.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import warnings
from typing import TYPE_CHECKING, Any, NamedTuple
from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
@@ -305,18 +306,27 @@ class ImagesClient(ClientEntityBase):
def get_by_name(self, name: str) -> BoundImage | None:
"""Get image by name
- Deprecated: Use get_by_name_and_architecture instead.
-
:param name: str
Used to get image by name.
:return: :class:`BoundImage <hcloud.images.client.BoundImage>`
+
+ .. deprecated:: 1.19
+ Use :func:`hcloud.images.client.ImagesClient.get_by_name_and_architecture` instead.
"""
+ warnings.warn(
+ "The 'hcloud.images.client.ImagesClient.get_by_name' method is deprecated, please use the "
+ "'hcloud.images.client.ImagesClient.get_by_name_and_architecture' method instead.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
return self._get_first_by(name=name)
def get_by_name_and_architecture(
self,
name: str,
architecture: str,
+ *,
+ include_deprecated: bool | None = None,
) -> BoundImage | None:
"""Get image by name
@@ -324,9 +334,15 @@ class ImagesClient(ClientEntityBase):
Used to identify the image.
:param architecture: str
Used to identify the image.
+ :param include_deprecated: bool (optional)
+ Include deprecated images. Default: False
:return: :class:`BoundImage <hcloud.images.client.BoundImage>`
"""
- return self._get_first_by(name=name, architecture=[architecture])
+ return self._get_first_by(
+ name=name,
+ architecture=[architecture],
+ include_deprecated=include_deprecated,
+ )
def update(
self,
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/load_balancers/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/load_balancers/domain.py
index 6d6f0700a..76e8db3f7 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/load_balancers/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/load_balancers/domain.py
@@ -7,7 +7,7 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
from .client import BoundLoadBalancer
-class LoadBalancer(BaseDomain):
+class LoadBalancer(BaseDomain, DomainIdentityMixin):
"""LoadBalancer Domain
:param id: int
@@ -79,7 +79,7 @@ class LoadBalancer(BaseDomain):
id: int,
name: str | None = None,
public_net: PublicNetwork | None = None,
- private_net: PrivateNet | None = None,
+ private_net: list[PrivateNet] | None = None,
location: BoundLocation | None = None,
algorithm: LoadBalancerAlgorithm | None = None,
services: list[LoadBalancerService] | None = None,
@@ -203,9 +203,9 @@ class LoadBalancerService(BaseDomain):
if self.health_check.http.response is not None:
health_check_http["response"] = self.health_check.http.response
if self.health_check.http.status_codes is not None:
- health_check_http[
- "status_codes"
- ] = self.health_check.http.status_codes
+ health_check_http["status_codes"] = (
+ self.health_check.http.status_codes
+ )
if self.health_check.http.tls is not None:
health_check_http["tls"] = self.health_check.http.tls
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/networks/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/networks/domain.py
index c307bf989..e04de2775 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/networks/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/networks/domain.py
@@ -7,7 +7,7 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
from .client import BoundNetwork
-class Network(BaseDomain):
+class Network(BaseDomain, DomainIdentityMixin):
"""Network Domain
:param id: int
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/placement_groups/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/placement_groups/domain.py
index 16b2a390d..1c6fc04cd 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/placement_groups/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/placement_groups/domain.py
@@ -7,14 +7,14 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
from .client import BoundPlacementGroup
-class PlacementGroup(BaseDomain):
+class PlacementGroup(BaseDomain, DomainIdentityMixin):
"""Placement Group Domain
:param id: int
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/primary_ips/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/primary_ips/domain.py
index aeb943f0a..2eebacef4 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/primary_ips/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/primary_ips/domain.py
@@ -7,7 +7,7 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
from .client import BoundPrimaryIP
-class PrimaryIP(BaseDomain):
+class PrimaryIP(BaseDomain, DomainIdentityMixin):
"""Primary IP Domain
:param id: int
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/domain.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/domain.py
index 0a0d34688..d5e769e5e 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/domain.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/vendor/hcloud/servers/domain.py
@@ -7,7 +7,7 @@ try:
except ImportError:
isoparse = None
-from ..core import BaseDomain
+from ..core import BaseDomain, DomainIdentityMixin
if TYPE_CHECKING:
from ..actions import BoundAction
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
from .client import BoundServer
-class Server(BaseDomain):
+class Server(BaseDomain, DomainIdentityMixin):
"""Server Domain
:param id: int
diff --git a/ansible_collections/hetzner/hcloud/plugins/module_utils/version.py b/ansible_collections/hetzner/hcloud/plugins/module_utils/version.py
index e78c320a2..0bf903564 100644
--- a/ansible_collections/hetzner/hcloud/plugins/module_utils/version.py
+++ b/ansible_collections/hetzner/hcloud/plugins/module_utils/version.py
@@ -1,3 +1,3 @@
from __future__ import annotations
-version = "2.5.0" # x-release-please-version
+version = "3.1.1" # x-release-please-version