Skip to content
Open
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
2 changes: 1 addition & 1 deletion services/iaas/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b155367fdf354045bbd1d2403a19bf4e363e76a3
20c75d1fe743052968e3837f1eb1cf9fc84f40cd
4 changes: 4 additions & 0 deletions services/iaas/src/stackit/iaas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"CreateVolumePayload",
"DestinationCIDRv4",
"DestinationCIDRv6",
"DestinationPrefixList",
"Error",
"GetServerLog200Response",
"ICMPParameters",
Expand Down Expand Up @@ -305,6 +306,9 @@
from stackit.iaas.models.destination_cidrv6 import (
DestinationCIDRv6 as DestinationCIDRv6,
)
from stackit.iaas.models.destination_prefix_list import (
DestinationPrefixList as DestinationPrefixList,
)
from stackit.iaas.models.error import Error as Error
from stackit.iaas.models.get_server_log200_response import (
GetServerLog200Response as GetServerLog200Response,
Expand Down
1 change: 1 addition & 0 deletions services/iaas/src/stackit/iaas/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
from stackit.iaas.models.create_volume_payload import CreateVolumePayload
from stackit.iaas.models.destination_cidrv4 import DestinationCIDRv4
from stackit.iaas.models.destination_cidrv6 import DestinationCIDRv6
from stackit.iaas.models.destination_prefix_list import DestinationPrefixList
from stackit.iaas.models.error import Error
from stackit.iaas.models.get_server_log200_response import GetServerLog200Response
from stackit.iaas.models.icmp_parameters import ICMPParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
from typing import Any, ClassVar, Dict, List, Optional, Set
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBool,
StrictInt,
StrictStr,
field_validator,
)
from pydantic_core import to_jsonable_python
from typing_extensions import Annotated, Self

