Skip to content

Generator: Update SDK /services/serviceenablement #1393

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,65 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

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


__version__ = "1.0.0"

# Define package exports
__all__ = [
"DefaultApi",
"ApiResponse",
"ApiClient",
"HostConfiguration",
"OpenApiException",
"ApiTypeError",
"ApiValueError",
"ApiKeyError",
"ApiAttributeError",
"ApiException",
"ActionError",
"CheckService",
"CloudService",
"Dependencies",
"ErrorResponse",
"ListServiceStatusRegional200Response",
"Parameters",
"ParametersGeneral",
"ServiceStatus",
]

# import apis into sdk package
from stackit.serviceenablement.api.default_api import DefaultApi
from stackit.serviceenablement.api_client import ApiClient
from stackit.serviceenablement.api.default_api import DefaultApi as DefaultApi
from stackit.serviceenablement.api_client import ApiClient as ApiClient

# import ApiClient
from stackit.serviceenablement.api_response import ApiResponse
from stackit.serviceenablement.configuration import HostConfiguration
from stackit.serviceenablement.exceptions import (
ApiAttributeError,
ApiException,
ApiKeyError,
ApiTypeError,
ApiValueError,
OpenApiException,
from stackit.serviceenablement.api_response import ApiResponse as ApiResponse
from stackit.serviceenablement.configuration import (
HostConfiguration as HostConfiguration,
)
from stackit.serviceenablement.exceptions import ApiAttributeError as ApiAttributeError
from stackit.serviceenablement.exceptions import ApiException as ApiException
from stackit.serviceenablement.exceptions import ApiKeyError as ApiKeyError
from stackit.serviceenablement.exceptions import ApiTypeError as ApiTypeError
from stackit.serviceenablement.exceptions import ApiValueError as ApiValueError
from stackit.serviceenablement.exceptions import OpenApiException as OpenApiException

# import models into sdk package
from stackit.serviceenablement.models.action_error import ActionError
from stackit.serviceenablement.models.check_service import CheckService
from stackit.serviceenablement.models.cloud_service import CloudService
from stackit.serviceenablement.models.dependencies import Dependencies
from stackit.serviceenablement.models.error_response import ErrorResponse
from stackit.serviceenablement.models.action_error import ActionError as ActionError
from stackit.serviceenablement.models.check_service import CheckService as CheckService
from stackit.serviceenablement.models.cloud_service import CloudService as CloudService
from stackit.serviceenablement.models.dependencies import Dependencies as Dependencies
from stackit.serviceenablement.models.error_response import (
ErrorResponse as ErrorResponse,
)
from stackit.serviceenablement.models.list_service_status_regional200_response import (
ListServiceStatusRegional200Response,
ListServiceStatusRegional200Response as ListServiceStatusRegional200Response,
)
from stackit.serviceenablement.models.parameters import Parameters as Parameters
from stackit.serviceenablement.models.parameters_general import (
ParametersGeneral as ParametersGeneral,
)
from stackit.serviceenablement.models.service_status import (
ServiceStatus as ServiceStatus,
)
from stackit.serviceenablement.models.parameters import Parameters
from stackit.serviceenablement.models.parameters_general import ParametersGeneral
from stackit.serviceenablement.models.service_status import ServiceStatus
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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, Dict, List, Optional, Tuple, Union

Expand Down Expand Up @@ -85,7 +85,7 @@ def disable_service_regional(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._disable_service_regional_serialize(
region=region,
Expand Down Expand Up @@ -157,7 +157,7 @@ def disable_service_regional_with_http_info(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._disable_service_regional_serialize(
region=region,
Expand Down Expand Up @@ -229,7 +229,7 @@ def disable_service_regional_without_preload_content(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._disable_service_regional_serialize(
region=region,
Expand Down Expand Up @@ -270,7 +270,7 @@ def _disable_service_regional_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[str, Union[str, bytes]] = {}
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand Down Expand Up @@ -353,7 +353,7 @@ def enable_service_regional(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._enable_service_regional_serialize(
region=region,
Expand Down Expand Up @@ -425,7 +425,7 @@ def enable_service_regional_with_http_info(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._enable_service_regional_serialize(
region=region,
Expand Down Expand Up @@ -497,7 +497,7 @@ def enable_service_regional_without_preload_content(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._enable_service_regional_serialize(
region=region,
Expand Down Expand Up @@ -538,7 +538,7 @@ def _enable_service_regional_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[str, Union[str, bytes]] = {}
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand Down Expand Up @@ -621,7 +621,7 @@ def get_service_status_regional(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._get_service_status_regional_serialize(
region=region,
Expand Down Expand Up @@ -693,7 +693,7 @@ def get_service_status_regional_with_http_info(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._get_service_status_regional_serialize(
region=region,
Expand Down Expand Up @@ -765,7 +765,7 @@ def get_service_status_regional_without_preload_content(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._get_service_status_regional_serialize(
region=region,
Expand Down Expand Up @@ -806,7 +806,7 @@ def _get_service_status_regional_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[str, Union[str, bytes]] = {}
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand Down Expand Up @@ -889,7 +889,7 @@ def list_service_status_regional(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._list_service_status_regional_serialize(
region=region,
Expand Down Expand Up @@ -960,7 +960,7 @@ def list_service_status_regional_with_http_info(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._list_service_status_regional_serialize(
region=region,
Expand Down Expand Up @@ -1031,7 +1031,7 @@ def list_service_status_regional_without_preload_content(
in the spec for a single request.
:type _host_index: int, optional
:return: Returns the result object.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

_param = self._list_service_status_regional_serialize(
region=region,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ def _list_service_status_regional_serialize(
_query_params: List[Tuple[str, str]] = []
_header_params: Dict[str, Optional[str]] = _headers or {}
_form_params: List[Tuple[str, str]] = []
_files: Dict[str, Union[str, bytes]] = {}
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
_body_params: Optional[bytes] = None

# process the path parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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 @@ -331,6 +331,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 @@ -350,12 +354,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 @@ -457,7 +461,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 @@ -473,7 +477,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 @@ -488,6 +495,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
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# coding: utf-8

import sys

import os


"""
STACKIT Service Enablement API

Expand All @@ -14,7 +9,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 @@ -53,7 +70,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 @@ -71,7 +88,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 @@ -111,7 +133,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 @@ -130,12 +152,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
Loading
Loading