From ac220139e4d4c5cbc31f9157c3b58dd324b07c16 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Fri, 27 Jun 2025 14:20:25 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/cockpit/v1/__init__.py | 6 +++ .../scaleway_async/cockpit/v1/api.py | 35 +++++++++++++ .../scaleway_async/cockpit/v1/marshalling.py | 50 +++++++++++++++++++ .../scaleway_async/cockpit/v1/types.py | 49 ++++++++++++++++++ scaleway/scaleway/cockpit/v1/__init__.py | 6 +++ scaleway/scaleway/cockpit/v1/api.py | 35 +++++++++++++ scaleway/scaleway/cockpit/v1/marshalling.py | 50 +++++++++++++++++++ scaleway/scaleway/cockpit/v1/types.py | 49 ++++++++++++++++++ 8 files changed, 280 insertions(+) diff --git a/scaleway-async/scaleway_async/cockpit/v1/__init__.py b/scaleway-async/scaleway_async/cockpit/v1/__init__.py index 44d90e37f..babe78261 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/__init__.py +++ b/scaleway-async/scaleway_async/cockpit/v1/__init__.py @@ -14,6 +14,7 @@ from .types import PreconfiguredAlertData from .types import ContactPointEmail from .types import GetConfigResponseRetention +from .types import RulesCount from .types import Alert from .types import ContactPoint from .types import DataSource @@ -26,6 +27,7 @@ from .types import DisableAlertRulesResponse from .types import EnableAlertRulesResponse from .types import GetConfigResponse +from .types import GetRulesCountResponse from .types import GlobalApiCreateGrafanaUserRequest from .types import GlobalApiDeleteGrafanaUserRequest from .types import GlobalApiGetCurrentPlanRequest @@ -60,6 +62,7 @@ from .types import RegionalApiGetAlertManagerRequest from .types import RegionalApiGetConfigRequest from .types import RegionalApiGetDataSourceRequest +from .types import RegionalApiGetRulesCountRequest from .types import RegionalApiGetTokenRequest from .types import RegionalApiGetUsageOverviewRequest from .types import RegionalApiListAlertsRequest @@ -88,6 +91,7 @@ "PreconfiguredAlertData", "ContactPointEmail", "GetConfigResponseRetention", + "RulesCount", "Alert", "ContactPoint", "DataSource", @@ -100,6 +104,7 @@ "DisableAlertRulesResponse", "EnableAlertRulesResponse", "GetConfigResponse", + "GetRulesCountResponse", "GlobalApiCreateGrafanaUserRequest", "GlobalApiDeleteGrafanaUserRequest", "GlobalApiGetCurrentPlanRequest", @@ -134,6 +139,7 @@ "RegionalApiGetAlertManagerRequest", "RegionalApiGetConfigRequest", "RegionalApiGetDataSourceRequest", + "RegionalApiGetRulesCountRequest", "RegionalApiGetTokenRequest", "RegionalApiGetUsageOverviewRequest", "RegionalApiListAlertsRequest", diff --git a/scaleway-async/scaleway_async/cockpit/v1/api.py b/scaleway-async/scaleway_async/cockpit/v1/api.py index 996aa0118..01351468c 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/api.py +++ b/scaleway-async/scaleway_async/cockpit/v1/api.py @@ -29,6 +29,7 @@ DisableAlertRulesResponse, EnableAlertRulesResponse, GetConfigResponse, + GetRulesCountResponse, GlobalApiCreateGrafanaUserRequest, GlobalApiResetGrafanaUserPasswordRequest, GlobalApiSelectPlanRequest, @@ -71,6 +72,7 @@ unmarshal_DisableAlertRulesResponse, unmarshal_EnableAlertRulesResponse, unmarshal_GetConfigResponse, + unmarshal_GetRulesCountResponse, unmarshal_Grafana, unmarshal_ListAlertsResponse, unmarshal_ListContactPointsResponse, @@ -1228,6 +1230,39 @@ async def disable_alert_manager( self._throw_on_error(res) return unmarshal_AlertManager(res.json()) + async def get_rules_count( + self, + *, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + ) -> GetRulesCountResponse: + """ + Get a detailed count of enabled rules in the specified Project. Includes preconfigured and custom alerting and recording rules. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Project to retrieve the rule count for. + :return: :class:`GetRulesCountResponse ` + + Usage: + :: + + result = await api.get_rules_count() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/cockpit/v1/regions/{param_region}/rules/count", + params={ + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_GetRulesCountResponse(res.json()) + async def create_contact_point( self, *, diff --git a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py index 863d437b1..4ea03b6c3 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py +++ b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py @@ -23,6 +23,8 @@ EnableAlertRulesResponse, GetConfigResponseRetention, GetConfigResponse, + RulesCount, + GetRulesCountResponse, Grafana, PreconfiguredAlertData, Alert, @@ -435,6 +437,54 @@ def unmarshal_GetConfigResponse(data: Any) -> GetConfigResponse: return GetConfigResponse(**args) +def unmarshal_RulesCount(data: Any) -> RulesCount: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RulesCount' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("data_source_id", None) + if field is not None: + args["data_source_id"] = field + + field = data.get("data_source_name", None) + if field is not None: + args["data_source_name"] = field + + field = data.get("rules_count", None) + if field is not None: + args["rules_count"] = field + + return RulesCount(**args) + + +def unmarshal_GetRulesCountResponse(data: Any) -> GetRulesCountResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetRulesCountResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("rules_count_by_datasource", None) + if field is not None: + args["rules_count_by_datasource"] = ( + [unmarshal_RulesCount(v) for v in field] if field is not None else None + ) + + field = data.get("preconfigured_rules_count", None) + if field is not None: + args["preconfigured_rules_count"] = field + + field = data.get("custom_rules_count", None) + if field is not None: + args["custom_rules_count"] = field + + return GetRulesCountResponse(**args) + + def unmarshal_Grafana(data: Any) -> Grafana: 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 92a135222..776b5d61a 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/types.py +++ b/scaleway-async/scaleway_async/cockpit/v1/types.py @@ -173,6 +173,24 @@ class GetConfigResponseRetention: default_days: int +@dataclass +class RulesCount: + data_source_id: str + """ + ID of the data source. + """ + + data_source_name: str + """ + Name of the data source. + """ + + rules_count: int + """ + Total count of rules associated with this data source. + """ + + @dataclass class Alert: """ @@ -594,6 +612,24 @@ class GetConfigResponse: """ +@dataclass +class GetRulesCountResponse: + rules_count_by_datasource: List[RulesCount] + """ + Total count of rules grouped by data source. + """ + + preconfigured_rules_count: int + """ + Total count of preconfigured rules. + """ + + custom_rules_count: int + """ + Total count of custom rules. + """ + + @dataclass class GlobalApiCreateGrafanaUserRequest: """ @@ -1220,6 +1256,19 @@ class RegionalApiGetDataSourceRequest: """ +@dataclass +class RegionalApiGetRulesCountRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project to retrieve the rule count for. + """ + + @dataclass class RegionalApiGetTokenRequest: """ diff --git a/scaleway/scaleway/cockpit/v1/__init__.py b/scaleway/scaleway/cockpit/v1/__init__.py index 44d90e37f..babe78261 100644 --- a/scaleway/scaleway/cockpit/v1/__init__.py +++ b/scaleway/scaleway/cockpit/v1/__init__.py @@ -14,6 +14,7 @@ from .types import PreconfiguredAlertData from .types import ContactPointEmail from .types import GetConfigResponseRetention +from .types import RulesCount from .types import Alert from .types import ContactPoint from .types import DataSource @@ -26,6 +27,7 @@ from .types import DisableAlertRulesResponse from .types import EnableAlertRulesResponse from .types import GetConfigResponse +from .types import GetRulesCountResponse from .types import GlobalApiCreateGrafanaUserRequest from .types import GlobalApiDeleteGrafanaUserRequest from .types import GlobalApiGetCurrentPlanRequest @@ -60,6 +62,7 @@ from .types import RegionalApiGetAlertManagerRequest from .types import RegionalApiGetConfigRequest from .types import RegionalApiGetDataSourceRequest +from .types import RegionalApiGetRulesCountRequest from .types import RegionalApiGetTokenRequest from .types import RegionalApiGetUsageOverviewRequest from .types import RegionalApiListAlertsRequest @@ -88,6 +91,7 @@ "PreconfiguredAlertData", "ContactPointEmail", "GetConfigResponseRetention", + "RulesCount", "Alert", "ContactPoint", "DataSource", @@ -100,6 +104,7 @@ "DisableAlertRulesResponse", "EnableAlertRulesResponse", "GetConfigResponse", + "GetRulesCountResponse", "GlobalApiCreateGrafanaUserRequest", "GlobalApiDeleteGrafanaUserRequest", "GlobalApiGetCurrentPlanRequest", @@ -134,6 +139,7 @@ "RegionalApiGetAlertManagerRequest", "RegionalApiGetConfigRequest", "RegionalApiGetDataSourceRequest", + "RegionalApiGetRulesCountRequest", "RegionalApiGetTokenRequest", "RegionalApiGetUsageOverviewRequest", "RegionalApiListAlertsRequest", diff --git a/scaleway/scaleway/cockpit/v1/api.py b/scaleway/scaleway/cockpit/v1/api.py index 275b0e603..083a4a535 100644 --- a/scaleway/scaleway/cockpit/v1/api.py +++ b/scaleway/scaleway/cockpit/v1/api.py @@ -29,6 +29,7 @@ DisableAlertRulesResponse, EnableAlertRulesResponse, GetConfigResponse, + GetRulesCountResponse, GlobalApiCreateGrafanaUserRequest, GlobalApiResetGrafanaUserPasswordRequest, GlobalApiSelectPlanRequest, @@ -71,6 +72,7 @@ unmarshal_DisableAlertRulesResponse, unmarshal_EnableAlertRulesResponse, unmarshal_GetConfigResponse, + unmarshal_GetRulesCountResponse, unmarshal_Grafana, unmarshal_ListAlertsResponse, unmarshal_ListContactPointsResponse, @@ -1228,6 +1230,39 @@ def disable_alert_manager( self._throw_on_error(res) return unmarshal_AlertManager(res.json()) + def get_rules_count( + self, + *, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + ) -> GetRulesCountResponse: + """ + Get a detailed count of enabled rules in the specified Project. Includes preconfigured and custom alerting and recording rules. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Project to retrieve the rule count for. + :return: :class:`GetRulesCountResponse ` + + Usage: + :: + + result = api.get_rules_count() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/cockpit/v1/regions/{param_region}/rules/count", + params={ + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_GetRulesCountResponse(res.json()) + def create_contact_point( self, *, diff --git a/scaleway/scaleway/cockpit/v1/marshalling.py b/scaleway/scaleway/cockpit/v1/marshalling.py index 863d437b1..4ea03b6c3 100644 --- a/scaleway/scaleway/cockpit/v1/marshalling.py +++ b/scaleway/scaleway/cockpit/v1/marshalling.py @@ -23,6 +23,8 @@ EnableAlertRulesResponse, GetConfigResponseRetention, GetConfigResponse, + RulesCount, + GetRulesCountResponse, Grafana, PreconfiguredAlertData, Alert, @@ -435,6 +437,54 @@ def unmarshal_GetConfigResponse(data: Any) -> GetConfigResponse: return GetConfigResponse(**args) +def unmarshal_RulesCount(data: Any) -> RulesCount: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RulesCount' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("data_source_id", None) + if field is not None: + args["data_source_id"] = field + + field = data.get("data_source_name", None) + if field is not None: + args["data_source_name"] = field + + field = data.get("rules_count", None) + if field is not None: + args["rules_count"] = field + + return RulesCount(**args) + + +def unmarshal_GetRulesCountResponse(data: Any) -> GetRulesCountResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GetRulesCountResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("rules_count_by_datasource", None) + if field is not None: + args["rules_count_by_datasource"] = ( + [unmarshal_RulesCount(v) for v in field] if field is not None else None + ) + + field = data.get("preconfigured_rules_count", None) + if field is not None: + args["preconfigured_rules_count"] = field + + field = data.get("custom_rules_count", None) + if field is not None: + args["custom_rules_count"] = field + + return GetRulesCountResponse(**args) + + def unmarshal_Grafana(data: Any) -> Grafana: if not isinstance(data, dict): raise TypeError( diff --git a/scaleway/scaleway/cockpit/v1/types.py b/scaleway/scaleway/cockpit/v1/types.py index 92a135222..776b5d61a 100644 --- a/scaleway/scaleway/cockpit/v1/types.py +++ b/scaleway/scaleway/cockpit/v1/types.py @@ -173,6 +173,24 @@ class GetConfigResponseRetention: default_days: int +@dataclass +class RulesCount: + data_source_id: str + """ + ID of the data source. + """ + + data_source_name: str + """ + Name of the data source. + """ + + rules_count: int + """ + Total count of rules associated with this data source. + """ + + @dataclass class Alert: """ @@ -594,6 +612,24 @@ class GetConfigResponse: """ +@dataclass +class GetRulesCountResponse: + rules_count_by_datasource: List[RulesCount] + """ + Total count of rules grouped by data source. + """ + + preconfigured_rules_count: int + """ + Total count of preconfigured rules. + """ + + custom_rules_count: int + """ + Total count of custom rules. + """ + + @dataclass class GlobalApiCreateGrafanaUserRequest: """ @@ -1220,6 +1256,19 @@ class RegionalApiGetDataSourceRequest: """ +@dataclass +class RegionalApiGetRulesCountRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project to retrieve the rule count for. + """ + + @dataclass class RegionalApiGetTokenRequest: """