Expand All @@ -40,6 +48,7 @@ class CreateSnapshotPayload(BaseModel):
description: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(
default=None, description="Description Object. Allows string up to 255 Characters."
)
encrypted: Optional[StrictBool] = Field(default=None, description="Indicates if a volume is encrypted.")
id: Optional[UUID] = Field(default=None, description="Universally Unique Identifier (UUID).")
labels: Optional[Dict[str, Any]] = Field(
default=None,
Expand All @@ -61,6 +70,7 @@ class CreateSnapshotPayload(BaseModel):
"availabilityZone",
"createdAt",
"description",
"encrypted",
"id",
"labels",
"name",
Expand Down Expand Up @@ -171,11 +181,13 @@ 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.
"""
excluded_fields: Set[str] = set(
[
"availability_zone",
"created_at",
"encrypted",
"id",
"size",
"status",
Expand Down Expand Up @@ -204,6 +216,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"availabilityZone": obj.get("availabilityZone"),
"createdAt": obj.get("createdAt"),
"description": obj.get("description"),
"encrypted": obj.get("encrypted"),
"id": obj.get("id"),
"labels": obj.get("labels"),
"name": obj.get("name"),
Expand Down
105 changes: 105 additions & 0 deletions services/iaas/src/stackit/iaas/models/destination_prefix_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# coding: utf-8

"""
STACKIT IaaS API

This API allows you to create and modify IaaS resources.

The version of the OpenAPI document: 2
Contact: stackit-iaas@mail.schwarz
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
import pprint
import re # noqa: F401
from typing import Any, ClassVar, Dict, List, Optional, Set
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from pydantic_core import to_jsonable_python
from typing_extensions import Self


class DestinationPrefixList(BaseModel):
"""
Prefix List destination reference object.
""" # noqa: E501

type: StrictStr
value: UUID = Field(description="Universally Unique Identifier (UUID).")
__properties: ClassVar[List[str]] = ["type", "value"]

@field_validator("type")
def type_validate_enum(cls, value):
"""Validates the enum"""
if value not in set(["prefixlist"]):
raise ValueError("must be one of enum values ('prefixlist')")
return value

@field_validator("value")
def value_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not isinstance(value, str):
value = str(value)

if not re.match(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", value):
raise ValueError(
r"must validate the regular expression /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/"
)
return value

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=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"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of DestinationPrefixList 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 DestinationPrefixList from a dict"""
if obj is None:
return None

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

_obj = cls.model_validate({"type": obj.get("type"), "value": obj.get("value")})
return _obj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ImageFromVolumePayload(BaseModel):
description="Object that represents a disk format. Possible values: `raw`, `qcow2`, `iso`.", alias="diskFormat"
)
force: Optional[StrictBool] = Field(
default=False, description="When true the image is force created from a volume is currently being used."
default=False, description="When true the image is force created from a volume that is currently being used."
)
name: Annotated[str, Field(strict=True, max_length=127)] = Field(
description="The name for a General Object. Matches Names and also UUIDs."
Expand Down
28 changes: 21 additions & 7 deletions services/iaas/src/stackit/iaas/models/route_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

from stackit.iaas.models.destination_cidrv4 import DestinationCIDRv4
from stackit.iaas.models.destination_cidrv6 import DestinationCIDRv6
from stackit.iaas.models.destination_prefix_list import DestinationPrefixList

ROUTEDESTINATION_ONE_OF_SCHEMAS = ["DestinationCIDRv4", "DestinationCIDRv6"]
ROUTEDESTINATION_ONE_OF_SCHEMAS = ["DestinationCIDRv4", "DestinationCIDRv6", "DestinationPrefixList"]


class RouteDestination(BaseModel):
Expand All @@ -41,8 +42,10 @@ class RouteDestination(BaseModel):
oneof_schema_1_validator: Optional[DestinationCIDRv4] = None
# data type: DestinationCIDRv6
oneof_schema_2_validator: Optional[DestinationCIDRv6] = None
actual_instance: Optional[Union[DestinationCIDRv4, DestinationCIDRv6]] = None
one_of_schemas: Set[str] = {"DestinationCIDRv4", "DestinationCIDRv6"}
# data type: DestinationPrefixList
oneof_schema_3_validator: Optional[DestinationPrefixList] = None
actual_instance: Optional[Union[DestinationCIDRv4, DestinationCIDRv6, DestinationPrefixList]] = None
one_of_schemas: Set[str] = {"DestinationCIDRv4", "DestinationCIDRv6", "DestinationPrefixList"}

model_config = ConfigDict(
validate_assignment=True,
Expand Down Expand Up @@ -76,10 +79,15 @@ def actual_instance_must_validate_oneof(cls, v):
error_messages.append(f"Error! Input type `{type(v)}` is not `DestinationCIDRv6`")
else:
match += 1
# validate data type: DestinationPrefixList
if not isinstance(v, DestinationPrefixList):
error_messages.append(f"Error! Input type `{type(v)}` is not `DestinationPrefixList`")
else:
match += 1
if match == 0:
# no match
raise ValueError(
"No match found when setting `actual_instance` in RouteDestination with oneOf schemas: DestinationCIDRv4, DestinationCIDRv6. Details: "
"No match found when setting `actual_instance` in RouteDestination with oneOf schemas: DestinationCIDRv4, DestinationCIDRv6, DestinationPrefixList. Details: "
+ ", ".join(error_messages)
)
else:
Expand Down Expand Up @@ -108,17 +116,23 @@ def from_json(cls, json_str: str) -> Self:
match += 1
except (ValidationError, ValueError) as e:
error_messages.append(str(e))
# deserialize data into DestinationPrefixList
try:
instance.actual_instance = DestinationPrefixList.from_json(json_str)
match += 1
except (ValidationError, ValueError) as e:
error_messages.append(str(e))

if match > 1:
# more than 1 match
raise ValueError(
"Multiple matches found when deserializing the JSON string into RouteDestination with oneOf schemas: DestinationCIDRv4, DestinationCIDRv6. Details: "
"Multiple matches found when deserializing the JSON string into RouteDestination with oneOf schemas: DestinationCIDRv4, DestinationCIDRv6, DestinationPrefixList. Details: "
+ ", ".join(error_messages)
)
elif match == 0:
# no match
raise ValueError(
"No match found when deserializing the JSON string into RouteDestination with oneOf schemas: DestinationCIDRv4, DestinationCIDRv6. Details: "
"No match found when deserializing the JSON string into RouteDestination with oneOf schemas: DestinationCIDRv4, DestinationCIDRv6, DestinationPrefixList. Details: "
+ ", ".join(error_messages)
)
else:
Expand All @@ -134,7 +148,7 @@ def to_json(self) -> str:
else:
return json.dumps(self.actual_instance)

def to_dict(self) -> Optional[Union[Dict[str, Any], DestinationCIDRv4, DestinationCIDRv6]]:
def to_dict(self) -> Optional[Union[Dict[str, Any], DestinationCIDRv4, DestinationCIDRv6, DestinationPrefixList]]:
"""Returns the dict representation of the actual instance"""
if self.actual_instance is None:
return None
Expand Down
15 changes: 14 additions & 1 deletion services/iaas/src/stackit/iaas/models/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
from typing import Any, ClassVar, Dict, List, Optional, Set
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBool,
StrictInt,
StrictStr,
field_validator,
)
from pydantic_core import to_jsonable_python
from typing_extensions import Annotated, Self

Expand All @@ -40,6 +48,7 @@ class Snapshot(BaseModel):
description: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(
default=None, description="Description Object. Allows string up to 255 Characters."
)
encrypted: Optional[StrictBool] = Field(default=None, description="Indicates if a volume is encrypted.")
id: Optional[UUID] = Field(default=None, description="Universally Unique Identifier (UUID).")
labels: Optional[Dict[str, Any]] = Field(
default=None,
Expand All @@ -61,6 +70,7 @@ class Snapshot(BaseModel):
"availabilityZone",
"createdAt",
"description",
"encrypted",
"id",
"labels",
"name",
Expand Down Expand Up @@ -171,11 +181,13 @@ 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.
"""
excluded_fields: Set[str] = set(
[
"availability_zone",
"created_at",
"encrypted",
"id",
"size",
"status",
Expand Down Expand Up @@ -204,6 +216,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"availabilityZone": obj.get("availabilityZone"),
"createdAt": obj.get("createdAt"),
"description": obj.get("description"),
"encrypted": obj.get("encrypted"),
"id": obj.get("id"),
"labels": obj.get("labels"),
"name": obj.get("name"),
Expand Down
Loading