Skip to content

Commit cb50c8d

Browse files
author
Robert Segal
committed
Added Accounts cloud tenants endpoints
1 parent b83abf8 commit cb50c8d

4 files changed

Lines changed: 94 additions & 0 deletions

File tree

mpt_api_client/resources/accounts/accounts.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
22
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
33
from mpt_api_client.resources.accounts.api_tokens import ApiTokensService, AsyncApiTokensService
4+
from mpt_api_client.resources.accounts.cloud_tenants import (
5+
AsyncCloudTenantsService,
6+
CloudTenantsService,
7+
)
48
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
59
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
610
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
@@ -52,6 +56,11 @@ def modules(self) -> ModulesService:
5256
"""Modules service."""
5357
return ModulesService(http_client=self.http_client)
5458

59+
@property
60+
def cloud_tenants(self) -> CloudTenantsService:
61+
"""Cloud Tenants service."""
62+
return CloudTenantsService(http_client=self.http_client)
63+
5564

5665
class AsyncAccounts:
5766
"""Async Accounts MPT API Module."""
@@ -93,3 +102,8 @@ def api_tokens(self) -> AsyncApiTokensService:
93102
def modules(self) -> AsyncModulesService:
94103
"""Modules service."""
95104
return AsyncModulesService(http_client=self.http_client)
105+
106+
@property
107+
def cloud_tenants(self) -> AsyncCloudTenantsService:
108+
"""Cloud Tenants service."""
109+
return AsyncCloudTenantsService(http_client=self.http_client)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import (
3+
AsyncCreateMixin,
4+
AsyncDeleteMixin,
5+
AsyncUpdateMixin,
6+
CreateMixin,
7+
DeleteMixin,
8+
UpdateMixin,
9+
)
10+
from mpt_api_client.models import Model
11+
12+
13+
class CloudTenant(Model):
14+
"""Cloud Tenant Model."""
15+
16+
17+
class CloudTenantsServiceConfig:
18+
"""Cloud Tenants Service Configuration."""
19+
20+
_endpoint = "/public/v1/accounts/cloud-tenants"
21+
_model_class = CloudTenant
22+
_collection_key = "data"
23+
24+
25+
class CloudTenantsService(
26+
CreateMixin[CloudTenant],
27+
DeleteMixin,
28+
UpdateMixin[CloudTenant],
29+
Service[CloudTenant],
30+
CloudTenantsServiceConfig,
31+
):
32+
"""Cloud Tenants Service."""
33+
34+
35+
class AsyncCloudTenantsService(
36+
AsyncCreateMixin[CloudTenant],
37+
AsyncDeleteMixin,
38+
AsyncUpdateMixin[CloudTenant],
39+
AsyncService[CloudTenant],
40+
CloudTenantsServiceConfig,
41+
):
42+
"""Async Cloud Tenants Service."""

tests/resources/accounts/test_accounts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
ApiTokensService,
77
AsyncApiTokensService,
88
)
9+
from mpt_api_client.resources.accounts.cloud_tenants import (
10+
AsyncCloudTenantsService,
11+
CloudTenantsService,
12+
)
913
from mpt_api_client.resources.accounts.licensees import AsyncLicenseesService, LicenseesService
1014
from mpt_api_client.resources.accounts.modules import AsyncModulesService, ModulesService
1115
from mpt_api_client.resources.accounts.sellers import AsyncSellersService, SellersService
@@ -36,6 +40,7 @@ def async_accounts(async_http_client):
3640
("user_groups", UserGroupsService),
3741
("api_tokens", ApiTokensService),
3842
("modules", ModulesService),
43+
("cloud_tenants", CloudTenantsService),
3944
],
4045
)
4146
def test_accounts_properties(accounts, property_name, expected_service_class):
@@ -56,6 +61,7 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
5661
("user_groups", AsyncUserGroupsService),
5762
("api_tokens", AsyncApiTokensService),
5863
("modules", AsyncModulesService),
64+
("cloud_tenants", AsyncCloudTenantsService),
5965
],
6066
)
6167
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.accounts.cloud_tenants import (
4+
AsyncCloudTenantsService,
5+
CloudTenantsService,
6+
)
7+
8+
9+
@pytest.fixture
10+
def cloud_tenants_service(http_client):
11+
return CloudTenantsService(http_client=http_client)
12+
13+
14+
@pytest.fixture
15+
def async_cloud_tenants_service(async_http_client):
16+
return AsyncCloudTenantsService(http_client=async_http_client)
17+
18+
19+
@pytest.mark.parametrize(
20+
"method",
21+
["get", "create", "update", "delete"],
22+
)
23+
def test_cloud_tenants_mixins_present(cloud_tenants_service, method):
24+
assert hasattr(cloud_tenants_service, method)
25+
26+
27+
@pytest.mark.parametrize(
28+
"method",
29+
["get", "create", "update", "delete"],
30+
)
31+
def test_async_cloud_tenants_mixins_present(async_cloud_tenants_service, method):
32+
assert hasattr(async_cloud_tenants_service, method)

0 commit comments

Comments
 (0)