From 2e747b4b60ddcd066d678f36d8a7c41e01cc1d7f Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Mon, 20 Oct 2025 09:07:10 +0000 Subject: [PATCH] Generate observability --- .../src/stackit/observability/__init__.py | 8 ++ .../stackit/observability/api/default_api.py | 38 +++--- .../stackit/observability/models/__init__.py | 6 + .../models/create_alertgroups_payload.py | 2 +- .../models/create_logs_alertgroups_payload.py | 10 +- ...te_logs_alertgroups_payload_rules_inner.py | 114 ++++++++++++++++++ ...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 +- 11 files changed, 282 insertions(+), 40 deletions(-) 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..35c90b063 100644 --- a/services/observability/src/stackit/observability/__init__.py +++ b/services/observability/src/stackit/observability/__init__.py @@ -56,6 +56,7 @@ "CreateInstancePayload", "CreateInstanceResponse", "CreateLogsAlertgroupsPayload", + "CreateLogsAlertgroupsPayloadRulesInner", "CreateScrapeConfigPayload", "CreateScrapeConfigPayloadBasicAuth", "CreateScrapeConfigPayloadHttpSdConfigsInner", @@ -95,6 +96,7 @@ "ModelGlobal", "OAuth2", "OpsgenieConfig", + "PartialUpdateAlertrulesRequestInner", "PermissionDenied", "Plan", "PlanModel", @@ -224,6 +226,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 +322,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..dba73fd3c 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, ) @@ -12509,7 +12509,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 +12530,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 +12558,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 +12583,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 +12604,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 +12632,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 +12657,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 +12678,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 +12706,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 +12726,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 +12736,7 @@ def _partial_update_alertrules_serialize( _host = None _collection_formats: Dict[str, str] = { - "UpdateAlertgroupsRequestInnerRulesInner": "", + "PartialUpdateAlertrulesRequestInner": "", } _path_params: Dict[str, str] = {} @@ -12757,8 +12757,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..cebd21b14 100644 --- a/services/observability/src/stackit/observability/models/__init__.py +++ b/services/observability/src/stackit/observability/models/__init__.py @@ -74,6 +74,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 +148,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/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_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/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 ),