diff --git a/scaleway-async/scaleway_async/cockpit/v1/__init__.py b/scaleway-async/scaleway_async/cockpit/v1/__init__.py index 5137711f8..abac82780 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/__init__.py +++ b/scaleway-async/scaleway_async/cockpit/v1/__init__.py @@ -1,12 +1,11 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from .types import AnyAlertState +from .types import AlertState from .types import DataSourceOrigin from .types import DataSourceType from .types import GrafanaUserRole from .types import ListDataSourcesRequestOrderBy from .types import ListGrafanaUsersRequestOrderBy -from .types import ListManagedAlertsRequestOrderBy from .types import ListPlansRequestOrderBy from .types import ListTokensRequestOrderBy from .types import PlanName @@ -14,12 +13,11 @@ from .types import UsageUnit from .types import ContactPointEmail from .types import GetConfigResponseRetention -from .types import AnyAlert +from .types import Alert from .types import ContactPoint from .types import DataSource from .types import GrafanaProductDashboard from .types import GrafanaUser -from .types import Alert from .types import Plan from .types import Token from .types import Usage @@ -42,7 +40,6 @@ from .types import ListDataSourcesResponse from .types import ListGrafanaProductDashboardsResponse from .types import ListGrafanaUsersResponse -from .types import ListManagedAlertsResponse from .types import ListPlansResponse from .types import ListTokensResponse from .types import RegionalApiCreateContactPointRequest @@ -63,7 +60,6 @@ from .types import RegionalApiListAlertsRequest from .types import RegionalApiListContactPointsRequest from .types import RegionalApiListDataSourcesRequest -from .types import RegionalApiListManagedAlertsRequest from .types import RegionalApiListTokensRequest from .types import RegionalApiTriggerTestAlertRequest from .types import RegionalApiUpdateContactPointRequest @@ -73,13 +69,12 @@ from .api import CockpitV1RegionalAPI __all__ = [ - "AnyAlertState", + "AlertState", "DataSourceOrigin", "DataSourceType", "GrafanaUserRole", "ListDataSourcesRequestOrderBy", "ListGrafanaUsersRequestOrderBy", - "ListManagedAlertsRequestOrderBy", "ListPlansRequestOrderBy", "ListTokensRequestOrderBy", "PlanName", @@ -87,12 +82,11 @@ "UsageUnit", "ContactPointEmail", "GetConfigResponseRetention", - "AnyAlert", + "Alert", "ContactPoint", "DataSource", "GrafanaProductDashboard", "GrafanaUser", - "Alert", "Plan", "Token", "Usage", @@ -115,7 +109,6 @@ "ListDataSourcesResponse", "ListGrafanaProductDashboardsResponse", "ListGrafanaUsersResponse", - "ListManagedAlertsResponse", "ListPlansResponse", "ListTokensResponse", "RegionalApiCreateContactPointRequest", @@ -136,7 +129,6 @@ "RegionalApiListAlertsRequest", "RegionalApiListContactPointsRequest", "RegionalApiListDataSourcesRequest", - "RegionalApiListManagedAlertsRequest", "RegionalApiListTokensRequest", "RegionalApiTriggerTestAlertRequest", "RegionalApiUpdateContactPointRequest", diff --git a/scaleway-async/scaleway_async/cockpit/v1/api.py b/scaleway-async/scaleway_async/cockpit/v1/api.py index 1d234dd48..22bda241f 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/api.py +++ b/scaleway-async/scaleway_async/cockpit/v1/api.py @@ -12,18 +12,16 @@ fetch_all_pages_async, ) from .types import ( - AnyAlertState, + AlertState, DataSourceOrigin, DataSourceType, GrafanaUserRole, ListDataSourcesRequestOrderBy, ListGrafanaUsersRequestOrderBy, - ListManagedAlertsRequestOrderBy, ListPlansRequestOrderBy, ListTokensRequestOrderBy, PlanName, TokenScope, - Alert, AlertManager, ContactPoint, ContactPointEmail, @@ -41,7 +39,6 @@ ListDataSourcesResponse, ListGrafanaProductDashboardsResponse, ListGrafanaUsersResponse, - ListManagedAlertsResponse, ListPlansResponse, ListTokensResponse, Plan, @@ -74,7 +71,6 @@ unmarshal_ListDataSourcesResponse, unmarshal_ListGrafanaProductDashboardsResponse, unmarshal_ListGrafanaUsersResponse, - unmarshal_ListManagedAlertsResponse, unmarshal_ListPlansResponse, unmarshal_ListTokensResponse, unmarshal_UsageOverview, @@ -1434,87 +1430,6 @@ async def delete_contact_point( self._throw_on_error(res) - async def list_managed_alerts( - self, - *, - region: Optional[ScwRegion] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - order_by: Optional[ListManagedAlertsRequestOrderBy] = None, - project_id: Optional[str] = None, - ) -> ListManagedAlertsResponse: - """ - List managed alerts. - List all managed alerts for the specified Project. - :param region: Region to target. If none is passed will use default region from the config. - :param page: Page number to return, from the paginated results. - :param page_size: Number of data sources to return per page. - :param order_by: Sort order for data sources in the response. - :param project_id: Project ID to filter for, only data sources from this Project will be returned. - :return: :class:`ListManagedAlertsResponse ` - - Usage: - :: - - result = await api.list_managed_alerts() - """ - - param_region = validate_path_param( - "region", region or self.client.default_region - ) - - res = self._request( - "GET", - f"/cockpit/v1/regions/{param_region}/managed-alerts", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - "project_id": project_id or self.client.default_project_id, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListManagedAlertsResponse(res.json()) - - async def list_managed_alerts_all( - self, - *, - region: Optional[ScwRegion] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - order_by: Optional[ListManagedAlertsRequestOrderBy] = None, - project_id: Optional[str] = None, - ) -> List[Alert]: - """ - List managed alerts. - List all managed alerts for the specified Project. - :param region: Region to target. If none is passed will use default region from the config. - :param page: Page number to return, from the paginated results. - :param page_size: Number of data sources to return per page. - :param order_by: Sort order for data sources in the response. - :param project_id: Project ID to filter for, only data sources from this Project will be returned. - :return: :class:`List[Alert] ` - - Usage: - :: - - result = await api.list_managed_alerts_all() - """ - - return await fetch_all_pages_async( - type=ListManagedAlertsResponse, - key="alerts", - fetcher=self.list_managed_alerts, - args={ - "region": region, - "page": page, - "page_size": page_size, - "order_by": order_by, - "project_id": project_id, - }, - ) - async def list_alerts( self, *, @@ -1522,7 +1437,7 @@ async def list_alerts( project_id: Optional[str] = None, is_enabled: Optional[bool] = None, is_preconfigured: Optional[bool] = None, - state: Optional[AnyAlertState] = None, + state: Optional[AlertState] = None, ) -> ListAlertsResponse: """ List alerts. diff --git a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py index 03b6090ff..5a72373eb 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py +++ b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py @@ -22,14 +22,12 @@ GetConfigResponseRetention, GetConfigResponse, Grafana, - AnyAlert, + Alert, ListAlertsResponse, ListContactPointsResponse, ListDataSourcesResponse, ListGrafanaProductDashboardsResponse, ListGrafanaUsersResponse, - Alert, - ListManagedAlertsResponse, ListPlansResponse, ListTokensResponse, Usage, @@ -417,10 +415,10 @@ def unmarshal_Grafana(data: Any) -> Grafana: return Grafana(**args) -def unmarshal_AnyAlert(data: Any) -> AnyAlert: +def unmarshal_Alert(data: Any) -> Alert: if not isinstance(data, dict): raise TypeError( - "Unmarshalling the type 'AnyAlert' failed as data isn't a dictionary." + "Unmarshalling the type 'Alert' failed as data isn't a dictionary." ) args: Dict[str, Any] = {} @@ -445,15 +443,21 @@ def unmarshal_AnyAlert(data: Any) -> AnyAlert: if field is not None: args["duration"] = field - field = data.get("state", None) + field = data.get("enabled", None) if field is not None: - args["state"] = field + args["enabled"] = field field = data.get("annotations", None) if field is not None: args["annotations"] = field - return AnyAlert(**args) + field = data.get("state", None) + if field is not None: + args["state"] = field + else: + args["state"] = None + + return Alert(**args) def unmarshal_ListAlertsResponse(data: Any) -> ListAlertsResponse: @@ -471,7 +475,7 @@ def unmarshal_ListAlertsResponse(data: Any) -> ListAlertsResponse: field = data.get("alerts", None) if field is not None: args["alerts"] = ( - [unmarshal_AnyAlert(v) for v in field] if field is not None else None + [unmarshal_Alert(v) for v in field] if field is not None else None ) return ListAlertsResponse(**args) @@ -573,58 +577,6 @@ def unmarshal_ListGrafanaUsersResponse(data: Any) -> ListGrafanaUsersResponse: return ListGrafanaUsersResponse(**args) -def unmarshal_Alert(data: Any) -> Alert: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Alert' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("product_family", None) - if field is not None: - args["product_family"] = field - - field = data.get("product", None) - if field is not None: - args["product"] = field - - field = data.get("name", None) - if field is not None: - args["name"] = field - - field = data.get("rule", None) - if field is not None: - args["rule"] = field - - field = data.get("description", None) - if field is not None: - args["description"] = field - - return Alert(**args) - - -def unmarshal_ListManagedAlertsResponse(data: Any) -> ListManagedAlertsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListManagedAlertsResponse' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - - field = data.get("alerts", None) - if field is not None: - args["alerts"] = ( - [unmarshal_Alert(v) for v in field] if field is not None else None - ) - - return ListManagedAlertsResponse(**args) - - def unmarshal_ListPlansResponse(data: Any) -> ListPlansResponse: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway-async/scaleway_async/cockpit/v1/types.py b/scaleway-async/scaleway_async/cockpit/v1/types.py index 7f50e6629..967fae25f 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/types.py +++ b/scaleway-async/scaleway_async/cockpit/v1/types.py @@ -15,10 +15,9 @@ ) -class AnyAlertState(str, Enum, metaclass=StrEnumMeta): +class AlertState(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATE = "unknown_state" - DISABLED = "disabled" - ENABLED = "enabled" + INACTIVE = "inactive" PENDING = "pending" FIRING = "firing" @@ -75,18 +74,6 @@ def __str__(self) -> str: return str(self.value) -class ListManagedAlertsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): - CREATED_AT_ASC = "created_at_asc" - CREATED_AT_DESC = "created_at_desc" - NAME_ASC = "name_asc" - NAME_DESC = "name_desc" - TYPE_ASC = "type_asc" - TYPE_DESC = "type_desc" - - def __str__(self) -> str: - return str(self.value) - - class ListPlansRequestOrderBy(str, Enum, metaclass=StrEnumMeta): NAME_ASC = "name_asc" NAME_DESC = "name_desc" @@ -155,7 +142,7 @@ class GetConfigResponseRetention: @dataclass -class AnyAlert: +class Alert: region: ScwRegion """ Region to target. If none is passed will use default region from the config. @@ -169,10 +156,12 @@ class AnyAlert: duration: str - state: AnyAlertState + enabled: bool annotations: Dict[str, str] + state: Optional[AlertState] + @dataclass class ContactPoint: @@ -314,19 +303,6 @@ class GrafanaUser: """ -@dataclass -class Alert: - product_family: str - - product: str - - name: str - - rule: str - - description: str - - @dataclass class Plan: """ @@ -749,7 +725,7 @@ class ListAlertsResponse: Total count of alerts matching the request. """ - alerts: List[AnyAlert] + alerts: List[Alert] """ List of alerts matching the applied filters. """ @@ -833,23 +809,6 @@ class ListGrafanaUsersResponse: """ -@dataclass -class ListManagedAlertsResponse: - """ - Response returned when listing data sources. - """ - - total_count: int - """ - Total count of data sources matching the request. - """ - - alerts: List[Alert] - """ - Alerts matching the request within the pagination. - """ - - @dataclass class ListPlansResponse: """ @@ -1189,7 +1148,7 @@ class RegionalApiListAlertsRequest: True returns only preconfigured alerts. False returns only custom alerts. If omitted, no filtering is applied on alert types. Other filters may still apply. """ - state: Optional[AnyAlertState] + state: Optional[AlertState] """ Valid values to filter on are `disabled`, `enabled`, `pending` and `firing`. If omitted, no filtering is applied on alert states. Other filters may still apply. """ @@ -1264,38 +1223,6 @@ class RegionalApiListDataSourcesRequest: """ -@dataclass -class RegionalApiListManagedAlertsRequest: - """ - Enable the sending of managed alerts. - """ - - region: Optional[ScwRegion] - """ - Region to target. If none is passed will use default region from the config. - """ - - page: Optional[int] - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] - """ - Number of data sources to return per page. - """ - - order_by: Optional[ListManagedAlertsRequestOrderBy] - """ - Sort order for data sources in the response. - """ - - project_id: Optional[str] - """ - Project ID to filter for, only data sources from this Project will be returned. - """ - - @dataclass class RegionalApiListTokensRequest: """ diff --git a/scaleway/scaleway/cockpit/v1/__init__.py b/scaleway/scaleway/cockpit/v1/__init__.py index 5137711f8..abac82780 100644 --- a/scaleway/scaleway/cockpit/v1/__init__.py +++ b/scaleway/scaleway/cockpit/v1/__init__.py @@ -1,12 +1,11 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from .types import AnyAlertState +from .types import AlertState from .types import DataSourceOrigin from .types import DataSourceType from .types import GrafanaUserRole from .types import ListDataSourcesRequestOrderBy from .types import ListGrafanaUsersRequestOrderBy -from .types import ListManagedAlertsRequestOrderBy from .types import ListPlansRequestOrderBy from .types import ListTokensRequestOrderBy from .types import PlanName @@ -14,12 +13,11 @@ from .types import UsageUnit from .types import ContactPointEmail from .types import GetConfigResponseRetention -from .types import AnyAlert +from .types import Alert from .types import ContactPoint from .types import DataSource from .types import GrafanaProductDashboard from .types import GrafanaUser -from .types import Alert from .types import Plan from .types import Token from .types import Usage @@ -42,7 +40,6 @@ from .types import ListDataSourcesResponse from .types import ListGrafanaProductDashboardsResponse from .types import ListGrafanaUsersResponse -from .types import ListManagedAlertsResponse from .types import ListPlansResponse from .types import ListTokensResponse from .types import RegionalApiCreateContactPointRequest @@ -63,7 +60,6 @@ from .types import RegionalApiListAlertsRequest from .types import RegionalApiListContactPointsRequest from .types import RegionalApiListDataSourcesRequest -from .types import RegionalApiListManagedAlertsRequest from .types import RegionalApiListTokensRequest from .types import RegionalApiTriggerTestAlertRequest from .types import RegionalApiUpdateContactPointRequest @@ -73,13 +69,12 @@ from .api import CockpitV1RegionalAPI __all__ = [ - "AnyAlertState", + "AlertState", "DataSourceOrigin", "DataSourceType", "GrafanaUserRole", "ListDataSourcesRequestOrderBy", "ListGrafanaUsersRequestOrderBy", - "ListManagedAlertsRequestOrderBy", "ListPlansRequestOrderBy", "ListTokensRequestOrderBy", "PlanName", @@ -87,12 +82,11 @@ "UsageUnit", "ContactPointEmail", "GetConfigResponseRetention", - "AnyAlert", + "Alert", "ContactPoint", "DataSource", "GrafanaProductDashboard", "GrafanaUser", - "Alert", "Plan", "Token", "Usage", @@ -115,7 +109,6 @@ "ListDataSourcesResponse", "ListGrafanaProductDashboardsResponse", "ListGrafanaUsersResponse", - "ListManagedAlertsResponse", "ListPlansResponse", "ListTokensResponse", "RegionalApiCreateContactPointRequest", @@ -136,7 +129,6 @@ "RegionalApiListAlertsRequest", "RegionalApiListContactPointsRequest", "RegionalApiListDataSourcesRequest", - "RegionalApiListManagedAlertsRequest", "RegionalApiListTokensRequest", "RegionalApiTriggerTestAlertRequest", "RegionalApiUpdateContactPointRequest", diff --git a/scaleway/scaleway/cockpit/v1/api.py b/scaleway/scaleway/cockpit/v1/api.py index 9f19a0c7a..e97de018e 100644 --- a/scaleway/scaleway/cockpit/v1/api.py +++ b/scaleway/scaleway/cockpit/v1/api.py @@ -12,18 +12,16 @@ fetch_all_pages, ) from .types import ( - AnyAlertState, + AlertState, DataSourceOrigin, DataSourceType, GrafanaUserRole, ListDataSourcesRequestOrderBy, ListGrafanaUsersRequestOrderBy, - ListManagedAlertsRequestOrderBy, ListPlansRequestOrderBy, ListTokensRequestOrderBy, PlanName, TokenScope, - Alert, AlertManager, ContactPoint, ContactPointEmail, @@ -41,7 +39,6 @@ ListDataSourcesResponse, ListGrafanaProductDashboardsResponse, ListGrafanaUsersResponse, - ListManagedAlertsResponse, ListPlansResponse, ListTokensResponse, Plan, @@ -74,7 +71,6 @@ unmarshal_ListDataSourcesResponse, unmarshal_ListGrafanaProductDashboardsResponse, unmarshal_ListGrafanaUsersResponse, - unmarshal_ListManagedAlertsResponse, unmarshal_ListPlansResponse, unmarshal_ListTokensResponse, unmarshal_UsageOverview, @@ -1434,87 +1430,6 @@ def delete_contact_point( self._throw_on_error(res) - def list_managed_alerts( - self, - *, - region: Optional[ScwRegion] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - order_by: Optional[ListManagedAlertsRequestOrderBy] = None, - project_id: Optional[str] = None, - ) -> ListManagedAlertsResponse: - """ - List managed alerts. - List all managed alerts for the specified Project. - :param region: Region to target. If none is passed will use default region from the config. - :param page: Page number to return, from the paginated results. - :param page_size: Number of data sources to return per page. - :param order_by: Sort order for data sources in the response. - :param project_id: Project ID to filter for, only data sources from this Project will be returned. - :return: :class:`ListManagedAlertsResponse ` - - Usage: - :: - - result = api.list_managed_alerts() - """ - - param_region = validate_path_param( - "region", region or self.client.default_region - ) - - res = self._request( - "GET", - f"/cockpit/v1/regions/{param_region}/managed-alerts", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - "project_id": project_id or self.client.default_project_id, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListManagedAlertsResponse(res.json()) - - def list_managed_alerts_all( - self, - *, - region: Optional[ScwRegion] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - order_by: Optional[ListManagedAlertsRequestOrderBy] = None, - project_id: Optional[str] = None, - ) -> List[Alert]: - """ - List managed alerts. - List all managed alerts for the specified Project. - :param region: Region to target. If none is passed will use default region from the config. - :param page: Page number to return, from the paginated results. - :param page_size: Number of data sources to return per page. - :param order_by: Sort order for data sources in the response. - :param project_id: Project ID to filter for, only data sources from this Project will be returned. - :return: :class:`List[Alert] ` - - Usage: - :: - - result = api.list_managed_alerts_all() - """ - - return fetch_all_pages( - type=ListManagedAlertsResponse, - key="alerts", - fetcher=self.list_managed_alerts, - args={ - "region": region, - "page": page, - "page_size": page_size, - "order_by": order_by, - "project_id": project_id, - }, - ) - def list_alerts( self, *, @@ -1522,7 +1437,7 @@ def list_alerts( project_id: Optional[str] = None, is_enabled: Optional[bool] = None, is_preconfigured: Optional[bool] = None, - state: Optional[AnyAlertState] = None, + state: Optional[AlertState] = None, ) -> ListAlertsResponse: """ List alerts. diff --git a/scaleway/scaleway/cockpit/v1/marshalling.py b/scaleway/scaleway/cockpit/v1/marshalling.py index 03b6090ff..5a72373eb 100644 --- a/scaleway/scaleway/cockpit/v1/marshalling.py +++ b/scaleway/scaleway/cockpit/v1/marshalling.py @@ -22,14 +22,12 @@ GetConfigResponseRetention, GetConfigResponse, Grafana, - AnyAlert, + Alert, ListAlertsResponse, ListContactPointsResponse, ListDataSourcesResponse, ListGrafanaProductDashboardsResponse, ListGrafanaUsersResponse, - Alert, - ListManagedAlertsResponse, ListPlansResponse, ListTokensResponse, Usage, @@ -417,10 +415,10 @@ def unmarshal_Grafana(data: Any) -> Grafana: return Grafana(**args) -def unmarshal_AnyAlert(data: Any) -> AnyAlert: +def unmarshal_Alert(data: Any) -> Alert: if not isinstance(data, dict): raise TypeError( - "Unmarshalling the type 'AnyAlert' failed as data isn't a dictionary." + "Unmarshalling the type 'Alert' failed as data isn't a dictionary." ) args: Dict[str, Any] = {} @@ -445,15 +443,21 @@ def unmarshal_AnyAlert(data: Any) -> AnyAlert: if field is not None: args["duration"] = field - field = data.get("state", None) + field = data.get("enabled", None) if field is not None: - args["state"] = field + args["enabled"] = field field = data.get("annotations", None) if field is not None: args["annotations"] = field - return AnyAlert(**args) + field = data.get("state", None) + if field is not None: + args["state"] = field + else: + args["state"] = None + + return Alert(**args) def unmarshal_ListAlertsResponse(data: Any) -> ListAlertsResponse: @@ -471,7 +475,7 @@ def unmarshal_ListAlertsResponse(data: Any) -> ListAlertsResponse: field = data.get("alerts", None) if field is not None: args["alerts"] = ( - [unmarshal_AnyAlert(v) for v in field] if field is not None else None + [unmarshal_Alert(v) for v in field] if field is not None else None ) return ListAlertsResponse(**args) @@ -573,58 +577,6 @@ def unmarshal_ListGrafanaUsersResponse(data: Any) -> ListGrafanaUsersResponse: return ListGrafanaUsersResponse(**args) -def unmarshal_Alert(data: Any) -> Alert: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Alert' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("product_family", None) - if field is not None: - args["product_family"] = field - - field = data.get("product", None) - if field is not None: - args["product"] = field - - field = data.get("name", None) - if field is not None: - args["name"] = field - - field = data.get("rule", None) - if field is not None: - args["rule"] = field - - field = data.get("description", None) - if field is not None: - args["description"] = field - - return Alert(**args) - - -def unmarshal_ListManagedAlertsResponse(data: Any) -> ListManagedAlertsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListManagedAlertsResponse' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - - field = data.get("alerts", None) - if field is not None: - args["alerts"] = ( - [unmarshal_Alert(v) for v in field] if field is not None else None - ) - - return ListManagedAlertsResponse(**args) - - def unmarshal_ListPlansResponse(data: Any) -> ListPlansResponse: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway/scaleway/cockpit/v1/types.py b/scaleway/scaleway/cockpit/v1/types.py index 7f50e6629..967fae25f 100644 --- a/scaleway/scaleway/cockpit/v1/types.py +++ b/scaleway/scaleway/cockpit/v1/types.py @@ -15,10 +15,9 @@ ) -class AnyAlertState(str, Enum, metaclass=StrEnumMeta): +class AlertState(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATE = "unknown_state" - DISABLED = "disabled" - ENABLED = "enabled" + INACTIVE = "inactive" PENDING = "pending" FIRING = "firing" @@ -75,18 +74,6 @@ def __str__(self) -> str: return str(self.value) -class ListManagedAlertsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): - CREATED_AT_ASC = "created_at_asc" - CREATED_AT_DESC = "created_at_desc" - NAME_ASC = "name_asc" - NAME_DESC = "name_desc" - TYPE_ASC = "type_asc" - TYPE_DESC = "type_desc" - - def __str__(self) -> str: - return str(self.value) - - class ListPlansRequestOrderBy(str, Enum, metaclass=StrEnumMeta): NAME_ASC = "name_asc" NAME_DESC = "name_desc" @@ -155,7 +142,7 @@ class GetConfigResponseRetention: @dataclass -class AnyAlert: +class Alert: region: ScwRegion """ Region to target. If none is passed will use default region from the config. @@ -169,10 +156,12 @@ class AnyAlert: duration: str - state: AnyAlertState + enabled: bool annotations: Dict[str, str] + state: Optional[AlertState] + @dataclass class ContactPoint: @@ -314,19 +303,6 @@ class GrafanaUser: """ -@dataclass -class Alert: - product_family: str - - product: str - - name: str - - rule: str - - description: str - - @dataclass class Plan: """ @@ -749,7 +725,7 @@ class ListAlertsResponse: Total count of alerts matching the request. """ - alerts: List[AnyAlert] + alerts: List[Alert] """ List of alerts matching the applied filters. """ @@ -833,23 +809,6 @@ class ListGrafanaUsersResponse: """ -@dataclass -class ListManagedAlertsResponse: - """ - Response returned when listing data sources. - """ - - total_count: int - """ - Total count of data sources matching the request. - """ - - alerts: List[Alert] - """ - Alerts matching the request within the pagination. - """ - - @dataclass class ListPlansResponse: """ @@ -1189,7 +1148,7 @@ class RegionalApiListAlertsRequest: True returns only preconfigured alerts. False returns only custom alerts. If omitted, no filtering is applied on alert types. Other filters may still apply. """ - state: Optional[AnyAlertState] + state: Optional[AlertState] """ Valid values to filter on are `disabled`, `enabled`, `pending` and `firing`. If omitted, no filtering is applied on alert states. Other filters may still apply. """ @@ -1264,38 +1223,6 @@ class RegionalApiListDataSourcesRequest: """ -@dataclass -class RegionalApiListManagedAlertsRequest: - """ - Enable the sending of managed alerts. - """ - - region: Optional[ScwRegion] - """ - Region to target. If none is passed will use default region from the config. - """ - - page: Optional[int] - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] - """ - Number of data sources to return per page. - """ - - order_by: Optional[ListManagedAlertsRequestOrderBy] - """ - Sort order for data sources in the response. - """ - - project_id: Optional[str] - """ - Project ID to filter for, only data sources from this Project will be returned. - """ - - @dataclass class RegionalApiListTokensRequest: """