Skip to content

Commit 30d5e30

Browse files
authored
chore(cockpit): remove list_managed_alerts (#860)
1 parent 6581fd2 commit 30d5e30

File tree

8 files changed

+54
-482
lines changed

8 files changed

+54
-482
lines changed

scaleway-async/scaleway_async/cockpit/v1/__init__.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
3-
from .types import AnyAlertState
3+
from .types import AlertState
44
from .types import DataSourceOrigin
55
from .types import DataSourceType
66
from .types import GrafanaUserRole
77
from .types import ListDataSourcesRequestOrderBy
88
from .types import ListGrafanaUsersRequestOrderBy
9-
from .types import ListManagedAlertsRequestOrderBy
109
from .types import ListPlansRequestOrderBy
1110
from .types import ListTokensRequestOrderBy
1211
from .types import PlanName
1312
from .types import TokenScope
1413
from .types import UsageUnit
1514
from .types import ContactPointEmail
1615
from .types import GetConfigResponseRetention
17-
from .types import AnyAlert
16+
from .types import Alert
1817
from .types import ContactPoint
1918
from .types import DataSource
2019
from .types import GrafanaProductDashboard
2120
from .types import GrafanaUser
22-
from .types import Alert
2321
from .types import Plan
2422
from .types import Token
2523
from .types import Usage
@@ -42,7 +40,6 @@
4240
from .types import ListDataSourcesResponse
4341
from .types import ListGrafanaProductDashboardsResponse
4442
from .types import ListGrafanaUsersResponse
45-
from .types import ListManagedAlertsResponse
4643
from .types import ListPlansResponse
4744
from .types import ListTokensResponse
4845
from .types import RegionalApiCreateContactPointRequest
@@ -63,7 +60,6 @@
6360
from .types import RegionalApiListAlertsRequest
6461
from .types import RegionalApiListContactPointsRequest
6562
from .types import RegionalApiListDataSourcesRequest
66-
from .types import RegionalApiListManagedAlertsRequest
6763
from .types import RegionalApiListTokensRequest
6864
from .types import RegionalApiTriggerTestAlertRequest
6965
from .types import RegionalApiUpdateContactPointRequest
@@ -73,26 +69,24 @@
7369
from .api import CockpitV1RegionalAPI
7470

7571
__all__ = [
76-
"AnyAlertState",
72+
"AlertState",
7773
"DataSourceOrigin",
7874
"DataSourceType",
7975
"GrafanaUserRole",
8076
"ListDataSourcesRequestOrderBy",
8177
"ListGrafanaUsersRequestOrderBy",
82-
"ListManagedAlertsRequestOrderBy",
8378
"ListPlansRequestOrderBy",
8479
"ListTokensRequestOrderBy",
8580
"PlanName",
8681
"TokenScope",
8782
"UsageUnit",
8883
"ContactPointEmail",
8984
"GetConfigResponseRetention",
90-
"AnyAlert",
85+
"Alert",
9186
"ContactPoint",
9287
"DataSource",
9388
"GrafanaProductDashboard",
9489
"GrafanaUser",
95-
"Alert",
9690
"Plan",
9791
"Token",
9892
"Usage",
@@ -115,7 +109,6 @@
115109
"ListDataSourcesResponse",
116110
"ListGrafanaProductDashboardsResponse",
117111
"ListGrafanaUsersResponse",
118-
"ListManagedAlertsResponse",
119112
"ListPlansResponse",
120113
"ListTokensResponse",
121114
"RegionalApiCreateContactPointRequest",
@@ -136,7 +129,6 @@
136129
"RegionalApiListAlertsRequest",
137130
"RegionalApiListContactPointsRequest",
138131
"RegionalApiListDataSourcesRequest",
139-
"RegionalApiListManagedAlertsRequest",
140132
"RegionalApiListTokensRequest",
141133
"RegionalApiTriggerTestAlertRequest",
142134
"RegionalApiUpdateContactPointRequest",

scaleway-async/scaleway_async/cockpit/v1/api.py

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
fetch_all_pages_async,
1313
)
1414
from .types import (
15-
AnyAlertState,
15+
AlertState,
1616
DataSourceOrigin,
1717
DataSourceType,
1818
GrafanaUserRole,
1919
ListDataSourcesRequestOrderBy,
2020
ListGrafanaUsersRequestOrderBy,
21-
ListManagedAlertsRequestOrderBy,
2221
ListPlansRequestOrderBy,
2322
ListTokensRequestOrderBy,
2423
PlanName,
2524
TokenScope,
26-
Alert,
2725
AlertManager,
2826
ContactPoint,
2927
ContactPointEmail,
@@ -41,7 +39,6 @@
4139
ListDataSourcesResponse,
4240
ListGrafanaProductDashboardsResponse,
4341
ListGrafanaUsersResponse,
44-
ListManagedAlertsResponse,
4542
ListPlansResponse,
4643
ListTokensResponse,
4744
Plan,
@@ -74,7 +71,6 @@
7471
unmarshal_ListDataSourcesResponse,
7572
unmarshal_ListGrafanaProductDashboardsResponse,
7673
unmarshal_ListGrafanaUsersResponse,
77-
unmarshal_ListManagedAlertsResponse,
7874
unmarshal_ListPlansResponse,
7975
unmarshal_ListTokensResponse,
8076
unmarshal_UsageOverview,
@@ -1434,95 +1430,14 @@ async def delete_contact_point(
14341430

14351431
self._throw_on_error(res)
14361432

1437-
async def list_managed_alerts(
1438-
self,
1439-
*,
1440-
region: Optional[ScwRegion] = None,
1441-
page: Optional[int] = None,
1442-
page_size: Optional[int] = None,
1443-
order_by: Optional[ListManagedAlertsRequestOrderBy] = None,
1444-
project_id: Optional[str] = None,
1445-
) -> ListManagedAlertsResponse:
1446-
"""
1447-
List managed alerts.
1448-
List all managed alerts for the specified Project.
1449-
:param region: Region to target. If none is passed will use default region from the config.
1450-
:param page: Page number to return, from the paginated results.
1451-
:param page_size: Number of data sources to return per page.
1452-
:param order_by: Sort order for data sources in the response.
1453-
:param project_id: Project ID to filter for, only data sources from this Project will be returned.
1454-
:return: :class:`ListManagedAlertsResponse <ListManagedAlertsResponse>`
1455-
1456-
Usage:
1457-
::
1458-
1459-
result = await api.list_managed_alerts()
1460-
"""
1461-
1462-
param_region = validate_path_param(
1463-
"region", region or self.client.default_region
1464-
)
1465-
1466-
res = self._request(
1467-
"GET",
1468-
f"/cockpit/v1/regions/{param_region}/managed-alerts",
1469-
params={
1470-
"order_by": order_by,
1471-
"page": page,
1472-
"page_size": page_size or self.client.default_page_size,
1473-
"project_id": project_id or self.client.default_project_id,
1474-
},
1475-
)
1476-
1477-
self._throw_on_error(res)
1478-
return unmarshal_ListManagedAlertsResponse(res.json())
1479-
1480-
async def list_managed_alerts_all(
1481-
self,
1482-
*,
1483-
region: Optional[ScwRegion] = None,
1484-
page: Optional[int] = None,
1485-
page_size: Optional[int] = None,
1486-
order_by: Optional[ListManagedAlertsRequestOrderBy] = None,
1487-
project_id: Optional[str] = None,
1488-
) -> List[Alert]:
1489-
"""
1490-
List managed alerts.
1491-
List all managed alerts for the specified Project.
1492-
:param region: Region to target. If none is passed will use default region from the config.
1493-
:param page: Page number to return, from the paginated results.
1494-
:param page_size: Number of data sources to return per page.
1495-
:param order_by: Sort order for data sources in the response.
1496-
:param project_id: Project ID to filter for, only data sources from this Project will be returned.
1497-
:return: :class:`List[Alert] <List[Alert]>`
1498-
1499-
Usage:
1500-
::
1501-
1502-
result = await api.list_managed_alerts_all()
1503-
"""
1504-
1505-
return await fetch_all_pages_async(
1506-
type=ListManagedAlertsResponse,
1507-
key="alerts",
1508-
fetcher=self.list_managed_alerts,
1509-
args={
1510-
"region": region,
1511-
"page": page,
1512-
"page_size": page_size,
1513-
"order_by": order_by,
1514-
"project_id": project_id,
1515-
},
1516-
)
1517-
15181433
async def list_alerts(
15191434
self,
15201435
*,
15211436
region: Optional[ScwRegion] = None,
15221437
project_id: Optional[str] = None,
15231438
is_enabled: Optional[bool] = None,
15241439
is_preconfigured: Optional[bool] = None,
1525-
state: Optional[AnyAlertState] = None,
1440+
state: Optional[AlertState] = None,
15261441
) -> ListAlertsResponse:
15271442
"""
15281443
List alerts.

scaleway-async/scaleway_async/cockpit/v1/marshalling.py

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@
2222
GetConfigResponseRetention,
2323
GetConfigResponse,
2424
Grafana,
25-
AnyAlert,
25+
Alert,
2626
ListAlertsResponse,
2727
ListContactPointsResponse,
2828
ListDataSourcesResponse,
2929
ListGrafanaProductDashboardsResponse,
3030
ListGrafanaUsersResponse,
31-
Alert,
32-
ListManagedAlertsResponse,
3331
ListPlansResponse,
3432
ListTokensResponse,
3533
Usage,
@@ -417,10 +415,10 @@ def unmarshal_Grafana(data: Any) -> Grafana:
417415
return Grafana(**args)
418416

419417

420-
def unmarshal_AnyAlert(data: Any) -> AnyAlert:
418+
def unmarshal_Alert(data: Any) -> Alert:
421419
if not isinstance(data, dict):
422420
raise TypeError(
423-
"Unmarshalling the type 'AnyAlert' failed as data isn't a dictionary."
421+
"Unmarshalling the type 'Alert' failed as data isn't a dictionary."
424422
)
425423

426424
args: Dict[str, Any] = {}
@@ -445,15 +443,21 @@ def unmarshal_AnyAlert(data: Any) -> AnyAlert:
445443
if field is not None:
446444
args["duration"] = field
447445

448-
field = data.get("state", None)
446+
field = data.get("enabled", None)
449447
if field is not None:
450-
args["state"] = field
448+
args["enabled"] = field
451449

452450
field = data.get("annotations", None)
453451
if field is not None:
454452
args["annotations"] = field
455453

456-
return AnyAlert(**args)
454+
field = data.get("state", None)
455+
if field is not None:
456+
args["state"] = field
457+
else:
458+
args["state"] = None
459+
460+
return Alert(**args)
457461

458462

459463
def unmarshal_ListAlertsResponse(data: Any) -> ListAlertsResponse:
@@ -471,7 +475,7 @@ def unmarshal_ListAlertsResponse(data: Any) -> ListAlertsResponse:
471475
field = data.get("alerts", None)
472476
if field is not None:
473477
args["alerts"] = (
474-
[unmarshal_AnyAlert(v) for v in field] if field is not None else None
478+
[unmarshal_Alert(v) for v in field] if field is not None else None
475479
)
476480

477481
return ListAlertsResponse(**args)
@@ -573,58 +577,6 @@ def unmarshal_ListGrafanaUsersResponse(data: Any) -> ListGrafanaUsersResponse:
573577
return ListGrafanaUsersResponse(**args)
574578

575579

576-
def unmarshal_Alert(data: Any) -> Alert:
577-
if not isinstance(data, dict):
578-
raise TypeError(
579-
"Unmarshalling the type 'Alert' failed as data isn't a dictionary."
580-
)
581-
582-
args: Dict[str, Any] = {}
583-
584-
field = data.get("product_family", None)
585-
if field is not None:
586-
args["product_family"] = field
587-
588-
field = data.get("product", None)
589-
if field is not None:
590-
args["product"] = field
591-
592-
field = data.get("name", None)
593-
if field is not None:
594-
args["name"] = field
595-
596-
field = data.get("rule", None)
597-
if field is not None:
598-
args["rule"] = field
599-
600-
field = data.get("description", None)
601-
if field is not None:
602-
args["description"] = field
603-
604-
return Alert(**args)
605-
606-
607-
def unmarshal_ListManagedAlertsResponse(data: Any) -> ListManagedAlertsResponse:
608-
if not isinstance(data, dict):
609-
raise TypeError(
610-
"Unmarshalling the type 'ListManagedAlertsResponse' failed as data isn't a dictionary."
611-
)
612-
613-
args: Dict[str, Any] = {}
614-
615-
field = data.get("total_count", None)
616-
if field is not None:
617-
args["total_count"] = field
618-
619-
field = data.get("alerts", None)
620-
if field is not None:
621-
args["alerts"] = (
622-
[unmarshal_Alert(v) for v in field] if field is not None else None
623-
)
624-
625-
return ListManagedAlertsResponse(**args)
626-
627-
628580
def unmarshal_ListPlansResponse(data: Any) -> ListPlansResponse:
629581
if not isinstance(data, dict):
630582
raise TypeError(

0 commit comments

Comments
 (0)