Skip to content

Commit 4128745

Browse files
Generate observability
1 parent ffbaa74 commit 4128745

File tree

6 files changed

+550
-0
lines changed

6 files changed

+550
-0
lines changed

services/observability/src/stackit/observability/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
from stackit.observability.models.alert_config_route_response import (
4242
AlertConfigRouteResponse,
4343
)
44+
from stackit.observability.models.alert_group import AlertGroup
45+
from stackit.observability.models.alert_groups_response import AlertGroupsResponse
46+
from stackit.observability.models.alert_rule_record import AlertRuleRecord
4447
from stackit.observability.models.basic_auth import BasicAuth
4548
from stackit.observability.models.create_alert_config_receiver_payload import (
4649
CreateAlertConfigReceiverPayload,

services/observability/src/stackit/observability/api/default_api.py

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from stackit.observability.models.alert_config_route_response import (
2727
AlertConfigRouteResponse,
2828
)
29+
from stackit.observability.models.alert_groups_response import AlertGroupsResponse
2930
from stackit.observability.models.create_alert_config_receiver_payload import (
3031
CreateAlertConfigReceiverPayload,
3132
)
@@ -9453,3 +9454,250 @@ def _update_scrape_config_serialize(
94539454
_host=_host,
94549455
_request_auth=_request_auth,
94559456
)
9457+
9458+
@validate_call
9459+
def v1_projects_instances_alertgroups_list(
9460+
self,
9461+
instance_id: StrictStr,
9462+
project_id: StrictStr,
9463+
_request_timeout: Union[
9464+
None,
9465+
Annotated[StrictFloat, Field(gt=0)],
9466+
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
9467+
] = None,
9468+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
9469+
_content_type: Optional[StrictStr] = None,
9470+
_headers: Optional[Dict[StrictStr, Any]] = None,
9471+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
9472+
) -> AlertGroupsResponse:
9473+
"""v1_projects_instances_alertgroups_list
9474+
9475+
Get alert groups.
9476+
9477+
:param instance_id: (required)
9478+
:type instance_id: str
9479+
:param project_id: (required)
9480+
:type project_id: str
9481+
:param _request_timeout: timeout setting for this request. If one
9482+
number provided, it will be total request
9483+
timeout. It can also be a pair (tuple) of
9484+
(connection, read) timeouts.
9485+
:type _request_timeout: int, tuple(int, int), optional
9486+
:param _request_auth: set to override the auth_settings for an a single
9487+
request; this effectively ignores the
9488+
authentication in the spec for a single request.
9489+
:type _request_auth: dict, optional
9490+
:param _content_type: force content-type for the request.
9491+
:type _content_type: str, Optional
9492+
:param _headers: set to override the headers for a single
9493+
request; this effectively ignores the headers
9494+
in the spec for a single request.
9495+
:type _headers: dict, optional
9496+
:param _host_index: set to override the host_index for a single
9497+
request; this effectively ignores the host_index
9498+
in the spec for a single request.
9499+
:type _host_index: int, optional
9500+
:return: Returns the result object.
9501+
""" # noqa: E501 docstring might be too long
9502+
9503+
_param = self._v1_projects_instances_alertgroups_list_serialize(
9504+
instance_id=instance_id,
9505+
project_id=project_id,
9506+
_request_auth=_request_auth,
9507+
_content_type=_content_type,
9508+
_headers=_headers,
9509+
_host_index=_host_index,
9510+
)
9511+
9512+
_response_types_map: Dict[str, Optional[str]] = {
9513+
"200": "AlertGroupsResponse",
9514+
"400": "Error",
9515+
"403": "PermissionDenied",
9516+
}
9517+
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
9518+
response_data.read()
9519+
return self.api_client.response_deserialize(
9520+
response_data=response_data,
9521+
response_types_map=_response_types_map,
9522+
).data
9523+
9524+
@validate_call
9525+
def v1_projects_instances_alertgroups_list_with_http_info(
9526+
self,
9527+
instance_id: StrictStr,
9528+
project_id: StrictStr,
9529+
_request_timeout: Union[
9530+
None,
9531+
Annotated[StrictFloat, Field(gt=0)],
9532+
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
9533+
] = None,
9534+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
9535+
_content_type: Optional[StrictStr] = None,
9536+
_headers: Optional[Dict[StrictStr, Any]] = None,
9537+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
9538+
) -> ApiResponse[AlertGroupsResponse]:
9539+
"""v1_projects_instances_alertgroups_list
9540+
9541+
Get alert groups.
9542+
9543+
:param instance_id: (required)
9544+
:type instance_id: str
9545+
:param project_id: (required)
9546+
:type project_id: str
9547+
:param _request_timeout: timeout setting for this request. If one
9548+
number provided, it will be total request
9549+
timeout. It can also be a pair (tuple) of
9550+
(connection, read) timeouts.
9551+
:type _request_timeout: int, tuple(int, int), optional
9552+
:param _request_auth: set to override the auth_settings for an a single
9553+
request; this effectively ignores the
9554+
authentication in the spec for a single request.
9555+
:type _request_auth: dict, optional
9556+
:param _content_type: force content-type for the request.
9557+
:type _content_type: str, Optional
9558+
:param _headers: set to override the headers for a single
9559+
request; this effectively ignores the headers
9560+
in the spec for a single request.
9561+
:type _headers: dict, optional
9562+
:param _host_index: set to override the host_index for a single
9563+
request; this effectively ignores the host_index
9564+
in the spec for a single request.
9565+
:type _host_index: int, optional
9566+
:return: Returns the result object.
9567+
""" # noqa: E501 docstring might be too long
9568+
9569+
_param = self._v1_projects_instances_alertgroups_list_serialize(
9570+
instance_id=instance_id,
9571+
project_id=project_id,
9572+
_request_auth=_request_auth,
9573+
_content_type=_content_type,
9574+
_headers=_headers,
9575+
_host_index=_host_index,
9576+
)
9577+
9578+
_response_types_map: Dict[str, Optional[str]] = {
9579+
"200": "AlertGroupsResponse",
9580+
"400": "Error",
9581+
"403": "PermissionDenied",
9582+
}
9583+
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
9584+
response_data.read()
9585+
return self.api_client.response_deserialize(
9586+
response_data=response_data,
9587+
response_types_map=_response_types_map,
9588+
)
9589+
9590+
@validate_call
9591+
def v1_projects_instances_alertgroups_list_without_preload_content(
9592+
self,
9593+
instance_id: StrictStr,
9594+
project_id: StrictStr,
9595+
_request_timeout: Union[
9596+
None,
9597+
Annotated[StrictFloat, Field(gt=0)],
9598+
Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]],
9599+
] = None,
9600+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
9601+
_content_type: Optional[StrictStr] = None,
9602+
_headers: Optional[Dict[StrictStr, Any]] = None,
9603+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
9604+
) -> RESTResponseType:
9605+
"""v1_projects_instances_alertgroups_list
9606+
9607+
Get alert groups.
9608+
9609+
:param instance_id: (required)
9610+
:type instance_id: str
9611+
:param project_id: (required)
9612+
:type project_id: str
9613+
:param _request_timeout: timeout setting for this request. If one
9614+
number provided, it will be total request
9615+
timeout. It can also be a pair (tuple) of
9616+
(connection, read) timeouts.
9617+
:type _request_timeout: int, tuple(int, int), optional
9618+
:param _request_auth: set to override the auth_settings for an a single
9619+
request; this effectively ignores the
9620+
authentication in the spec for a single request.
9621+
:type _request_auth: dict, optional
9622+
:param _content_type: force content-type for the request.
9623+
:type _content_type: str, Optional
9624+
:param _headers: set to override the headers for a single
9625+
request; this effectively ignores the headers
9626+
in the spec for a single request.
9627+
:type _headers: dict, optional
9628+
:param _host_index: set to override the host_index for a single
9629+
request; this effectively ignores the host_index
9630+
in the spec for a single request.
9631+
:type _host_index: int, optional
9632+
:return: Returns the result object.
9633+
""" # noqa: E501 docstring might be too long
9634+
9635+
_param = self._v1_projects_instances_alertgroups_list_serialize(
9636+
instance_id=instance_id,
9637+
project_id=project_id,
9638+
_request_auth=_request_auth,
9639+
_content_type=_content_type,
9640+
_headers=_headers,
9641+
_host_index=_host_index,
9642+
)
9643+
9644+
_response_types_map: Dict[str, Optional[str]] = {
9645+
"200": "AlertGroupsResponse",
9646+
"400": "Error",
9647+
"403": "PermissionDenied",
9648+
}
9649+
response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout)
9650+
return response_data.response
9651+
9652+
def _v1_projects_instances_alertgroups_list_serialize(
9653+
self,
9654+
instance_id,
9655+
project_id,
9656+
_request_auth,
9657+
_content_type,
9658+
_headers,
9659+
_host_index,
9660+
) -> RequestSerialized:
9661+
9662+
_host = None
9663+
9664+
_collection_formats: Dict[str, str] = {}
9665+
9666+
_path_params: Dict[str, str] = {}
9667+
_query_params: List[Tuple[str, str]] = []
9668+
_header_params: Dict[str, Optional[str]] = _headers or {}
9669+
_form_params: List[Tuple[str, str]] = []
9670+
_files: Dict[str, Union[str, bytes]] = {}
9671+
_body_params: Optional[bytes] = None
9672+
9673+
# process the path parameters
9674+
if instance_id is not None:
9675+
_path_params["instanceId"] = instance_id
9676+
if project_id is not None:
9677+
_path_params["projectId"] = project_id
9678+
# process the query parameters
9679+
# process the header parameters
9680+
# process the form parameters
9681+
# process the body parameter
9682+
9683+
# set the HTTP header `Accept`
9684+
if "Accept" not in _header_params:
9685+
_header_params["Accept"] = self.api_client.select_header_accept(["application/json"])
9686+
9687+
# authentication setting
9688+
_auth_settings: List[str] = []
9689+
9690+
return self.api_client.param_serialize(
9691+
method="GET",
9692+
resource_path="/v1/projects/{projectId}/instances/{instanceId}/alertgroups",
9693+
path_params=_path_params,
9694+
query_params=_query_params,
9695+
header_params=_header_params,
9696+
body=_body_params,
9697+
post_params=_form_params,
9698+
files=_files,
9699+
auth_settings=_auth_settings,
9700+
collection_formats=_collection_formats,
9701+
_host=_host,
9702+
_request_auth=_request_auth,
9703+
)

