Skip to content

Commit f543726

Browse files
authored
MPT-19057: add first-level field annotations to commerce resource models (#233)
Add typed field annotations (str | None, bool | None, BaseModel | None, list[BaseModel] | None) to all commerce resource Model subclasses: - Agreement, AgreementAttachment (agreements.py, agreements_attachments.py) - Asset (assets.py) - Order (orders.py) - OrdersAsset (orders_asset.py) - OrderSubscription (orders_subscription.py) - Subscription (subscriptions.py) Fields are derived from openapi-dev.json first-level properties. id is inherited from Model and skipped. $meta is skipped (invalid identifier). camelCase API names are converted to snake_case Python attributes. All fields are | None since no fields appear in the OpenAPI required array. Add corresponding unit tests for each model covering: - primitive field round-trip (to_dict) - nested object fields resolved as BaseModel instances - optional fields absent when not in input data <!-- This is an auto-generated comment: release notes by coderabbit.ai --> Closes [MPT-19057](https://softwareone.atlassian.net/browse/MPT-19057) ## Release Notes - Added typed first-level field annotations to commerce resource model classes: Agreement, AgreementAttachment, Asset, Order, OrdersAsset, OrderSubscription, and Subscription. - All added fields are optional and use types: str | None, bool | None, BaseModel | None, or list[BaseModel] | None. - Field lists were derived from first-level properties in openapi-dev.json; API camelCase names converted to snake_case Python attributes. - Inherited id field and $meta property were excluded from annotations. - Added comprehensive docstrings describing the new attributes for each resource model. - Added unit tests for each model covering: - primitive field round-trip serialization via to_dict(), - nested object fields resolved as BaseModel instances, - absence of optional fields when not provided in input data. - Corrected test filename: replaced test_order_subcription.py with test_order_subscription.py. <!-- end of auto-generated comment: release notes by coderabbit.ai --> [MPT-19057]: https://softwareone.atlassian.net/browse/MPT-19057?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2 parents 06cfc79 + 9f357b8 commit f543726

15 files changed

+742
-55
lines changed

mpt_api_client/resources/commerce/agreements.py

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
ManagedResourceMixin,
77
)
88
from mpt_api_client.models import Model
9+
from mpt_api_client.models.model import BaseModel
910
from mpt_api_client.resources.commerce.agreements_attachments import (
1011
AgreementsAttachmentService,
1112
AsyncAgreementsAttachmentService,
@@ -19,7 +20,61 @@
1920

2021

2122
class Agreement(Model):
22-
"""Agreement resource."""
23+
"""Agreement resource.
24+
25+
Attributes:
26+
icon: URL or identifier for the agreement icon.
27+
status: Agreement status.
28+
name: Agreement name.
29+
start_date: Agreement start date.
30+
end_date: Agreement end date.
31+
listing: Reference to the listing.
32+
authorization: Reference to the authorization.
33+
vendor: Reference to the vendor account.
34+
client: Reference to the client account.
35+
price: Price information.
36+
template: Reference to the template.
37+
error: Error information.
38+
lines: List of agreement lines.
39+
assets: List of assets.
40+
subscriptions: List of subscriptions.
41+
parameters: Agreement parameters.
42+
licensee: Reference to the licensee.
43+
buyer: Reference to the buyer.
44+
seller: Reference to the seller.
45+
product: Reference to the product.
46+
external_ids: External identifiers.
47+
split: Split billing information.
48+
terms_and_conditions: List of terms and conditions.
49+
certificates: List of certificates.
50+
audit: Audit information.
51+
"""
52+
53+
icon: str | None
54+
status: str | None
55+
name: str | None
56+
start_date: str | None
57+
end_date: str | None
58+
listing: BaseModel | None
59+
authorization: BaseModel | None
60+
vendor: BaseModel | None
61+
client: BaseModel | None
62+
price: BaseModel | None
63+
template: BaseModel | None
64+
error: BaseModel | None
65+
lines: list[BaseModel] | None
66+
assets: list[BaseModel] | None
67+
subscriptions: list[BaseModel] | None
68+
parameters: BaseModel | None # noqa: WPS110
69+
licensee: BaseModel | None
70+
buyer: BaseModel | None
71+
seller: BaseModel | None
72+
product: BaseModel | None
73+
external_ids: BaseModel | None
74+
split: BaseModel | None
75+
terms_and_conditions: list[BaseModel] | None
76+
certificates: list[BaseModel] | None
77+
audit: BaseModel | None
2378

2479

2580
class AgreementsServiceConfig:

mpt_api_client/resources/commerce/agreements_attachments.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,19 @@
1414
UpdateMixin,
1515
)
1616
from mpt_api_client.models import Model
17+
from mpt_api_client.models.model import BaseModel
1718

1819

1920
class AgreementAttachment(Model):
20-
"""Agreement attachment resource."""
21+
"""Agreement attachment resource.
22+
23+
Attributes:
24+
attachment: Attachment metadata.
25+
file: File reference or URL.
26+
"""
27+
28+
attachment: BaseModel | None
29+
file: str | None # noqa: WPS110
2130

2231

2332
class AgreementsAttachmentServiceConfig:

mpt_api_client/resources/commerce/assets.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
UpdateMixin,
1111
)
1212
from mpt_api_client.models import Model
13+
from mpt_api_client.models.model import BaseModel
1314
from mpt_api_client.resources.commerce.mixins import (
1415
AsyncRenderMixin,
1516
AsyncTerminateMixin,
@@ -19,7 +20,39 @@
1920

2021

2122
class Asset(Model):
22-
"""Asset resource."""
23+
"""Asset resource.
24+
25+
Attributes:
26+
name: Asset name.
27+
status: Asset status.
28+
external_ids: External identifiers.
29+
price: Price information.
30+
template: Reference to the template.
31+
parameters: Asset parameters.
32+
terms: Reference to terms and conditions.
33+
agreement: Reference to the agreement.
34+
product: Reference to the product.
35+
price_list: Reference to the price list.
36+
listing: Reference to the listing.
37+
licensee: Reference to the licensee.
38+
lines: List of asset lines.
39+
audit: Audit information.
40+
"""
41+
42+
name: str | None
43+
status: str | None
44+
external_ids: BaseModel | None
45+
price: BaseModel | None
46+
template: BaseModel | None
47+
parameters: BaseModel | None # noqa: WPS110
48+
terms: BaseModel | None
49+
agreement: BaseModel | None
50+
product: BaseModel | None
51+
price_list: BaseModel | None
52+
listing: BaseModel | None
53+
licensee: BaseModel | None
54+
lines: list[BaseModel] | None
55+
audit: BaseModel | None
2356

2457

2558
class AssetTemplate(Model):

mpt_api_client/resources/commerce/orders.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
ManagedResourceMixin,
1010
)
1111
from mpt_api_client.models import Model, ResourceData
12+
from mpt_api_client.models.model import BaseModel
1213
from mpt_api_client.resources.commerce.mixins import (
1314
AsyncRenderMixin,
1415
AsyncTemplateMixin,
@@ -26,7 +27,69 @@
2627

2728

2829
class Order(Model):
29-
"""Order resource."""
30+
"""Order resource.
31+
32+
Attributes:
33+
type: Order type.
34+
status: Order status.
35+
notes: Order notes.
36+
comments: Order comments.
37+
default_markup_source: Default markup source.
38+
status_notes: Status notes details.
39+
template: Reference to the template.
40+
listing: Reference to the listing.
41+
authorization: Reference to the authorization.
42+
agreement: Reference to the agreement.
43+
assignee: Reference to the assignee.
44+
external_ids: External identifiers.
45+
price: Price information.
46+
lines: List of order lines.
47+
subscriptions: List of subscriptions.
48+
assets: List of assets.
49+
parameters: Order parameters.
50+
error: Error information.
51+
product: Reference to the product.
52+
client: Reference to the client account.
53+
licensee: Reference to the licensee.
54+
buyer: Reference to the buyer.
55+
seller: Reference to the seller.
56+
vendor: Reference to the vendor account.
57+
bill_to: Bill-to address.
58+
pricing_policy: Reference to the pricing policy.
59+
terms_and_conditions: List of terms and conditions.
60+
certificates: List of certificates.
61+
audit: Audit information.
62+
"""
63+
64+
type: str | None
65+
status: str | None
66+
notes: str | None
67+
comments: str | None
68+
default_markup_source: str | None
69+
status_notes: BaseModel | None
70+
template: BaseModel | None
71+
listing: BaseModel | None
72+
authorization: BaseModel | None
73+
agreement: BaseModel | None
74+
assignee: BaseModel | None
75+
external_ids: BaseModel | None
76+
price: BaseModel | None
77+
lines: list[BaseModel] | None
78+
subscriptions: list[BaseModel] | None
79+
assets: list[BaseModel] | None
80+
parameters: BaseModel | None # noqa: WPS110
81+
error: BaseModel | None
82+
product: BaseModel | None
83+
client: BaseModel | None
84+
licensee: BaseModel | None
85+
buyer: BaseModel | None
86+
seller: BaseModel | None
87+
vendor: BaseModel | None
88+
bill_to: BaseModel | None
89+
pricing_policy: BaseModel | None
90+
terms_and_conditions: list[BaseModel] | None
91+
certificates: list[BaseModel] | None
92+
audit: BaseModel | None
3093

3194

3295
class OrdersServiceConfig:

mpt_api_client/resources/commerce/orders_asset.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,34 @@
66
ManagedResourceMixin,
77
)
88
from mpt_api_client.models import Model
9+
from mpt_api_client.models.model import BaseModel
910
from mpt_api_client.resources.commerce.mixins import AsyncRenderMixin, RenderMixin
1011

