Skip to content

Commit a8d8c17

Browse files
Generate iaasalpha (#404)
1 parent 82b9635 commit a8d8c17

File tree

5 files changed

+121
-0
lines changed

5 files changed

+121
-0
lines changed

services/iaasalpha/src/stackit/iaasalpha/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
from stackit.iaasalpha.models.get_server_log_request import GetServerLogRequest
8080
from stackit.iaasalpha.models.icmp_parameters import ICMPParameters
8181
from stackit.iaasalpha.models.image import Image
82+
from stackit.iaasalpha.models.image_checksum import ImageChecksum
8283
from stackit.iaasalpha.models.image_config import ImageConfig
8384
from stackit.iaasalpha.models.image_create_response import ImageCreateResponse
8485
from stackit.iaasalpha.models.image_list_response import ImageListResponse

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from stackit.iaasalpha.models.get_server_log_request import GetServerLogRequest
6161
from stackit.iaasalpha.models.icmp_parameters import ICMPParameters
6262
from stackit.iaasalpha.models.image import Image
63+
from stackit.iaasalpha.models.image_checksum import ImageChecksum
6364
from stackit.iaasalpha.models.image_config import ImageConfig
6465
from stackit.iaasalpha.models.image_create_response import ImageCreateResponse
6566
from stackit.iaasalpha.models.image_list_response import ImageListResponse

services/iaasalpha/src/stackit/iaasalpha/models/create_image_payload.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
)
3232
from typing_extensions import Annotated, Self
3333

34+
from stackit.iaasalpha.models.image_checksum import ImageChecksum
3435
from stackit.iaasalpha.models.image_config import ImageConfig
3536

3637

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

43+
checksum: Optional[ImageChecksum] = None
4244
config: Optional[ImageConfig] = None
4345
created_at: Optional[datetime] = Field(
4446
default=None, description="Date-time when resource was created.", alias="createdAt"
@@ -56,11 +58,13 @@ class CreateImagePayload(BaseModel):
5658
description="The name for a General Object. Matches Names and also UUIDs."
5759
)
5860
protected: Optional[StrictBool] = None
61+
scope: Optional[StrictStr] = Field(default=None, description="Scope of an Image.")
5962
status: Optional[StrictStr] = Field(default=None, description="The status of an image object.")
6063
updated_at: Optional[datetime] = Field(
6164
default=None, description="Date-time when resource was last updated.", alias="updatedAt"
6265
)
6366
__properties: ClassVar[List[str]] = [
67+
"checksum",
6468
"config",
6569
"createdAt",
6670
"diskFormat",
@@ -70,6 +74,7 @@ class CreateImagePayload(BaseModel):
7074
"minRam",
7175
"name",
7276
"protected",
77+
"scope",
7378
"status",
7479
"updatedAt",
7580
]
@@ -126,11 +131,15 @@ def to_dict(self) -> Dict[str, Any]:
126131
* OpenAPI `readOnly` fields are excluded.
127132
* OpenAPI `readOnly` fields are excluded.
128133
* OpenAPI `readOnly` fields are excluded.
134+
* OpenAPI `readOnly` fields are excluded.
135+
* OpenAPI `readOnly` fields are excluded.
129136
"""
130137
excluded_fields: Set[str] = set(
131138
[
139+
"checksum",
132140
"created_at",
133141
"id",
142+
"scope",
134143
"status",
135144
"updated_at",
136145
]
@@ -141,6 +150,9 @@ def to_dict(self) -> Dict[str, Any]:
141150
exclude=excluded_fields,
142151
exclude_none=True,
143152
)
153+
# override the default output from pydantic by calling `to_dict()` of checksum
154+
if self.checksum:
155+
_dict["checksum"] = self.checksum.to_dict()
144156
# override the default output from pydantic by calling `to_dict()` of config
145157
if self.config:
146158
_dict["config"] = self.config.to_dict()
@@ -157,6 +169,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
157169

158170
_obj = cls.model_validate(
159171
{
172+
"checksum": ImageChecksum.from_dict(obj["checksum"]) if obj.get("checksum") is not None else None,
160173
"config": ImageConfig.from_dict(obj["config"]) if obj.get("config") is not None else None,
161174
"createdAt": obj.get("createdAt"),
162175
"diskFormat": obj.get("diskFormat"),
@@ -166,6 +179,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
166179
"minRam": obj.get("minRam"),
167180
"name": obj.get("name"),
168181
"protected": obj.get("protected"),
182+
"scope": obj.get("scope"),
169183
"status": obj.get("status"),
170184
"updatedAt": obj.get("updatedAt"),
171185
}

services/iaasalpha/src/stackit/iaasalpha/models/image.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
)
3232
from typing_extensions import Annotated, Self
3333

34+
from stackit.iaasalpha.models.image_checksum import ImageChecksum
3435
from stackit.iaasalpha.models.image_config import ImageConfig
3536

3637

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

43+
checksum: Optional[ImageChecksum] = None
4244
config: Optional[ImageConfig] = None
4345
created_at: Optional[datetime] = Field(
4446
default=None, description="Date-time when resource was created.", alias="createdAt"
@@ -56,11 +58,13 @@ class Image(BaseModel):
5658
description="The name for a General Object. Matches Names and also UUIDs."
5759
)
5860
protected: Optional[StrictBool] = None
61+
scope: Optional[StrictStr] = Field(default=None, description="Scope of an Image.")
5962
status: Optional[StrictStr] = Field(default=None, description="The status of an image object.")
6063
updated_at: Optional[datetime] = Field(
6164
default=None, description="Date-time when resource was last updated.", alias="updatedAt"
6265
)
6366
__properties: ClassVar[List[str]] = [
67+
"checksum",
6468
"config",
6569
"createdAt",
6670
"diskFormat",
@@ -70,6 +74,7 @@ class Image(BaseModel):
7074
"minRam",
7175
"name",
7276
"protected",
77+
"scope",
7378
"status",
7479
"updatedAt",
7580
]
@@ -126,11 +131,15 @@ def to_dict(self) -> Dict[str, Any]:
126131
* OpenAPI `readOnly` fields are excluded.
127132
* OpenAPI `readOnly` fields are excluded.
128133
* OpenAPI `readOnly` fields are excluded.
134+
* OpenAPI `readOnly` fields are excluded.
135+
* OpenAPI `readOnly` fields are excluded.
129136
"""
130137
excluded_fields: Set[str] = set(
131138
[
139+
"checksum",
132140
"created_at",
133141
"id",
142+
"scope",
134143
"status",
135144
"updated_at",
136145
]
@@ -141,6 +150,9 @@ def to_dict(self) -> Dict[str, Any]:
141150
exclude=excluded_fields,
142151
exclude_none=True,
143152
)
153+
# override the default output from pydantic by calling `to_dict()` of checksum
154+
if self.checksum:
155+
_dict["checksum"] = self.checksum.to_dict()
144156
# override the default output from pydantic by calling `to_dict()` of config
145157
if self.config:
146158
_dict["config"] = self.config.to_dict()
@@ -157,6 +169,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
157169

