Skip to content
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
68 changes: 47 additions & 21 deletions services/git/src/stackit/git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,61 @@
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",
"CreateInstancePayload",
"Flavor",
"GenericErrorResponse",
"Instance",
"InternalServerErrorResponse",
"ListFlavors",
"ListInstances",
"UnauthorizedResponse",
]

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

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

# import models into sdk package
from stackit.git.models.create_instance_payload import CreateInstancePayload
from stackit.git.models.flavor import Flavor
from stackit.git.models.generic_error_response import GenericErrorResponse
from stackit.git.models.instance import Instance
from stackit.git.models.create_instance_payload import (
CreateInstancePayload as CreateInstancePayload,
)
from stackit.git.models.flavor import Flavor as Flavor
from stackit.git.models.generic_error_response import (
GenericErrorResponse as GenericErrorResponse,
)
from stackit.git.models.instance import Instance as Instance
from stackit.git.models.internal_server_error_response import (
InternalServerErrorResponse,
InternalServerErrorResponse as InternalServerErrorResponse,
)
from stackit.git.models.list_flavors import ListFlavors as ListFlavors
from stackit.git.models.list_instances import ListInstances as ListInstances
from stackit.git.models.unauthorized_response import (
UnauthorizedResponse as UnauthorizedResponse,
)
from stackit.git.models.list_flavors import ListFlavors
from stackit.git.models.list_instances import ListInstances
from stackit.git.models.unauthorized_response import UnauthorizedResponse
42 changes: 21 additions & 21 deletions services/git/src/stackit/git/api/default_api.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, Dict, List, Optional, Tuple, Union

Expand Down Expand Up @@ -89,7 +89,7 @@ def create_instance(
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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -157,7 +157,7 @@ def create_instance_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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -225,7 +225,7 @@ def create_instance_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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -264,7 +264,7 @@ def _create_instance_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 @@ -352,7 +352,7 @@ def delete_instance(
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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -423,7 +423,7 @@ def delete_instance_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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -494,7 +494,7 @@ def delete_instance_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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -534,7 +534,7 @@ def _delete_instance_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 @@ -614,7 +614,7 @@ def get_instance(
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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -684,7 +684,7 @@ def get_instance_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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -754,7 +754,7 @@ def get_instance_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_instance_serialize(
project_id=project_id,
Expand Down Expand Up @@ -793,7 +793,7 @@ def _get_instance_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 @@ -875,7 +875,7 @@ def list_flavors(
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_flavors_serialize(
project_id=project_id,
Expand Down Expand Up @@ -946,7 +946,7 @@ def list_flavors_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_flavors_serialize(
project_id=project_id,
Expand Down Expand Up @@ -1017,7 +1017,7 @@ def list_flavors_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_flavors_serialize(
project_id=project_id,
Expand Down Expand Up @@ -1054,7 +1054,7 @@ def _list_flavors_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 @@ -1127,7 +1127,7 @@ def list_instances(
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_instances_serialize(
project_id=project_id,
Expand Down Expand Up @@ -1190,7 +1190,7 @@ def list_instances_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_instances_serialize(
project_id=project_id,
Expand Down Expand Up @@ -1253,7 +1253,7 @@ def list_instances_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_instances_serialize(
project_id=project_id,
Expand Down Expand Up @@ -1289,7 +1289,7 @@ def _list_instances_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
23 changes: 18 additions & 5 deletions services/git/src/stackit/git/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
Loading
Loading