1112

1213
class OrdersAsset(Model):
13-
"""Orders Asset resource."""
14+
"""Orders Asset resource.
15+
16+
Attributes:
17+
name: Asset name.
18+
status: Asset status.
19+
external_ids: External identifiers.
20+
price: Price information.
21+
template: Reference to the template.
22+
parameters: Asset parameters.
23+
terms: Reference to terms and conditions.
24+
lines: List of asset lines.
25+
audit: Audit information.
26+
"""
27+
28+
name: str | None
29+
status: str | None
30+
external_ids: BaseModel | None
31+
price: BaseModel | None
32+
template: BaseModel | None
33+
parameters: BaseModel | None # noqa: WPS110
34+
terms: BaseModel | None
35+
lines: list[BaseModel] | None
36+
audit: BaseModel | None
1437

1538

1639
class OrdersAssetServiceConfig:

mpt_api_client/resources/commerce/orders_subscription.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,45 @@
66
ManagedResourceMixin,
77
)
88
from mpt_api_client.models import Model
9+
from mpt_api_client.models.model import BaseModel
910

1011

1112
class OrderSubscription(Model):
12-
"""Order Subscription resource."""
13+
"""Order Subscription resource.
14+
15+
Attributes:
16+
name: Subscription name.
17+
status: Subscription status.
18+
start_date: Subscription start date.
19+
termination_date: Subscription termination date.
20+
commitment_date: Subscription commitment date.
21+
auto_renew: Whether the subscription auto-renews.
22+
external_ids: External identifiers.
23+
terms: Reference to terms and conditions.
24+
product: Reference to the product.
25+
parameters: Subscription parameters.
26+
agreement: Reference to the agreement.
27+
price: Price information.
28+
template: Reference to the template.
29+
lines: List of subscription lines.
30+
audit: Audit information.
31+
"""
32+
33+
name: str | None
34+
status: str | None
35+
start_date: str | None
36+
termination_date: str | None
37+
commitment_date: str | None
38+
auto_renew: bool | None
39+
external_ids: BaseModel | None
40+
terms: BaseModel | None
41+
product: BaseModel | None
42+
parameters: BaseModel | None # noqa: WPS110
43+
agreement: BaseModel | None
44+
price: BaseModel | None
45+
template: BaseModel | None
46+
lines: list[BaseModel] | None
47+
audit: BaseModel | None
1348

