diff --git a/services/certificates/src/stackit/certificates/__init__.py b/services/certificates/src/stackit/certificates/__init__.py index 011746452..c4e79e4e4 100644 --- a/services/certificates/src/stackit/certificates/__init__.py +++ b/services/certificates/src/stackit/certificates/__init__.py @@ -11,37 +11,59 @@ 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", + "CreateCertificatePayload", + "CreateCertificateResponse", + "GetCertificateResponse", + "GoogleProtobufAny", + "ListCertificatesResponse", + "Status", +] + # import apis into sdk package -from stackit.certificates.api.default_api import DefaultApi -from stackit.certificates.api_client import ApiClient +from stackit.certificates.api.default_api import DefaultApi as DefaultApi +from stackit.certificates.api_client import ApiClient as ApiClient # import ApiClient -from stackit.certificates.api_response import ApiResponse -from stackit.certificates.configuration import HostConfiguration -from stackit.certificates.exceptions import ( - ApiAttributeError, - ApiException, - ApiKeyError, - ApiTypeError, - ApiValueError, - OpenApiException, -) +from stackit.certificates.api_response import ApiResponse as ApiResponse +from stackit.certificates.configuration import HostConfiguration as HostConfiguration +from stackit.certificates.exceptions import ApiAttributeError as ApiAttributeError +from stackit.certificates.exceptions import ApiException as ApiException +from stackit.certificates.exceptions import ApiKeyError as ApiKeyError +from stackit.certificates.exceptions import ApiTypeError as ApiTypeError +from stackit.certificates.exceptions import ApiValueError as ApiValueError +from stackit.certificates.exceptions import OpenApiException as OpenApiException # import models into sdk package from stackit.certificates.models.create_certificate_payload import ( - CreateCertificatePayload, + CreateCertificatePayload as CreateCertificatePayload, ) from stackit.certificates.models.create_certificate_response import ( - CreateCertificateResponse, + CreateCertificateResponse as CreateCertificateResponse, +) +from stackit.certificates.models.get_certificate_response import ( + GetCertificateResponse as GetCertificateResponse, +) +from stackit.certificates.models.google_protobuf_any import ( + GoogleProtobufAny as GoogleProtobufAny, ) -from stackit.certificates.models.get_certificate_response import GetCertificateResponse -from stackit.certificates.models.google_protobuf_any import GoogleProtobufAny from stackit.certificates.models.list_certificates_response import ( - ListCertificatesResponse, + ListCertificatesResponse as ListCertificatesResponse, ) -from stackit.certificates.models.status import Status +from stackit.certificates.models.status import Status as Status diff --git a/services/certificates/src/stackit/certificates/api/default_api.py b/services/certificates/src/stackit/certificates/api/default_api.py index e7af4e128..c91ea4201 100644 --- a/services/certificates/src/stackit/certificates/api/default_api.py +++ b/services/certificates/src/stackit/certificates/api/default_api.py @@ -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 @@ -91,7 +91,7 @@ def create_certificate( 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_certificate_serialize( project_id=project_id, @@ -163,7 +163,7 @@ def create_certificate_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_certificate_serialize( project_id=project_id, @@ -235,7 +235,7 @@ def create_certificate_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_certificate_serialize( project_id=project_id, @@ -276,7 +276,7 @@ def _create_certificate_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 @@ -367,7 +367,7 @@ def delete_certificate( 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_certificate_serialize( project_id=project_id, @@ -439,7 +439,7 @@ def delete_certificate_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_certificate_serialize( project_id=project_id, @@ -511,7 +511,7 @@ def delete_certificate_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_certificate_serialize( project_id=project_id, @@ -552,7 +552,7 @@ def _delete_certificate_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 @@ -635,7 +635,7 @@ def get_certificate( 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_certificate_serialize( project_id=project_id, @@ -708,7 +708,7 @@ def get_certificate_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_certificate_serialize( project_id=project_id, @@ -781,7 +781,7 @@ def get_certificate_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_certificate_serialize( project_id=project_id, @@ -823,7 +823,7 @@ def _get_certificate_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 @@ -919,7 +919,7 @@ def list_certificates( 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_certificates_serialize( project_id=project_id, @@ -1006,7 +1006,7 @@ def list_certificates_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_certificates_serialize( project_id=project_id, @@ -1093,7 +1093,7 @@ def list_certificates_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_certificates_serialize( project_id=project_id, @@ -1137,7 +1137,7 @@ def _list_certificates_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/certificates/src/stackit/certificates/api_client.py b/services/certificates/src/stackit/certificates/api_client.py index d7bc573ae..6e8c8efc6 100644 --- a/services/certificates/src/stackit/certificates/api_client.py +++ b/services/certificates/src/stackit/certificates/api_client.py @@ -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 @@ -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]): @@ -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)) @@ -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 = " " @@ -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. @@ -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" diff --git a/services/certificates/src/stackit/certificates/configuration.py b/services/certificates/src/stackit/certificates/configuration.py index 06035173c..eb8bb2a13 100644 --- a/services/certificates/src/stackit/certificates/configuration.py +++ b/services/certificates/src/stackit/certificates/configuration.py @@ -1,10 +1,5 @@ # coding: utf-8 -import sys - -import os - - """ Load Balancer Certificates API @@ -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: @@ -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 @@ -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 @@ -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"]) @@ -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 diff --git a/services/certificates/src/stackit/certificates/exceptions.py b/services/certificates/src/stackit/certificates/exceptions.py index df5804a2f..94747580e 100644 --- a/services/certificates/src/stackit/certificates/exceptions.py +++ b/services/certificates/src/stackit/certificates/exceptions.py @@ -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, Optional @@ -127,7 +127,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() @@ -151,6 +151,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) @@ -187,6 +194,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/certificates/src/stackit/certificates/models/__init__.py b/services/certificates/src/stackit/certificates/models/__init__.py index 35ab1726e..d658ac5a7 100644 --- a/services/certificates/src/stackit/certificates/models/__init__.py +++ b/services/certificates/src/stackit/certificates/models/__init__.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 models into model package diff --git a/services/certificates/src/stackit/certificates/models/create_certificate_payload.py b/services/certificates/src/stackit/certificates/models/create_certificate_payload.py index ac3059426..16a36406a 100644 --- a/services/certificates/src/stackit/certificates/models/create_certificate_payload.py +++ b/services/certificates/src/stackit/certificates/models/create_certificate_payload.py @@ -9,13 +9,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 @@ -25,7 +25,7 @@ class CreateCertificatePayload(BaseModel): """ Uploads a PEM encoded X509 public/private key pair - """ + """ # noqa: E501 name: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="TLS certificate name") private_key: Optional[StrictStr] = Field( diff --git a/services/certificates/src/stackit/certificates/models/create_certificate_response.py b/services/certificates/src/stackit/certificates/models/create_certificate_response.py index 9c7f20084..f176a07d0 100644 --- a/services/certificates/src/stackit/certificates/models/create_certificate_response.py +++ b/services/certificates/src/stackit/certificates/models/create_certificate_response.py @@ -9,13 +9,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 @@ -25,7 +25,7 @@ class CreateCertificateResponse(BaseModel): """ CreateCertificateResponse returns unique resource id - """ + """ # noqa: E501 id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The certificates resource id") region: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="Region") diff --git a/services/certificates/src/stackit/certificates/models/get_certificate_response.py b/services/certificates/src/stackit/certificates/models/get_certificate_response.py index dab99f13d..97ef2fab6 100644 --- a/services/certificates/src/stackit/certificates/models/get_certificate_response.py +++ b/services/certificates/src/stackit/certificates/models/get_certificate_response.py @@ -9,13 +9,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 @@ -25,7 +25,7 @@ class GetCertificateResponse(BaseModel): """ GetCertificateResponse returns name, id and public key - """ + """ # noqa: E501 id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="The certificates resource id") name: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="TLS certificate name") diff --git a/services/certificates/src/stackit/certificates/models/google_protobuf_any.py b/services/certificates/src/stackit/certificates/models/google_protobuf_any.py index d2c1c9286..dacf82c5f 100644 --- a/services/certificates/src/stackit/certificates/models/google_protobuf_any.py +++ b/services/certificates/src/stackit/certificates/models/google_protobuf_any.py @@ -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 __future__ import annotations @@ -24,7 +24,7 @@ class GoogleProtobufAny(BaseModel): """ Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - """ + """ # noqa: E501 type: Optional[StrictStr] = Field(default=None, description="The type of the serialized message.", alias="@type") additional_properties: Dict[str, Any] = {} diff --git a/services/certificates/src/stackit/certificates/models/list_certificates_response.py b/services/certificates/src/stackit/certificates/models/list_certificates_response.py index d984d9f90..a1d83feab 100644 --- a/services/certificates/src/stackit/certificates/models/list_certificates_response.py +++ b/services/certificates/src/stackit/certificates/models/list_certificates_response.py @@ -9,13 +9,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 @@ -27,7 +27,7 @@ class ListCertificatesResponse(BaseModel): """ ListCertificateResponse returns a list of certificate responses - """ + """ # noqa: E501 items: Optional[List[GetCertificateResponse]] = None next_page_id: Optional[Annotated[str, Field(strict=True)]] = Field( diff --git a/services/certificates/src/stackit/certificates/models/status.py b/services/certificates/src/stackit/certificates/models/status.py index cc9a56fd7..da393ba4a 100644 --- a/services/certificates/src/stackit/certificates/models/status.py +++ b/services/certificates/src/stackit/certificates/models/status.py @@ -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 __future__ import annotations @@ -26,7 +26,7 @@ class Status(BaseModel): """ The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). - """ + """ # noqa: E501 code: Optional[StrictInt] = Field( default=None, diff --git a/services/certificates/src/stackit/certificates/rest.py b/services/certificates/src/stackit/certificates/rest.py index 0b85b3032..5b4361c8f 100644 --- a/services/certificates/src/stackit/certificates/rest.py +++ b/services/certificates/src/stackit/certificates/rest.py @@ -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 io import json @@ -124,7 +124,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: