diff --git a/services/dns/src/stackit/dns/__init__.py b/services/dns/src/stackit/dns/__init__.py index 040af0b4..9a5d2410 100644 --- a/services/dns/src/stackit/dns/__init__.py +++ b/services/dns/src/stackit/dns/__init__.py @@ -65,4 +65,8 @@ from stackit.dns.models.validate_move_code_payload import ValidateMoveCodePayload from stackit.dns.models.zone import Zone from stackit.dns.models.zone_data_exchange import ZoneDataExchange +from stackit.dns.models.zone_models_import_record_model import ( + ZoneModelsImportRecordModel, +) +from stackit.dns.models.zone_models_import_zone_json import ZoneModelsImportZoneJson from stackit.dns.models.zone_response import ZoneResponse diff --git a/services/dns/src/stackit/dns/models/__init__.py b/services/dns/src/stackit/dns/models/__init__.py index df40c11f..a42fe47b 100644 --- a/services/dns/src/stackit/dns/models/__init__.py +++ b/services/dns/src/stackit/dns/models/__init__.py @@ -46,4 +46,8 @@ from stackit.dns.models.validate_move_code_payload import ValidateMoveCodePayload from stackit.dns.models.zone import Zone from stackit.dns.models.zone_data_exchange import ZoneDataExchange +from stackit.dns.models.zone_models_import_record_model import ( + ZoneModelsImportRecordModel, +) +from stackit.dns.models.zone_models_import_zone_json import ZoneModelsImportZoneJson from stackit.dns.models.zone_response import ZoneResponse diff --git a/services/dns/src/stackit/dns/models/import_record_sets_payload.py b/services/dns/src/stackit/dns/models/import_record_sets_payload.py index 876f75a8..fd97fd61 100644 --- a/services/dns/src/stackit/dns/models/import_record_sets_payload.py +++ b/services/dns/src/stackit/dns/models/import_record_sets_payload.py @@ -21,7 +21,9 @@ from pydantic import BaseModel, ConfigDict, Field from typing_extensions import Self -from stackit.dns.models.record_data_exchange import RecordDataExchange +from stackit.dns.models.zone_models_import_record_model import ( + ZoneModelsImportRecordModel, +) class ImportRecordSetsPayload(BaseModel): @@ -29,7 +31,7 @@ class ImportRecordSetsPayload(BaseModel): ImportRecordSetsPayload """ - rr_sets: Optional[List[RecordDataExchange]] = Field(default=None, alias="rrSets") + rr_sets: Optional[List[ZoneModelsImportRecordModel]] = Field(default=None, alias="rrSets") __properties: ClassVar[List[str]] = ["rrSets"] model_config = ConfigDict( @@ -90,7 +92,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { "rrSets": ( - [RecordDataExchange.from_dict(_item) for _item in obj["rrSets"]] + [ZoneModelsImportRecordModel.from_dict(_item) for _item in obj["rrSets"]] if obj.get("rrSets") is not None else None ) diff --git a/services/dns/src/stackit/dns/models/zone_models_import_record_model.py b/services/dns/src/stackit/dns/models/zone_models_import_record_model.py new file mode 100644 index 00000000..d1c3200f --- /dev/null +++ b/services/dns/src/stackit/dns/models/zone_models_import_record_model.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + STACKIT DNS API + + This api provides dns + + The version of the OpenAPI document: 1.0 + Contact: stackit-dns@mail.schwarz + 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, StrictInt, StrictStr +from typing_extensions import Self + + +class ZoneModelsImportRecordModel(BaseModel): + """ + ZoneModelsImportRecordModel + """ + + comment: Optional[StrictStr] = None + content: Optional[List[StrictStr]] = None + name: Optional[StrictStr] = None + ttl: Optional[StrictInt] = None + type: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["comment", "content", "name", "ttl", "type"] + + 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 ZoneModelsImportRecordModel 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 ZoneModelsImportRecordModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "comment": obj.get("comment"), + "content": obj.get("content"), + "name": obj.get("name"), + "ttl": obj.get("ttl"), + "type": obj.get("type"), + } + ) + return _obj diff --git a/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py b/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py new file mode 100644 index 00000000..a0a7bfe5 --- /dev/null +++ b/services/dns/src/stackit/dns/models/zone_models_import_zone_json.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + STACKIT DNS API + + This api provides dns + + The version of the OpenAPI document: 1.0 + Contact: stackit-dns@mail.schwarz + 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.dns.models.zone_models_import_record_model import ( + ZoneModelsImportRecordModel, +) + + +class ZoneModelsImportZoneJson(BaseModel): + """ + ZoneModelsImportZoneJson + """ + + rr_sets: Optional[List[ZoneModelsImportRecordModel]] = Field(default=None, alias="rrSets") + __properties: ClassVar[List[str]] = ["rrSets"] + + 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 ZoneModelsImportZoneJson 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 each item in rr_sets (list) + _items = [] + if self.rr_sets: + for _item in self.rr_sets: + if _item: + _items.append(_item.to_dict()) + _dict["rrSets"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ZoneModelsImportZoneJson from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "rrSets": ( + [ZoneModelsImportRecordModel.from_dict(_item) for _item in obj["rrSets"]] + if obj.get("rrSets") is not None + else None + ) + } + ) + return _obj