1449

1550
class OrderSubscriptionsServiceConfig:

mpt_api_client/resources/commerce/subscriptions.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
UpdateMixin,
1414
)
1515
from mpt_api_client.models import Model
16+
from mpt_api_client.models.model import BaseModel
1617
from mpt_api_client.resources.commerce.mixins import (
1718
AsyncRenderMixin,
1819
AsyncTerminateMixin,
@@ -22,7 +23,51 @@
2223

2324

2425
class Subscription(Model):
25-
"""Subscription resource."""
26+
"""Subscription resource.
27+
28+
Attributes:
29+
name: Subscription name.
30+
status: Subscription status.
31+
start_date: Subscription start date.
32+
termination_date: Subscription termination date.
33+
commitment_date: Subscription commitment date.
34+
split_status: Split billing status.
35+
auto_renew: Whether the subscription auto-renews.
36+
external_ids: External identifiers.
37+
terms: Reference to terms and conditions.
38+
product: Reference to the product.
39+
price: Price information.
40+
parameters: Subscription parameters.
41+
agreement: Reference to the agreement.
42+
buyer: Reference to the buyer.
43+
licensee: Reference to the licensee.
44+
seller: Reference to the seller.
45+
split: Split billing information.
46+
template: Reference to the template.
47+
lines: List of subscription lines.
48+
audit: Audit information.
49+
"""
50+
51+
name: str | None
52+
status: str | None
53+
start_date: str | None
54+
termination_date: str | None
55+
commitment_date: str | None
56+
split_status: str | None
57+
auto_renew: bool | None
58+
external_ids: BaseModel | None
59+
terms: BaseModel | None
60+
product: BaseModel | None
61+
price: BaseModel | None
62+
parameters: BaseModel | None # noqa: WPS110
63+
agreement: BaseModel | None
64+
buyer: BaseModel | None
65+
licensee: BaseModel | None
66+
seller: BaseModel | None
67+
split: BaseModel | None
68+
template: BaseModel | None
69+
lines: list[BaseModel] | None
70+
audit: BaseModel | None
2671

2772

2873
class SubscriptionsServiceConfig:

0 commit comments

Comments
 (0)