Skip to content

Generator: Update SDK /services/observability #1382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
361 changes: 254 additions & 107 deletions services/observability/src/stackit/observability/__init__.py

Large diffs are not rendered by default.

426 changes: 213 additions & 213 deletions services/observability/src/stackit/observability/api/default_api.py

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions services/observability/src/stackit/observability/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
44 changes: 33 additions & 11 deletions services/observability/src/stackit/observability/configuration.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# coding: utf-8

import sys

import os


"""
STACKIT Observability API

Expand All @@ -15,7 +10,29 @@
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long
""" # noqa: E501

import sys
from typing import Dict, List, Optional, TypedDict

from typing_extensions import NotRequired

import os


ServerVariablesT = Dict[str, str]


class HostSettingVariable(TypedDict):
description: str
default_value: str
enum_values: List[str]


class HostSetting(TypedDict):
url: str
description: str
variables: NotRequired[Dict[str, HostSettingVariable]]


class HostConfiguration:
Expand Down Expand Up @@ -54,7 +71,7 @@ def __init__(
"""Ignore operation servers
"""

def get_host_settings(self):
def get_host_settings(self) -> List[HostSetting]:
"""Gets an array of host settings

:return: An array of host settings
Expand All @@ -73,7 +90,12 @@ def get_host_settings(self):
}
]

def get_host_from_settings(self, index, variables=None, servers=None):
def get_host_from_settings(
self,
index: Optional[int],
variables: Optional[ServerVariablesT] = None,
servers: Optional[List[HostSetting]] = None,
) -> str:
"""Gets host URL based on the index and variables
:param index: array index of the host settings
:param variables: hash of variable and the corresponding value
Expand Down Expand Up @@ -113,7 +135,7 @@ def get_host_from_settings(self, index, variables=None, servers=None):
and variables.get(variable_name) is not None
):
raise ValueError(
"this API does not support setting a region in the the client configuration, "
"this API does not support setting a region in the client configuration, "
"please check if the region can be specified as a function parameter"
)
used_value = variables.get(variable_name, variable["default_value"])
Expand All @@ -132,12 +154,12 @@ def get_host_from_settings(self, index, variables=None, servers=None):
return url

@property
def host(self):
def host(self) -> str:
"""Return generated host."""
return self.get_host_from_settings(self.server_index, variables=self.server_variables)

@host.setter
def host(self, value):
def host(self, value: str) -> None:
"""Fix base path."""
self._base_path = value
self.server_index = None
23 changes: 21 additions & 2 deletions services/observability/src/stackit/observability/exceptions.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, Optional

Expand Down Expand Up @@ -128,7 +128,7 @@ def __init__(
if self.body is None:
try:
self.body = http_resp.data.decode("utf-8")
except Exception: # noqa: S110
except Exception:
pass
self.headers = http_resp.getheaders()

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

# Added new conditions for 409 and 422
if http_resp.status == 409:
raise ConflictException(http_resp=http_resp, body=body, data=data)

if http_resp.status == 422:
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)

if 500 <= http_resp.status <= 599:
raise ServiceException(http_resp=http_resp, body=body, data=data)
raise ApiException(http_resp=http_resp, body=body, data=data)
Expand Down Expand Up @@ -188,6 +195,18 @@ class ServiceException(ApiException):
pass


class ConflictException(ApiException):
"""Exception for HTTP 409 Conflict."""

pass


class UnprocessableEntityException(ApiException):
"""Exception for HTTP 422 Unprocessable Entity."""

pass


def render_path(path_to_item):
"""Returns a string representation of a path"""
result = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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 models into model package
Expand Down
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 __future__ import annotations

Expand All @@ -30,7 +30,7 @@
class Alert(BaseModel):
"""
Alert
"""
""" # noqa: E501

var_global: Optional[ModelGlobal] = Field(default=None, alias="global")
inhibit_rules: Optional[List[InhibitRules]] = Field(default=None, alias="inhibitRules")
Expand Down
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 __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AlertConfigReceiversResponse(BaseModel):
"""
AlertConfigReceiversResponse
"""
""" # noqa: E501

data: List[Receivers]
message: Annotated[str, Field(min_length=1, strict=True)]
Expand Down
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 __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AlertConfigRouteResponse(BaseModel):
"""
AlertConfigRouteResponse
"""
""" # noqa: E501

data: Route
message: Annotated[str, Field(min_length=1, strict=True)]
Expand Down
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 __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AlertGroup(BaseModel):
"""
AlertGroup
"""
""" # noqa: E501

interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = "60s"
name: Annotated[str, Field(min_length=1, strict=True, max_length=200)]
Expand Down
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 __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AlertGroupResponse(BaseModel):
"""
AlertGroupResponse
"""
""" # noqa: E501

data: AlertGroup
message: Annotated[str, Field(min_length=1, strict=True)]
Expand Down
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 __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AlertGroupsResponse(BaseModel):
"""
AlertGroupsResponse
"""
""" # noqa: E501

data: List[AlertGroup]
message: Annotated[str, Field(min_length=1, strict=True)]
Expand Down
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 __future__ import annotations

Expand All @@ -25,7 +25,7 @@
class AlertRule(BaseModel):
"""
AlertRule
"""
""" # noqa: E501

alert: Annotated[str, Field(min_length=1, strict=True, max_length=200)]
annotations: Optional[Dict[str, Annotated[str, Field(min_length=1, strict=True)]]] = None
Expand Down
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 __future__ import annotations

Expand All @@ -25,7 +25,7 @@
class AlertRuleRecord(BaseModel):
"""
AlertRuleRecord
"""
""" # noqa: E501

alert: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = None
annotations: Optional[Dict[str, Annotated[str, Field(min_length=1, strict=True)]]] = None
Expand Down
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 __future__ import annotations

Expand All @@ -27,7 +27,7 @@
class AlertRulesResponse(BaseModel):
"""
AlertRulesResponse
"""
""" # noqa: E501

data: List[AlertRule]
message: Annotated[str, Field(min_length=1, strict=True)]
Expand Down
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 __future__ import annotations

Expand All @@ -25,7 +25,7 @@
class BasicAuth(BaseModel):
"""
BasicAuth
"""
""" # noqa: E501

password: Annotated[str, Field(min_length=1, strict=True, max_length=200)]
username: Annotated[str, Field(min_length=1, strict=True, max_length=200)]
Expand Down
Loading
Loading