Skip to content
Merged
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
14 changes: 14 additions & 0 deletions mpt_api_client/resources/accounts/accounts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService
from mpt_api_client.resources.accounts.cloud_tenants import (
AsyncCloudTenantsService,
CloudTenantsService,
)
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
Expand Down Expand Up @@ -52,6 +56,11 @@ def modules(self) -> ModulesService:
"""Modules service."""
return ModulesService(http_client=self.http_client)

@property
def cloud_tenants(self) -> CloudTenantsService:
"""Cloud Tenants service."""
return CloudTenantsService(http_client=self.http_client)


class AsyncAccounts:
"""Async Accounts MPT API Module."""
Expand Down Expand Up @@ -93,3 +102,8 @@ def api_tokens(self) -> AsyncApiTokensService:
def modules(self) -> AsyncModulesService:
"""Modules service."""
return AsyncModulesService(http_client=self.http_client)

@property
def cloud_tenants(self) -> AsyncCloudTenantsService:
"""Cloud Tenants service."""
return AsyncCloudTenantsService(http_client=self.http_client)
42 changes: 42 additions & 0 deletions mpt_api_client/resources/accounts/cloud_tenants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCreateMixin,
AsyncDeleteMixin,
AsyncUpdateMixin,
CreateMixin,
DeleteMixin,
UpdateMixin,
)
from mpt_api_client.models import Model


class CloudTenant(Model):
"""Cloud Tenant Model."""


class CloudTenantsServiceConfig:
"""Cloud Tenants Service Configuration."""

_endpoint = "/public/v1/accounts/cloud-tenants"
_model_class = CloudTenant
_collection_key = "data"


class CloudTenantsService(
CreateMixin[CloudTenant],
DeleteMixin,
UpdateMixin[CloudTenant],
Service[CloudTenant],
CloudTenantsServiceConfig,
):
"""Cloud Tenants Service."""


class AsyncCloudTenantsService(
AsyncCreateMixin[CloudTenant],
AsyncDeleteMixin,
AsyncUpdateMixin[CloudTenant],
AsyncService[CloudTenant],
CloudTenantsServiceConfig,
):
"""Async Cloud Tenants Service."""
6 changes: 6 additions & 0 deletions tests/resources/accounts/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
ApiTokensService,
AsyncApiTokensService,
)
from mpt_api_client.resources.accounts.cloud_tenants import (
AsyncCloudTenantsService,
CloudTenantsService,
)
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
Expand Down Expand Up @@ -36,6 +40,7 @@ def async_accounts(async_http_client):
("user_groups", UserGroupsService),
("api_tokens", ApiTokensService),
("modules", ModulesService),
("cloud_tenants", CloudTenantsService),
],
)
def test_accounts_properties(accounts, property_name, expected_service_class):
Expand All @@ -56,6 +61,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
("user_groups", AsyncUserGroupsService),
("api_tokens", AsyncApiTokensService),
("modules", AsyncModulesService),
("cloud_tenants", AsyncCloudTenantsService),
],
)
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Expand Down
32 changes: 32 additions & 0 deletions tests/resources/accounts/test_cloud_tenants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from mpt_api_client.resources.accounts.cloud_tenants import (
AsyncCloudTenantsService,
CloudTenantsService,
)


@pytest.fixture
def cloud_tenants_service(http_client):
return CloudTenantsService(http_client=http_client)


@pytest.fixture
def async_cloud_tenants_service(async_http_client):
return AsyncCloudTenantsService(http_client=async_http_client)


@pytest.mark.parametrize(
"method",
["get", "create", "update", "delete"],
)
def test_cloud_tenants_mixins_present(cloud_tenants_service, method):
assert hasattr(cloud_tenants_service, method)


@pytest.mark.parametrize(
"method",
["get", "create", "update", "delete"],
)
def test_async_cloud_tenants_mixins_present(async_cloud_tenants_service, method):
assert hasattr(async_cloud_tenants_service, method)