Skip to content

Commit f6f9479

Browse files
author
Robert Segal
committed
Added Accounts cloud tenants endpoints
1 parent 7b59f65 commit f6f9479

4 files changed

Lines changed: 102 additions & 2 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,5 +1,9 @@
11
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
22
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
3+
from mpt_api_client.resources.accounts.cloud_tenants import (
4+
AsyncCloudTenantsService,
5+
CloudTenantsService,
6+
)
37

48

59
class Accounts:
@@ -13,6 +17,11 @@ def accounts(self) -> AccountsService:
1317
"""Accounts service."""
1418
return AccountsService(http_client=self.http_client)
1519

20+
@property
21+
def cloud_tenants(self) -> CloudTenantsService:
22+
"""Cloud Tenants service."""
23+
return CloudTenantsService(http_client=self.http_client)
24+
1625

1726
class AsyncAccounts:
1827
"""Async Accounts MPT API Module."""
@@ -24,3 +33,8 @@ def __init__(self, *, http_client: AsyncHTTPClient):
2433
def accounts(self) -> AsyncAccountsService:
2534
"""Accounts service."""
2635
return AsyncAccountsService(http_client=self.http_client)
36+
37+
@property
38+
def cloud_tenants(self) -> AsyncCloudTenantsService:
39+
"""Cloud Tenants service."""
40+
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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
from mpt_api_client.resources.accounts.account import AccountsService, AsyncAccountsService
44
from mpt_api_client.resources.accounts.accounts import Accounts, AsyncAccounts
5+
from mpt_api_client.resources.accounts.cloud_tenants import (
6+
AsyncCloudTenantsService,
7+
CloudTenantsService,
8+
)
59

610

711
@pytest.fixture
@@ -15,7 +19,11 @@ def async_accounts(async_http_client):
1519

1620

1721
@pytest.mark.parametrize(
18-
("property_name", "expected_service_class"), [("accounts", AccountsService)]
22+
("property_name", "expected_service_class"),
23+
[
24+
("accounts", AccountsService),
25+
("cloud_tenants", CloudTenantsService),
26+
],
1927
)
2028
def test_accounts_properties(accounts, property_name, expected_service_class):
2129
"""Test that Accounts properties return correct instances."""
@@ -26,7 +34,11 @@ def test_accounts_properties(accounts, property_name, expected_service_class):
2634

2735

2836
@pytest.mark.parametrize(
29-
("property_name", "expected_service_class"), [("accounts", AsyncAccountsService)]
37+
("property_name", "expected_service_class"),
38+
[
39+
("accounts", AsyncAccountsService),
40+
("cloud_tenants", AsyncCloudTenantsService),
41+
],
3042
)
3143
def test_async_accounts_properties(async_accounts, property_name, expected_service_class):
3244
"""Test that AsyncAccounts properties return correct instances."""
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)