Skip to content

Commit 4211305

Browse files
Generate dns (#44)
1 parent 695fae4 commit 4211305

File tree

5 files changed

+208
-3
lines changed

5 files changed

+208
-3
lines changed

services/dns/src/stackit/dns/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,8 @@
6565
from stackit.dns.models.validate_move_code_payload import ValidateMoveCodePayload
6666
from stackit.dns.models.zone import Zone
6767
from stackit.dns.models.zone_data_exchange import ZoneDataExchange
68+
from stackit.dns.models.zone_models_import_record_model import (
69+
ZoneModelsImportRecordModel,
70+
)
71+
from stackit.dns.models.zone_models_import_zone_json import ZoneModelsImportZoneJson
6872
from stackit.dns.models.zone_response import ZoneResponse

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,8 @@
4646
from stackit.dns.models.validate_move_code_payload import ValidateMoveCodePayload
4747
from stackit.dns.models.zone import Zone
4848
from stackit.dns.models.zone_data_exchange import ZoneDataExchange
49+
from stackit.dns.models.zone_models_import_record_model import (
50+
ZoneModelsImportRecordModel,
51+
)
52+
from stackit.dns.models.zone_models_import_zone_json import ZoneModelsImportZoneJson
4953
from stackit.dns.models.zone_response import ZoneResponse

services/dns/src/stackit/dns/models/import_record_sets_payload.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
from pydantic import BaseModel, ConfigDict, Field
2222
from typing_extensions import Self
2323

24-
from stackit.dns.models.record_data_exchange import RecordDataExchange
24+
from stackit.dns.models.zone_models_import_record_model import (
25+
ZoneModelsImportRecordModel,
26+
)
2527

2628

2729
class ImportRecordSetsPayload(BaseModel):
2830
"""
2931
ImportRecordSetsPayload
3032
"""
3133

32-
rr_sets: Optional[List[RecordDataExchange]] = Field(default=None, alias="rrSets")
34+
rr_sets: Optional[List[ZoneModelsImportRecordModel]] = Field(default=None, alias="rrSets")
3335
__properties: ClassVar[List[str]] = ["rrSets"]
3436

3537
model_config = ConfigDict(
@@ -90,7 +92,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
9092
_obj = cls.model_validate(
9193
{
9294
"rrSets": (
93-
[RecordDataExchange.from_dict(_item) for _item in obj["rrSets"]]
95+
[ZoneModelsImportRecordModel.from_dict(_item) for _item in obj["rrSets"]]
9496
if obj.get("rrSets") is not None
9597
else None
9698
)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT DNS API
5+
6+
This api provides dns
7+
8+
The version of the OpenAPI document: 1.0
9+
Contact: stackit-dns@mail.schwarz
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, StrictInt, StrictStr
22+
from typing_extensions import Self
23+
24+
25+
class ZoneModelsImportRecordModel(BaseModel):
26+
"""
27+
ZoneModelsImportRecordModel
28+
"""
29+
30+
comment: Optional[StrictStr] = None
31+
content: Optional[List[StrictStr]] = None
32+
name: Optional[StrictStr] = None
33+
ttl: Optional[StrictInt] = None
34+
type: Optional[StrictStr] = None
35+
__properties: ClassVar[List[str]] = ["comment", "content", "name", "ttl", "type"]
36+
37+
model_config = ConfigDict(
38+
populate_by_name=True,
39+
validate_assignment=True,
40+
protected_namespaces=(),
41+
)
42+
43+
def to_str(self) -> str:
44+
"""Returns the string representation of the model using alias"""
45+
return pprint.pformat(self.model_dump(by_alias=True))
46+
47+
def to_json(self) -> str:
48+
"""Returns the JSON representation of the model using alias"""
49+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50+
return json.dumps(self.to_dict())
51+
52+
@classmethod
53+
def from_json(cls, json_str: str) -> Optional[Self]:
54+
"""Create an instance of ZoneModelsImportRecordModel from a JSON string"""
55+
return cls.from_dict(json.loads(json_str))
56+
57+
def to_dict(self) -> Dict[str, Any]:
58+
"""Return the dictionary representation of the model using alias.
59+
60+
This has the following differences from calling pydantic's
61+
`self.model_dump(by_alias=True)`:
62+
63+
* `None` is only added to the output dict for nullable fields that
64+
were set at model initialization. Other fields with value `None`
65+
are ignored.
66+
"""
67+
excluded_fields: Set[str] = set([])
68+
69+
_dict = self.model_dump(
70+
by_alias=True,
71+
exclude=excluded_fields,
72+
exclude_none=True,
73+
)
74+
return _dict
75+
76+
@classmethod
77+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78+
"""Create an instance of ZoneModelsImportRecordModel from a dict"""
79+
if obj is None:
80+
return None
81+
82+
if not isinstance(obj, dict):
83+
return cls.model_validate(obj)
84+
85+
_obj = cls.model_validate(
86+
{
87+
"comment": obj.get("comment"),
88+
"content": obj.get("content"),
89+
"name": obj.get("name"),
90+
"ttl": obj.get("ttl"),
91+
"type": obj.get("type"),
92+
}
93+
)
94+
return _obj
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT DNS API
5+
6+
This api provides dns
7+
8+
The version of the OpenAPI document: 1.0
9+
Contact: stackit-dns@mail.schwarz
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
22+
from typing_extensions import Self
23+
24+
from stackit.dns.models.zone_models_import_record_model import (
25+
ZoneModelsImportRecordModel,
26+
)
27+
28+
29+
class ZoneModelsImportZoneJson(BaseModel):
30+
"""
31+
ZoneModelsImportZoneJson
32+
"""
33+
34+
rr_sets: Optional[List[ZoneModelsImportRecordModel]] = Field(default=None, alias="rrSets")
35+
__properties: ClassVar[List[str]] = ["rrSets"]
36+
37+
model_config = ConfigDict(
38+
populate_by_name=True,
39+
validate_assignment=True,
40+
protected_namespaces=(),
41+
)
42+
43+
def to_str(self) -> str:
44+
"""Returns the string representation of the model using alias"""
45+
return pprint.pformat(self.model_dump(by_alias=True))
46+
47+
def to_json(self) -> str:
48+
"""Returns the JSON representation of the model using alias"""
49+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50+
return json.dumps(self.to_dict())
51+
52+
@classmethod
53+
def from_json(cls, json_str: str) -> Optional[Self]:
54+
"""Create an instance of ZoneModelsImportZoneJson from a JSON string"""
55+
return cls.from_dict(json.loads(json_str))
56+
57+
def to_dict(self) -> Dict[str, Any]:
58+
"""Return the dictionary representation of the model using alias.
59+
60+
This has the following differences from calling pydantic's
61+
`self.model_dump(by_alias=True)`:
62+
63+
* `None` is only added to the output dict for nullable fields that
64+
were set at model initialization. Other fields with value `None`
65+
are ignored.
66+
"""
67+
excluded_fields: Set[str] = set([])
68+
69+
_dict = self.model_dump(
70+
by_alias=True,
71+
exclude=excluded_fields,
72+
exclude_none=True,
73+
)
74+
# override the default output from pydantic by calling `to_dict()` of each item in rr_sets (list)
75+
_items = []
76+
if self.rr_sets:
77+
for _item in self.rr_sets:
78+
if _item:
79+
_items.append(_item.to_dict())
80+
_dict["rrSets"] = _items
81+
return _dict
82+
83+
@classmethod
84+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85+
"""Create an instance of ZoneModelsImportZoneJson from a dict"""
86+
if obj is None:
87+
return None
88+
89+
if not isinstance(obj, dict):
90+
return cls.model_validate(obj)
91+
92+
_obj = cls.model_validate(
93+
{
94+
"rrSets": (
95+
[ZoneModelsImportRecordModel.from_dict(_item) for _item in obj["rrSets"]]
96+
if obj.get("rrSets") is not None
97+
else None
98+
)
99+
}
100+
)
101+
return _obj

0 commit comments

Comments
 (0)