Skip to content

Generator: Update SDK /services/iaasalpha #1373

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
326 changes: 128 additions & 198 deletions services/iaasalpha/src/stackit/iaasalpha/__init__.py

Large diffs are not rendered by default.

34,929 changes: 1,517 additions & 33,412 deletions services/iaasalpha/src/stackit/iaasalpha/api/default_api.py

Large diffs are not rendered by default.

25 changes: 19 additions & 6 deletions services/iaasalpha/src/stackit/iaasalpha/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

This API allows you to create and modify IaaS resources.

The version of the OpenAPI document: 1alpha1
The version of the OpenAPI document: 2alpha1
Contact: [email protected]
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
53 changes: 37 additions & 16 deletions services/iaasalpha/src/stackit/iaasalpha/configuration.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# coding: utf-8

import sys

import os


"""
IaaS-API

This API allows you to create and modify IaaS resources.

The version of the OpenAPI document: 1alpha1
The version of the OpenAPI document: 2alpha1
Contact: [email protected]
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 All @@ -37,7 +54,7 @@ def __init__(
)
"""Constructor
"""
self._base_path = "https://iaas.api.eu01.stackit.cloud"
self._base_path = "https://iaas.api.stackit.cloud"
"""Default Base url
"""
self.server_index = 0 if server_index is None else server_index
Expand All @@ -54,26 +71,30 @@ 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
"""
return [
{
"url": "https://iaas.api.{region}stackit.cloud",
"url": "https://iaas.api.stackit.cloud",
"description": "No description provided",
"variables": {
"region": {
"description": "No description provided",
"default_value": "eu01.",
"enum_values": ["eu01."],
"default_value": "global",
}
},
}
]

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 +134,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 +153,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
25 changes: 22 additions & 3 deletions services/iaasalpha/src/stackit/iaasalpha/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

This API allows you to create and modify IaaS resources.

The version of the OpenAPI document: 1alpha1
The version of the OpenAPI document: 2alpha1
Contact: [email protected]
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
Loading
Loading