From 253e245b254a7621d1b2c8448d9a437300fcf8e8 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 8 Aug 2023 17:39:48 +0200 Subject: [PATCH 1/8] test: improve existing actions tests --- tests/unit/actions/test_client.py | 2 ++ tests/unit/certificates/test_client.py | 2 ++ tests/unit/firewalls/test_client.py | 2 ++ tests/unit/floating_ips/test_client.py | 1 + tests/unit/images/test_client.py | 2 ++ tests/unit/load_balancers/test_client.py | 2 ++ tests/unit/networks/test_client.py | 1 + tests/unit/servers/test_client.py | 8 ++++++++ tests/unit/volumes/test_client.py | 1 + 9 files changed, 21 insertions(+) diff --git a/tests/unit/actions/test_client.py b/tests/unit/actions/test_client.py index 16a79618..9df0c1b3 100644 --- a/tests/unit/actions/test_client.py +++ b/tests/unit/actions/test_client.py @@ -30,6 +30,8 @@ def test_wait_until_finished( ): mocked_requests.request.side_effect = [running_action, successfully_action] bound_running_action.wait_until_finished() + mocked_requests.request.assert_called_with(url="/actions/2", method="GET") + assert bound_running_action.status == "success" assert mocked_requests.request.call_count == 2 diff --git a/tests/unit/certificates/test_client.py b/tests/unit/certificates/test_client.py index a039f3b5..d245108d 100644 --- a/tests/unit/certificates/test_client.py +++ b/tests/unit/certificates/test_client.py @@ -33,6 +33,7 @@ def test_get_actions_list( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "change_protection" @@ -48,6 +49,7 @@ def test_get_actions(self, hetzner_client, bound_certificate, response_get_actio assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "change_protection" diff --git a/tests/unit/firewalls/test_client.py b/tests/unit/firewalls/test_client.py index fdf1d116..14fe291d 100644 --- a/tests/unit/firewalls/test_client.py +++ b/tests/unit/firewalls/test_client.py @@ -88,6 +88,7 @@ def test_get_actions_list( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "set_firewall_rules" @@ -106,6 +107,7 @@ def test_get_actions( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "set_firewall_rules" diff --git a/tests/unit/floating_ips/test_client.py b/tests/unit/floating_ips/test_client.py index 36eaf7ca..d3308084 100644 --- a/tests/unit/floating_ips/test_client.py +++ b/tests/unit/floating_ips/test_client.py @@ -52,6 +52,7 @@ def test_get_actions(self, hetzner_client, bound_floating_ip, response_get_actio assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "assign_floating_ip" diff --git a/tests/unit/images/test_client.py b/tests/unit/images/test_client.py index 876fbfe4..debbd8f9 100644 --- a/tests/unit/images/test_client.py +++ b/tests/unit/images/test_client.py @@ -63,6 +63,7 @@ def test_get_actions_list( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "change_protection" @@ -81,6 +82,7 @@ def test_get_actions( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "change_protection" diff --git a/tests/unit/load_balancers/test_client.py b/tests/unit/load_balancers/test_client.py index c8702046..f0f343f6 100644 --- a/tests/unit/load_balancers/test_client.py +++ b/tests/unit/load_balancers/test_client.py @@ -50,6 +50,7 @@ def test_get_actions_list( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "change_protection" @@ -68,6 +69,7 @@ def test_get_actions( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "change_protection" diff --git a/tests/unit/networks/test_client.py b/tests/unit/networks/test_client.py index 68855fd1..3db775b0 100644 --- a/tests/unit/networks/test_client.py +++ b/tests/unit/networks/test_client.py @@ -60,6 +60,7 @@ def test_get_actions(self, hetzner_client, bound_network, response_get_actions): assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "add_subnet" diff --git a/tests/unit/servers/test_client.py b/tests/unit/servers/test_client.py index 6402d7db..ca2d499b 100644 --- a/tests/unit/servers/test_client.py +++ b/tests/unit/servers/test_client.py @@ -147,6 +147,7 @@ def test_get_actions_list( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "start_server" @@ -167,6 +168,7 @@ def test_get_actions( assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "start_server" @@ -604,11 +606,17 @@ def test_create_with_datacenter( ) bound_server = response.server + bound_action = response.action assert bound_server._client is servers_client assert bound_server.id == 1 assert bound_server.name == "my-server" + assert isinstance(bound_action, BoundAction) + assert bound_action._client == servers_client._client.actions + assert bound_action.id == 1 + assert bound_action.command == "create_server" + def test_create_with_location(self, servers_client, response_create_simple_server): servers_client._client.request.return_value = response_create_simple_server response = servers_client.create( diff --git a/tests/unit/volumes/test_client.py b/tests/unit/volumes/test_client.py index 0ed3fb1d..9927d48f 100644 --- a/tests/unit/volumes/test_client.py +++ b/tests/unit/volumes/test_client.py @@ -52,6 +52,7 @@ def test_get_actions(self, hetzner_client, bound_volume, response_get_actions): assert len(actions) == 1 assert isinstance(actions[0], BoundAction) + assert actions[0]._client == hetzner_client.actions assert actions[0].id == 13 assert actions[0].command == "attach_volume" From 256734c51aa67dfee0241e2c3125b43431c83562 Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 31 Jul 2023 16:32:55 +0200 Subject: [PATCH 2/8] feat: create ResourceActionsClient --- hcloud/actions/__init__.py | 7 ++++++- hcloud/actions/client.py | 34 +++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/hcloud/actions/__init__.py b/hcloud/actions/__init__.py index 66bb7b4d..ca93c89f 100644 --- a/hcloud/actions/__init__.py +++ b/hcloud/actions/__init__.py @@ -1,6 +1,11 @@ from __future__ import annotations -from .client import ActionsClient, ActionsPageResult, BoundAction # noqa: F401 +from .client import ( # noqa: F401 + ActionsClient, + ActionsPageResult, + BoundAction, + ResourceActionsClient, +) from .domain import ( # noqa: F401 Action, ActionException, diff --git a/hcloud/actions/client.py b/hcloud/actions/client.py index 3105b3c5..4fe2731e 100644 --- a/hcloud/actions/client.py +++ b/hcloud/actions/client.py @@ -40,8 +40,12 @@ class ActionsPageResult(NamedTuple): meta: Meta | None -class ActionsClient(ClientEntityBase): - _client: Client +class ResourceActionsClient(ClientEntityBase): + _resource: str + + def __init__(self, client: Client, resource: str | None): + super().__init__(client) + self._resource = resource or "" def get_by_id(self, id: int) -> BoundAction: """Get a specific action by its ID. @@ -49,9 +53,11 @@ def get_by_id(self, id: int) -> BoundAction: :param id: int :return: :class:`BoundAction ` """ - - response = self._client.request(url=f"/actions/{id}", method="GET") - return BoundAction(self, response["action"]) + response = self._client.request( + url=f"{self._resource}/actions/{id}", + method="GET", + ) + return BoundAction(self._client.actions, response["action"]) def get_list( self, @@ -60,7 +66,7 @@ def get_list( page: int | None = None, per_page: int | None = None, ) -> ActionsPageResult: - """Get a list of actions from this account + """Get a list of actions. :param status: List[str] (optional) Response will have only actions with specified statuses. Choices: `running` `success` `error` @@ -82,9 +88,14 @@ def get_list( if per_page is not None: params["per_page"] = per_page - response = self._client.request(url="/actions", method="GET", params=params) + response = self._client.request( + url=f"{self._resource}/actions", + method="GET", + params=params, + ) actions = [ - BoundAction(self, action_data) for action_data in response["actions"] + BoundAction(self._client.actions, action_data) + for action_data in response["actions"] ] return ActionsPageResult(actions, Meta.parse_meta(response)) @@ -93,7 +104,7 @@ def get_all( status: list[str] | None = None, sort: list[str] | None = None, ) -> list[BoundAction]: - """Get all actions of the account + """Get all actions. :param status: List[str] (optional) Response will have only actions with specified statuses. Choices: `running` `success` `error` @@ -102,3 +113,8 @@ def get_all( :return: List[:class:`BoundAction `] """ return self._iter_pages(self.get_list, status=status, sort=sort) + + +class ActionsClient(ResourceActionsClient): + def __init__(self, client: Client): + super().__init__(client, None) From 887b97ca5c775dba546f91049545cc82c35fe97f Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 8 Aug 2023 12:36:06 +0200 Subject: [PATCH 3/8] feat: deprecated /actions endpoint --- hcloud/actions/client.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hcloud/actions/client.py b/hcloud/actions/client.py index 4fe2731e..87d174d3 100644 --- a/hcloud/actions/client.py +++ b/hcloud/actions/client.py @@ -1,6 +1,7 @@ from __future__ import annotations import time +import warnings from typing import TYPE_CHECKING, Any, NamedTuple from ..core import BoundModelBase, ClientEntityBase, Meta @@ -118,3 +119,33 @@ def get_all( class ActionsClient(ResourceActionsClient): def __init__(self, client: Client): super().__init__(client, None) + + def get_list( + self, + status: list[str] | None = None, + sort: list[str] | None = None, + page: int | None = None, + per_page: int | None = None, + ) -> ActionsPageResult: + warnings.warn( + "The 'client.actions.get_list' method is deprecated, please use the " + "'client..actions.get_list' method instead (e.g. " + "'client.certificates.actions.get_list').", + DeprecationWarning, + stacklevel=2, + ) + return super().get_list(status=status, sort=sort, page=page, per_page=per_page) + + def get_all( + self, + status: list[str] | None = None, + sort: list[str] | None = None, + ) -> list[BoundAction]: + warnings.warn( + "The 'client.actions.get_all' method is deprecated, please use the " + "'client..actions.get_all' method instead (e.g. " + "'client.certificates.actions.get_all').", + DeprecationWarning, + stacklevel=2, + ) + return super().get_all(status=status, sort=sort) From 5d7296e9ee6282849b1b2a0763424822c81ec01a Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 8 Aug 2023 17:37:14 +0200 Subject: [PATCH 4/8] test: add tests for ResourceActionsClient --- tests/unit/actions/test_client.py | 84 ++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 7 deletions(-) diff --git a/tests/unit/actions/test_client.py b/tests/unit/actions/test_client.py index 9df0c1b3..519a8b88 100644 --- a/tests/unit/actions/test_client.py +++ b/tests/unit/actions/test_client.py @@ -10,6 +10,7 @@ ActionsClient, ActionTimeoutException, BoundAction, + ResourceActionsClient, ) @@ -61,6 +62,73 @@ def test_wait_until_finished_max_retries( assert mocked_requests.request.call_count == 1 +class TestResourceActionsClient: + @pytest.fixture() + def actions_client(self): + return ResourceActionsClient(client=mock.MagicMock(), resource="/resource") + + def test_get_by_id(self, actions_client, generic_action): + actions_client._client.request.return_value = generic_action + action = actions_client.get_by_id(1) + actions_client._client.request.assert_called_with( + url="/resource/actions/1", method="GET" + ) + assert action._client == actions_client._client.actions + assert action.id == 1 + assert action.command == "stop_server" + + @pytest.mark.parametrize( + "params", + [{}, {"status": ["active"], "sort": ["status"], "page": 2, "per_page": 10}], + ) + def test_get_list(self, actions_client, generic_action_list, params): + actions_client._client.request.return_value = generic_action_list + result = actions_client.get_list(**params) + actions_client._client.request.assert_called_with( + url="/resource/actions", method="GET", params=params + ) + + assert result.meta is None + + actions = result.actions + assert len(actions) == 2 + + action1 = actions[0] + action2 = actions[1] + + assert action1._client == actions_client._client.actions + assert action1.id == 1 + assert action1.command == "start_server" + + assert action2._client == actions_client._client.actions + assert action2.id == 2 + assert action2.command == "stop_server" + + @pytest.mark.parametrize("params", [{}, {"status": ["active"], "sort": ["status"]}]) + def test_get_all(self, actions_client, generic_action_list, params): + actions_client._client.request.return_value = generic_action_list + actions = actions_client.get_all(**params) + + params.update({"page": 1, "per_page": 50}) + + actions_client._client.request.assert_called_with( + url="/resource/actions", method="GET", params=params + ) + + assert len(actions) == 2 + + action1 = actions[0] + action2 = actions[1] + + assert action1._client == actions_client._client.actions + assert action1.id == 1 + assert action1.command == "start_server" + + assert action2._client == actions_client._client.actions + assert action2.id == 2 + assert action2.command == "stop_server" + + class TestActionsClient: @pytest.fixture() def actions_client(self): @@ -72,7 +140,7 @@ def test_get_by_id(self, actions_client, generic_action): actions_client._client.request.assert_called_with( url="/actions/1", method="GET" ) - assert action._client is actions_client + assert action._client == actions_client._client.actions assert action.id == 1 assert action.command == "stop_server" @@ -82,7 +150,8 @@ def test_get_by_id(self, actions_client, generic_action): ) def test_get_list(self, actions_client, generic_action_list, params): actions_client._client.request.return_value = generic_action_list - result = actions_client.get_list(**params) + with pytest.deprecated_call(): + result = actions_client.get_list(**params) actions_client._client.request.assert_called_with( url="/actions", method="GET", params=params ) @@ -95,18 +164,19 @@ def test_get_list(self, actions_client, generic_action_list, params): action1 = actions[0] action2 = actions[1] - assert action1._client is actions_client + assert action1._client == actions_client._client.actions assert action1.id == 1 assert action1.command == "start_server" - assert action2._client is actions_client + assert action2._client == actions_client._client.actions assert action2.id == 2 assert action2.command == "stop_server" @pytest.mark.parametrize("params", [{}, {"status": ["active"], "sort": ["status"]}]) def test_get_all(self, actions_client, generic_action_list, params): actions_client._client.request.return_value = generic_action_list - actions = actions_client.get_all(**params) + with pytest.deprecated_call(): + actions = actions_client.get_all(**params) params.update({"page": 1, "per_page": 50}) @@ -119,10 +189,10 @@ def test_get_all(self, actions_client, generic_action_list, params): action1 = actions[0] action2 = actions[1] - assert action1._client is actions_client + assert action1._client == actions_client._client.actions assert action1.id == 1 assert action1.command == "start_server" - assert action2._client is actions_client + assert action2._client == actions_client._client.actions assert action2.id == 2 assert action2.command == "stop_server" From c8ea678ab224764d0349d5677d12e0310e2dc12b Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 1 Aug 2023 13:35:16 +0200 Subject: [PATCH 5/8] feat: spread ResourceActionsClient to all clients --- hcloud/certificates/client.py | 12 +++++++++++- hcloud/firewalls/client.py | 12 +++++++++++- hcloud/floating_ips/client.py | 12 +++++++++++- hcloud/images/client.py | 12 +++++++++++- hcloud/load_balancers/client.py | 12 +++++++++++- hcloud/networks/client.py | 12 +++++++++++- hcloud/primary_ips/client.py | 12 +++++++++++- hcloud/servers/client.py | 12 +++++++++++- hcloud/volumes/client.py | 12 +++++++++++- 9 files changed, 99 insertions(+), 9 deletions(-) diff --git a/hcloud/certificates/client.py b/hcloud/certificates/client.py index ff245678..bb45d2c5 100644 --- a/hcloud/certificates/client.py +++ b/hcloud/certificates/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from .domain import ( Certificate, @@ -106,6 +106,16 @@ class CertificatesPageResult(NamedTuple): class CertificatesClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Certificates actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/certificates") + def get_by_id(self, id: int) -> BoundCertificate: """Get a specific certificate by its ID. diff --git a/hcloud/firewalls/client.py b/hcloud/firewalls/client.py index 86960808..babbbc6b 100644 --- a/hcloud/firewalls/client.py +++ b/hcloud/firewalls/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from .domain import ( CreateFirewallResponse, @@ -161,6 +161,16 @@ class FirewallsPageResult(NamedTuple): class FirewallsClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Firewalls actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/firewalls") + def get_actions_list( self, firewall: Firewall | BoundFirewall, diff --git a/hcloud/floating_ips/client.py b/hcloud/floating_ips/client.py index b85cd9d9..b797364b 100644 --- a/hcloud/floating_ips/client.py +++ b/hcloud/floating_ips/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from ..locations import BoundLocation from .domain import CreateFloatingIPResponse, FloatingIP @@ -141,6 +141,16 @@ class FloatingIPsPageResult(NamedTuple): class FloatingIPsClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Floating IPs actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/floating_ips") + def get_actions_list( self, floating_ip: FloatingIP | BoundFloatingIP, diff --git a/hcloud/images/client.py b/hcloud/images/client.py index 132efdac..221b938b 100644 --- a/hcloud/images/client.py +++ b/hcloud/images/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from .domain import Image @@ -113,6 +113,16 @@ class ImagesPageResult(NamedTuple): class ImagesClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Images actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/images") + def get_actions_list( self, image: Image | BoundImage, diff --git a/hcloud/load_balancers/client.py b/hcloud/load_balancers/client.py index e228cc21..68faf953 100644 --- a/hcloud/load_balancers/client.py +++ b/hcloud/load_balancers/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..certificates import BoundCertificate from ..core import BoundModelBase, ClientEntityBase, Meta from ..load_balancer_types import BoundLoadBalancerType @@ -331,6 +331,16 @@ class LoadBalancersPageResult(NamedTuple): class LoadBalancersClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Load Balancers actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/load_balancers") + def get_by_id(self, id: int) -> BoundLoadBalancer: """Get a specific Load Balancer diff --git a/hcloud/networks/client.py b/hcloud/networks/client.py index c6b90a65..82539a0e 100644 --- a/hcloud/networks/client.py +++ b/hcloud/networks/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from .domain import Network, NetworkRoute, NetworkSubnet @@ -168,6 +168,16 @@ class NetworksPageResult(NamedTuple): class NetworksClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Networks actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/networks") + def get_by_id(self, id: int) -> BoundNetwork: """Get a specific network diff --git a/hcloud/primary_ips/client.py b/hcloud/primary_ips/client.py index a54de6dc..95d20e61 100644 --- a/hcloud/primary_ips/client.py +++ b/hcloud/primary_ips/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import BoundAction +from ..actions import BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from .domain import CreatePrimaryIPResponse, PrimaryIP @@ -99,6 +99,16 @@ class PrimaryIPsPageResult(NamedTuple): class PrimaryIPsClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Primary IPs actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/primary_ips") + def get_by_id(self, id: int) -> BoundPrimaryIP: """Returns a specific Primary IP object. diff --git a/hcloud/servers/client.py b/hcloud/servers/client.py index c1282881..eff65b5e 100644 --- a/hcloud/servers/client.py +++ b/hcloud/servers/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from ..datacenters import BoundDatacenter from ..firewalls import BoundFirewall @@ -448,6 +448,16 @@ class ServersPageResult(NamedTuple): class ServersClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Servers actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/servers") + def get_by_id(self, id: int) -> BoundServer: """Get a specific server diff --git a/hcloud/volumes/client.py b/hcloud/volumes/client.py index 3dd628a1..2c9f14a8 100644 --- a/hcloud/volumes/client.py +++ b/hcloud/volumes/client.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple -from ..actions import ActionsPageResult, BoundAction +from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient from ..core import BoundModelBase, ClientEntityBase, Meta from ..locations import BoundLocation from .domain import CreateVolumeResponse, Volume @@ -137,6 +137,16 @@ class VolumesPageResult(NamedTuple): class VolumesClient(ClientEntityBase): _client: Client + actions: ResourceActionsClient + """Volumes actions client + + :type: :class:`ResourceActionsClient ` + """ + + def __init__(self, client: Client): + super().__init__(client) + self.actions = ResourceActionsClient(client, "/volumes") + def get_by_id(self, id: int) -> BoundVolume: """Get a specific volume by its id From 46608ac5d54f0faa1d612c536edfb9dc3041921a Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 8 Aug 2023 17:40:14 +0200 Subject: [PATCH 6/8] test: add tests for all ResourceActionsClient --- tests/unit/certificates/test_client.py | 50 +++++++++++++++++++++++ tests/unit/firewalls/test_client.py | 50 +++++++++++++++++++++++ tests/unit/floating_ips/test_client.py | 50 +++++++++++++++++++++++ tests/unit/images/test_client.py | 50 +++++++++++++++++++++++ tests/unit/load_balancers/test_client.py | 50 +++++++++++++++++++++++ tests/unit/networks/test_client.py | 50 +++++++++++++++++++++++ tests/unit/primary_ips/test_client.py | 51 ++++++++++++++++++++++++ tests/unit/servers/test_client.py | 50 +++++++++++++++++++++++ tests/unit/volumes/test_client.py | 50 +++++++++++++++++++++++ 9 files changed, 451 insertions(+) diff --git a/tests/unit/certificates/test_client.py b/tests/unit/certificates/test_client.py index d245108d..0857d0c9 100644 --- a/tests/unit/certificates/test_client.py +++ b/tests/unit/certificates/test_client.py @@ -288,3 +288,53 @@ def test_retry_issuance( assert action.id == 14 assert action.command == "issue_certificate" + + def test_actions_get_by_id(self, certificates_client, response_get_actions): + certificates_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = certificates_client.actions.get_by_id(13) + + certificates_client._client.request.assert_called_with( + url="/certificates/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == certificates_client._client.actions + assert action.id == 13 + assert action.command == "change_protection" + + def test_actions_get_list(self, certificates_client, response_get_actions): + certificates_client._client.request.return_value = response_get_actions + result = certificates_client.actions.get_list() + + certificates_client._client.request.assert_called_with( + url="/certificates/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == certificates_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "change_protection" + + def test_actions_get_all(self, certificates_client, response_get_actions): + certificates_client._client.request.return_value = response_get_actions + actions = certificates_client.actions.get_all() + + certificates_client._client.request.assert_called_with( + url="/certificates/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == certificates_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "change_protection" diff --git a/tests/unit/firewalls/test_client.py b/tests/unit/firewalls/test_client.py index 14fe291d..4e8cea94 100644 --- a/tests/unit/firewalls/test_client.py +++ b/tests/unit/firewalls/test_client.py @@ -462,3 +462,53 @@ def test_remove_from_resources( assert actions[0].id == 13 assert actions[0].progress == 100 + + def test_actions_get_by_id(self, firewalls_client, response_get_actions): + firewalls_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = firewalls_client.actions.get_by_id(13) + + firewalls_client._client.request.assert_called_with( + url="/firewalls/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == firewalls_client._client.actions + assert action.id == 13 + assert action.command == "set_firewall_rules" + + def test_actions_get_list(self, firewalls_client, response_get_actions): + firewalls_client._client.request.return_value = response_get_actions + result = firewalls_client.actions.get_list() + + firewalls_client._client.request.assert_called_with( + url="/firewalls/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == firewalls_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "set_firewall_rules" + + def test_actions_get_all(self, firewalls_client, response_get_actions): + firewalls_client._client.request.return_value = response_get_actions + actions = firewalls_client.actions.get_all() + + firewalls_client._client.request.assert_called_with( + url="/firewalls/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == firewalls_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "set_firewall_rules" diff --git a/tests/unit/floating_ips/test_client.py b/tests/unit/floating_ips/test_client.py index d3308084..a56f0829 100644 --- a/tests/unit/floating_ips/test_client.py +++ b/tests/unit/floating_ips/test_client.py @@ -392,3 +392,53 @@ def test_change_dns_ptr(self, floating_ips_client, floating_ip, generic_action): ) assert action.id == 1 assert action.progress == 0 + + def test_actions_get_by_id(self, floating_ips_client, response_get_actions): + floating_ips_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = floating_ips_client.actions.get_by_id(13) + + floating_ips_client._client.request.assert_called_with( + url="/floating_ips/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == floating_ips_client._client.actions + assert action.id == 13 + assert action.command == "assign_floating_ip" + + def test_actions_get_list(self, floating_ips_client, response_get_actions): + floating_ips_client._client.request.return_value = response_get_actions + result = floating_ips_client.actions.get_list() + + floating_ips_client._client.request.assert_called_with( + url="/floating_ips/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == floating_ips_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "assign_floating_ip" + + def test_actions_get_all(self, floating_ips_client, response_get_actions): + floating_ips_client._client.request.return_value = response_get_actions + actions = floating_ips_client.actions.get_all() + + floating_ips_client._client.request.assert_called_with( + url="/floating_ips/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == floating_ips_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "assign_floating_ip" diff --git a/tests/unit/images/test_client.py b/tests/unit/images/test_client.py index debbd8f9..8e1dc490 100644 --- a/tests/unit/images/test_client.py +++ b/tests/unit/images/test_client.py @@ -310,3 +310,53 @@ def test_delete(self, images_client, image, generic_action): ) assert delete_success is True + + def test_actions_get_by_id(self, images_client, response_get_actions): + images_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = images_client.actions.get_by_id(13) + + images_client._client.request.assert_called_with( + url="/images/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == images_client._client.actions + assert action.id == 13 + assert action.command == "change_protection" + + def test_actions_get_list(self, images_client, response_get_actions): + images_client._client.request.return_value = response_get_actions + result = images_client.actions.get_list() + + images_client._client.request.assert_called_with( + url="/images/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == images_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "change_protection" + + def test_actions_get_all(self, images_client, response_get_actions): + images_client._client.request.return_value = response_get_actions + actions = images_client.actions.get_all() + + images_client._client.request.assert_called_with( + url="/images/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == images_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "change_protection" diff --git a/tests/unit/load_balancers/test_client.py b/tests/unit/load_balancers/test_client.py index f0f343f6..191334c3 100644 --- a/tests/unit/load_balancers/test_client.py +++ b/tests/unit/load_balancers/test_client.py @@ -518,3 +518,53 @@ def test_change_type_with_load_balancer_type_id( assert action.id == 1 assert action.progress == 0 + + def test_actions_get_by_id(self, load_balancers_client, response_get_actions): + load_balancers_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = load_balancers_client.actions.get_by_id(13) + + load_balancers_client._client.request.assert_called_with( + url="/load_balancers/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == load_balancers_client._client.actions + assert action.id == 13 + assert action.command == "change_protection" + + def test_actions_get_list(self, load_balancers_client, response_get_actions): + load_balancers_client._client.request.return_value = response_get_actions + result = load_balancers_client.actions.get_list() + + load_balancers_client._client.request.assert_called_with( + url="/load_balancers/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == load_balancers_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "change_protection" + + def test_actions_get_all(self, load_balancers_client, response_get_actions): + load_balancers_client._client.request.return_value = response_get_actions + actions = load_balancers_client.actions.get_all() + + load_balancers_client._client.request.assert_called_with( + url="/load_balancers/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == load_balancers_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "change_protection" diff --git a/tests/unit/networks/test_client.py b/tests/unit/networks/test_client.py index 3db775b0..ff4dd233 100644 --- a/tests/unit/networks/test_client.py +++ b/tests/unit/networks/test_client.py @@ -586,3 +586,53 @@ def test_change_ip_range(self, networks_client, network, generic_action): assert action.id == 1 assert action.progress == 0 + + def test_actions_get_by_id(self, networks_client, response_get_actions): + networks_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = networks_client.actions.get_by_id(13) + + networks_client._client.request.assert_called_with( + url="/networks/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == networks_client._client.actions + assert action.id == 13 + assert action.command == "add_subnet" + + def test_actions_get_list(self, networks_client, response_get_actions): + networks_client._client.request.return_value = response_get_actions + result = networks_client.actions.get_list() + + networks_client._client.request.assert_called_with( + url="/networks/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == networks_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "add_subnet" + + def test_actions_get_all(self, networks_client, response_get_actions): + networks_client._client.request.return_value = response_get_actions + actions = networks_client.actions.get_all() + + networks_client._client.request.assert_called_with( + url="/networks/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == networks_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "add_subnet" diff --git a/tests/unit/primary_ips/test_client.py b/tests/unit/primary_ips/test_client.py index 85d4b9c4..413ed2bb 100644 --- a/tests/unit/primary_ips/test_client.py +++ b/tests/unit/primary_ips/test_client.py @@ -4,6 +4,7 @@ import pytest +from hcloud.actions import BoundAction from hcloud.datacenters import BoundDatacenter, Datacenter from hcloud.primary_ips import BoundPrimaryIP, PrimaryIP, PrimaryIPsClient @@ -295,3 +296,53 @@ def test_change_dns_ptr(self, primary_ips_client, primary_ip, generic_action): ) assert action.id == 1 assert action.progress == 0 + + def test_actions_get_by_id(self, primary_ips_client, response_get_actions): + primary_ips_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = primary_ips_client.actions.get_by_id(13) + + primary_ips_client._client.request.assert_called_with( + url="/primary_ips/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == primary_ips_client._client.actions + assert action.id == 13 + assert action.command == "assign_primary_ip" + + def test_actions_get_list(self, primary_ips_client, response_get_actions): + primary_ips_client._client.request.return_value = response_get_actions + result = primary_ips_client.actions.get_list() + + primary_ips_client._client.request.assert_called_with( + url="/primary_ips/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == primary_ips_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "assign_primary_ip" + + def test_actions_get_all(self, primary_ips_client, response_get_actions): + primary_ips_client._client.request.return_value = response_get_actions + actions = primary_ips_client.actions.get_all() + + primary_ips_client._client.request.assert_called_with( + url="/primary_ips/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == primary_ips_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "assign_primary_ip" diff --git a/tests/unit/servers/test_client.py b/tests/unit/servers/test_client.py index ca2d499b..2490ecfa 100644 --- a/tests/unit/servers/test_client.py +++ b/tests/unit/servers/test_client.py @@ -1226,3 +1226,53 @@ def test_change_alias_ips( assert action.id == 1 assert action.progress == 0 assert action.command == "change_alias_ips" + + def test_actions_get_by_id(self, servers_client, response_get_actions): + servers_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = servers_client.actions.get_by_id(13) + + servers_client._client.request.assert_called_with( + url="/servers/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == servers_client._client.actions + assert action.id == 13 + assert action.command == "start_server" + + def test_actions_get_list(self, servers_client, response_get_actions): + servers_client._client.request.return_value = response_get_actions + result = servers_client.actions.get_list() + + servers_client._client.request.assert_called_with( + url="/servers/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == servers_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "start_server" + + def test_actions_get_all(self, servers_client, response_get_actions): + servers_client._client.request.return_value = response_get_actions + actions = servers_client.actions.get_all() + + servers_client._client.request.assert_called_with( + url="/servers/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == servers_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "start_server" diff --git a/tests/unit/volumes/test_client.py b/tests/unit/volumes/test_client.py index 9927d48f..bb8bed00 100644 --- a/tests/unit/volumes/test_client.py +++ b/tests/unit/volumes/test_client.py @@ -385,3 +385,53 @@ def test_resize(self, volumes_client, volume, generic_action): ) assert action.id == 1 assert action.progress == 0 + + def test_actions_get_by_id(self, volumes_client, response_get_actions): + volumes_client._client.request.return_value = { + "action": response_get_actions["actions"][0] + } + action = volumes_client.actions.get_by_id(13) + + volumes_client._client.request.assert_called_with( + url="/volumes/actions/13", method="GET" + ) + + assert isinstance(action, BoundAction) + assert action._client == volumes_client._client.actions + assert action.id == 13 + assert action.command == "attach_volume" + + def test_actions_get_list(self, volumes_client, response_get_actions): + volumes_client._client.request.return_value = response_get_actions + result = volumes_client.actions.get_list() + + volumes_client._client.request.assert_called_with( + url="/volumes/actions", + method="GET", + params={}, + ) + + actions = result.actions + assert result.meta is None + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == volumes_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "attach_volume" + + def test_actions_get_all(self, volumes_client, response_get_actions): + volumes_client._client.request.return_value = response_get_actions + actions = volumes_client.actions.get_all() + + volumes_client._client.request.assert_called_with( + url="/volumes/actions", + method="GET", + params={"page": 1, "per_page": 50}, + ) + + assert len(actions) == 1 + assert isinstance(actions[0], BoundAction) + assert actions[0]._client == volumes_client._client.actions + assert actions[0].id == 13 + assert actions[0].command == "attach_volume" From 3bbc798d849d76bcbb82ab06895756105f9c168e Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 14 Aug 2023 11:10:20 +0200 Subject: [PATCH 7/8] docs: improve reference docs --- docs/api.clients.actions.rst | 3 +++ hcloud/actions/client.py | 10 ++++++++++ hcloud/certificates/client.py | 4 ++-- hcloud/firewalls/client.py | 4 ++-- hcloud/floating_ips/client.py | 4 ++-- hcloud/images/client.py | 4 ++-- hcloud/load_balancers/client.py | 4 ++-- hcloud/networks/client.py | 4 ++-- hcloud/primary_ips/client.py | 4 ++-- hcloud/servers/client.py | 4 ++-- hcloud/volumes/client.py | 4 ++-- 11 files changed, 31 insertions(+), 18 deletions(-) diff --git a/docs/api.clients.actions.rst b/docs/api.clients.actions.rst index ab7d0999..aecd2fe0 100644 --- a/docs/api.clients.actions.rst +++ b/docs/api.clients.actions.rst @@ -1,9 +1,12 @@ ActionsClient ================== +.. autoclass:: hcloud.actions.client.ResourceActionsClient + :members: .. autoclass:: hcloud.actions.client.ActionsClient :members: + :inherited-members: .. autoclass:: hcloud.actions.client.BoundAction :members: diff --git a/hcloud/actions/client.py b/hcloud/actions/client.py index 87d174d3..e013cc1b 100644 --- a/hcloud/actions/client.py +++ b/hcloud/actions/client.py @@ -127,6 +127,11 @@ def get_list( page: int | None = None, per_page: int | None = None, ) -> ActionsPageResult: + """ + .. deprecated:: 1.28 + Use :func:`client..actions.get_list` instead, + e.g. using :attr:`hcloud.certificates.client.CertificatesClient.actions`. + """ warnings.warn( "The 'client.actions.get_list' method is deprecated, please use the " "'client..actions.get_list' method instead (e.g. " @@ -141,6 +146,11 @@ def get_all( status: list[str] | None = None, sort: list[str] | None = None, ) -> list[BoundAction]: + """ + .. deprecated:: 1.28 + Use :func:`client..actions.get_all` instead, + e.g. using :attr:`hcloud.certificates.client.CertificatesClient.actions`. + """ warnings.warn( "The 'client.actions.get_all' method is deprecated, please use the " "'client..actions.get_all' method instead (e.g. " diff --git a/hcloud/certificates/client.py b/hcloud/certificates/client.py index bb45d2c5..e368a952 100644 --- a/hcloud/certificates/client.py +++ b/hcloud/certificates/client.py @@ -107,9 +107,9 @@ class CertificatesClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Certificates actions client + """Certificates scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/firewalls/client.py b/hcloud/firewalls/client.py index babbbc6b..b9b341b6 100644 --- a/hcloud/firewalls/client.py +++ b/hcloud/firewalls/client.py @@ -162,9 +162,9 @@ class FirewallsClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Firewalls actions client + """Firewalls scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/floating_ips/client.py b/hcloud/floating_ips/client.py index b797364b..49d7c8e5 100644 --- a/hcloud/floating_ips/client.py +++ b/hcloud/floating_ips/client.py @@ -142,9 +142,9 @@ class FloatingIPsClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Floating IPs actions client + """Floating IPs scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/images/client.py b/hcloud/images/client.py index 221b938b..dee910f0 100644 --- a/hcloud/images/client.py +++ b/hcloud/images/client.py @@ -114,9 +114,9 @@ class ImagesClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Images actions client + """Images scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/load_balancers/client.py b/hcloud/load_balancers/client.py index 68faf953..b999ddc0 100644 --- a/hcloud/load_balancers/client.py +++ b/hcloud/load_balancers/client.py @@ -332,9 +332,9 @@ class LoadBalancersClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Load Balancers actions client + """Load Balancers scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/networks/client.py b/hcloud/networks/client.py index 82539a0e..36eaaa40 100644 --- a/hcloud/networks/client.py +++ b/hcloud/networks/client.py @@ -169,9 +169,9 @@ class NetworksClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Networks actions client + """Networks scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/primary_ips/client.py b/hcloud/primary_ips/client.py index 95d20e61..acd2f69e 100644 --- a/hcloud/primary_ips/client.py +++ b/hcloud/primary_ips/client.py @@ -100,9 +100,9 @@ class PrimaryIPsClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Primary IPs actions client + """Primary IPs scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/servers/client.py b/hcloud/servers/client.py index eff65b5e..d19180c5 100644 --- a/hcloud/servers/client.py +++ b/hcloud/servers/client.py @@ -449,9 +449,9 @@ class ServersClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Servers actions client + """Servers scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): diff --git a/hcloud/volumes/client.py b/hcloud/volumes/client.py index 2c9f14a8..9017ff49 100644 --- a/hcloud/volumes/client.py +++ b/hcloud/volumes/client.py @@ -138,9 +138,9 @@ class VolumesClient(ClientEntityBase): _client: Client actions: ResourceActionsClient - """Volumes actions client + """Volumes scoped actions client - :type: :class:`ResourceActionsClient ` + :type: :class:`ResourceActionsClient ` """ def __init__(self, client: Client): From 357accb7da694fc5339438fe757faaf737002ae4 Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 14 Aug 2023 11:24:48 +0200 Subject: [PATCH 8/8] docs: add link to deprecation changelog --- hcloud/actions/client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hcloud/actions/client.py b/hcloud/actions/client.py index e013cc1b..63e1d884 100644 --- a/hcloud/actions/client.py +++ b/hcloud/actions/client.py @@ -131,6 +131,8 @@ def get_list( .. deprecated:: 1.28 Use :func:`client..actions.get_list` instead, e.g. using :attr:`hcloud.certificates.client.CertificatesClient.actions`. + + `Starting 1 October 2023, it will no longer be available. `_ """ warnings.warn( "The 'client.actions.get_list' method is deprecated, please use the " @@ -150,6 +152,8 @@ def get_all( .. deprecated:: 1.28 Use :func:`client..actions.get_all` instead, e.g. using :attr:`hcloud.certificates.client.CertificatesClient.actions`. + + `Starting 1 October 2023, it will no longer be available. `_ """ warnings.warn( "The 'client.actions.get_all' method is deprecated, please use the "