Skip to content

Commit 39be8b9

Browse files
author
Robert Segal
committed
Added audit event types endpoints
1 parent ca6e2ce commit 39be8b9

File tree

9 files changed

+134
-3
lines changed

9 files changed

+134
-3
lines changed

mpt_api_client/mpt_client.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
from typing import Self
22

33
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
4-
from mpt_api_client.resources import AsyncCatalog, AsyncCommerce, Catalog, Commerce
4+
from mpt_api_client.resources import (
5+
AsyncAudit,
6+
AsyncBilling,
7+
AsyncCatalog,
8+
AsyncCommerce,
9+
Audit,
10+
Billing,
11+
Catalog,
12+
Commerce,
13+
)
514

615

716
class AsyncMPTClient:
@@ -37,6 +46,16 @@ def commerce(self) -> AsyncCommerce:
3746
"""Commerce MPT API Client."""
3847
return AsyncCommerce(http_client=self.http_client)
3948

49+
@property
50+
def audit(self) -> AsyncAudit:
51+
"""Audit MPT API Client."""
52+
return AsyncAudit(http_client=self.http_client)
53+
54+
@property
55+
def billing(self) -> AsyncBilling:
56+
"""Billing MPT API Client."""
57+
return AsyncBilling(http_client=self.http_client)
58+
4059

4160
class MPTClient:
4261
"""MPT API Client."""
@@ -75,3 +94,13 @@ def commerce(self) -> Commerce:
7594
def catalog(self) -> Catalog:
7695
"""Catalog MPT API Client."""
7796
return Catalog(http_client=self.http_client)
97+
98+
@property
99+
def audit(self) -> Audit:
100+
"""Audit MPT API Client."""
101+
return Audit(http_client=self.http_client)
102+
103+
@property
104+
def billing(self) -> Billing:
105+
"""Billing MPT API Client."""
106+
return Billing(http_client=self.http_client)
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
from mpt_api_client.resources.audit import AsyncAudit, Audit
2+
from mpt_api_client.resources.billing import AsyncBilling, Billing
13
from mpt_api_client.resources.catalog import AsyncCatalog, Catalog
24
from mpt_api_client.resources.commerce import AsyncCommerce, Commerce
35

