Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hcloud/actions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import warnings
from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import Action, ActionFailedException, ActionTimeoutException

if TYPE_CHECKING:
from .._client import Client


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

model = Action
Expand Down
4 changes: 2 additions & 2 deletions hcloud/certificates/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import (
Certificate,
CreateManagedCertificateResponse,
Expand All @@ -15,7 +15,7 @@
from .._client import Client


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

model = Certificate
Expand Down
3 changes: 2 additions & 1 deletion hcloud/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from .client import BaseResourceClient, BoundModelBase, ClientEntityBase
from .client import BaseBoundModel, BaseResourceClient, BoundModelBase, ClientEntityBase
from .domain import BaseDomain, DomainIdentityMixin, Meta, Pagination

__all__ = [
"BaseBoundModel",
"BaseDomain",
"BaseResourceClient",
"BoundModelBase",
Expand Down
30 changes: 27 additions & 3 deletions hcloud/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

if TYPE_CHECKING:
from .._client import Client
from .domain import BaseDomain


class BaseResourceClient:
Expand Down Expand Up @@ -69,10 +70,10 @@ def __init__(self, client: Client):
super().__init__(client)


class BoundModelBase:
"""Bound Model Base"""
class BaseBoundModel:
"""Base Bound Model"""

model: Any
model: type[BaseDomain]

def __init__(
self,
Expand Down Expand Up @@ -121,3 +122,26 @@ def __eq__(self, other: Any) -> bool:
if not isinstance(other, self.__class__):
return NotImplemented
return self.data_model == other.data_model


class BoundModelBase(BaseBoundModel):
"""
Kept for backward compatibility.

.. deprecated:: 2.6.0
Use :class:``hcloud.core.client.BaseBoundModel`` instead.
"""

def __init__(
self,
client: BaseResourceClient,
data: dict,
complete: bool = True,
):
warnings.warn(
"The 'hcloud.core.client.BoundModelBase' class is deprecated, please use the "
"'hcloud.core.client.BaseBoundModel' class instead.",
DeprecationWarning,
stacklevel=2,
)
super().__init__(client, data, complete)
4 changes: 2 additions & 2 deletions hcloud/datacenters/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from ..locations import BoundLocation
from ..server_types import BoundServerType
from .domain import Datacenter, DatacenterServerTypes
Expand All @@ -11,7 +11,7 @@
from .._client import Client


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

model = Datacenter
Expand Down
4 changes: 2 additions & 2 deletions hcloud/firewalls/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import (
CreateFirewallResponse,
Firewall,
Expand All @@ -17,7 +17,7 @@
from .._client import Client


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

model = Firewall
Expand Down
4 changes: 2 additions & 2 deletions hcloud/floating_ips/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from ..locations import BoundLocation
from .domain import CreateFloatingIPResponse, FloatingIP

Expand All @@ -13,7 +13,7 @@
from ..servers import BoundServer, Server


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

model = FloatingIP
Expand Down
4 changes: 2 additions & 2 deletions hcloud/images/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import Image

if TYPE_CHECKING:
from .._client import Client


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

model = Image
Expand Down
4 changes: 2 additions & 2 deletions hcloud/isos/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import Iso

if TYPE_CHECKING:
from .._client import Client


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

model = Iso
Expand Down
4 changes: 2 additions & 2 deletions hcloud/load_balancer_types/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import LoadBalancerType

if TYPE_CHECKING:
from .._client import Client


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

model = LoadBalancerType
Expand Down
4 changes: 2 additions & 2 deletions hcloud/load_balancers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..certificates import BoundCertificate
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from ..load_balancer_types import BoundLoadBalancerType
from ..locations import BoundLocation
from ..metrics import Metrics
Expand Down Expand Up @@ -40,7 +40,7 @@
from ..networks import Network


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

model = LoadBalancer
Expand Down
4 changes: 2 additions & 2 deletions hcloud/locations/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import Location

if TYPE_CHECKING:
from .._client import Client


class BoundLocation(BoundModelBase, Location):
class BoundLocation(BaseBoundModel, Location):
_client: LocationsClient

model = Location
Expand Down
4 changes: 2 additions & 2 deletions hcloud/networks/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import Network, NetworkRoute, NetworkSubnet

if TYPE_CHECKING:
from .._client import Client


class BoundNetwork(BoundModelBase, Network):
class BoundNetwork(BaseBoundModel, Network):
_client: NetworksClient

model = Network
Expand Down
4 changes: 2 additions & 2 deletions hcloud/placement_groups/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import BoundAction
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import CreatePlacementGroupResponse, PlacementGroup

if TYPE_CHECKING:
from .._client import Client


class BoundPlacementGroup(BoundModelBase, PlacementGroup):
class BoundPlacementGroup(BaseBoundModel, PlacementGroup):
_client: PlacementGroupsClient

model = PlacementGroup
Expand Down
4 changes: 2 additions & 2 deletions hcloud/primary_ips/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import CreatePrimaryIPResponse, PrimaryIP

if TYPE_CHECKING:
from .._client import Client
from ..datacenters import BoundDatacenter, Datacenter


class BoundPrimaryIP(BoundModelBase, PrimaryIP):
class BoundPrimaryIP(BaseBoundModel, PrimaryIP):
_client: PrimaryIPsClient

model = PrimaryIP
Expand Down
4 changes: 2 additions & 2 deletions hcloud/server_types/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import ServerType

if TYPE_CHECKING:
from .._client import Client


class BoundServerType(BoundModelBase, ServerType):
class BoundServerType(BaseBoundModel, ServerType):
_client: ServerTypesClient

model = ServerType
Expand Down
4 changes: 2 additions & 2 deletions hcloud/servers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dateutil.parser import isoparse

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from ..datacenters import BoundDatacenter
from ..firewalls import BoundFirewall
from ..floating_ips import BoundFloatingIP
Expand Down Expand Up @@ -48,7 +48,7 @@
from .domain import ServerCreatePublicNetwork


class BoundServer(BoundModelBase, Server):
class BoundServer(BaseBoundModel, Server):
_client: ServersClient

model = Server
Expand Down
4 changes: 2 additions & 2 deletions hcloud/ssh_keys/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from typing import TYPE_CHECKING, Any, NamedTuple

from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from .domain import SSHKey

if TYPE_CHECKING:
from .._client import Client


class BoundSSHKey(BoundModelBase, SSHKey):
class BoundSSHKey(BaseBoundModel, SSHKey):
_client: SSHKeysClient

model = SSHKey
Expand Down
4 changes: 2 additions & 2 deletions hcloud/volumes/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Any, NamedTuple

from ..actions import ActionsPageResult, BoundAction, ResourceActionsClient
from ..core import BaseResourceClient, BoundModelBase, Meta
from ..core import BaseBoundModel, BaseResourceClient, Meta
from ..locations import BoundLocation
from .domain import CreateVolumeResponse, Volume

Expand All @@ -13,7 +13,7 @@
from ..servers import BoundServer, Server


class BoundVolume(BoundModelBase, Volume):
class BoundVolume(BaseBoundModel, Volume):
_client: VolumesClient

model = Volume
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/core/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import pytest

from hcloud.actions import ActionsPageResult
from hcloud.core import BaseDomain, BaseResourceClient, BoundModelBase, Meta
from hcloud.core import BaseBoundModel, BaseDomain, BaseResourceClient, Meta


class TestBoundModelBase:
class TestBaseBoundModel:
@pytest.fixture()
def bound_model_class(self):
class Model(BaseDomain):
Expand All @@ -21,7 +21,7 @@ def __init__(self, id, name="", description=""):
self.name = name
self.description = description

class BoundModel(BoundModelBase, Model):
class BoundModel(BaseBoundModel, Model):
model = Model

return BoundModel
Expand Down