Skip to content

Commit 2c11725

Browse files
Generate serviceenablement
1 parent 06bdc2a commit 2c11725

File tree

16 files changed

+162
-79
lines changed

16 files changed

+162
-79
lines changed

services/serviceenablement/src/stackit/serviceenablement/__init__.py

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,65 @@
1111
Generated by OpenAPI Generator (https://openapi-generator.tech)
1212
1313
Do not edit the class manually.
14-
""" # noqa: E501 docstring might be too long
14+
""" # noqa: E501
1515

1616

1717
__version__ = "1.0.0"
1818

19+
# Define package exports
20+
__all__ = [
21+
"DefaultApi",
22+
"ApiResponse",
23+
"ApiClient",
24+
"HostConfiguration",
25+
"OpenApiException",
26+
"ApiTypeError",
27+
"ApiValueError",
28+
"ApiKeyError",
29+
"ApiAttributeError",
30+
"ApiException",
31+
"ActionError",
32+
"CheckService",
33+
"CloudService",
34+
"Dependencies",
35+
"ErrorResponse",
36+
"ListServiceStatusRegional200Response",
37+
"Parameters",
38+
"ParametersGeneral",
39+
"ServiceStatus",
40+
]
41+
1942
# import apis into sdk package
20-
from stackit.serviceenablement.api.default_api import DefaultApi
21-
from stackit.serviceenablement.api_client import ApiClient
43+
from stackit.serviceenablement.api.default_api import DefaultApi as DefaultApi
44+
from stackit.serviceenablement.api_client import ApiClient as ApiClient
2245

2346
# import ApiClient
24-
from stackit.serviceenablement.api_response import ApiResponse
25-
from stackit.serviceenablement.configuration import HostConfiguration
26-
from stackit.serviceenablement.exceptions import (
27-
ApiAttributeError,
28-
ApiException,
29-
ApiKeyError,
30-
ApiTypeError,
31-
ApiValueError,
32-
OpenApiException,
47+
from stackit.serviceenablement.api_response import ApiResponse as ApiResponse
48+
from stackit.serviceenablement.configuration import (
49+
HostConfiguration as HostConfiguration,
3350
)
51+
from stackit.serviceenablement.exceptions import ApiAttributeError as ApiAttributeError
52+
from stackit.serviceenablement.exceptions import ApiException as ApiException
53+
from stackit.serviceenablement.exceptions import ApiKeyError as ApiKeyError
54+
from stackit.serviceenablement.exceptions import ApiTypeError as ApiTypeError
55+
from stackit.serviceenablement.exceptions import ApiValueError as ApiValueError
56+
from stackit.serviceenablement.exceptions import OpenApiException as OpenApiException
3457

3558
# import models into sdk package
36-
from stackit.serviceenablement.models.action_error import ActionError
37-
from stackit.serviceenablement.models.check_service import CheckService
38-
from stackit.serviceenablement.models.cloud_service import CloudService
39-
from stackit.serviceenablement.models.dependencies import Dependencies
40-
from stackit.serviceenablement.models.error_response import ErrorResponse
59+
from stackit.serviceenablement.models.action_error import ActionError as ActionError
60+
from stackit.serviceenablement.models.check_service import CheckService as CheckService
61+
from stackit.serviceenablement.models.cloud_service import CloudService as CloudService
62+
from stackit.serviceenablement.models.dependencies import Dependencies as Dependencies
63+
from stackit.serviceenablement.models.error_response import (
64+
ErrorResponse as ErrorResponse,
65+
)
4166
from stackit.serviceenablement.models.list_service_status_regional200_response import (
42-
ListServiceStatusRegional200Response,
67+
ListServiceStatusRegional200Response as ListServiceStatusRegional200Response,
68+
)
69+
from stackit.serviceenablement.models.parameters import Parameters as Parameters
70+
from stackit.serviceenablement.models.parameters_general import (
71+
ParametersGeneral as ParametersGeneral,
72+
)
73+
from stackit.serviceenablement.models.service_status import (
74+
ServiceStatus as ServiceStatus,
4375
)
44-
from stackit.serviceenablement.models.parameters import Parameters
45-
from stackit.serviceenablement.models.parameters_general import ParametersGeneral
46-
from stackit.serviceenablement.models.service_status import ServiceStatus

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

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

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

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

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

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

234234
_param = self._disable_service_regional_serialize(
235235
region=region,
@@ -270,7 +270,7 @@ def _disable_service_regional_serialize(
270270
_query_params: List[Tuple[str, str]] = []
271271
_header_params: Dict[str, Optional[str]] = _headers or {}
272272
_form_params: List[Tuple[str, str]] = []
273-
_files: Dict[str, Union[str, bytes]] = {}
273+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
274274
_body_params: Optional[bytes] = None
275275

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

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

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

502502
_param = self._enable_service_regional_serialize(
503503
region=region,
@@ -538,7 +538,7 @@ def _enable_service_regional_serialize(
538538
_query_params: List[Tuple[str, str]] = []
539539
_header_params: Dict[str, Optional[str]] = _headers or {}
540540
_form_params: List[Tuple[str, str]] = []
541-
_files: Dict[str, Union[str, bytes]] = {}
541+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
542542
_body_params: Optional[bytes] = None
543543

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

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

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

770770
_param = self._get_service_status_regional_serialize(
771771
region=region,
@@ -806,7 +806,7 @@ def _get_service_status_regional_serialize(
806806
_query_params: List[Tuple[str, str]] = []
807807
_header_params: Dict[str, Optional[str]] = _headers or {}
808808
_form_params: List[Tuple[str, str]] = []
809-
_files: Dict[str, Union[str, bytes]] = {}
809+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
810810
_body_params: Optional[bytes] = None
811811

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

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

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

10361036
_param = self._list_service_status_regional_serialize(
10371037
region=region,
@@ -1071,7 +1071,7 @@ def _list_service_status_regional_serialize(
10711071
_query_params: List[Tuple[str, str]] = []
10721072
_header_params: Dict[str, Optional[str]] = _headers or {}
10731073
_form_params: List[Tuple[str, str]] = []
1074-
_files: Dict[str, Union[str, bytes]] = {}
1074+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
10751075
_body_params: Optional[bytes] = None
10761076

10771077
# process the path parameters

services/serviceenablement/src/stackit/serviceenablement/api_client.py

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

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

334+
if isinstance(obj_dict, list):
335+
# 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
336+
return self.sanitize_for_serialization(obj_dict)
337+
334338
return {key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()}
335339

336340
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
350354
data = json.loads(response_text)
351355
except ValueError:
352356
data = response_text
353-
elif content_type.startswith("application/json"):
357+
elif re.match(r"^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)", content_type, re.IGNORECASE):
354358
if response_text == "":
355359
data = ""
356360
else:
357361
data = json.loads(response_text)
358-
elif content_type.startswith("text/plain"):
362+
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
359363
data = response_text
360364
else:
361365
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):
457461
if k in collection_formats:
458462
collection_format = collection_formats[k]
459463
if collection_format == "multi":
460-
new_params.extend((k, str(value)) for value in v)
464+
new_params.extend((k, quote(str(value))) for value in v)
461465
else:
462466
if collection_format == "ssv":
463467
delimiter = " "
@@ -473,7 +477,10 @@ def parameters_to_url_query(self, params, collection_formats):
473477

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

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

services/serviceenablement/src/stackit/serviceenablement/configuration.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# coding: utf-8
22

3-
import sys
4-
5-
import os
6-
7-
83
"""
94
STACKIT Service Enablement API
105
@@ -14,7 +9,29 @@
149
Generated by OpenAPI Generator (https://openapi-generator.tech)
1510
1611
Do not edit the class manually.
17-
""" # noqa: E501 docstring might be too long
12+
""" # noqa: E501
13+
14+
import sys
15+
from typing import Dict, List, Optional, TypedDict
16+
17+
from typing_extensions import NotRequired
18+
19+
import os
20+
21+
22+
ServerVariablesT = Dict[str, str]
23+
24+
25+
class HostSettingVariable(TypedDict):
26+
description: str
27+
default_value: str
28+
enum_values: List[str]
29+
30+
31+
class HostSetting(TypedDict):
32+
url: str
33+
description: str
34+
variables: NotRequired[Dict[str, HostSettingVariable]]
1835

1936

2037
class HostConfiguration:
@@ -53,7 +70,7 @@ def __init__(
5370
"""Ignore operation servers
5471
"""
5572

56-
def get_host_settings(self):
73+
def get_host_settings(self) -> List[HostSetting]:
5774
"""Gets an array of host settings
5875
5976
:return: An array of host settings
@@ -71,7 +88,12 @@ def get_host_settings(self):
7188
}
7289
]
7390

74-
def get_host_from_settings(self, index, variables=None, servers=None):
91+
def get_host_from_settings(
92+
self,
93+
index: Optional[int],
94+
variables: Optional[ServerVariablesT] = None,
95+
servers: Optional[List[HostSetting]] = None,
96+
) -> str:
7597
"""Gets host URL based on the index and variables
7698
:param index: array index of the host settings
7799
:param variables: hash of variable and the corresponding value
@@ -111,7 +133,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
111133
and variables.get(variable_name) is not None
112134
):
113135
raise ValueError(
114-
"this API does not support setting a region in the the client configuration, "
136+
"this API does not support setting a region in the client configuration, "
115137
"please check if the region can be specified as a function parameter"
116138
)
117139
used_value = variables.get(variable_name, variable["default_value"])
@@ -130,12 +152,12 @@ def get_host_from_settings(self, index, variables=None, servers=None):
130152
return url
131153

132154
@property
133-
def host(self):
155+
def host(self) -> str:
134156
"""Return generated host."""
135157
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
136158

137159
@host.setter
138-
def host(self, value):
160+
def host(self, value: str) -> None:
139161
"""Fix base path."""
140162
self._base_path = value
141163
self.server_index = None

0 commit comments

Comments
 (0)