Skip to content

Commit 9ddbb51

Browse files
stackit-pipelinemarceljk
authored andcommitted
Generate runcommand
1 parent 4fc018f commit 9ddbb51

19 files changed

+182
-90
lines changed

services/runcommand/src/stackit/runcommand/__init__.py

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,75 @@
1212
Generated by OpenAPI Generator (https://openapi-generator.tech)
1313
1414
Do not edit the class manually.
15-
""" # noqa: E501 docstring might be too long
15+
""" # noqa: E501
1616

1717

1818
__version__ = "1.0.0"
1919

20+
# Define package exports
21+
__all__ = [
22+
"DefaultApi",
23+
"ApiResponse",
24+
"ApiClient",
25+
"HostConfiguration",
26+
"OpenApiException",
27+
"ApiTypeError",
28+
"ApiValueError",
29+
"ApiKeyError",
30+
"ApiAttributeError",
31+
"ApiException",
32+
"CommandDetails",
33+
"CommandTemplate",
34+
"CommandTemplateResponse",
35+
"CommandTemplateSchema",
36+
"Commands",
37+
"CreateCommandPayload",
38+
"ErrorResponse",
39+
"GetCommandsResponse",
40+
"ModelField",
41+
"NewCommandResponse",
42+
"ParametersSchema",
43+
"Properties",
44+
]
45+
2046
# import apis into sdk package
21-
from stackit.runcommand.api.default_api import DefaultApi
22-
from stackit.runcommand.api_client import ApiClient
47+
from stackit.runcommand.api.default_api import DefaultApi as DefaultApi
48+
from stackit.runcommand.api_client import ApiClient as ApiClient
2349

2450
# import ApiClient
25-
from stackit.runcommand.api_response import ApiResponse
26-
from stackit.runcommand.configuration import HostConfiguration
27-
from stackit.runcommand.exceptions import (
28-
ApiAttributeError,
29-
ApiException,
30-
ApiKeyError,
31-
ApiTypeError,
32-
ApiValueError,
33-
OpenApiException,
34-
)
51+
from stackit.runcommand.api_response import ApiResponse as ApiResponse
52+
from stackit.runcommand.configuration import HostConfiguration as HostConfiguration
53+
from stackit.runcommand.exceptions import ApiAttributeError as ApiAttributeError
54+
from stackit.runcommand.exceptions import ApiException as ApiException
55+
from stackit.runcommand.exceptions import ApiKeyError as ApiKeyError
56+
from stackit.runcommand.exceptions import ApiTypeError as ApiTypeError
57+
from stackit.runcommand.exceptions import ApiValueError as ApiValueError
58+
from stackit.runcommand.exceptions import OpenApiException as OpenApiException
3559

3660
# import models into sdk package
37-
from stackit.runcommand.models.command_details import CommandDetails
38-
from stackit.runcommand.models.command_template import CommandTemplate
39-
from stackit.runcommand.models.command_template_response import CommandTemplateResponse
40-
from stackit.runcommand.models.command_template_schema import CommandTemplateSchema
41-
from stackit.runcommand.models.commands import Commands
42-
from stackit.runcommand.models.create_command_payload import CreateCommandPayload
43-
from stackit.runcommand.models.error_response import ErrorResponse
44-
from stackit.runcommand.models.get_commands_response import GetCommandsResponse
45-
from stackit.runcommand.models.model_field import ModelField
46-
from stackit.runcommand.models.new_command_response import NewCommandResponse
47-
from stackit.runcommand.models.parameters_schema import ParametersSchema
48-
from stackit.runcommand.models.properties import Properties
61+
from stackit.runcommand.models.command_details import CommandDetails as CommandDetails
62+
from stackit.runcommand.models.command_template import (
63+
CommandTemplate as CommandTemplate,
64+
)
65+
from stackit.runcommand.models.command_template_response import (
66+
CommandTemplateResponse as CommandTemplateResponse,
67+
)
68+
from stackit.runcommand.models.command_template_schema import (
69+
CommandTemplateSchema as CommandTemplateSchema,
70+
)
71+
from stackit.runcommand.models.commands import Commands as Commands
72+
from stackit.runcommand.models.create_command_payload import (
73+
CreateCommandPayload as CreateCommandPayload,
74+
)
75+
from stackit.runcommand.models.error_response import ErrorResponse as ErrorResponse
76+
from stackit.runcommand.models.get_commands_response import (
77+
GetCommandsResponse as GetCommandsResponse,
78+
)
79+
from stackit.runcommand.models.model_field import ModelField as ModelField
80+
from stackit.runcommand.models.new_command_response import (
81+
NewCommandResponse as NewCommandResponse,
82+
)
83+
from stackit.runcommand.models.parameters_schema import (
84+
ParametersSchema as ParametersSchema,
85+
)
86+
from stackit.runcommand.models.properties import Properties as Properties

services/runcommand/src/stackit/runcommand/api/default_api.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Generated by OpenAPI Generator (https://openapi-generator.tech)
1111
1212
Do not edit the class manually.
13-
""" # noqa: E501 docstring might be too long
13+
""" # noqa: E501
1414

1515
from typing import Any, Dict, List, Optional, Tuple, Union
1616

@@ -91,7 +91,7 @@ def create_command(
9191
in the spec for a single request.
9292
:type _host_index: int, optional
9393
:return: Returns the result object.
94-
""" # noqa: E501 docstring might be too long
94+
""" # noqa: E501
9595

9696
_param = self._create_command_serialize(
9797
project_id=project_id,
@@ -166,7 +166,7 @@ def create_command_with_http_info(
166166
in the spec for a single request.
167167
:type _host_index: int, optional
168168
:return: Returns the result object.
169-
""" # noqa: E501 docstring might be too long
169+
""" # noqa: E501
170170

171171
_param = self._create_command_serialize(
172172
project_id=project_id,
@@ -241,7 +241,7 @@ def create_command_without_preload_content(
241241
in the spec for a single request.
242242
:type _host_index: int, optional
243243
:return: Returns the result object.
244-
""" # noqa: E501 docstring might be too long
244+
""" # noqa: E501
245245

246246
_param = self._create_command_serialize(
247247
project_id=project_id,
@@ -283,7 +283,7 @@ def _create_command_serialize(
283283
_query_params: List[Tuple[str, str]] = []
284284
_header_params: Dict[str, Optional[str]] = _headers or {}
285285
_form_params: List[Tuple[str, str]] = []
286-
_files: Dict[str, Union[str, bytes]] = {}
286+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
287287
_body_params: Optional[bytes] = None
288288

289289
# process the path parameters
@@ -379,7 +379,7 @@ def get_command(
379379
in the spec for a single request.
380380
:type _host_index: int, optional
381381
:return: Returns the result object.
382-
""" # noqa: E501 docstring might be too long
382+
""" # noqa: E501
383383

384384
_param = self._get_command_serialize(
385385
project_id=project_id,
@@ -454,7 +454,7 @@ def get_command_with_http_info(
454454
in the spec for a single request.
455455
:type _host_index: int, optional
456456
:return: Returns the result object.
457-
""" # noqa: E501 docstring might be too long
457+
""" # noqa: E501
458458

459459
_param = self._get_command_serialize(
460460
project_id=project_id,
@@ -529,7 +529,7 @@ def get_command_without_preload_content(
529529
in the spec for a single request.
530530
:type _host_index: int, optional
531531
:return: Returns the result object.
532-
""" # noqa: E501 docstring might be too long
532+
""" # noqa: E501
533533

534534
_param = self._get_command_serialize(
535535
project_id=project_id,
@@ -571,7 +571,7 @@ def _get_command_serialize(
571571
_query_params: List[Tuple[str, str]] = []
572572
_header_params: Dict[str, Optional[str]] = _headers or {}
573573
_form_params: List[Tuple[str, str]] = []
574-
_files: Dict[str, Union[str, bytes]] = {}
574+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
575575
_body_params: Optional[bytes] = None
576576

577577
# process the path parameters
@@ -659,7 +659,7 @@ def get_command_template(
659659
in the spec for a single request.
660660
:type _host_index: int, optional
661661
:return: Returns the result object.
662-
""" # noqa: E501 docstring might be too long
662+
""" # noqa: E501
663663

664664
_param = self._get_command_template_serialize(
665665
project_id=project_id,
@@ -734,7 +734,7 @@ def get_command_template_with_http_info(
734734
in the spec for a single request.
735735
:type _host_index: int, optional
736736
:return: Returns the result object.
737-
""" # noqa: E501 docstring might be too long
737+
""" # noqa: E501
738738

739739
_param = self._get_command_template_serialize(
740740
project_id=project_id,
@@ -809,7 +809,7 @@ def get_command_template_without_preload_content(
809809
in the spec for a single request.
810810
:type _host_index: int, optional
811811
:return: Returns the result object.
812-
""" # noqa: E501 docstring might be too long
812+
""" # noqa: E501
813813

814814
_param = self._get_command_template_serialize(
815815
project_id=project_id,
@@ -851,7 +851,7 @@ def _get_command_template_serialize(
851851
_query_params: List[Tuple[str, str]] = []
852852
_header_params: Dict[str, Optional[str]] = _headers or {}
853853
_form_params: List[Tuple[str, str]] = []
854-
_files: Dict[str, Union[str, bytes]] = {}
854+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
855855
_body_params: Optional[bytes] = None
856856

857857
# process the path parameters
@@ -935,7 +935,7 @@ def list_command_templates(
935935
in the spec for a single request.
936936
:type _host_index: int, optional
937937
:return: Returns the result object.
938-
""" # noqa: E501 docstring might be too long
938+
""" # noqa: E501
939939

940940
_param = self._list_command_templates_serialize(
941941
os_type=os_type,
@@ -1002,7 +1002,7 @@ def list_command_templates_with_http_info(
10021002
in the spec for a single request.
10031003
:type _host_index: int, optional
10041004
:return: Returns the result object.
1005-
""" # noqa: E501 docstring might be too long
1005+
""" # noqa: E501
10061006

10071007
_param = self._list_command_templates_serialize(
10081008
os_type=os_type,
@@ -1069,7 +1069,7 @@ def list_command_templates_without_preload_content(
10691069
in the spec for a single request.
10701070
:type _host_index: int, optional
10711071
:return: Returns the result object.
1072-
""" # noqa: E501 docstring might be too long
1072+
""" # noqa: E501
10731073

10741074
_param = self._list_command_templates_serialize(
10751075
os_type=os_type,
@@ -1104,7 +1104,7 @@ def _list_command_templates_serialize(
11041104
_query_params: List[Tuple[str, str]] = []
11051105
_header_params: Dict[str, Optional[str]] = _headers or {}
11061106
_form_params: List[Tuple[str, str]] = []
1107-
_files: Dict[str, Union[str, bytes]] = {}
1107+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
11081108
_body_params: Optional[bytes] = None
11091109

11101110
# process the path parameters
@@ -1185,7 +1185,7 @@ def list_commands(
11851185
in the spec for a single request.
11861186
:type _host_index: int, optional
11871187
:return: Returns the result object.
1188-
""" # noqa: E501 docstring might be too long
1188+
""" # noqa: E501
11891189

11901190
_param = self._list_commands_serialize(
11911191
project_id=project_id,
@@ -1256,7 +1256,7 @@ def list_commands_with_http_info(
12561256
in the spec for a single request.
12571257
:type _host_index: int, optional
12581258
:return: Returns the result object.
1259-
""" # noqa: E501 docstring might be too long
1259+
""" # noqa: E501
12601260

12611261
_param = self._list_commands_serialize(
12621262
project_id=project_id,
@@ -1327,7 +1327,7 @@ def list_commands_without_preload_content(
13271327
in the spec for a single request.
13281328
:type _host_index: int, optional
13291329
:return: Returns the result object.
1330-
""" # noqa: E501 docstring might be too long
1330+
""" # noqa: E501
13311331

13321332
_param = self._list_commands_serialize(
13331333
project_id=project_id,
@@ -1367,7 +1367,7 @@ def _list_commands_serialize(
13671367
_query_params: List[Tuple[str, str]] = []
13681368
_header_params: Dict[str, Optional[str]] = _headers or {}
13691369
_form_params: List[Tuple[str, str]] = []
1370-
_files: Dict[str, Union[str, bytes]] = {}
1370+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
13711371
_body_params: Optional[bytes] = None
13721372

13731373
# process the path parameters

services/runcommand/src/stackit/runcommand/api_client.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Generated by OpenAPI Generator (https://openapi-generator.tech)
1111
1212
Do not edit the class manually.
13-
""" # noqa: E501 docstring might be too long
13+
""" # noqa: E501
1414

1515
import datetime
1616
import json
@@ -332,6 +332,10 @@ def sanitize_for_serialization(self, obj):
332332
else:
333333
obj_dict = obj.__dict__
334334

335+
if isinstance(obj_dict, list):
336+
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict() # noqa: E501
337+
return self.sanitize_for_serialization(obj_dict)
338+
335339
return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
336340

337341
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
351355
data = json.loads(response_text)
352356
except ValueError:
353357
data = response_text
354-
elif content_type.startswith("application/json"):
358+
elif re.match(r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE):
355359
if response_text == "":
356360
data = ""
357361
else:
358362
data = json.loads(response_text)
359-
elif content_type.startswith("text/plain"):
363+
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
360364
data = response_text
361365
else:
362366
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):
458462
if k in collection_formats:
459463
collection_format = collection_formats[k]
460464
if collection_format == "multi":
461-
new_params.extend((k, str(value)) for value in v)
465+
new_params.extend((k, quote(str(value))) for value in v)
462466
else:
463467
if collection_format == "ssv":
464468
delimiter = " "
@@ -474,7 +478,10 @@ def parameters_to_url_query(self, params, collection_formats):
474478

475479
return "&".join(["=".join(map(str, item)) for item in new_params])
476480

477-
def files_parameters(self, files: Dict[str, Union[str, bytes]]):
481+
def files_parameters(
482+
self,
483+
files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
484+
):
478485
"""Builds form parameters.
479486
480487
:param files: File parameters.
@@ -489,6 +496,12 @@ def files_parameters(self, files: Dict[str, Union[str, bytes]]):
489496
elif isinstance(v, bytes):
490497
filename = k
491498
filedata = v
499+
elif isinstance(v, tuple):
500+
filename, filedata = v
501+
elif isinstance(v, list):
502+
for file_param in v:
503+
params.extend(self.files_parameters({k: file_param}))
504+
continue
492505
else:
493506
raise ValueError("Unsupported file value")
494507
mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"

0 commit comments

Comments
 (0)