Skip to content

Commit 0784861

Browse files
stackit-pipelinemarceljk
authored andcommitted
Generate stackitmarketplace
1 parent e70d141 commit 0784861

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
from stackit.stackitmarketplace.models.catalog_product_details_vendor import (
4848
CatalogProductDetailsVendor,
4949
)
50+
from stackit.stackitmarketplace.models.catalog_product_facets_value_inner import (
51+
CatalogProductFacetsValueInner,
52+
)
5053
from stackit.stackitmarketplace.models.catalog_product_highlight import (
5154
CatalogProductHighlight,
5255
)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
from stackit.stackitmarketplace.models.catalog_product_details_vendor import (
2929
CatalogProductDetailsVendor,
3030
)
31+
from stackit.stackitmarketplace.models.catalog_product_facets_value_inner import (
32+
CatalogProductFacetsValueInner,
33+
)
3134
from stackit.stackitmarketplace.models.catalog_product_highlight import (
3235
CatalogProductHighlight,
3336
)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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
22+
from typing_extensions import Self
23+
24+
25+
class CatalogProductFacetsValueInner(BaseModel):
26+
"""
27+
CatalogProductFacetsValueInner
28+
"""
29+
30+
count: StrictInt = Field(description="The number of items associated with this facet value.")
31+
value: StrictStr = Field(description="The value of the facet.")
32+
__properties: ClassVar[List[str]] = ["count", "value"]
33+
34+
model_config = ConfigDict(
35+
populate_by_name=True,
36+
validate_assignment=True,
37+
protected_namespaces=(),
38+
)
39+
40+
def to_str(self) -> str:
41+
"""Returns the string representation of the model using alias"""
42+
return pprint.pformat(self.model_dump(by_alias=True))
43+
44+
def to_json(self) -> str:
45+
"""Returns the JSON representation of the model using alias"""
46+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47+
return json.dumps(self.to_dict())
48+
49+
@classmethod
50+
def from_json(cls, json_str: str) -> Optional[Self]:
51+
"""Create an instance of CatalogProductFacetsValueInner from a JSON string"""
52+
return cls.from_dict(json.loads(json_str))
53+
54+
def to_dict(self) -> Dict[str, Any]:
55+
"""Return the dictionary representation of the model using alias.
56+
57+
This has the following differences from calling pydantic's
58+
`self.model_dump(by_alias=True)`:
59+
60+
* `None` is only added to the output dict for nullable fields that
61+
were set at model initialization. Other fields with value `None`
62+
are ignored.
63+
"""
64+
excluded_fields: Set[str] = set([])
65+
66+
_dict = self.model_dump(
67+
by_alias=True,
68+
exclude=excluded_fields,
69+
exclude_none=True,
70+
)
71+
return _dict
72+
73+
@classmethod
74+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
75+
"""Create an instance of CatalogProductFacetsValueInner from a dict"""
76+
if obj is None:
77+
return None
78+
79+
if not isinstance(obj, dict):
80+
return cls.model_validate(obj)
81+
82+
_obj = cls.model_validate({"count": obj.get("count"), "value": obj.get("value")})
83+
return _obj

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
from pydantic import BaseModel, ConfigDict, Field, StrictStr
2222
from typing_extensions import Annotated, Self
2323

24+
from stackit.stackitmarketplace.models.catalog_product_facets_value_inner import (
25+
CatalogProductFacetsValueInner,
26+
)
2427
from stackit.stackitmarketplace.models.catalog_product_overview import (
2528
CatalogProductOverview,
2629
)
@@ -34,11 +37,14 @@ class ListCatalogProductsResponse(BaseModel):
3437
cursor: StrictStr = Field(
3538
description="A pagination cursor that represents a position in the dataset. If given, results will be returned from the item after the cursor. If not given, results will be returned from the beginning."
3639
)
40+
facets: Optional[Dict[str, List[CatalogProductFacetsValueInner]]] = Field(
41+
default=None, description="A collection of facets, where each key represents a facet category."
42+
)
3743
items: List[CatalogProductOverview]
3844
limit: Union[
3945
Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]
4046
] = Field(description="Limit for returned Objects.")
41-
__properties: ClassVar[List[str]] = ["cursor", "items", "limit"]
47+
__properties: ClassVar[List[str]] = ["cursor", "facets", "items", "limit"]
4248

4349
model_config = ConfigDict(
4450
populate_by_name=True,
@@ -77,6 +83,13 @@ def to_dict(self) -> Dict[str, Any]:
7783
exclude=excluded_fields,
7884
exclude_none=True,
7985
)
86+
# override the default output from pydantic by calling `to_dict()` of each value in facets (dict of array)
87+
_field_dict_of_array = {}
88+
if self.facets:
89+
for _key in self.facets:
90+
if self.facets[_key] is not None:
91+
_field_dict_of_array[_key] = [_item.to_dict() for _item in self.facets[_key]]
92+
_dict["facets"] = _field_dict_of_array
8093
# override the default output from pydantic by calling `to_dict()` of each item in items (list)
8194
_items = []
8295
if self.items:
@@ -98,6 +111,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98111
_obj = cls.model_validate(
99112
{
100113
"cursor": obj.get("cursor"),
114+
"facets": dict(
115+
(_k, [CatalogProductFacetsValueInner.from_dict(_item) for _item in _v] if _v is not None else None)
116+
for _k, _v in obj.get("facets", {}).items()
117+
),
101118
"items": (
102119
[CatalogProductOverview.from_dict(_item) for _item in obj["items"]]
103120
if obj.get("items") is not None

0 commit comments

Comments
 (0)