Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"CreateInstancePayload",
"CreateInstanceResponse",
"CreateLogsAlertgroupsPayload",
"CreateLogsAlertgroupsPayloadRulesInner",
"CreateScrapeConfigPayload",
"CreateScrapeConfigPayloadBasicAuth",
"CreateScrapeConfigPayloadHttpSdConfigsInner",
Expand Down Expand Up @@ -95,6 +96,7 @@
"ModelGlobal",
"OAuth2",
"OpsgenieConfig",
"PartialUpdateAlertrulesRequestInner",
"PermissionDenied",
"Plan",
"PlanModel",
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
Expand Down Expand Up @@ -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)],
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)],
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)],
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -12736,7 +12736,7 @@ def _partial_update_alertrules_serialize(
_host = None

_collection_formats: Dict[str, str] = {
"UpdateAlertgroupsRequestInnerRulesInner": "",
"PartialUpdateAlertrulesRequestInner": "",
}

_path_params: Dict[str, str] = {}
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading