diff --git a/services/observability/src/stackit/observability/__init__.py b/services/observability/src/stackit/observability/__init__.py index 6c897ffd..07c3569b 100644 --- a/services/observability/src/stackit/observability/__init__.py +++ b/services/observability/src/stackit/observability/__init__.py @@ -77,6 +77,9 @@ ) from stackit.observability.models.create_instance_payload import CreateInstancePayload from stackit.observability.models.create_instance_response import CreateInstanceResponse +from stackit.observability.models.create_logs_alertgroups_payload import ( + CreateLogsAlertgroupsPayload, +) from stackit.observability.models.create_scrape_config_payload import ( CreateScrapeConfigPayload, ) @@ -199,6 +202,9 @@ UpdateGrafanaConfigsPayloadGenericOauth, ) from stackit.observability.models.update_instance_payload import UpdateInstancePayload +from stackit.observability.models.update_logs_alertgroup_payload import ( + UpdateLogsAlertgroupPayload, +) from stackit.observability.models.update_metrics_storage_retention_payload import ( UpdateMetricsStorageRetentionPayload, ) diff --git a/services/observability/src/stackit/observability/api/default_api.py b/services/observability/src/stackit/observability/api/default_api.py index f21d5a64..bffeac75 100644 --- a/services/observability/src/stackit/observability/api/default_api.py +++ b/services/observability/src/stackit/observability/api/default_api.py @@ -46,6 +46,9 @@ ) from stackit.observability.models.create_instance_payload import CreateInstancePayload from stackit.observability.models.create_instance_response import CreateInstanceResponse +from stackit.observability.models.create_logs_alertgroups_payload import ( + CreateLogsAlertgroupsPayload, +) from stackit.observability.models.create_scrape_config_payload import ( CreateScrapeConfigPayload, ) @@ -112,6 +115,9 @@ UpdateGrafanaConfigsPayload, ) from stackit.observability.models.update_instance_payload import UpdateInstancePayload +from stackit.observability.models.update_logs_alertgroup_payload import ( + UpdateLogsAlertgroupPayload, +) from stackit.observability.models.update_metrics_storage_retention_payload import ( UpdateMetricsStorageRetentionPayload, ) @@ -1728,6 +1734,276 @@ def _create_instance_serialize( _request_auth=_request_auth, ) + @validate_call + def create_logs_alertgroups( + self, + instance_id: StrictStr, + project_id: StrictStr, + create_logs_alertgroups_payload: CreateLogsAlertgroupsPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AlertGroupsResponse: + """create_logs_alertgroups + + Create logs alert group config. + + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :param create_logs_alertgroups_payload: (required) + :type create_logs_alertgroups_payload: CreateLogsAlertgroupsPayload + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_logs_alertgroups_serialize( + instance_id=instance_id, + project_id=project_id, + create_logs_alertgroups_payload=create_logs_alertgroups_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Error", + "403": "PermissionDenied", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def create_logs_alertgroups_with_http_info( + self, + instance_id: StrictStr, + project_id: StrictStr, + create_logs_alertgroups_payload: CreateLogsAlertgroupsPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AlertGroupsResponse]: + """create_logs_alertgroups + + Create logs alert group config. + + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :param create_logs_alertgroups_payload: (required) + :type create_logs_alertgroups_payload: CreateLogsAlertgroupsPayload + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_logs_alertgroups_serialize( + instance_id=instance_id, + project_id=project_id, + create_logs_alertgroups_payload=create_logs_alertgroups_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Error", + "403": "PermissionDenied", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def create_logs_alertgroups_without_preload_content( + self, + instance_id: StrictStr, + project_id: StrictStr, + create_logs_alertgroups_payload: CreateLogsAlertgroupsPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """create_logs_alertgroups + + Create logs alert group config. + + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :param create_logs_alertgroups_payload: (required) + :type create_logs_alertgroups_payload: CreateLogsAlertgroupsPayload + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._create_logs_alertgroups_serialize( + instance_id=instance_id, + project_id=project_id, + create_logs_alertgroups_payload=create_logs_alertgroups_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Error", + "403": "PermissionDenied", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _create_logs_alertgroups_serialize( + self, + instance_id, + project_id, + create_logs_alertgroups_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if instance_id is not None: + _path_params["instanceId"] = instance_id + if project_id is not None: + _path_params["projectId"] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_logs_alertgroups_payload is not None: + _body_params = create_logs_alertgroups_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call def create_scrape_config( self, @@ -4106,10 +4382,10 @@ def _delete_instance_serialize( ) @validate_call - def delete_scrape_config( + def delete_logs_alertgroup( self, + group_name: StrictStr, instance_id: StrictStr, - job_name: StrictStr, project_id: StrictStr, _request_timeout: Union[ None, @@ -4120,15 +4396,15 @@ def delete_scrape_config( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> DeleteScrapeConfigResponse: - """delete_scrape_config + ) -> AlertGroupsResponse: + """delete_logs_alertgroup - Delete scrape config. + Delete logs alert group config. + :param group_name: (required) + :type group_name: str :param instance_id: (required) :type instance_id: str - :param job_name: (required) - :type job_name: str :param project_id: (required) :type project_id: str :param _request_timeout: timeout setting for this request. If one @@ -4153,7 +4429,272 @@ def delete_scrape_config( :return: Returns the result object. """ # noqa: E501 docstring might be too long - _param = self._delete_scrape_config_serialize( + _param = self._delete_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def delete_logs_alertgroup_with_http_info( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AlertGroupsResponse]: + """delete_logs_alertgroup + + Delete logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def delete_logs_alertgroup_without_preload_content( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """delete_logs_alertgroup + + Delete logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _delete_logs_alertgroup_serialize( + self, + group_name, + instance_id, + project_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if group_name is not None: + _path_params["groupName"] = group_name + if instance_id is not None: + _path_params["instanceId"] = instance_id + if project_id is not None: + _path_params["projectId"] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="DELETE", + resource_path="/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def delete_scrape_config( + self, + instance_id: StrictStr, + job_name: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> DeleteScrapeConfigResponse: + """delete_scrape_config + + Delete scrape config. + + :param instance_id: (required) + :type instance_id: str + :param job_name: (required) + :type job_name: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._delete_scrape_config_serialize( instance_id=instance_id, job_name=job_name, project_id=project_id, @@ -6413,7 +6954,272 @@ def _get_instance_serialize( ) @validate_call - def get_metrics_storage_retention( + def get_logs_alertgroup( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AlertGroupResponse: + """get_logs_alertgroup + + Get logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "AlertGroupResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def get_logs_alertgroup_with_http_info( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AlertGroupResponse]: + """get_logs_alertgroup + + Get logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "AlertGroupResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def get_logs_alertgroup_without_preload_content( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """get_logs_alertgroup + + Get logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._get_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "AlertGroupResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _get_logs_alertgroup_serialize( + self, + group_name, + instance_id, + project_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if group_name is not None: + _path_params["groupName"] = group_name + if instance_id is not None: + _path_params["instanceId"] = instance_id + if project_id is not None: + _path_params["projectId"] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def get_metrics_storage_retention( self, instance_id: StrictStr, project_id: StrictStr, @@ -8627,8 +9433,9 @@ def _list_instances_serialize( ) @validate_call - def list_plans( + def list_logs_alertgroups( self, + instance_id: StrictStr, project_id: StrictStr, _request_timeout: Union[ None, @@ -8639,8 +9446,254 @@ def list_plans( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> PlansResponse: - """list_plans + ) -> AlertGroupsResponse: + """list_logs_alertgroups + + Get logs alert groups config. + + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_logs_alertgroups_serialize( + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "AlertGroupsResponse", + "400": "Error", + "403": "PermissionDenied", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def list_logs_alertgroups_with_http_info( + self, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AlertGroupsResponse]: + """list_logs_alertgroups + + Get logs alert groups config. + + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_logs_alertgroups_serialize( + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "AlertGroupsResponse", + "400": "Error", + "403": "PermissionDenied", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def list_logs_alertgroups_without_preload_content( + self, + instance_id: StrictStr, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """list_logs_alertgroups + + Get logs alert groups config. + + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._list_logs_alertgroups_serialize( + instance_id=instance_id, + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "200": "AlertGroupsResponse", + "400": "Error", + "403": "PermissionDenied", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _list_logs_alertgroups_serialize( + self, + instance_id, + project_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if instance_id is not None: + _path_params["instanceId"] = instance_id + if project_id is not None: + _path_params["projectId"] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def list_plans( + self, + project_id: StrictStr, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PlansResponse: + """list_plans Get all plans. @@ -12165,6 +13218,294 @@ def _update_instance_serialize( _request_auth=_request_auth, ) + @validate_call + def update_logs_alertgroup( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + update_logs_alertgroup_payload: UpdateLogsAlertgroupPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> AlertGroupsResponse: + """update_logs_alertgroup + + Update logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :param update_logs_alertgroup_payload: (required) + :type update_logs_alertgroup_payload: UpdateLogsAlertgroupPayload + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._update_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + update_logs_alertgroup_payload=update_logs_alertgroup_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def update_logs_alertgroup_with_http_info( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + update_logs_alertgroup_payload: UpdateLogsAlertgroupPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[AlertGroupsResponse]: + """update_logs_alertgroup + + Update logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :param update_logs_alertgroup_payload: (required) + :type update_logs_alertgroup_payload: UpdateLogsAlertgroupPayload + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._update_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + update_logs_alertgroup_payload=update_logs_alertgroup_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def update_logs_alertgroup_without_preload_content( + self, + group_name: StrictStr, + instance_id: StrictStr, + project_id: StrictStr, + update_logs_alertgroup_payload: UpdateLogsAlertgroupPayload, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]], + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """update_logs_alertgroup + + Update logs alert group config. + + :param group_name: (required) + :type group_name: str + :param instance_id: (required) + :type instance_id: str + :param project_id: (required) + :type project_id: str + :param update_logs_alertgroup_payload: (required) + :type update_logs_alertgroup_payload: UpdateLogsAlertgroupPayload + :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 + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 docstring might be too long + + _param = self._update_logs_alertgroup_serialize( + group_name=group_name, + instance_id=instance_id, + project_id=project_id, + update_logs_alertgroup_payload=update_logs_alertgroup_payload, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: Dict[str, Optional[str]] = { + "202": "AlertGroupsResponse", + "400": "Message", + "403": "PermissionDenied", + "404": "Message", + } + response_data = self.api_client.call_api(*_param, _request_timeout=_request_timeout) + return response_data.response + + def _update_logs_alertgroup_serialize( + self, + group_name, + instance_id, + project_id, + update_logs_alertgroup_payload, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = {} + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if group_name is not None: + _path_params["groupName"] = group_name + if instance_id is not None: + _path_params["instanceId"] = instance_id + if project_id is not None: + _path_params["projectId"] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if update_logs_alertgroup_payload is not None: + _body_params = update_logs_alertgroup_payload + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept(["application/json"]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type(["application/json"]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [] + + return self.api_client.param_serialize( + method="PUT", + resource_path="/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + @validate_call def update_metrics_storage_retention( self, diff --git a/services/observability/src/stackit/observability/models/__init__.py b/services/observability/src/stackit/observability/models/__init__.py index a7649dce..2b1497a5 100644 --- a/services/observability/src/stackit/observability/models/__init__.py +++ b/services/observability/src/stackit/observability/models/__init__.py @@ -58,6 +58,9 @@ ) from stackit.observability.models.create_instance_payload import CreateInstancePayload from stackit.observability.models.create_instance_response import CreateInstanceResponse +from stackit.observability.models.create_logs_alertgroups_payload import ( + CreateLogsAlertgroupsPayload, +) from stackit.observability.models.create_scrape_config_payload import ( CreateScrapeConfigPayload, ) @@ -180,6 +183,9 @@ UpdateGrafanaConfigsPayloadGenericOauth, ) from stackit.observability.models.update_instance_payload import UpdateInstancePayload +from stackit.observability.models.update_logs_alertgroup_payload import ( + UpdateLogsAlertgroupPayload, +) from stackit.observability.models.update_metrics_storage_retention_payload import ( UpdateMetricsStorageRetentionPayload, ) 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 new file mode 100644 index 00000000..3ab22d6c --- /dev/null +++ b/services/observability/src/stackit/observability/models/create_logs_alertgroups_payload.py @@ -0,0 +1,110 @@ +# 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 docstring might be too long + +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 + +from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( + UpdateAlertgroupsRequestInnerRulesInner, +) + + +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. + """ + + 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", + ) + 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") + __properties: ClassVar[List[str]] = ["interval", "name", "rules"] + + 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 CreateLogsAlertgroupsPayload 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, + ) + # override the default output from pydantic by calling `to_dict()` of each item in rules (list) + _items = [] + if self.rules: + for _item in self.rules: + if _item: + _items.append(_item.to_dict()) + _dict["rules"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateLogsAlertgroupsPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "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"]] + if obj.get("rules") is not None + else None + ), + } + ) + 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 new file mode 100644 index 00000000..e7b9b823 --- /dev/null +++ b/services/observability/src/stackit/observability/models/update_logs_alertgroup_payload.py @@ -0,0 +1,106 @@ +# 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 docstring might be too long + +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 + +from stackit.observability.models.update_alertgroups_request_inner_rules_inner import ( + UpdateAlertgroupsRequestInnerRulesInner, +) + + +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. + """ + + 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") + __properties: ClassVar[List[str]] = ["interval", "rules"] + + 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 UpdateLogsAlertgroupPayload 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, + ) + # override the default output from pydantic by calling `to_dict()` of each item in rules (list) + _items = [] + if self.rules: + for _item in self.rules: + if _item: + _items.append(_item.to_dict()) + _dict["rules"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpdateLogsAlertgroupPayload from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "interval": obj.get("interval") if obj.get("interval") is not None else "60s", + "rules": ( + [UpdateAlertgroupsRequestInnerRulesInner.from_dict(_item) for _item in obj["rules"]] + if obj.get("rules") is not None + else None + ), + } + ) + return _obj