diff --git a/services/serverupdate/src/stackit/serverupdate/__init__.py b/services/serverupdate/src/stackit/serverupdate/__init__.py index 19298904..36235330 100644 --- a/services/serverupdate/src/stackit/serverupdate/__init__.py +++ b/services/serverupdate/src/stackit/serverupdate/__init__.py @@ -12,52 +12,81 @@ 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", + "CreateUpdatePayload", + "CreateUpdateSchedulePayload", + "EnableServiceResourcePayload", + "ErrorResponse", + "GetUpdatePoliciesResponse", + "GetUpdateSchedulesResponse", + "GetUpdateServiceResponse", + "GetUpdatesListResponse", + "Update", + "UpdatePolicy", + "UpdateSchedule", + "UpdateScheduleCreateRequest", + "UpdateUpdateSchedulePayload", +] + # import apis into sdk package -from stackit.serverupdate.api.default_api import DefaultApi -from stackit.serverupdate.api_client import ApiClient +from stackit.serverupdate.api.default_api import DefaultApi as DefaultApi +from stackit.serverupdate.api_client import ApiClient as ApiClient # import ApiClient -from stackit.serverupdate.api_response import ApiResponse -from stackit.serverupdate.configuration import HostConfiguration -from stackit.serverupdate.exceptions import ( - ApiAttributeError, - ApiException, - ApiKeyError, - ApiTypeError, - ApiValueError, - OpenApiException, -) +from stackit.serverupdate.api_response import ApiResponse as ApiResponse +from stackit.serverupdate.configuration import HostConfiguration as HostConfiguration +from stackit.serverupdate.exceptions import ApiAttributeError as ApiAttributeError +from stackit.serverupdate.exceptions import ApiException as ApiException +from stackit.serverupdate.exceptions import ApiKeyError as ApiKeyError +from stackit.serverupdate.exceptions import ApiTypeError as ApiTypeError +from stackit.serverupdate.exceptions import ApiValueError as ApiValueError +from stackit.serverupdate.exceptions import OpenApiException as OpenApiException # import models into sdk package -from stackit.serverupdate.models.create_update_payload import CreateUpdatePayload +from stackit.serverupdate.models.create_update_payload import ( + CreateUpdatePayload as CreateUpdatePayload, +) from stackit.serverupdate.models.create_update_schedule_payload import ( - CreateUpdateSchedulePayload, + CreateUpdateSchedulePayload as CreateUpdateSchedulePayload, ) from stackit.serverupdate.models.enable_service_resource_payload import ( - EnableServiceResourcePayload, + EnableServiceResourcePayload as EnableServiceResourcePayload, ) -from stackit.serverupdate.models.error_response import ErrorResponse +from stackit.serverupdate.models.error_response import ErrorResponse as ErrorResponse from stackit.serverupdate.models.get_update_policies_response import ( - GetUpdatePoliciesResponse, + GetUpdatePoliciesResponse as GetUpdatePoliciesResponse, ) from stackit.serverupdate.models.get_update_schedules_response import ( - GetUpdateSchedulesResponse, + GetUpdateSchedulesResponse as GetUpdateSchedulesResponse, ) from stackit.serverupdate.models.get_update_service_response import ( - GetUpdateServiceResponse, + GetUpdateServiceResponse as GetUpdateServiceResponse, +) +from stackit.serverupdate.models.get_updates_list_response import ( + GetUpdatesListResponse as GetUpdatesListResponse, ) -from stackit.serverupdate.models.get_updates_list_response import GetUpdatesListResponse -from stackit.serverupdate.models.update import Update -from stackit.serverupdate.models.update_policy import UpdatePolicy -from stackit.serverupdate.models.update_schedule import UpdateSchedule +from stackit.serverupdate.models.update import Update as Update +from stackit.serverupdate.models.update_policy import UpdatePolicy as UpdatePolicy +from stackit.serverupdate.models.update_schedule import UpdateSchedule as UpdateSchedule from stackit.serverupdate.models.update_schedule_create_request import ( - UpdateScheduleCreateRequest, + UpdateScheduleCreateRequest as UpdateScheduleCreateRequest, ) from stackit.serverupdate.models.update_update_schedule_payload import ( - UpdateUpdateSchedulePayload, + UpdateUpdateSchedulePayload as UpdateUpdateSchedulePayload, ) diff --git a/services/serverupdate/src/stackit/serverupdate/api/default_api.py b/services/serverupdate/src/stackit/serverupdate/api/default_api.py index d009290e..1782c75f 100644 --- a/services/serverupdate/src/stackit/serverupdate/api/default_api.py +++ b/services/serverupdate/src/stackit/serverupdate/api/default_api.py @@ -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, Dict, List, Optional, Tuple, Union @@ -106,7 +106,7 @@ def create_update( 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._create_update_serialize( project_id=project_id, @@ -181,7 +181,7 @@ def create_update_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._create_update_serialize( project_id=project_id, @@ -256,7 +256,7 @@ def create_update_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._create_update_serialize( project_id=project_id, @@ -299,7 +299,7 @@ def _create_update_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 @@ -394,7 +394,7 @@ def create_update_schedule( 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._create_update_schedule_serialize( project_id=project_id, @@ -468,7 +468,7 @@ def create_update_schedule_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._create_update_schedule_serialize( project_id=project_id, @@ -542,7 +542,7 @@ def create_update_schedule_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._create_update_schedule_serialize( project_id=project_id, @@ -584,7 +584,7 @@ def _create_update_schedule_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 @@ -679,7 +679,7 @@ def delete_update_schedule( 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._delete_update_schedule_serialize( project_id=project_id, @@ -753,7 +753,7 @@ def delete_update_schedule_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._delete_update_schedule_serialize( project_id=project_id, @@ -827,7 +827,7 @@ def delete_update_schedule_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._delete_update_schedule_serialize( project_id=project_id, @@ -869,7 +869,7 @@ def _delete_update_schedule_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 @@ -953,7 +953,7 @@ def disable_service_resource( 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_resource_serialize( project_id=project_id, @@ -1023,7 +1023,7 @@ def disable_service_resource_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_resource_serialize( project_id=project_id, @@ -1093,7 +1093,7 @@ def disable_service_resource_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_resource_serialize( project_id=project_id, @@ -1133,7 +1133,7 @@ def _disable_service_resource_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 @@ -1218,7 +1218,7 @@ def enable_service_resource( 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_resource_serialize( project_id=project_id, @@ -1292,7 +1292,7 @@ def enable_service_resource_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_resource_serialize( project_id=project_id, @@ -1366,7 +1366,7 @@ def enable_service_resource_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_resource_serialize( project_id=project_id, @@ -1408,7 +1408,7 @@ def _enable_service_resource_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 @@ -1500,7 +1500,7 @@ def get_service_resource( 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_resource_serialize( project_id=project_id, @@ -1570,7 +1570,7 @@ def get_service_resource_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_resource_serialize( project_id=project_id, @@ -1640,7 +1640,7 @@ def get_service_resource_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_resource_serialize( project_id=project_id, @@ -1680,7 +1680,7 @@ def _get_service_resource_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 @@ -1765,7 +1765,7 @@ def get_update( 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_update_serialize( project_id=project_id, @@ -1839,7 +1839,7 @@ def get_update_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_update_serialize( project_id=project_id, @@ -1913,7 +1913,7 @@ def get_update_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_update_serialize( project_id=project_id, @@ -1955,7 +1955,7 @@ def _get_update_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 @@ -2042,7 +2042,7 @@ def get_update_schedule( 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_update_schedule_serialize( project_id=project_id, @@ -2116,7 +2116,7 @@ def get_update_schedule_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_update_schedule_serialize( project_id=project_id, @@ -2190,7 +2190,7 @@ def get_update_schedule_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_update_schedule_serialize( project_id=project_id, @@ -2232,7 +2232,7 @@ def _get_update_schedule_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 @@ -2310,7 +2310,7 @@ def list_update_policies( 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_update_policies_serialize( project_id=project_id, @@ -2372,7 +2372,7 @@ def list_update_policies_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_update_policies_serialize( project_id=project_id, @@ -2434,7 +2434,7 @@ def list_update_policies_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_update_policies_serialize( project_id=project_id, @@ -2470,7 +2470,7 @@ def _list_update_policies_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 @@ -2548,7 +2548,7 @@ def list_update_schedules( 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_update_schedules_serialize( project_id=project_id, @@ -2618,7 +2618,7 @@ def list_update_schedules_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_update_schedules_serialize( project_id=project_id, @@ -2688,7 +2688,7 @@ def list_update_schedules_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_update_schedules_serialize( project_id=project_id, @@ -2728,7 +2728,7 @@ def _list_update_schedules_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 @@ -2810,7 +2810,7 @@ def list_updates( 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_updates_serialize( project_id=project_id, @@ -2880,7 +2880,7 @@ def list_updates_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_updates_serialize( project_id=project_id, @@ -2950,7 +2950,7 @@ def list_updates_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_updates_serialize( project_id=project_id, @@ -2990,7 +2990,7 @@ def _list_updates_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 @@ -3078,7 +3078,7 @@ def update_update_schedule( 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._update_update_schedule_serialize( project_id=project_id, @@ -3156,7 +3156,7 @@ def update_update_schedule_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._update_update_schedule_serialize( project_id=project_id, @@ -3234,7 +3234,7 @@ def update_update_schedule_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._update_update_schedule_serialize( project_id=project_id, @@ -3278,7 +3278,7 @@ def _update_update_schedule_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 diff --git a/services/serverupdate/src/stackit/serverupdate/api_client.py b/services/serverupdate/src/stackit/serverupdate/api_client.py index bac0e6a1..9abf5645 100644 --- a/services/serverupdate/src/stackit/serverupdate/api_client.py +++ b/services/serverupdate/src/stackit/serverupdate/api_client.py @@ -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 @@ -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]): @@ -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)) @@ -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 = " " @@ -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. @@ -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" diff --git a/services/serverupdate/src/stackit/serverupdate/configuration.py b/services/serverupdate/src/stackit/serverupdate/configuration.py index e400d969..d3e803e0 100644 --- a/services/serverupdate/src/stackit/serverupdate/configuration.py +++ b/services/serverupdate/src/stackit/serverupdate/configuration.py @@ -1,10 +1,5 @@ # coding: utf-8 -import sys - -import os - - """ STACKIT Server Update Management API @@ -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: @@ -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 @@ -72,7 +89,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 @@ -112,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"]) @@ -131,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 diff --git a/services/serverupdate/src/stackit/serverupdate/exceptions.py b/services/serverupdate/src/stackit/serverupdate/exceptions.py index a60279c4..5941cfc9 100644 --- a/services/serverupdate/src/stackit/serverupdate/exceptions.py +++ b/services/serverupdate/src/stackit/serverupdate/exceptions.py @@ -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 @@ -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() @@ -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) @@ -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 = "" diff --git a/services/serverupdate/src/stackit/serverupdate/models/__init__.py b/services/serverupdate/src/stackit/serverupdate/models/__init__.py index b9eec8cb..e5254b31 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/__init__.py +++ b/services/serverupdate/src/stackit/serverupdate/models/__init__.py @@ -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 diff --git a/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py b/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py index ee988557..7a5ef8b2 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/create_update_payload.py @@ -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 @@ -25,7 +25,7 @@ class CreateUpdatePayload(BaseModel): """ CreateUpdatePayload - """ + """ # noqa: E501 backup_before_update: Optional[StrictBool] = Field(default=None, alias="backupBeforeUpdate") maintenance_window: Annotated[int, Field(le=24, strict=True, ge=1)] = Field(alias="maintenanceWindow") diff --git a/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py b/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py index ff573ddd..19b174c9 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/create_update_schedule_payload.py @@ -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 @@ -25,7 +25,7 @@ class CreateUpdateSchedulePayload(BaseModel): """ CreateUpdateSchedulePayload - """ + """ # noqa: E501 enabled: StrictBool maintenance_window: Annotated[int, Field(le=24, strict=True, ge=1)] = Field(alias="maintenanceWindow") diff --git a/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py b/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py index 5a4f8bdf..b4f7b550 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/enable_service_resource_payload.py @@ -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 @@ -25,7 +25,7 @@ class EnableServiceResourcePayload(BaseModel): """ EnableServiceResourcePayload - """ + """ # noqa: E501 update_policy_id: Optional[StrictStr] = Field(default=None, alias="updatePolicyId") __properties: ClassVar[List[str]] = ["updatePolicyId"] diff --git a/services/serverupdate/src/stackit/serverupdate/models/error_response.py b/services/serverupdate/src/stackit/serverupdate/models/error_response.py index f3b89a6a..15adb7bd 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/error_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/error_response.py @@ -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 @@ -25,7 +25,7 @@ class ErrorResponse(BaseModel): """ ErrorResponse - """ + """ # noqa: E501 message: StrictStr = Field(description="Details about the error") status: StrictStr = Field( diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py index 2a76ce6c..0cae8f44 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_policies_response.py @@ -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 @@ -27,7 +27,7 @@ class GetUpdatePoliciesResponse(BaseModel): """ GetUpdatePoliciesResponse - """ + """ # noqa: E501 items: Optional[List[UpdatePolicy]] = None __properties: ClassVar[List[str]] = ["items"] diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py index c4e2c168..92025c4a 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_schedules_response.py @@ -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 @@ -27,7 +27,7 @@ class GetUpdateSchedulesResponse(BaseModel): """ GetUpdateSchedulesResponse - """ + """ # noqa: E501 items: Optional[List[UpdateSchedule]] = None __properties: ClassVar[List[str]] = ["items"] diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py index eb44ea56..a6f7303a 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_update_service_response.py @@ -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 @@ -25,7 +25,7 @@ class GetUpdateServiceResponse(BaseModel): """ GetUpdateServiceResponse - """ + """ # noqa: E501 enabled: Optional[StrictBool] = None __properties: ClassVar[List[str]] = ["enabled"] diff --git a/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py b/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py index 30ea367f..3050fca8 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py +++ b/services/serverupdate/src/stackit/serverupdate/models/get_updates_list_response.py @@ -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 @@ -27,7 +27,7 @@ class GetUpdatesListResponse(BaseModel): """ GetUpdatesListResponse - """ + """ # noqa: E501 items: Optional[List[Update]] = None __properties: ClassVar[List[str]] = ["items"] diff --git a/services/serverupdate/src/stackit/serverupdate/models/update.py b/services/serverupdate/src/stackit/serverupdate/models/update.py index cf466ed4..214052e1 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update.py @@ -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 @@ -25,7 +25,7 @@ class Update(BaseModel): """ Update - """ + """ # noqa: E501 end_date: Optional[StrictStr] = Field(default=None, alias="endDate") fail_reason: Optional[StrictStr] = Field(default=None, alias="failReason") diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_policy.py b/services/serverupdate/src/stackit/serverupdate/models/update_policy.py index edc318d6..d1736029 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_policy.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_policy.py @@ -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 @@ -25,7 +25,7 @@ class UpdatePolicy(BaseModel): """ UpdatePolicy - """ + """ # noqa: E501 default: Optional[StrictBool] = None description: Optional[StrictStr] = None diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py b/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py index 3abd5c00..a7fccd49 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_schedule.py @@ -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 @@ -25,7 +25,7 @@ class UpdateSchedule(BaseModel): """ UpdateSchedule - """ + """ # noqa: E501 enabled: StrictBool maintenance_window: Annotated[int, Field(le=24, strict=True, ge=1)] = Field(alias="maintenanceWindow") diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py b/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py index a78ac8f9..be3428a5 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_schedule_create_request.py @@ -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 @@ -25,7 +25,7 @@ class UpdateScheduleCreateRequest(BaseModel): """ UpdateScheduleCreateRequest - """ + """ # noqa: E501 enabled: StrictBool maintenance_window: Annotated[int, Field(le=24, strict=True, ge=1)] = Field(alias="maintenanceWindow") diff --git a/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py b/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py index db85baa6..d86f8f48 100644 --- a/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py +++ b/services/serverupdate/src/stackit/serverupdate/models/update_update_schedule_payload.py @@ -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 @@ -25,7 +25,7 @@ class UpdateUpdateSchedulePayload(BaseModel): """ UpdateUpdateSchedulePayload - """ + """ # noqa: E501 enabled: StrictBool maintenance_window: Annotated[int, Field(le=24, strict=True, ge=1)] = Field(alias="maintenanceWindow") diff --git a/services/serverupdate/src/stackit/serverupdate/rest.py b/services/serverupdate/src/stackit/serverupdate/rest.py index 42a57625..d810cfee 100644 --- a/services/serverupdate/src/stackit/serverupdate/rest.py +++ b/services/serverupdate/src/stackit/serverupdate/rest.py @@ -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 io import json @@ -125,7 +125,7 @@ def request(self, method, url, headers=None, body=None, post_params=None, _reque data=body, headers=headers, ) - elif headers["Content-Type"] == "text/plain" and isinstance(body, bool): + elif headers["Content-Type"].startswith("text/") and isinstance(body, bool): request_body = "true" if body else "false" r = self.session.request(method, url, data=request_body, headers=headers) else: