Skip to content

Commit da9f3df

Browse files
Generate certificates
1 parent 5171137 commit da9f3df

File tree

13 files changed

+149
-73
lines changed

13 files changed

+149
-73
lines changed

services/certificates/src/stackit/certificates/__init__.py

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,59 @@
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+
"CreateCertificatePayload",
32+
"CreateCertificateResponse",
33+
"GetCertificateResponse",
34+
"GoogleProtobufAny",
35+
"ListCertificatesResponse",
36+
"Status",
37+
]
38+
1939
# import apis into sdk package
20-
from stackit.certificates.api.default_api import DefaultApi
21-
from stackit.certificates.api_client import ApiClient
40+
from stackit.certificates.api.default_api import DefaultApi as DefaultApi
41+
from stackit.certificates.api_client import ApiClient as ApiClient
2242

2343
# import ApiClient
24-
from stackit.certificates.api_response import ApiResponse
25-
from stackit.certificates.configuration import HostConfiguration
26-
from stackit.certificates.exceptions import (
27-
ApiAttributeError,
28-
ApiException,
29-
ApiKeyError,
30-
ApiTypeError,
31-
ApiValueError,
32-
OpenApiException,
33-
)
44+
from stackit.certificates.api_response import ApiResponse as ApiResponse
45+
from stackit.certificates.configuration import HostConfiguration as HostConfiguration
46+
from stackit.certificates.exceptions import ApiAttributeError as ApiAttributeError
47+
from stackit.certificates.exceptions import ApiException as ApiException
48+
from stackit.certificates.exceptions import ApiKeyError as ApiKeyError
49+
from stackit.certificates.exceptions import ApiTypeError as ApiTypeError
50+
from stackit.certificates.exceptions import ApiValueError as ApiValueError
51+
from stackit.certificates.exceptions import OpenApiException as OpenApiException
3452

3553
# import models into sdk package
3654
from stackit.certificates.models.create_certificate_payload import (
37-
CreateCertificatePayload,
55+
CreateCertificatePayload as CreateCertificatePayload,
3856
)
3957
from stackit.certificates.models.create_certificate_response import (
40-
CreateCertificateResponse,
58+
CreateCertificateResponse as CreateCertificateResponse,
59+
)
60+
from stackit.certificates.models.get_certificate_response import (
61+
GetCertificateResponse as GetCertificateResponse,
62+
)
63+
from stackit.certificates.models.google_protobuf_any import (
64+
GoogleProtobufAny as GoogleProtobufAny,
4165
)
42-
from stackit.certificates.models.get_certificate_response import GetCertificateResponse
43-
from stackit.certificates.models.google_protobuf_any import GoogleProtobufAny
4466
from stackit.certificates.models.list_certificates_response import (
45-
ListCertificatesResponse,
67+
ListCertificatesResponse as ListCertificatesResponse,
4668
)
47-
from stackit.certificates.models.status import Status
69+
from stackit.certificates.models.status import Status as Status

services/certificates/src/stackit/certificates/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

