Skip to content

Commit 4c844d3

Browse files
Generate stackitmarketplace
1 parent c7340e3 commit 4c844d3

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed

services/stackitmarketplace/src/stackit/stackitmarketplace/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import (
9090
ListVendorSubscriptionsResponse,
9191
)
92+
from stackit.stackitmarketplace.models.notice_period import NoticePeriod
9293
from stackit.stackitmarketplace.models.offer_type import OfferType
9394
from stackit.stackitmarketplace.models.price_type import PriceType
9495
from stackit.stackitmarketplace.models.pricing_option_unit import PricingOptionUnit

services/stackitmarketplace/src/stackit/stackitmarketplace/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import (
7171
ListVendorSubscriptionsResponse,
7272
)
73+
from stackit.stackitmarketplace.models.notice_period import NoticePeriod
7374
from stackit.stackitmarketplace.models.offer_type import OfferType
7475
from stackit.stackitmarketplace.models.price_type import PriceType
7576
from stackit.stackitmarketplace.models.pricing_option_unit import PricingOptionUnit

services/stackitmarketplace/src/stackit/stackitmarketplace/models/catalog_product_pricing_option.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from stackit.stackitmarketplace.models.catalog_pricing_option_highlight import (
2525
CatalogPricingOptionHighlight,
2626
)
27+
from stackit.stackitmarketplace.models.notice_period import NoticePeriod
2728
from stackit.stackitmarketplace.models.price_type import PriceType
2829
from stackit.stackitmarketplace.models.pricing_option_unit import PricingOptionUnit
2930

@@ -36,6 +37,7 @@ class CatalogProductPricingOption(BaseModel):
3637
description: StrictStr = Field(description="The pricing option description.")
3738
highlights: List[CatalogPricingOptionHighlight] = Field(description="The list of highlights.")
3839
name: StrictStr = Field(description="The pricing option name.")
40+
notice_period: Optional[NoticePeriod] = Field(default=None, alias="noticePeriod")
3941
price_type: Optional[PriceType] = Field(default=None, alias="priceType")
4042
pricing_plan: Optional[StrictStr] = Field(
4143
default=None, description="Additional price type information.", alias="pricingPlan"
@@ -51,6 +53,7 @@ class CatalogProductPricingOption(BaseModel):
5153
"description",
5254
"highlights",
5355
"name",
56+
"noticePeriod",
5457
"priceType",
5558
"pricingPlan",
5659
"rate",
@@ -104,6 +107,9 @@ def to_dict(self) -> Dict[str, Any]:
104107
if _item:
105108
_items.append(_item.to_dict())
106109
_dict["highlights"] = _items
110+
# override the default output from pydantic by calling `to_dict()` of notice_period
111+
if self.notice_period:
112+
_dict["noticePeriod"] = self.notice_period.to_dict()
107113
return _dict
108114

109115
@classmethod
@@ -124,6 +130,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
124130
else None
125131
),
126132
"name": obj.get("name"),
133+
"noticePeriod": (
134+
NoticePeriod.from_dict(obj["noticePeriod"]) if obj.get("noticePeriod") is not None else None
135+
),
127136
"priceType": obj.get("priceType"),
128137
"pricingPlan": obj.get("pricingPlan"),
129138
"rate": obj.get("rate"),
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Marketplace API
5+
6+
API to manage STACKIT Marketplace.
7+
8+
The version of the OpenAPI document: 1
9+
Contact: marketplace@stackit.cloud
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501 docstring might be too long
14+
15+
from __future__ import annotations
16+
17+
import json
18+
import pprint
19+
from typing import Any, ClassVar, Dict, List, Optional, Set
20+
21+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
22+
from typing_extensions import Self
23+
24+
25+
class NoticePeriod(BaseModel):
26+
"""
27+
The notice period for a product and plan.
28+
"""
29+
30+
type: Optional[StrictStr] = Field(default=None, description="The notice period type.")
31+
value: Optional[StrictInt] = Field(
32+
default=None, description="The value of the corresponding type. Omitted for _SAME_DAY_."
33+
)
34+
__properties: ClassVar[List[str]] = ["type", "value"]
35+
36+
@field_validator("type")
37+
def type_validate_enum(cls, value):
38+
"""Validates the enum"""
39+
if value is None:
40+
return value
41+
42+
if value not in set(["SAME_DAY", "DAYS", "MONTHS"]):
43+
raise ValueError("must be one of enum values ('SAME_DAY', 'DAYS', 'MONTHS')")
44+
return value
45+
46+
model_config = ConfigDict(
47+
populate_by_name=True,
48+
validate_assignment=True,
49+
protected_namespaces=(),
50+
)
51+
52+
def to_str(self) -> str:
53+
"""Returns the string representation of the model using alias"""
54+
return pprint.pformat(self.model_dump(by_alias=True))
55+
56+
def to_json(self) -> str:
57+
"""Returns the JSON representation of the model using alias"""
58+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
59+
return json.dumps(self.to_dict())
60+
61+
@classmethod
62+
def from_json(cls, json_str: str) -> Optional[Self]:
63+
"""Create an instance of NoticePeriod from a JSON string"""
64+
return cls.from_dict(json.loads(json_str))
65+
66+
def to_dict(self) -> Dict[str, Any]:
67+
"""Return the dictionary representation of the model using alias.
68+
69+
This has the following differences from calling pydantic's
70+
`self.model_dump(by_alias=True)`:
71+
72+
* `None` is only added to the output dict for nullable fields that
73+
were set at model initialization. Other fields with value `None`
74+
are ignored.
75+
"""
76+
excluded_fields: Set[str] = set([])
77+
78+
_dict = self.model_dump(
79+
by_alias=True,
80+
exclude=excluded_fields,
81+
exclude_none=True,
82+
)
83+
return _dict
84+
85+
@classmethod
86+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87+
"""Create an instance of NoticePeriod from a dict"""
88+
if obj is None:
89+
return None
90+
91+
if not isinstance(obj, dict):
92+
return cls.model_validate(obj)
93+
94+
_obj = cls.model_validate({"type": obj.get("type"), "value": obj.get("value")})
95+
return _obj

0 commit comments

Comments
 (0)