Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import (
ListVendorSubscriptionsResponse,
)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import (
ListVendorSubscriptionsResponse,
)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -51,6 +53,7 @@ class CatalogProductPricingOption(BaseModel):
"description",
"highlights",
"name",
"noticePeriod",
"priceType",
"pricingPlan",
"rate",
Expand Down Expand Up @@ -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
Expand All @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading