Skip to content

Generator: Update SDK /services/iaas #1564

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
529 changes: 391 additions & 138 deletions services/iaas/src/stackit/iaas/__init__.py

Large diffs are not rendered by default.

962 changes: 481 additions & 481 deletions services/iaas/src/stackit/iaas/api/default_api.py

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions services/iaas/src/stackit/iaas/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

import datetime
import json
Expand Down Expand Up @@ -332,6 +332,10 @@ def sanitize_for_serialization(self, obj):
else:
obj_dict = obj.__dict__

if isinstance(obj_dict, list):
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
return self.sanitize_for_serialization(obj_dict)

return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}

def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
Expand All @@ -351,12 +355,12 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti
data = json.loads(response_text)
except ValueError:
data = response_text
elif content_type.startswith("application/json"):
elif re.match(r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE):
if response_text == "":
data = ""
else:
data = json.loads(response_text)
elif content_type.startswith("text/plain"):
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
data = response_text
else:
raise ApiException(status=0, reason="Unsupported content type: {0}".format(content_type))
Expand Down Expand Up @@ -458,7 +462,7 @@ def parameters_to_url_query(self, params, collection_formats):
if k in collection_formats:
collection_format = collection_formats[k]
if collection_format == "multi":
new_params.extend((k, str(value)) for value in v)
new_params.extend((k, quote(str(value))) for value in v)
else:
if collection_format == "ssv":
delimiter = " "
Expand All @@ -474,7 +478,10 @@ def parameters_to_url_query(self, params, collection_formats):

return "&".join(["=".join(map(str, item)) for item in new_params])

def files_parameters(self, files: Dict[str, Union[str, bytes]]):
def files_parameters(
self,
files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
):
"""Builds form parameters.

:param files: File parameters.
Expand All @@ -489,6 +496,12 @@ def files_parameters(self, files: Dict[str, Union[str, bytes]]):
elif isinstance(v, bytes):
filename = k
filedata = v
elif isinstance(v, tuple):
filename, filedata = v
elif isinstance(v, list):
for file_param in v:
params.extend(self.files_parameters({k: file_param}))
continue
else:
raise ValueError("Unsupported file value")
mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
Expand Down
44 changes: 33 additions & 11 deletions services/iaas/src/stackit/iaas/configuration.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# coding: utf-8

import sys

import os


"""
IaaS-API

Expand All @@ -15,7 +10,29 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

import sys
from typing import Dict, List, Optional, TypedDict

from typing_extensions import NotRequired

import os


ServerVariablesT = Dict[str, str]


class HostSettingVariable(TypedDict):
description: str
default_value: str
enum_values: List[str]


class HostSetting(TypedDict):
url: str
description: str
variables: NotRequired[Dict[str, HostSettingVariable]]


class HostConfiguration:
Expand Down Expand Up @@ -54,7 +71,7 @@ def __init__(
"""Ignore operation servers
"""

def get_host_settings(self):
def get_host_settings(self) -> List[HostSetting]:
"""Gets an array of host settings

:return: An array of host settings
Expand All @@ -73,7 +90,12 @@ def get_host_settings(self):
}
]

def get_host_from_settings(self, index, variables=None, servers=None):
def get_host_from_settings(
self,
index: Optional[int],
variables: Optional[ServerVariablesT] = None,
servers: Optional[List[HostSetting]] = None,
) -> str:
"""Gets host URL based on the index and variables
:param index: array index of the host settings
:param variables: hash of variable and the corresponding value
Expand Down Expand Up @@ -113,7 +135,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
and variables.get(variable_name) is not None
):
raise ValueError(
"this API does not support setting a region in the the client configuration, "
"this API does not support setting a region in the client configuration, "
"please check if the region can be specified as a function parameter"
)
used_value = variables.get(variable_name, variable["default_value"])
Expand All @@ -132,12 +154,12 @@ def get_host_from_settings(self, index, variables=None, servers=None):
return url

@property
def host(self):
def host(self) -> str:
"""Return generated host."""
return self.get_host_from_settings(self.server_index, variables=self.server_variables)

@host.setter
def host(self, value):
def host(self, value: str) -> None:
"""Fix base path."""
self._base_path = value
self.server_index = None
23 changes: 21 additions & 2 deletions services/iaas/src/stackit/iaas/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from typing import Any, Optional

Expand Down Expand Up @@ -128,7 +128,7 @@ def __init__(
if self.body is None:
try:
self.body = http_resp.data.decode("utf-8")
except Exception: # noqa: S110
except Exception:
pass
self.headers = http_resp.getheaders()

Expand All @@ -152,6 +152,13 @@ def from_response(
if http_resp.status == 404:
raise NotFoundException(http_resp=http_resp, body=body, data=data)

# Added new conditions for 409 and 422
if http_resp.status == 409:
raise ConflictException(http_resp=http_resp, body=body, data=data)

if http_resp.status == 422:
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)

if 500 <= http_resp.status <= 599:
raise ServiceException(http_resp=http_resp, body=body, data=data)
raise ApiException(http_resp=http_resp, body=body, data=data)
Expand Down Expand Up @@ -188,6 +195,18 @@ class ServiceException(ApiException):
pass


class ConflictException(ApiException):
"""Exception for HTTP 409 Conflict."""

pass


class UnprocessableEntityException(ApiException):
"""Exception for HTTP 422 Unprocessable Entity."""

pass


def render_path(path_to_item):
"""Returns a string representation of a path"""
result = ""
Expand Down
2 changes: 1 addition & 1 deletion services/iaas/src/stackit/iaas/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501


# import models into model package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

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

from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
Expand All @@ -26,7 +26,7 @@
class AddVolumeToServerPayload(BaseModel):
"""
Object that represents a Volume attachment to a server.
"""
""" # noqa: E501

delete_on_termination: Optional[StrictBool] = Field(
default=None,
Expand Down
6 changes: 3 additions & 3 deletions services/iaas/src/stackit/iaas/models/affinity_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

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

from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
Expand All @@ -26,7 +26,7 @@
class AffinityGroup(BaseModel):
"""
Definition of an affinity group.
"""
""" # noqa: E501

id: Optional[Annotated[str, Field(min_length=36, strict=True, max_length=36)]] = Field(
default=None, description="Universally Unique Identifier (UUID)."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AffinityGroupListResponse(BaseModel):
"""
Response object for affinity group list request.
"""
""" # noqa: E501

items: List[AffinityGroup] = Field(description="A list of affinity groups.")
__properties: ClassVar[List[str]] = ["items"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

Expand Down
6 changes: 3 additions & 3 deletions services/iaas/src/stackit/iaas/models/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

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

from pydantic import BaseModel, ConfigDict, Field, field_validator
Expand All @@ -29,7 +29,7 @@
class Area(BaseModel):
"""
The basic properties of a network area.
"""
""" # noqa: E501

default_nameservers: Optional[Annotated[List[Annotated[str, Field(strict=True)]], Field(max_length=3)]] = Field(
default=None, description="A list containing DNS Servers/Nameservers for IPv4.", alias="defaultNameservers"
Expand Down
6 changes: 3 additions & 3 deletions services/iaas/src/stackit/iaas/models/area_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

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

from pydantic import BaseModel, ConfigDict, Field, field_validator
Expand All @@ -29,7 +29,7 @@
class AreaConfig(BaseModel):
"""
The basic network area object.
"""
""" # noqa: E501

default_nameservers: Optional[Annotated[List[Annotated[str, Field(strict=True)]], Field(max_length=3)]] = Field(
default=None, alias="defaultNameservers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

Expand All @@ -25,7 +25,7 @@
class AreaPrefixConfigIPv4(BaseModel):
"""
The IPv4 prefix config for a network area.
"""
""" # noqa: E501

default_prefix_len: Optional[Annotated[int, Field(le=29, strict=True, ge=24)]] = Field(
default=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

from __future__ import annotations

Expand All @@ -25,7 +25,7 @@
class AvailabilityZoneListResponse(BaseModel):
"""
Availability Zone list response.
"""
""" # noqa: E501

items: List[StrictStr] = Field(description="A list of availability zones.")
__properties: ClassVar[List[str]] = ["items"]
Expand Down
Loading
Loading