diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/__init__.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/__init__.py index cb4ffcfe..a2c31bc1 100644 --- a/services/stackitmarketplace/src/stackit/stackitmarketplace/__init__.py +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/__init__.py @@ -37,6 +37,7 @@ from stackit.stackitmarketplace.models.approve_subscription_payload import ( ApproveSubscriptionPayload, ) +from stackit.stackitmarketplace.models.assets import Assets from stackit.stackitmarketplace.models.become_vendor import BecomeVendor from stackit.stackitmarketplace.models.catalog_pricing_option_highlight import ( CatalogPricingOptionHighlight, @@ -89,6 +90,8 @@ from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import ( ListVendorSubscriptionsResponse, ) +from stackit.stackitmarketplace.models.localized_version import LocalizedVersion +from stackit.stackitmarketplace.models.notice_period import NoticePeriod from stackit.stackitmarketplace.models.offer_type import OfferType from stackit.stackitmarketplace.models.price_type import PriceType from stackit.stackitmarketplace.models.pricing_option_unit import PricingOptionUnit @@ -99,6 +102,7 @@ from stackit.stackitmarketplace.models.resolve_customer_payload import ( ResolveCustomerPayload, ) +from stackit.stackitmarketplace.models.service_certificate import ServiceCertificate from stackit.stackitmarketplace.models.subscription_lifecycle_state import ( SubscriptionLifecycleState, ) diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/__init__.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/__init__.py index 6f537b8b..e078b229 100644 --- a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/__init__.py +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/__init__.py @@ -18,6 +18,7 @@ from stackit.stackitmarketplace.models.approve_subscription_payload import ( ApproveSubscriptionPayload, ) +from stackit.stackitmarketplace.models.assets import Assets from stackit.stackitmarketplace.models.become_vendor import BecomeVendor from stackit.stackitmarketplace.models.catalog_pricing_option_highlight import ( CatalogPricingOptionHighlight, @@ -70,6 +71,8 @@ from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import ( ListVendorSubscriptionsResponse, ) +from stackit.stackitmarketplace.models.localized_version import LocalizedVersion +from stackit.stackitmarketplace.models.notice_period import NoticePeriod from stackit.stackitmarketplace.models.offer_type import OfferType from stackit.stackitmarketplace.models.price_type import PriceType from stackit.stackitmarketplace.models.pricing_option_unit import PricingOptionUnit @@ -80,6 +83,7 @@ from stackit.stackitmarketplace.models.resolve_customer_payload import ( ResolveCustomerPayload, ) +from stackit.stackitmarketplace.models.service_certificate import ServiceCertificate from stackit.stackitmarketplace.models.subscription_lifecycle_state import ( SubscriptionLifecycleState, ) diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/assets.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/assets.py new file mode 100644 index 00000000..a8bdafd5 --- /dev/null +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/assets.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + STACKIT Marketplace API + + API to manage STACKIT Marketplace. + + The version of the OpenAPI document: 1 + Contact: marketplace@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Self + +from stackit.stackitmarketplace.models.service_certificate import ServiceCertificate + + +class Assets(BaseModel): + """ + The assets associated with the product. + """ + + service_certificate: Optional[ServiceCertificate] = Field(default=None, alias="serviceCertificate") + __properties: ClassVar[List[str]] = ["serviceCertificate"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Assets from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of service_certificate + if self.service_certificate: + _dict["serviceCertificate"] = self.service_certificate.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Assets from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "serviceCertificate": ( + ServiceCertificate.from_dict(obj["serviceCertificate"]) + if obj.get("serviceCertificate") is not None + else None + ) + } + ) + return _obj diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_detail.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_detail.py index 4414a1fc..90985f3a 100644 --- a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_detail.py +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_detail.py @@ -30,6 +30,7 @@ ) from typing_extensions import Annotated, Self +from stackit.stackitmarketplace.models.assets import Assets from stackit.stackitmarketplace.models.catalog_product_details_vendor import ( CatalogProductDetailsVendor, ) @@ -57,6 +58,7 @@ class CatalogProductDetail(BaseModel): CatalogProductDetail """ + assets: Optional[Assets] = None categories: Optional[List[StrictStr]] = Field( default=None, description="The list of categories associated to the product." ) @@ -103,6 +105,7 @@ class CatalogProductDetail(BaseModel): description="The video URL.", alias="videoUrl" ) __properties: ClassVar[List[str]] = [ + "assets", "categories", "deliveryMethod", "description", @@ -207,6 +210,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of assets + if self.assets: + _dict["assets"] = self.assets.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in highlights (list) _items = [] if self.highlights: @@ -251,6 +257,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "assets": Assets.from_dict(obj["assets"]) if obj.get("assets") is not None else None, "categories": obj.get("categories"), "deliveryMethod": obj.get("deliveryMethod"), "description": obj.get("description"), diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_pricing_option.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_pricing_option.py index 1cfb562c..b8916f21 100644 --- a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_pricing_option.py +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_pricing_option.py @@ -24,6 +24,7 @@ from stackit.stackitmarketplace.models.catalog_pricing_option_highlight import ( CatalogPricingOptionHighlight, ) +from stackit.stackitmarketplace.models.notice_period import NoticePeriod from stackit.stackitmarketplace.models.price_type import PriceType from stackit.stackitmarketplace.models.pricing_option_unit import PricingOptionUnit @@ -36,6 +37,7 @@ class CatalogProductPricingOption(BaseModel): description: StrictStr = Field(description="The pricing option description.") highlights: List[CatalogPricingOptionHighlight] = Field(description="The list of highlights.") name: StrictStr = Field(description="The pricing option name.") + notice_period: Optional[NoticePeriod] = Field(default=None, alias="noticePeriod") price_type: Optional[PriceType] = Field(default=None, alias="priceType") pricing_plan: Optional[StrictStr] = Field( default=None, description="Additional price type information.", alias="pricingPlan" @@ -51,6 +53,7 @@ class CatalogProductPricingOption(BaseModel): "description", "highlights", "name", + "noticePeriod", "priceType", "pricingPlan", "rate", @@ -104,6 +107,9 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict["highlights"] = _items + # override the default output from pydantic by calling `to_dict()` of notice_period + if self.notice_period: + _dict["noticePeriod"] = self.notice_period.to_dict() return _dict @classmethod @@ -124,6 +130,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: else None ), "name": obj.get("name"), + "noticePeriod": ( + NoticePeriod.from_dict(obj["noticePeriod"]) if obj.get("noticePeriod") is not None else None + ), "priceType": obj.get("priceType"), "pricingPlan": obj.get("pricingPlan"), "rate": obj.get("rate"), diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/localized_version.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/localized_version.py new file mode 100644 index 00000000..6c669ed9 --- /dev/null +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/localized_version.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + STACKIT Marketplace API + + API to manage STACKIT Marketplace. + + The version of the OpenAPI document: 1 + Contact: marketplace@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +import re +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, field_validator +from typing_extensions import Annotated, Self + + +class LocalizedVersion(BaseModel): + """ + The localized version (file name) of a file. + """ + + de: Optional[Annotated[str, Field(strict=True)]] = Field( + default=None, description="The file version matching the file name (localized)." + ) + en: Optional[Annotated[str, Field(strict=True)]] = Field( + default=None, description="The file version matching the file name (localized)." + ) + __properties: ClassVar[List[str]] = ["de", "en"] + + @field_validator("de") + def de_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^\d{4}_\d{2}_\d{2}_\d{3}_[a-zA-Z0-9_-]+_(DE|EN)\.$", value): + raise ValueError( + r"must validate the regular expression /^\d{4}_\d{2}_\d{2}_\d{3}_[a-zA-Z0-9_-]+_(DE|EN)\.$/" + ) + return value + + @field_validator("en") + def en_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not re.match(r"^\d{4}_\d{2}_\d{2}_\d{3}_[a-zA-Z0-9_-]+_(DE|EN)\.$", value): + raise ValueError( + r"must validate the regular expression /^\d{4}_\d{2}_\d{2}_\d{3}_[a-zA-Z0-9_-]+_(DE|EN)\.$/" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of LocalizedVersion from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LocalizedVersion from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"de": obj.get("de"), "en": obj.get("en")}) + return _obj diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/notice_period.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/notice_period.py new file mode 100644 index 00000000..7b0e1b45 --- /dev/null +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/notice_period.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + STACKIT Marketplace API + + API to manage STACKIT Marketplace. + + The version of the OpenAPI document: 1 + Contact: marketplace@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing_extensions import Self + + +class NoticePeriod(BaseModel): + """ + The notice period for a product and plan. + """ + + type: Optional[StrictStr] = Field(default=None, description="The notice period type.") + value: Optional[StrictInt] = Field( + default=None, description="The value of the corresponding type. Omitted for _SAME_DAY_." + ) + __properties: ClassVar[List[str]] = ["type", "value"] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["SAME_DAY", "DAYS", "MONTHS"]): + raise ValueError("must be one of enum values ('SAME_DAY', 'DAYS', 'MONTHS')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of NoticePeriod from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of NoticePeriod from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"type": obj.get("type"), "value": obj.get("value")}) + return _obj diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/service_certificate.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/service_certificate.py new file mode 100644 index 00000000..d2f00b8c --- /dev/null +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/service_certificate.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + STACKIT Marketplace API + + API to manage STACKIT Marketplace. + + The version of the OpenAPI document: 1 + Contact: marketplace@stackit.cloud + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 docstring might be too long + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict +from typing_extensions import Self + +from stackit.stackitmarketplace.models.localized_version import LocalizedVersion + + +class ServiceCertificate(BaseModel): + """ + The related service certificate of the (subscription) product. + """ + + version: Optional[LocalizedVersion] = None + __properties: ClassVar[List[str]] = ["version"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ServiceCertificate from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of version + if self.version: + _dict["version"] = self.version.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ServiceCertificate from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + {"version": LocalizedVersion.from_dict(obj["version"]) if obj.get("version") is not None else None} + ) + return _obj diff --git a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/subscription_product.py b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/subscription_product.py index c3f8698d..b27a03c8 100644 --- a/services/stackitmarketplace/src/stackit/stackitmarketplace/models/subscription_product.py +++ b/services/stackitmarketplace/src/stackit/stackitmarketplace/models/subscription_product.py @@ -22,6 +22,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing_extensions import Annotated, Self +from stackit.stackitmarketplace.models.assets import Assets from stackit.stackitmarketplace.models.delivery_method import DeliveryMethod from stackit.stackitmarketplace.models.price_type import PriceType from stackit.stackitmarketplace.models.product_lifecycle_state import ( @@ -34,6 +35,7 @@ class SubscriptionProduct(BaseModel): The product of a subscription """ + assets: Optional[Assets] = None delivery_method: DeliveryMethod = Field(alias="deliveryMethod") lifecycle_state: ProductLifecycleState = Field(alias="lifecycleState") price_type: PriceType = Field(alias="priceType") @@ -57,6 +59,7 @@ class SubscriptionProduct(BaseModel): description="The vendor's website.", alias="vendorWebsiteUrl" ) __properties: ClassVar[List[str]] = [ + "assets", "deliveryMethod", "lifecycleState", "priceType", @@ -156,6 +159,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of assets + if self.assets: + _dict["assets"] = self.assets.to_dict() return _dict @classmethod @@ -169,6 +175,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "assets": Assets.from_dict(obj["assets"]) if obj.get("assets") is not None else None, "deliveryMethod": obj.get("deliveryMethod"), "lifecycleState": obj.get("lifecycleState"), "priceType": obj.get("priceType"),