Skip to content

Generator: Update SDK /services/dns #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 8, 2024
Merged
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
4 changes: 4 additions & 0 deletions services/dns/src/stackit/dns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions services/dns/src/stackit/dns/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
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):
"""
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(
Expand Down Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
101 changes: 101 additions & 0 deletions services/dns/src/stackit/dns/models/zone_models_import_zone_json.py
Original file line number Diff line number Diff line change
@@ -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
Loading