|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + STACKIT Observability API |
| 5 | +
|
| 6 | + API endpoints for Observability on STACKIT |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1.1.1 |
| 9 | + Contact: stackit-argus@mail.schwarz |
| 10 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 11 | +
|
| 12 | + Do not edit the class manually. |
| 13 | +""" # noqa: E501 docstring might be too long |
| 14 | + |
| 15 | +from __future__ import annotations |
| 16 | + |
| 17 | +import json |
| 18 | +import pprint |
| 19 | +from typing import Any, ClassVar, Dict, List, Optional, Set |
| 20 | + |
| 21 | +from pydantic import BaseModel, ConfigDict, Field |
| 22 | +from typing_extensions import Annotated, Self |
| 23 | + |
| 24 | + |
| 25 | +class UpdateAlertgroupsRequestInnerRulesInner(BaseModel): |
| 26 | + """ |
| 27 | + 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. |
| 28 | + """ |
| 29 | + |
| 30 | + alert: Annotated[str, Field(min_length=1, strict=True, max_length=200)] = Field( |
| 31 | + 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-" |
| 32 | + ) |
| 33 | + annotations: Optional[Dict[str, Any]] = Field( |
| 34 | + default=None, |
| 35 | + 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", |
| 36 | + ) |
| 37 | + expr: Annotated[str, Field(min_length=1, strict=True, max_length=600)] = Field( |
| 38 | + 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." |
| 39 | + ) |
| 40 | + var_for: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = Field( |
| 41 | + default="0s", |
| 42 | + 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", |
| 43 | + alias="for", |
| 44 | + ) |
| 45 | + labels: Optional[Dict[str, Any]] = Field( |
| 46 | + default=None, |
| 47 | + 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", |
| 48 | + ) |
| 49 | + __properties: ClassVar[List[str]] = ["alert", "annotations", "expr", "for", "labels"] |
| 50 | + |
| 51 | + model_config = ConfigDict( |
| 52 | + populate_by_name=True, |
| 53 | + validate_assignment=True, |
| 54 | + protected_namespaces=(), |
| 55 | + ) |
| 56 | + |
| 57 | + def to_str(self) -> str: |
| 58 | + """Returns the string representation of the model using alias""" |
| 59 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 60 | + |
| 61 | + def to_json(self) -> str: |
| 62 | + """Returns the JSON representation of the model using alias""" |
| 63 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 64 | + return json.dumps(self.to_dict()) |
| 65 | + |
| 66 | + @classmethod |
| 67 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 68 | + """Create an instance of UpdateAlertgroupsRequestInnerRulesInner from a JSON string""" |
| 69 | + return cls.from_dict(json.loads(json_str)) |
| 70 | + |
| 71 | + def to_dict(self) -> Dict[str, Any]: |
| 72 | + """Return the dictionary representation of the model using alias. |
| 73 | +
|
| 74 | + This has the following differences from calling pydantic's |
| 75 | + `self.model_dump(by_alias=True)`: |
| 76 | +
|
| 77 | + * `None` is only added to the output dict for nullable fields that |
| 78 | + were set at model initialization. Other fields with value `None` |
| 79 | + are ignored. |
| 80 | + """ |
| 81 | + excluded_fields: Set[str] = set([]) |
| 82 | + |
| 83 | + _dict = self.model_dump( |
| 84 | + by_alias=True, |
| 85 | + exclude=excluded_fields, |
| 86 | + exclude_none=True, |
| 87 | + ) |
| 88 | + return _dict |
| 89 | + |
| 90 | + @classmethod |
| 91 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 92 | + """Create an instance of UpdateAlertgroupsRequestInnerRulesInner from a dict""" |
| 93 | + if obj is None: |
| 94 | + return None |
| 95 | + |
| 96 | + if not isinstance(obj, dict): |
| 97 | + return cls.model_validate(obj) |
| 98 | + |
| 99 | + _obj = cls.model_validate( |
| 100 | + { |
| 101 | + "alert": obj.get("alert"), |
| 102 | + "annotations": obj.get("annotations"), |
| 103 | + "expr": obj.get("expr"), |
| 104 | + "for": obj.get("for") if obj.get("for") is not None else "0s", |
| 105 | + "labels": obj.get("labels"), |
| 106 | + } |
| 107 | + ) |
| 108 | + return _obj |
0 commit comments