@@ -91,7 +91,7 @@ def create_certificate(
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_certificate_serialize(
9797
project_id=project_id,
@@ -163,7 +163,7 @@ def create_certificate_with_http_info(
163163
in the spec for a single request.
164164
:type _host_index: int, optional
165165
:return: Returns the result object.
166-
""" # noqa: E501 docstring might be too long
166+
""" # noqa: E501
167167

168168
_param = self._create_certificate_serialize(
169169
project_id=project_id,
@@ -235,7 +235,7 @@ def create_certificate_without_preload_content(
235235
in the spec for a single request.
236236
:type _host_index: int, optional
237237
:return: Returns the result object.
238-
""" # noqa: E501 docstring might be too long
238+
""" # noqa: E501
239239

240240
_param = self._create_certificate_serialize(
241241
project_id=project_id,
@@ -276,7 +276,7 @@ def _create_certificate_serialize(
276276
_query_params: List[Tuple[str, str]] = []
277277
_header_params: Dict[str, Optional[str]] = _headers or {}
278278
_form_params: List[Tuple[str, str]] = []
279-
_files: Dict[str, Union[str, bytes]] = {}
279+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
280280
_body_params: Optional[bytes] = None
281281

282282
# process the path parameters
@@ -367,7 +367,7 @@ def delete_certificate(
367367
in the spec for a single request.
368368
:type _host_index: int, optional
369369
:return: Returns the result object.
370-
""" # noqa: E501 docstring might be too long
370+
""" # noqa: E501
371371

372372
_param = self._delete_certificate_serialize(
373373
project_id=project_id,
@@ -439,7 +439,7 @@ def delete_certificate_with_http_info(
439439
in the spec for a single request.
440440
:type _host_index: int, optional
441441
:return: Returns the result object.
442-
""" # noqa: E501 docstring might be too long
442+
""" # noqa: E501
443443

444444
_param = self._delete_certificate_serialize(
445445
project_id=project_id,
@@ -511,7 +511,7 @@ def delete_certificate_without_preload_content(
511511
in the spec for a single request.
512512
:type _host_index: int, optional
513513
:return: Returns the result object.
514-
""" # noqa: E501 docstring might be too long
514+
""" # noqa: E501
515515

516516
_param = self._delete_certificate_serialize(
517517
project_id=project_id,
@@ -552,7 +552,7 @@ def _delete_certificate_serialize(
552552
_query_params: List[Tuple[str, str]] = []
553553
_header_params: Dict[str, Optional[str]] = _headers or {}
554554
_form_params: List[Tuple[str, str]] = []
555-
_files: Dict[str, Union[str, bytes]] = {}
555+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
556556
_body_params: Optional[bytes] = None
557557

558558
# process the path parameters
@@ -635,7 +635,7 @@ def get_certificate(
635635
in the spec for a single request.
636636
:type _host_index: int, optional
637637
:return: Returns the result object.
638-
""" # noqa: E501 docstring might be too long
638+
""" # noqa: E501
639639

640640
_param = self._get_certificate_serialize(
641641
project_id=project_id,
@@ -708,7 +708,7 @@ def get_certificate_with_http_info(
708708
in the spec for a single request.
709709
:type _host_index: int, optional
710710
:return: Returns the result object.
711-
""" # noqa: E501 docstring might be too long
711+
""" # noqa: E501
712712

713713
_param = self._get_certificate_serialize(
714714
project_id=project_id,
@@ -781,7 +781,7 @@ def get_certificate_without_preload_content(
781781
in the spec for a single request.
782782
:type _host_index: int, optional
783783
:return: Returns the result object.
784-
""" # noqa: E501 docstring might be too long
784+
""" # noqa: E501
785785

786786
_param = self._get_certificate_serialize(
787787
project_id=project_id,
@@ -823,7 +823,7 @@ def _get_certificate_serialize(
823823
_query_params: List[Tuple[str, str]] = []
824824
_header_params: Dict[str, Optional[str]] = _headers or {}
825825
_form_params: List[Tuple[str, str]] = []
826-
_files: Dict[str, Union[str, bytes]] = {}
826+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
827827
_body_params: Optional[bytes] = None
828828

829829
# process the path parameters
@@ -919,7 +919,7 @@ def list_certificates(
919919
in the spec for a single request.
920920
:type _host_index: int, optional
921921
:return: Returns the result object.
922-
""" # noqa: E501 docstring might be too long
922+
""" # noqa: E501
923923

924924
_param = self._list_certificates_serialize(
925925
project_id=project_id,
@@ -1006,7 +1006,7 @@ def list_certificates_with_http_info(
10061006
in the spec for a single request.
10071007
:type _host_index: int, optional
10081008
:return: Returns the result object.
1009-
""" # noqa: E501 docstring might be too long
1009+
""" # noqa: E501
10101010

10111011
_param = self._list_certificates_serialize(
10121012
project_id=project_id,
@@ -1093,7 +1093,7 @@ def list_certificates_without_preload_content(
10931093
in the spec for a single request.
10941094
:type _host_index: int, optional
10951095
:return: Returns the result object.
1096-
""" # noqa: E501 docstring might be too long
1096+
""" # noqa: E501
10971097

10981098
_param = self._list_certificates_serialize(
10991099
project_id=project_id,
@@ -1137,7 +1137,7 @@ def _list_certificates_serialize(
11371137
_query_params: List[Tuple[str, str]] = []
11381138
_header_params: Dict[str, Optional[str]] = _headers or {}
11391139
_form_params: List[Tuple[str, str]] = []
1140-
_files: Dict[str, Union[str, bytes]] = {}
1140+
_files: Dict[str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]] = {}
11411141
_body_params: Optional[bytes] = None
11421142

11431143
# process the path parameters

services/certificates/src/stackit/certificates/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()
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/certificates/src/stackit/certificates/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
Load Balancer Certificates 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)