Skip to content

chore(cockpit): remove list_managed_alerts #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions scaleway-async/scaleway_async/cockpit/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
# 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
from .types import TokenScope
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -73,26 +69,24 @@
from .api import CockpitV1RegionalAPI

__all__ = [
"AnyAlertState",
"AlertState",
"DataSourceOrigin",
"DataSourceType",
"GrafanaUserRole",
"ListDataSourcesRequestOrderBy",
"ListGrafanaUsersRequestOrderBy",
"ListManagedAlertsRequestOrderBy",
"ListPlansRequestOrderBy",
"ListTokensRequestOrderBy",
"PlanName",
"TokenScope",
"UsageUnit",
"ContactPointEmail",
"GetConfigResponseRetention",
"AnyAlert",
"Alert",
"ContactPoint",
"DataSource",
"GrafanaProductDashboard",
"GrafanaUser",
"Alert",
"Plan",
"Token",
"Usage",
Expand All @@ -115,7 +109,6 @@
"ListDataSourcesResponse",
"ListGrafanaProductDashboardsResponse",
"ListGrafanaUsersResponse",
"ListManagedAlertsResponse",
"ListPlansResponse",
"ListTokensResponse",
"RegionalApiCreateContactPointRequest",
Expand All @@ -136,7 +129,6 @@
"RegionalApiListAlertsRequest",
"RegionalApiListContactPointsRequest",
"RegionalApiListDataSourcesRequest",
"RegionalApiListManagedAlertsRequest",
"RegionalApiListTokensRequest",
"RegionalApiTriggerTestAlertRequest",
"RegionalApiUpdateContactPointRequest",
Expand Down
89 changes: 2 additions & 87 deletions scaleway-async/scaleway_async/cockpit/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -41,7 +39,6 @@
ListDataSourcesResponse,
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersResponse,
ListManagedAlertsResponse,
ListPlansResponse,
ListTokensResponse,
Plan,
Expand Down Expand Up @@ -74,7 +71,6 @@
unmarshal_ListDataSourcesResponse,
unmarshal_ListGrafanaProductDashboardsResponse,
unmarshal_ListGrafanaUsersResponse,
unmarshal_ListManagedAlertsResponse,
unmarshal_ListPlansResponse,
unmarshal_ListTokensResponse,
unmarshal_UsageOverview,
Expand Down Expand Up @@ -1434,95 +1430,14 @@ 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 <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] <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,
*,
region: Optional[ScwRegion] = None,
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.
Expand Down
74 changes: 13 additions & 61 deletions scaleway-async/scaleway_async/cockpit/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
GetConfigResponseRetention,
GetConfigResponse,
Grafana,
AnyAlert,
Alert,
ListAlertsResponse,
ListContactPointsResponse,
ListDataSourcesResponse,
ListGrafanaProductDashboardsResponse,
ListGrafanaUsersResponse,
Alert,
ListManagedAlertsResponse,
ListPlansResponse,
ListTokensResponse,
Usage,
Expand Down Expand Up @@ -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] = {}
Expand All @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
Loading