158170
_obj = cls.model_validate(
159171
{
172+
"checksum": ImageChecksum.from_dict(obj["checksum"]) if obj.get("checksum") is not None else None,
160173
"config": ImageConfig.from_dict(obj["config"]) if obj.get("config") is not None else None,
161174
"createdAt": obj.get("createdAt"),
162175
"diskFormat": obj.get("diskFormat"),
@@ -166,6 +179,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
166179
"minRam": obj.get("minRam"),
167180
"name": obj.get("name"),
168181
"protected": obj.get("protected"),
182+
"scope": obj.get("scope"),
169183
"status": obj.get("status"),
170184
"updatedAt": obj.get("updatedAt"),
171185
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# coding: utf-8
2+
3+
"""
4+
IaaS-API
5+
6+
This API allows you to create and modify IaaS resources.
7+
8+
The version of the OpenAPI document: 1alpha1
9+
Contact: stackit-iaas@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+
import re
20+
from typing import Any, ClassVar, Dict, List, Optional, Set
21+
22+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
23+
from typing_extensions import Annotated, Self
24+
25+
26+
class ImageChecksum(BaseModel):
27+
"""
28+
Representation of an image checksum.
29+
"""
30+
31+
algorithm: StrictStr = Field(description="Algorithm for the checksum of the image data.")
32+
digest: Annotated[str, Field(strict=True)] = Field(description="Hexdigest of the checksum of the image data.")
33+
__properties: ClassVar[List[str]] = ["algorithm", "digest"]
34+
35+
@field_validator("digest")
36+
def digest_validate_regular_expression(cls, value):
37+
"""Validates the regular expression"""
38+
if not re.match(r"^[0-9a-f]+$", value):
39+
raise ValueError(r"must validate the regular expression /^[0-9a-f]+$/")
40+
return value
41+
42+
model_config = ConfigDict(
43+
populate_by_name=True,
44+
validate_assignment=True,
45+
protected_namespaces=(),
46+
)
47+
48+
def to_str(self) -> str:
49+
"""Returns the string representation of the model using alias"""
50+
return pprint.pformat(self.model_dump(by_alias=True))
51+
52+
def to_json(self) -> str:
53+
"""Returns the JSON representation of the model using alias"""
54+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
55+
return json.dumps(self.to_dict())
56+
57+
@classmethod
58+
def from_json(cls, json_str: str) -> Optional[Self]:
59+
"""Create an instance of ImageChecksum from a JSON string"""
60+
return cls.from_dict(json.loads(json_str))
61+
62+
def to_dict(self) -> Dict[str, Any]:
63+
"""Return the dictionary representation of the model using alias.
64+
65+
This has the following differences from calling pydantic's
66+
`self.model_dump(by_alias=True)`:
67+
68+
* `None` is only added to the output dict for nullable fields that
69+
were set at model initialization. Other fields with value `None`
70+
are ignored.
71+
"""
72+
excluded_fields: Set[str] = set([])
73+
74+
_dict = self.model_dump(
75+
by_alias=True,
76+
exclude=excluded_fields,
77+
exclude_none=True,
78+
)
79+
return _dict
80+
81+
@classmethod
82+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83+
"""Create an instance of ImageChecksum from a dict"""
84+
if obj is None:
85+
return None
86+
87+
if not isinstance(obj, dict):
88+
return cls.model_validate(obj)
89+
90+
_obj = cls.model_validate({"algorithm": obj.get("algorithm"), "digest": obj.get("digest")})
91+
return _obj

0 commit comments

Comments
 (0)