From 8293a96bfa85171e8d5395236beaf8e95b970d69 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Thu, 23 Oct 2025 09:04:41 +0000 Subject: [PATCH] Generate observability --- .../src/stackit/observability/__init__.py | 12 ++ .../stackit/observability/api/default_api.py | 62 ++++--- .../stackit/observability/models/__init__.py | 9 + .../models/cert_check_response.py | 9 +- .../models/create_alertgroups_payload.py | 2 +- .../models/create_cert_check400_response.py | 155 ++++++++++++++++++ .../models/create_logs_alertgroups_payload.py | 10 +- ...te_logs_alertgroups_payload_rules_inner.py | 114 +++++++++++++ .../models/http_check_response.py | 9 +- ...partial_update_alertrules_request_inner.py | 108 ++++++++++++ .../models/update_alertgroup_payload.py | 2 +- .../update_alertgroups_request_inner.py | 2 +- ...e_alertgroups_request_inner_rules_inner.py | 22 ++- .../models/update_logs_alertgroup_payload.py | 10 +- 14 files changed, 478 insertions(+), 48 deletions(-) create mode 100644 services/observability/src/stackit/observability/models/create_cert_check400_response.py create mode 100644 services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py create mode 100644 services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py diff --git a/services/observability/src/stackit/observability/__init__.py b/services/observability/src/stackit/observability/__init__.py index c1d2ea087..91a206f72 100644 --- a/services/observability/src/stackit/observability/__init__.py +++ b/services/observability/src/stackit/observability/__init__.py @@ -49,6 +49,7 @@ "CreateAlertConfigRoutePayloadRoutesInner", "CreateAlertgroupsPayload", "CreateAlertrulesPayload", + "CreateCertCheck400Response", "CreateCertCheckPayload", "CreateCredentialsPayload", "CreateCredentialsResponse", @@ -56,6 +57,7 @@ "CreateInstancePayload", "CreateInstanceResponse", "CreateLogsAlertgroupsPayload", + "CreateLogsAlertgroupsPayloadRulesInner", "CreateScrapeConfigPayload", "CreateScrapeConfigPayloadBasicAuth", "CreateScrapeConfigPayloadHttpSdConfigsInner", @@ -95,6 +97,7 @@ "ModelGlobal", "OAuth2", "OpsgenieConfig", + "PartialUpdateAlertrulesRequestInner", "PermissionDenied", "Plan", "PlanModel", @@ -203,6 +206,9 @@ from stackit.observability.models.create_alertrules_payload import ( CreateAlertrulesPayload as CreateAlertrulesPayload, ) +from stackit.observability.models.create_cert_check400_response import ( + CreateCertCheck400Response as CreateCertCheck400Response, +) from stackit.observability.models.create_cert_check_payload import ( CreateCertCheckPayload as CreateCertCheckPayload, ) @@ -224,6 +230,9 @@ from stackit.observability.models.create_logs_alertgroups_payload import ( CreateLogsAlertgroupsPayload as CreateLogsAlertgroupsPayload, ) +from stackit.observability.models.create_logs_alertgroups_payload_rules_inner import ( + CreateLogsAlertgroupsPayloadRulesInner as CreateLogsAlertgroupsPayloadRulesInner, +) from stackit.observability.models.create_scrape_config_payload import ( CreateScrapeConfigPayload as CreateScrapeConfigPayload, ) @@ -317,6 +326,9 @@ from stackit.observability.models.opsgenie_config import ( OpsgenieConfig as OpsgenieConfig, ) +from stackit.observability.models.partial_update_alertrules_request_inner import ( + PartialUpdateAlertrulesRequestInner as PartialUpdateAlertrulesRequestInner, +) from stackit.observability.models.permission_denied import ( PermissionDenied as PermissionDenied, ) diff --git a/services/observability/src/stackit/observability/api/default_api.py b/services/observability/src/stackit/observability/api/default_api.py index 05ea694c1..e8eab162b 100644 --- a/services/observability/src/stackit/observability/api/default_api.py +++ b/services/observability/src/stackit/observability/api/default_api.py @@ -95,6 +95,9 @@ ) from stackit.observability.models.logs_config_response import LogsConfigResponse from stackit.observability.models.message import Message +from stackit.observability.models.partial_update_alertrules_request_inner import ( + PartialUpdateAlertrulesRequestInner, +) from stackit.observability.models.plans_response import PlansResponse from stackit.observability.models.receiver import Receiver from stackit.observability.models.scrape_configs_response import ScrapeConfigsResponse @@ -118,9 +121,6 @@ from stackit.observability.models.update_alertgroups_request_inner import ( UpdateAlertgroupsRequestInner, ) -from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( - UpdateAlertgroupsRequestInnerRulesInner, -) from stackit.observability.models.update_credentials_remote_write_config_payload import ( UpdateCredentialsRemoteWriteConfigPayload, ) @@ -1314,6 +1314,7 @@ def create_cert_check( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "CreateCertCheck400Response", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1383,6 +1384,7 @@ def create_cert_check_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "CreateCertCheck400Response", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1452,6 +1454,7 @@ def create_cert_check_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "CreateCertCheck400Response", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1851,6 +1854,7 @@ def create_http_check( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "CreateCertCheck400Response", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1920,6 +1924,7 @@ def create_http_check_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "CreateCertCheck400Response", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -1989,6 +1994,7 @@ def create_http_check_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "CreateCertCheck400Response", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -4243,8 +4249,8 @@ def delete_cert_check( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "List[str]", "403": "PermissionDenied", - "404": "Message", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -4313,8 +4319,8 @@ def delete_cert_check_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "List[str]", "403": "PermissionDenied", - "404": "Message", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -4383,8 +4389,8 @@ def delete_cert_check_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "List[str]", "403": "PermissionDenied", - "404": "Message", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response @@ -5038,8 +5044,8 @@ def delete_http_check( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "List[str]", "403": "PermissionDenied", - "404": "Message", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -5108,8 +5114,8 @@ def delete_http_check_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "List[str]", "403": "PermissionDenied", - "404": "Message", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) response_data.read() @@ -5178,8 +5184,8 @@ def delete_http_check_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "List[str]", "403": "PermissionDenied", - "404": "Message", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) return response_data.response @@ -10606,6 +10612,7 @@ def list_cert_checks( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "List[str]", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -10671,6 +10678,7 @@ def list_cert_checks_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "List[str]", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -10736,6 +10744,7 @@ def list_cert_checks_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "CertCheckResponse", + "400": "List[str]", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -11094,6 +11103,7 @@ def list_http_checks( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "List[str]", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -11159,6 +11169,7 @@ def list_http_checks_with_http_info( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "List[str]", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -11224,6 +11235,7 @@ def list_http_checks_without_preload_content( _response_types_map: Dict[str, Optional[str]] = { "200": "HttpCheckResponse", + "400": "List[str]", "403": "PermissionDenied", } response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) @@ -12509,7 +12521,7 @@ def partial_update_alertrules( group_name: StrictStr, instance_id: StrictStr, project_id: StrictStr, - update_alertgroups_request_inner_rules_inner: List[UpdateAlertgroupsRequestInnerRulesInner], + partial_update_alertrules_request_inner: List[PartialUpdateAlertrulesRequestInner], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -12530,8 +12542,8 @@ def partial_update_alertrules( :type instance_id: str :param project_id: (required) :type project_id: str - :param update_alertgroups_request_inner_rules_inner: (required) - :type update_alertgroups_request_inner_rules_inner: List[UpdateAlertgroupsRequestInnerRulesInner] + :param partial_update_alertrules_request_inner: (required) + :type partial_update_alertrules_request_inner: List[PartialUpdateAlertrulesRequestInner] :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -12558,7 +12570,7 @@ def partial_update_alertrules( group_name=group_name, instance_id=instance_id, project_id=project_id, - update_alertgroups_request_inner_rules_inner=update_alertgroups_request_inner_rules_inner, + partial_update_alertrules_request_inner=partial_update_alertrules_request_inner, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -12583,7 +12595,7 @@ def partial_update_alertrules_with_http_info( group_name: StrictStr, instance_id: StrictStr, project_id: StrictStr, - update_alertgroups_request_inner_rules_inner: List[UpdateAlertgroupsRequestInnerRulesInner], + partial_update_alertrules_request_inner: List[PartialUpdateAlertrulesRequestInner], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -12604,8 +12616,8 @@ def partial_update_alertrules_with_http_info( :type instance_id: str :param project_id: (required) :type project_id: str - :param update_alertgroups_request_inner_rules_inner: (required) - :type update_alertgroups_request_inner_rules_inner: List[UpdateAlertgroupsRequestInnerRulesInner] + :param partial_update_alertrules_request_inner: (required) + :type partial_update_alertrules_request_inner: List[PartialUpdateAlertrulesRequestInner] :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -12632,7 +12644,7 @@ def partial_update_alertrules_with_http_info( group_name=group_name, instance_id=instance_id, project_id=project_id, - update_alertgroups_request_inner_rules_inner=update_alertgroups_request_inner_rules_inner, + partial_update_alertrules_request_inner=partial_update_alertrules_request_inner, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -12657,7 +12669,7 @@ def partial_update_alertrules_without_preload_content( group_name: StrictStr, instance_id: StrictStr, project_id: StrictStr, - update_alertgroups_request_inner_rules_inner: List[UpdateAlertgroupsRequestInnerRulesInner], + partial_update_alertrules_request_inner: List[PartialUpdateAlertrulesRequestInner], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -12678,8 +12690,8 @@ def partial_update_alertrules_without_preload_content( :type instance_id: str :param project_id: (required) :type project_id: str - :param update_alertgroups_request_inner_rules_inner: (required) - :type update_alertgroups_request_inner_rules_inner: List[UpdateAlertgroupsRequestInnerRulesInner] + :param partial_update_alertrules_request_inner: (required) + :type partial_update_alertrules_request_inner: List[PartialUpdateAlertrulesRequestInner] :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of @@ -12706,7 +12718,7 @@ def partial_update_alertrules_without_preload_content( group_name=group_name, instance_id=instance_id, project_id=project_id, - update_alertgroups_request_inner_rules_inner=update_alertgroups_request_inner_rules_inner, + partial_update_alertrules_request_inner=partial_update_alertrules_request_inner, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -12726,7 +12738,7 @@ def _partial_update_alertrules_serialize( group_name, instance_id, project_id, - update_alertgroups_request_inner_rules_inner, + partial_update_alertrules_request_inner, _request_auth, _content_type, _headers, @@ -12736,7 +12748,7 @@ def _partial_update_alertrules_serialize( _host = None _collection_formats: Dict[str, str] = { - "UpdateAlertgroupsRequestInnerRulesInner": "", + "PartialUpdateAlertrulesRequestInner": "", } _path_params: Dict[str, str] = {} @@ -12757,8 +12769,8 @@ def _partial_update_alertrules_serialize( # process the header parameters # process the form parameters # process the body parameter - if update_alertgroups_request_inner_rules_inner is not None: - _body_params = update_alertgroups_request_inner_rules_inner + if partial_update_alertrules_request_inner is not None: + _body_params = partial_update_alertrules_request_inner # set the HTTP header `Accept` if "Accept" not in _header_params: diff --git a/services/observability/src/stackit/observability/models/__init__.py b/services/observability/src/stackit/observability/models/__init__.py index 726b7070f..b2938298d 100644 --- a/services/observability/src/stackit/observability/models/__init__.py +++ b/services/observability/src/stackit/observability/models/__init__.py @@ -57,6 +57,9 @@ from stackit.observability.models.create_alertrules_payload import ( CreateAlertrulesPayload, ) +from stackit.observability.models.create_cert_check400_response import ( + CreateCertCheck400Response, +) from stackit.observability.models.create_cert_check_payload import ( CreateCertCheckPayload, ) @@ -74,6 +77,9 @@ from stackit.observability.models.create_logs_alertgroups_payload import ( CreateLogsAlertgroupsPayload, ) +from stackit.observability.models.create_logs_alertgroups_payload_rules_inner import ( + CreateLogsAlertgroupsPayloadRulesInner, +) from stackit.observability.models.create_scrape_config_payload import ( CreateScrapeConfigPayload, ) @@ -145,6 +151,9 @@ from stackit.observability.models.model_global import ModelGlobal from stackit.observability.models.o_auth2 import OAuth2 from stackit.observability.models.opsgenie_config import OpsgenieConfig +from stackit.observability.models.partial_update_alertrules_request_inner import ( + PartialUpdateAlertrulesRequestInner, +) from stackit.observability.models.permission_denied import PermissionDenied from stackit.observability.models.plan import Plan from stackit.observability.models.plan_model import PlanModel diff --git a/services/observability/src/stackit/observability/models/cert_check_response.py b/services/observability/src/stackit/observability/models/cert_check_response.py index a9afeef66..d3018d5ca 100644 --- a/services/observability/src/stackit/observability/models/cert_check_response.py +++ b/services/observability/src/stackit/observability/models/cert_check_response.py @@ -31,9 +31,10 @@ class CertCheckResponse(BaseModel): CertCheckResponse """ # noqa: E501 + cert_check: Optional[CertCheckChildResponse] = Field(default=None, alias="certCheck") cert_checks: Annotated[List[CertCheckChildResponse], Field(max_length=100)] = Field(alias="certChecks") message: Annotated[str, Field(min_length=1, strict=True)] - __properties: ClassVar[List[str]] = ["certChecks", "message"] + __properties: ClassVar[List[str]] = ["certCheck", "certChecks", "message"] model_config = ConfigDict( populate_by_name=True, @@ -72,6 +73,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of cert_check + if self.cert_check: + _dict["certCheck"] = self.cert_check.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in cert_checks (list) _items = [] if self.cert_checks: @@ -92,6 +96,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "certCheck": ( + CertCheckChildResponse.from_dict(obj["certCheck"]) if obj.get("certCheck") is not None else None + ), "certChecks": ( [CertCheckChildResponse.from_dict(_item) for _item in obj["certChecks"]] if obj.get("certChecks") is not None diff --git a/services/observability/src/stackit/observability/models/create_alertgroups_payload.py b/services/observability/src/stackit/observability/models/create_alertgroups_payload.py index a6ffa1a4a..688e87cbd 100644 --- a/services/observability/src/stackit/observability/models/create_alertgroups_payload.py +++ b/services/observability/src/stackit/observability/models/create_alertgroups_payload.py @@ -28,7 +28,7 @@ class CreateAlertgroupsPayload(BaseModel): """ - Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. + Alert group that should be created or updated. `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. """ # noqa: E501 interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( diff --git a/services/observability/src/stackit/observability/models/create_cert_check400_response.py b/services/observability/src/stackit/observability/models/create_cert_check400_response.py new file mode 100644 index 000000000..3e316a60b --- /dev/null +++ b/services/observability/src/stackit/observability/models/create_cert_check400_response.py @@ -0,0 +1,155 @@ +# coding: utf-8 + +""" + STACKIT Observability API + + API endpoints for Observability on STACKIT + + The version of the OpenAPI document: 1.1.1 + Contact: stackit-argus@mail.schwarz + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, Dict, List, Optional, Set, Union + +from pydantic import ( + BaseModel, + ConfigDict, + StrictStr, + ValidationError, + field_validator, +) +from typing_extensions import Self + + +CREATECERTCHECK400RESPONSE_ONE_OF_SCHEMAS = ["Dict[str, List[str]]", "List[str]"] + + +class CreateCertCheck400Response(BaseModel): + """ + CreateCertCheck400Response + """ + + # data type: Dict[str, List[str]] + oneof_schema_1_validator: Optional[Dict[str, List[StrictStr]]] = None + # data type: List[str] + oneof_schema_2_validator: Optional[List[StrictStr]] = None + actual_instance: Optional[Union[Dict[str, List[str]], List[str]]] = None + one_of_schemas: Set[str] = {"Dict[str, List[str]]", "List[str]"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = CreateCertCheck400Response.model_construct() + error_messages = [] + match = 0 + # validate data type: Dict[str, List[str]] + try: + instance.oneof_schema_1_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: List[str] + try: + instance.oneof_schema_2_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in CreateCertCheck400Response with oneOf schemas: Dict[str, List[str]], List[str]. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into Dict[str, List[str]] + try: + # validation + instance.oneof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_1_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into List[str] + try: + # validation + instance.oneof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_2_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into CreateCertCheck400Response with oneOf schemas: Dict[str, List[str]], List[str]. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into CreateCertCheck400Response with oneOf schemas: Dict[str, List[str]], List[str]. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], Dict[str, List[str]], List[str]]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py index d620dc339..fdaf0631f 100644 --- a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py +++ b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py @@ -21,14 +21,14 @@ from pydantic import BaseModel, ConfigDict, Field from typing_extensions import Annotated, Self -from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( - UpdateAlertgroupsRequestInnerRulesInner, +from stackit.observability.models.create_logs_alertgroups_payload_rules_inner import ( + CreateLogsAlertgroupsPayloadRulesInner, ) class CreateLogsAlertgroupsPayload(BaseModel): """ - Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. + Alert group that should be created or updated. `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. """ # noqa: E501 interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( @@ -38,7 +38,7 @@ class CreateLogsAlertgroupsPayload(BaseModel): name: Annotated[str, Field(min_length=1, strict=True, max_length=200)] = Field( description="The name of the group. Must be unique. `Additional Validators:` * is the identifier and so unique * should only include the characters: a-zA-Z0-9-" ) - rules: List[UpdateAlertgroupsRequestInnerRulesInner] = Field(description="rules for the alert group") + rules: List[CreateLogsAlertgroupsPayloadRulesInner] = Field(description="rules for the alert group") __properties: ClassVar[List[str]] = ["interval", "name", "rules"] model_config = ConfigDict( @@ -101,7 +101,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "interval": obj.get("interval") if obj.get("interval") is not None else "60s", "name": obj.get("name"), "rules": ( - [UpdateAlertgroupsRequestInnerRulesInner.from_dict(_item) for _item in obj["rules"]] + [CreateLogsAlertgroupsPayloadRulesInner.from_dict(_item) for _item in obj["rules"]] if obj.get("rules") is not None else None ), diff --git a/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py new file mode 100644 index 000000000..285dc0374 --- /dev/null +++ b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload_rules_inner.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + STACKIT Observability API + + API endpoints for Observability on STACKIT + + The version of the OpenAPI document: 1.1.1 + Contact: stackit-argus@mail.schwarz + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Annotated, Self + + +class CreateLogsAlertgroupsPayloadRulesInner(BaseModel): + """ + Rule definition. Must be either an Alerting Rule (using 'alert') or a Recording Rule (using 'record'). `Additional Validators:` * total config (all alert groups/rules) should not be bigger than 500000 characters as string since this the limitation of prometheus. + """ # noqa: E501 + + alert: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = Field( + default=None, + description="The name of the alert. When this attribute is used, an Alerting Rule will be created. `Additional Validators:` * is the identifier and so unique in the group * should only include the characters: a-zA-Z0-9- * required when 'record' is not used in this rule, otherwise not allowed", + ) + annotations: Optional[Dict[str, Any]] = Field( + default=None, + description="Map of key:value. Annotations to add to each alert. `Additional Validators:` * should not contain more than 5 keys * each key and value should not be longer than 200 characters * is not allowed to use when 'record' is used in this rule", + ) + expr: Annotated[str, Field(min_length=1, strict=True, max_length=600)] = Field( + description="The LogQL expression to evaluate to create alerts when using the 'alert' attribute in this rule, or to create a metric when using the 'record' attribute." + ) + var_for: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( + default="0s", + description="Alerts are considered firing once they have been returned for this long. Alerts which have not yet fired for long enough are considered pending. `Additional Validators:` * must be a valid time string * is not allowed to use when 'record' is used in this rule", + alias="for", + ) + labels: Optional[Dict[str, Any]] = Field( + default=None, + description="Map of key:value. Labels to add or overwrite for each alert or metric. `Additional Validators:` * should not contain more than 10 keys * each key and value should not be longer than 200 characters", + ) + record: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=300)]] = Field( + default=None, + description="The name of the metric. When this attribute is used, an Recording Rule will be created. `Additional Validators:` * is the identifier and so unique in the group * should only include the characters: a-zA-Z0-9:_ * required when 'alert' is not used in this rule, otherwise not allowed", + ) + __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels", "record"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateLogsAlertgroupsPayloadRulesInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateLogsAlertgroupsPayloadRulesInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "alert": obj.get("alert"), + "annotations": obj.get("annotations"), + "expr": obj.get("expr"), + "for": obj.get("for") if obj.get("for") is not None else "0s", + "labels": obj.get("labels"), + "record": obj.get("record"), + } + ) + return _obj diff --git a/services/observability/src/stackit/observability/models/http_check_response.py b/services/observability/src/stackit/observability/models/http_check_response.py index b6258d748..241265800 100644 --- a/services/observability/src/stackit/observability/models/http_check_response.py +++ b/services/observability/src/stackit/observability/models/http_check_response.py @@ -31,9 +31,10 @@ class HttpCheckResponse(BaseModel): HttpCheckResponse """ # noqa: E501 + http_check: Optional[HttpCheckChildResponse] = Field(default=None, alias="httpCheck") http_checks: Annotated[List[HttpCheckChildResponse], Field(max_length=100)] = Field(alias="httpChecks") message: Annotated[str, Field(min_length=1, strict=True)] - __properties: ClassVar[List[str]] = ["httpChecks", "message"] + __properties: ClassVar[List[str]] = ["httpCheck", "httpChecks", "message"] model_config = ConfigDict( populate_by_name=True, @@ -72,6 +73,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of http_check + if self.http_check: + _dict["httpCheck"] = self.http_check.to_dict() # override the default output from pydantic by calling `to_dict()` of each item in http_checks (list) _items = [] if self.http_checks: @@ -92,6 +96,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate( { + "httpCheck": ( + HttpCheckChildResponse.from_dict(obj["httpCheck"]) if obj.get("httpCheck") is not None else None + ), "httpChecks": ( [HttpCheckChildResponse.from_dict(_item) for _item in obj["httpChecks"]] if obj.get("httpChecks") is not None diff --git a/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py b/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py new file mode 100644 index 000000000..2863d7f72 --- /dev/null +++ b/services/observability/src/stackit/observability/models/partial_update_alertrules_request_inner.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" + STACKIT Observability API + + API endpoints for Observability on STACKIT + + The version of the OpenAPI document: 1.1.1 + Contact: stackit-argus@mail.schwarz + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Annotated, Self + + +class PartialUpdateAlertrulesRequestInner(BaseModel): + """ + Alert rule. `Additional Validators:` * total config (all alert groups/rules) should not be bigger than 500000 characters as string since this the limitation of prometheus. + """ # noqa: E501 + + alert: Annotated[str, Field(min_length=1, strict=True, max_length=200)] = Field( + description="The name of the alert. `Additional Validators:` * is the identifier and so unique in the group * should only include the characters: a-zA-Z0-9-" + ) + annotations: Optional[Dict[str, Any]] = Field( + default=None, + description="map of key:value. Annotations to add to each alert. `Additional Validators:` * should not contain more than 5 keys * each key and value should not be longer than 200 characters", + ) + expr: Annotated[str, Field(min_length=1, strict=True, max_length=600)] = Field( + description="The PromQL expression to evaluate. Every evaluation cycle this is evaluated at the current time, and all resultant time series become pending/firing alerts." + ) + var_for: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( + default="0s", + description="Alerts are considered firing once they have been returned for this long. Alerts which have not yet fired for long enough are considered pending. `Additional Validators:` * must be a valid time string", + alias="for", + ) + labels: Optional[Dict[str, Any]] = Field( + default=None, + description="map of key:value. Labels to add or overwrite for each alert. `Additional Validators:` * should not contain more than 10 keys * each key and value should not be longer than 200 characters", + ) + __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PartialUpdateAlertrulesRequestInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PartialUpdateAlertrulesRequestInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "alert": obj.get("alert"), + "annotations": obj.get("annotations"), + "expr": obj.get("expr"), + "for": obj.get("for") if obj.get("for") is not None else "0s", + "labels": obj.get("labels"), + } + ) + return _obj diff --git a/services/observability/src/stackit/observability/models/update_alertgroup_payload.py b/services/observability/src/stackit/observability/models/update_alertgroup_payload.py index 8a74a297c..c642f559f 100644 --- a/services/observability/src/stackit/observability/models/update_alertgroup_payload.py +++ b/services/observability/src/stackit/observability/models/update_alertgroup_payload.py @@ -28,7 +28,7 @@ class UpdateAlertgroupPayload(BaseModel): """ - Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. + Alert group that should be created or updated. `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. """ # noqa: E501 interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( diff --git a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py index 0fd8000bc..8551c8e46 100644 --- a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py +++ b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner.py @@ -28,7 +28,7 @@ class UpdateAlertgroupsRequestInner(BaseModel): """ - Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. + Alert group that should be created or updated. `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. """ # noqa: E501 interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( diff --git a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py index 97c6ad3a6..64ed7f275 100644 --- a/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py +++ b/services/observability/src/stackit/observability/models/update_alertgroups_request_inner_rules_inner.py @@ -24,29 +24,34 @@ class UpdateAlertgroupsRequestInnerRulesInner(BaseModel): """ - Alert rule. `Additional Validators:` * total config (all alert groups/rules) should not be bigger than 500000 characters as string since this the limitation of prometheus. + Rule definition. Must be either an Alerting Rule (using 'alert') or a Recording Rule (using 'record'). `Additional Validators:` * total config (all alert groups/rules) should not be bigger than 500000 characters as string since this the limitation of prometheus. """ # noqa: E501 - alert: Annotated[str, Field(min_length=1, strict=True, max_length=200)] = Field( - description="The name of the alert. `Additional Validators:` * is the identifier and so unique in the group * should only include the characters: a-zA-Z0-9-" + alert: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=200)]] = Field( + default=None, + description="The name of the alert. When this attribute is used, an Alerting Rule will be created. `Additional Validators:` * is the identifier and so unique in the group * should only include the characters: a-zA-Z0-9- * required when 'record' is not used in this rule, otherwise not allowed", ) annotations: Optional[Dict[str, Any]] = Field( default=None, - description="map of key:value. Annotations to add to each alert. `Additional Validators:` * should not contain more than 5 keys * each key and value should not be longer than 200 characters", + description="Map of key:value. Annotations to add to each alert. `Additional Validators:` * should not contain more than 5 keys * each key and value should not be longer than 200 characters * is not allowed to use when 'record' is used in this rule", ) expr: Annotated[str, Field(min_length=1, strict=True, max_length=600)] = Field( - description="The PromQL expression to evaluate. Every evaluation cycle this is evaluated at the current time, and all resultant time series become pending/firing alerts." + description="The PromQL expression to evaluate to create alerts when using the 'alert' attribute in this rule, or to create a metric when using the 'record' attribute." ) var_for: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( default="0s", - description="Alerts are considered firing once they have been returned for this long. Alerts which have not yet fired for long enough are considered pending. `Additional Validators:` * must be a valid time string", + description="Alerts are considered firing once they have been returned for this long. Alerts which have not yet fired for long enough are considered pending. `Additional Validators:` * must be a valid time string * is not allowed to use when 'record' is used in this rule", alias="for", ) labels: Optional[Dict[str, Any]] = Field( default=None, - description="map of key:value. Labels to add or overwrite for each alert. `Additional Validators:` * should not contain more than 10 keys * each key and value should not be longer than 200 characters", + description="Map of key:value. Labels to add or overwrite for each alert or metric. `Additional Validators:` * should not contain more than 10 keys * each key and value should not be longer than 200 characters", + ) + record: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=300)]] = Field( + default=None, + description="The name of the metric. When this attribute is used, an Recording Rule will be created. `Additional Validators:` * is the identifier and so unique in the group * should only include the characters: a-zA-Z0-9:_ * required when 'alert' is not used in this rule, otherwise not allowed", ) - __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels"] + __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels", "record"] model_config = ConfigDict( populate_by_name=True, @@ -103,6 +108,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "expr": obj.get("expr"), "for": obj.get("for") if obj.get("for") is not None else "0s", "labels": obj.get("labels"), + "record": obj.get("record"), } ) return _obj diff --git a/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py b/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py index 5971c7e5c..de7769576 100644 --- a/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py +++ b/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py @@ -21,21 +21,21 @@ from pydantic import BaseModel, ConfigDict, Field from typing_extensions import Annotated, Self -from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( - UpdateAlertgroupsRequestInnerRulesInner, +from stackit.observability.models.create_logs_alertgroups_payload_rules_inner import ( + CreateLogsAlertgroupsPayloadRulesInner, ) class UpdateLogsAlertgroupPayload(BaseModel): """ - Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. + Alert group that should be created or updated. `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. """ # noqa: E501 interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( default="60s", description="How often rules in the group are evaluated. `Additional Validators:` * must be a valid time string * should be >=60s", ) - rules: List[UpdateAlertgroupsRequestInnerRulesInner] = Field(description="rules for the alert group") + rules: List[CreateLogsAlertgroupsPayloadRulesInner] = Field(description="rules for the alert group") __properties: ClassVar[List[str]] = ["interval", "rules"] model_config = ConfigDict( @@ -97,7 +97,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: { "interval": obj.get("interval") if obj.get("interval") is not None else "60s", "rules": ( - [UpdateAlertgroupsRequestInnerRulesInner.from_dict(_item) for _item in obj["rules"]] + [CreateLogsAlertgroupsPayloadRulesInner.from_dict(_item) for _item in obj["rules"]] if obj.get("rules") is not None else None ),