Skip to content

Generator: Update SDK /services/iaasalpha #375

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions services/iaasalpha/src/stackit/iaasalpha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
from stackit.iaasalpha.models.get_server_log_request import GetServerLogRequest
from stackit.iaasalpha.models.icmp_parameters import ICMPParameters
from stackit.iaasalpha.models.image import Image
from stackit.iaasalpha.models.image_checksum import ImageChecksum
from stackit.iaasalpha.models.image_config import ImageConfig
from stackit.iaasalpha.models.image_create_response import ImageCreateResponse
from stackit.iaasalpha.models.image_list_response import ImageListResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from stackit.iaasalpha.models.get_server_log_request import GetServerLogRequest
from stackit.iaasalpha.models.icmp_parameters import ICMPParameters
from stackit.iaasalpha.models.image import Image
from stackit.iaasalpha.models.image_checksum import ImageChecksum
from stackit.iaasalpha.models.image_config import ImageConfig
from stackit.iaasalpha.models.image_create_response import ImageCreateResponse
from stackit.iaasalpha.models.image_list_response import ImageListResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from typing_extensions import Annotated, Self

from stackit.iaasalpha.models.image_checksum import ImageChecksum
from stackit.iaasalpha.models.image_config import ImageConfig


Expand All @@ -39,6 +40,7 @@ class CreateImagePayload(BaseModel):
Object that represents an Image and its parameters. Used for Creating and returning (get/list).
"""

checksum: Optional[ImageChecksum] = None
config: Optional[ImageConfig] = None
created_at: Optional[datetime] = Field(
default=None, description="Date-time when resource was created.", alias="createdAt"
Expand All @@ -56,11 +58,13 @@ class CreateImagePayload(BaseModel):
description="The name for a General Object. Matches Names and also UUIDs."
)
protected: Optional[StrictBool] = None
scope: Optional[StrictStr] = Field(default=None, description="Scope of an Image.")
status: Optional[StrictStr] = Field(default=None, description="The status of an image object.")
updated_at: Optional[datetime] = Field(
default=None, description="Date-time when resource was last updated.", alias="updatedAt"
)
__properties: ClassVar[List[str]] = [
"checksum",
"config",
"createdAt",
"diskFormat",
Expand All @@ -70,6 +74,7 @@ class CreateImagePayload(BaseModel):
"minRam",
"name",
"protected",
"scope",
"status",
"updatedAt",
]
Expand Down Expand Up @@ -126,11 +131,15 @@ def to_dict(self) -> Dict[str, Any]:
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
"""
excluded_fields: Set[str] = set(
[
"checksum",
"created_at",
"id",
"scope",
"status",
"updated_at",
]
Expand All @@ -141,6 +150,9 @@ def to_dict(self) -> Dict[str, Any]:
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of checksum
if self.checksum:
_dict["checksum"] = self.checksum.to_dict()
# override the default output from pydantic by calling `to_dict()` of config
if self.config:
_dict["config"] = self.config.to_dict()
Expand All @@ -157,6 +169,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:

_obj = cls.model_validate(
{
"checksum": ImageChecksum.from_dict(obj["checksum"]) if obj.get("checksum") is not None else None,
"config": ImageConfig.from_dict(obj["config"]) if obj.get("config") is not None else None,
"createdAt": obj.get("createdAt"),
"diskFormat": obj.get("diskFormat"),
Expand All @@ -166,6 +179,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"minRam": obj.get("minRam"),
"name": obj.get("name"),
"protected": obj.get("protected"),
"scope": obj.get("scope"),
"status": obj.get("status"),
"updatedAt": obj.get("updatedAt"),
}
Expand Down
14 changes: 14 additions & 0 deletions services/iaasalpha/src/stackit/iaasalpha/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from typing_extensions import Annotated, Self

from stackit.iaasalpha.models.image_checksum import ImageChecksum
from stackit.iaasalpha.models.image_config import ImageConfig


Expand All @@ -39,6 +40,7 @@ class Image(BaseModel):
Object that represents an Image and its parameters. Used for Creating and returning (get/list).
"""

checksum: Optional[ImageChecksum] = None
config: Optional[ImageConfig] = None
created_at: Optional[datetime] = Field(
default=None, description="Date-time when resource was created.", alias="createdAt"
Expand All @@ -56,11 +58,13 @@ class Image(BaseModel):
description="The name for a General Object. Matches Names and also UUIDs."
)
protected: Optional[StrictBool] = None
scope: Optional[StrictStr] = Field(default=None, description="Scope of an Image.")
status: Optional[StrictStr] = Field(default=None, description="The status of an image object.")
updated_at: Optional[datetime] = Field(
default=None, description="Date-time when resource was last updated.", alias="updatedAt"
)
__properties: ClassVar[List[str]] = [
"checksum",
"config",
"createdAt",
"diskFormat",
Expand All @@ -70,6 +74,7 @@ class Image(BaseModel):
"minRam",
"name",
"protected",
"scope",
"status",
"updatedAt",
]
Expand Down Expand Up @@ -126,11 +131,15 @@ def to_dict(self) -> Dict[str, Any]:
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
"""
excluded_fields: Set[str] = set(
[
"checksum",
"created_at",
"id",
"scope",
"status",
"updated_at",
]
Expand All @@ -141,6 +150,9 @@ def to_dict(self) -> Dict[str, Any]:
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of checksum
if self.checksum:
_dict["checksum"] = self.checksum.to_dict()
# override the default output from pydantic by calling `to_dict()` of config
if self.config:
_dict["config"] = self.config.to_dict()
Expand All @@ -157,6 +169,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:

_obj = cls.model_validate(
{
"checksum": ImageChecksum.from_dict(obj["checksum"]) if obj.get("checksum") is not None else None,
"config": ImageConfig.from_dict(obj["config"]) if obj.get("config") is not None else None,
"createdAt": obj.get("createdAt"),
"diskFormat": obj.get("diskFormat"),
Expand All @@ -166,6 +179,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"minRam": obj.get("minRam"),
"name": obj.get("name"),
"protected": obj.get("protected"),
"scope": obj.get("scope"),
"status": obj.get("status"),
"updatedAt": obj.get("updatedAt"),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# coding: utf-8

"""
IaaS-API

This API allows you to create and modify IaaS resources.

The version of the OpenAPI document: 1alpha1
Contact: stackit-iaas@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
import re
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing_extensions import Annotated, Self


class ImageChecksum(BaseModel):
"""
Representation of an image checksum.
"""

algorithm: StrictStr = Field(description="Algorithm for the checksum of the image data.")
digest: Annotated[str, Field(strict=True)] = Field(description="Hexdigest of the checksum of the image data.")
__properties: ClassVar[List[str]] = ["algorithm", "digest"]

@field_validator("digest")
def digest_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^[0-9a-f]+$", value):
raise ValueError(r"must validate the regular expression /^[0-9a-f]+$/")
return value

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 ImageChecksum 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 ImageChecksum from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({"algorithm": obj.get("algorithm"), "digest": obj.get("digest")})
return _obj
Loading