Skip to content

Commit a7480d2

Browse files
Generate observability
1 parent 5171137 commit a7480d2

File tree

98 files changed

+724
-523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+724
-523
lines changed

services/observability/src/stackit/observability/__init__.py

Lines changed: 254 additions & 107 deletions
Large diffs are not rendered by default.

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

Lines changed: 213 additions & 213 deletions
Large diffs are not rendered by default.

services/observability/src/stackit/observability/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()
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"

services/observability/src/stackit/observability/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 Observability API
105
@@ -15,7 +10,29 @@
1510
Generated by OpenAPI Generator (https://openapi-generator.tech)
1611
1712
Do not edit the class manually.
18-
""" # noqa: E501 docstring might be too long
13+
""" # noqa: E501
14+
15+
import sys
16+
from typing import Dict, List, Optional, TypedDict
17+
18+
from typing_extensions import NotRequired
19+
20+
import os
21+
22+
23+
ServerVariablesT = Dict[str, str]
24+
25+
26+
class HostSettingVariable(TypedDict):
27+
description: str
28+
default_value: str
29+
enum_values: List[str]
30+
31+
32+
class HostSetting(TypedDict):
33+
url: str
34+
description: str
35+
variables: NotRequired[Dict[str, HostSettingVariable]]
1936

2037

2138
class HostConfiguration:
@@ -54,7 +71,7 @@ def __init__(
5471
"""Ignore operation servers
5572
"""
5673

57-
def get_host_settings(self):
74+
def get_host_settings(self) -> List[HostSetting]:
5875
"""Gets an array of host settings
5976
6077
:return: An array of host settings
@@ -73,7 +90,12 @@ def get_host_settings(self):
7390
}
7491
]
7592

76-
def get_host_from_settings(self, index, variables=None, servers=None):
93+
def get_host_from_settings(
94+
self,
95+
index: Optional[int],
96+
variables: Optional[ServerVariablesT] = None,
97+
servers: Optional[List[HostSetting]] = None,
98+
) -> str:
7799
"""Gets host URL based on the index and variables
78100
:param index: array index of the host settings
79101
:param variables: hash of variable and the corresponding value
@@ -113,7 +135,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
113135
and variables.get(variable_name) is not None
114136
):
115137
raise ValueError(
116-
"this API does not support setting a region in the the client configuration, "
138+
"this API does not support setting a region in the client configuration, "
117139
"please check if the region can be specified as a function parameter"
118140
)
119141
used_value = variables.get(variable_name, variable["default_value"])
@@ -132,12 +154,12 @@ def get_host_from_settings(self, index, variables=None, servers=None):
132154
return url
133155

134156
@property
135-
def host(self):
157+
def host(self) -> str:
136158
"""Return generated host."""
137159
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
138160

139161
@host.setter
140-
def host(self, value):
162+
def host(self, value: str) -> None:
141163
"""Fix base path."""
142164
self._base_path = value
143165
self.server_index = None

services/observability/src/stackit/observability/exceptions.py

Lines changed: 21 additions & 2 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, Optional
1616

@@ -128,7 +128,7 @@ def __init__(
128128
if self.body is None:
129129
try:
130130
self.body = http_resp.data.decode("utf-8")
131-
except Exception: # noqa: S110
131+
except Exception:
132132
pass
133133
self.headers = http_resp.getheaders()
134134

@@ -152,6 +152,13 @@ def from_response(
152152
if http_resp.status == 404:
153153
raise NotFoundException(http_resp=http_resp, body=body, data=data)
154154

155+
# Added new conditions for 409 and 422
156+
if http_resp.status == 409:
157+
raise ConflictException(http_resp=http_resp, body=body, data=data)
158+
159+
if http_resp.status == 422:
160+
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
161+
155162
if 500 <= http_resp.status <= 599:
156163
raise ServiceException(http_resp=http_resp, body=body, data=data)
157164
raise ApiException(http_resp=http_resp, body=body, data=data)
@@ -188,6 +195,18 @@ class ServiceException(ApiException):
188195
pass
189196

190197

198+
class ConflictException(ApiException):
199+
"""Exception for HTTP 409 Conflict."""
200+
201+
pass
202+
203+
204+
class UnprocessableEntityException(ApiException):
205+
"""Exception for HTTP 422 Unprocessable Entity."""
206+
207+
pass
208+
209+
191210
def render_path(path_to_item):
192211
"""Returns a string representation of a path"""
193212
result = ""

services/observability/src/stackit/observability/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
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
# import models into model package

services/observability/src/stackit/observability/models/alert.py

Lines changed: 2 additions & 2 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 __future__ import annotations
1616

@@ -30,7 +30,7 @@
3030
class Alert(BaseModel):
3131
"""
3232
Alert
33-
"""
33+
""" # noqa: E501
3434

3535
var_global: Optional[ModelGlobal] = Field(default=None, alias="global")
3636
inhibit_rules: Optional[List[InhibitRules]] = Field(default=None, alias="inhibitRules")

services/observability/src/stackit/observability/models/alert_config_receivers_response.py

Lines changed: 2 additions & 2 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 __future__ import annotations
1616

@@ -27,7 +27,7 @@
2727
class AlertConfigReceiversResponse(BaseModel):
2828
"""
2929
AlertConfigReceiversResponse
30-
"""
30+
""" # noqa: E501
3131

3232
data: List[Receivers]
3333
message: Annotated[str, Field(min_length=1, strict=True)]

services/observability/src/stackit/observability/models/alert_config_route_response.py

Lines changed: 2 additions & 2 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 __future__ import annotations
1616

@@ -27,7 +27,7 @@
2727
class AlertConfigRouteResponse(BaseModel):
2828
"""
2929
AlertConfigRouteResponse
30-
"""
30+
""" # noqa: E501
3131

3232
data: Route
3333
message: Annotated[str, Field(min_length=1, strict=True)]

services/observability/src/stackit/observability/models/alert_group.py

Lines changed: 2 additions & 2 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 __future__ import annotations
1616

@@ -27,7 +27,7 @@
2727
class AlertGroup(BaseModel):
2828
"""
2929
AlertGroup
30-
"""
30+
""" # noqa: E501
3131

3232
interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = "60s"
3333
name: Annotated[str, Field(min_length=1, strict=True, max_length=200)]

0 commit comments

Comments
 (0)