4-
__all__ = ["AsyncCatalog", "AsyncCommerce", "Catalog", "Commerce"] # noqa: WPS410
6+
__all__ = [ # noqa: WPS410
7+
"AsyncAudit",
8+
"AsyncBilling",
9+
"AsyncCatalog",
10+
"AsyncCommerce",
11+
"Audit",
12+
"Billing",
13+
"Catalog",
14+
"Commerce",
15+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from mpt_api_client.resources.audit.audit import AsyncAudit, Audit
2+
3+
__all__ = ["AsyncAudit", "Audit"] # noqa: WPS410

mpt_api_client/resources/audit/audit.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
2+
from mpt_api_client.resources.audit.event_types import (
3+
AsyncEventTypesService,
4+
EventTypesService,
5+
)
26
from mpt_api_client.resources.audit.records import AsyncRecordsService, RecordsService
37

48

@@ -13,6 +17,11 @@ def records(self) -> RecordsService:
1317
"""Records service."""
1418
return RecordsService(http_client=self.http_client)
1519

20+
@property
21+
def event_types(self) -> EventTypesService:
22+
"""Event Types service."""
23+
return EventTypesService(http_client=self.http_client)
24+
1625

1726
class AsyncAudit:
1827
"""Async Audit MPT API Module."""
@@ -24,3 +33,8 @@ def __init__(self, *, http_client: AsyncHTTPClient):
2433
def records(self) -> AsyncRecordsService:
2534
"""Records service."""
2635
return AsyncRecordsService(http_client=self.http_client)
36+
37+
@property
38+
def event_types(self) -> AsyncEventTypesService:
39+
"""Event Types service."""
40+
return AsyncEventTypesService(http_client=self.http_client)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from mpt_api_client.http import AsyncService, Service
2+
from mpt_api_client.http.mixins import (
3+
AsyncUpdateMixin,
4+
UpdateMixin,
5+
)
6+
from mpt_api_client.models import Model
7+
8+
9+
class EventType(Model):
10+
"""Event Type resource."""
11+
12+
13+
class EventTypesServiceConfig:
14+
"""Event Types service configuration."""
15+
16+
_endpoint = "/public/v1/audit/event-types"
17+
_model_class = EventType
18+
_collection_key = "data"
19+
20+
21+
class EventTypesService(UpdateMixin[EventType], Service[EventType], EventTypesServiceConfig):
22+
"""Event Types service."""
23+
24+
25+
class AsyncEventTypesService(
26+
AsyncUpdateMixin[EventType], AsyncService[EventType], EventTypesServiceConfig
27+
):
28+
"""Async Event Types service."""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from mpt_api_client.resources.billing.billing import AsyncBilling, Billing
2+
3+
__all__ = ["AsyncBilling", "Billing"] # noqa: WPS410

tests/resources/audit/test_audit.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
from mpt_api_client.resources.audit.audit import AsyncAudit, Audit
4+
from mpt_api_client.resources.audit.event_types import AsyncEventTypesService, EventTypesService
45
from mpt_api_client.resources.audit.records import AsyncRecordsService, RecordsService
56

67

@@ -18,6 +19,7 @@ def async_audit(async_http_client):
1819
("property_name", "expected_service_class"),
1920
[
2021
("records", RecordsService),
22+
("event_types", EventTypesService),
2123
],
2224
)
2325
def test_audit_properties(audit, property_name, expected_service_class):
@@ -32,6 +34,7 @@ def test_audit_properties(audit, property_name, expected_service_class):
3234
("property_name", "expected_service_class"),
3335
[
3436
("records", AsyncRecordsService),
37+
("event_types", AsyncEventTypesService),
3538
],
3639
)
3740
def test_async_audit_properties(async_audit, property_name, expected_service_class):
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
3+
from mpt_api_client.resources.audit.event_types import AsyncEventTypesService, EventTypesService
4+
5+
6+
@pytest.fixture
7+
def event_types_service(http_client):
8+
return EventTypesService(http_client=http_client)
9+
10+
11+
@pytest.fixture
12+
def async_event_types_service(async_http_client):
13+
return AsyncEventTypesService(http_client=async_http_client)
14+
15+
16+
@pytest.mark.parametrize("method", ["get", "update"])
17+
def test_mixins_present(event_types_service, method):
18+
assert hasattr(event_types_service, method)
19+
20+
21+
@pytest.mark.parametrize("method", ["get", "update"])
22+
def test_async_mixins_present(async_event_types_service, method):
23+
assert hasattr(async_event_types_service, method)

tests/test_mpt.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,31 @@
22

33
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
44
from mpt_api_client.mpt_client import AsyncMPTClient, MPTClient
5-
from mpt_api_client.resources import AsyncCatalog, AsyncCommerce, Catalog, Commerce
5+
from mpt_api_client.resources import (
6+
AsyncAudit,
7+
AsyncBilling,
8+
AsyncCatalog,
9+
AsyncCommerce,
10+
Audit,
11+
Billing,
12+
Catalog,
13+
Commerce,
14+
)
615
from tests.conftest import API_TOKEN, API_URL
716

817

918
def test_mpt_client() -> None:
1019
mpt = MPTClient.from_config(base_url=API_URL, api_token=API_TOKEN)
1120
commerce = mpt.commerce
1221
catalog = mpt.catalog
22+
audit = mpt.audit
23+
billing = mpt.billing
1324

1425
assert isinstance(mpt, MPTClient)
1526
assert isinstance(commerce, Commerce)
1627
assert isinstance(catalog, Catalog)
28+
assert isinstance(audit, Audit)
29+
assert isinstance(billing, Billing)
1730

1831

1932
def test_mpt_client_env(monkeypatch: pytest.MonkeyPatch) -> None:
@@ -30,10 +43,14 @@ def test_async_mpt_client() -> None:
3043
mpt = AsyncMPTClient.from_config(base_url=API_URL, api_token=API_TOKEN)
3144
commerce = mpt.commerce
3245
catalog = mpt.catalog
46+
audit = mpt.audit
47+
billing = mpt.billing
3348

3449
assert isinstance(mpt, AsyncMPTClient)
3550
assert isinstance(commerce, AsyncCommerce)
3651
assert isinstance(catalog, AsyncCatalog)
52+
assert isinstance(audit, AsyncAudit)
53+
assert isinstance(billing, AsyncBilling)
3754

3855

3956
def test_async_mpt_client_env(monkeypatch: pytest.MonkeyPatch) -> None:

0 commit comments

Comments
 (0)