services/observability/src/stackit/observability/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
from stackit.observability.models.alert_config_route_response import (
2323
AlertConfigRouteResponse,
2424
)
25+
from stackit.observability.models.alert_group import AlertGroup
26+
from stackit.observability.models.alert_groups_response import AlertGroupsResponse
27+
from stackit.observability.models.alert_rule_record import AlertRuleRecord
2528
from stackit.observability.models.basic_auth import BasicAuth
2629
from stackit.observability.models.create_alert_config_receiver_payload import (
2730
CreateAlertConfigReceiverPayload,
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
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+
from stackit.observability.models.alert_rule_record import AlertRuleRecord
25+
26+
27+
class AlertGroup(BaseModel):
28+
"""
29+
AlertGroup
30+
"""
31+
32+
interval: Optional[Annotated[str, Field(min_length=2, strict=True, max_length=8)]] = "60s"
33+
name: Annotated[str, Field(min_length=1, strict=True, max_length=200)]
34+
rules: List[AlertRuleRecord]
35+
__properties: ClassVar[List[str]] = ["interval", "name", "rules"]
36+
37+
model_config = ConfigDict(
38+
populate_by_name=True,
39+
validate_assignment=True,
40+
protected_namespaces=(),
41+
)
42+
43+
def to_str(self) -> str:
44+
"""Returns the string representation of the model using alias"""
45+
return pprint.pformat(self.model_dump(by_alias=True))
46+
47+
def to_json(self) -> str:
48+
"""Returns the JSON representation of the model using alias"""
49+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50+
return json.dumps(self.to_dict())
51+
52+
@classmethod
53+
def from_json(cls, json_str: str) -> Optional[Self]:
54+
"""Create an instance of AlertGroup from a JSON string"""
55+
return cls.from_dict(json.loads(json_str))
56+
57+
def to_dict(self) -> Dict[str, Any]:
58+
"""Return the dictionary representation of the model using alias.
59+
60+
This has the following differences from calling pydantic's
61+
`self.model_dump(by_alias=True)`:
62+
63+
* `None` is only added to the output dict for nullable fields that
64+
were set at model initialization. Other fields with value `None`
65+
are ignored.
66+
"""
67+
excluded_fields: Set[str] = set([])
68+
69+
_dict = self.model_dump(
70+
by_alias=True,
71+
exclude=excluded_fields,
72+
exclude_none=True,
73+
)
74+
# override the default output from pydantic by calling `to_dict()` of each item in rules (list)
75+
_items = []
76+
if self.rules:
77+
for _item in self.rules:
78+
if _item:
79+
_items.append(_item.to_dict())
80+
_dict["rules"] = _items
81+
return _dict
82+
83+
@classmethod
84+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85+
"""Create an instance of AlertGroup from a dict"""
86+
if obj is None:
87+
return None
88+
89+
if not isinstance(obj, dict):
90+
return cls.model_validate(obj)
91+
92+
_obj = cls.model_validate(
93+
{
94+
"interval": obj.get("interval") if obj.get("interval") is not None else "60s",
95+
"name": obj.get("name"),
96+
"rules": (
97+
[AlertRuleRecord.from_dict(_item) for _item in obj["rules"]]
98+
if obj.get("rules") is not None
99+
else None
100+
),
101+
}
102+
)
103+
return _obj

0 commit comments

Comments
 (0)