Skip to content

Commit d9a8bab

Browse files
feat(cockpit): add datasource filter on listAlert endpoint (scaleway#983)
Co-authored-by: Laure-di <[email protected]>
1 parent 1fedb2f commit d9a8bab

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ async def list_alerts(
14461446
is_enabled: Optional[bool] = None,
14471447
is_preconfigured: Optional[bool] = None,
14481448
state: Optional[AlertState] = None,
1449+
data_source_id: Optional[str] = None,
14491450
) -> ListAlertsResponse:
14501451
"""
14511452
List alerts.
@@ -1455,6 +1456,7 @@ async def list_alerts(
14551456
:param is_enabled: True returns only enabled alerts. False returns only disabled alerts. If omitted, no alert filtering is applied. Other filters may still apply.
14561457
:param is_preconfigured: True returns only preconfigured alerts. False returns only custom alerts. If omitted, no filtering is applied on alert types. Other filters may still apply.
14571458
:param state: Valid values to filter on are `inactive`, `pending` and `firing`. If omitted, no filtering is applied on alert states. Other filters may still apply.
1459+
:param data_source_id: If omitted, only alerts from the default scaleway data source will be listed.
14581460
:return: :class:`ListAlertsResponse <ListAlertsResponse>`
14591461
14601462
Usage:
@@ -1471,6 +1473,7 @@ async def list_alerts(
14711473
"GET",
14721474
f"/cockpit/v1/regions/{param_region}/alerts",
14731475
params={
1476+
"data_source_id": data_source_id,
14741477
"is_enabled": is_enabled,
14751478
"is_preconfigured": is_preconfigured,
14761479
"project_id": project_id or self.client.default_project_id,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ def unmarshal_Alert(data: Any) -> Alert:
509509
if field is not None:
510510
args["annotations"] = field
511511

512+
field = data.get("data_source_id", None)
513+
if field is not None:
514+
args["data_source_id"] = field
515+
512516
field = data.get("state", None)
513517
if field is not None:
514518
args["state"] = field

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ class Alert:
204204
Annotations for the alert, used to provide additional information about the alert.
205205
"""
206206

207+
data_source_id: str
208+
"""
209+
ID of the data source containing the alert rule.
210+
"""
211+
207212
state: Optional[AlertState]
208213
"""
209214
Current state of the alert. Possible states are `inactive`, `pending`, and `firing`.
@@ -1239,6 +1244,11 @@ class RegionalApiListAlertsRequest:
12391244
Valid values to filter on are `inactive`, `pending` and `firing`. If omitted, no filtering is applied on alert states. Other filters may still apply.
12401245
"""
12411246

1247+
data_source_id: Optional[str]
1248+
"""
1249+
If omitted, only alerts from the default scaleway data source will be listed.
1250+
"""
1251+
12421252

12431253
@dataclass
12441254
class RegionalApiListContactPointsRequest:

scaleway/scaleway/cockpit/v1/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ def list_alerts(
14461446
is_enabled: Optional[bool] = None,
14471447
is_preconfigured: Optional[bool] = None,
14481448
state: Optional[AlertState] = None,
1449+
data_source_id: Optional[str] = None,
14491450
) -> ListAlertsResponse:
14501451
"""
14511452
List alerts.
@@ -1455,6 +1456,7 @@ def list_alerts(
14551456
:param is_enabled: True returns only enabled alerts. False returns only disabled alerts. If omitted, no alert filtering is applied. Other filters may still apply.
14561457
:param is_preconfigured: True returns only preconfigured alerts. False returns only custom alerts. If omitted, no filtering is applied on alert types. Other filters may still apply.
14571458
:param state: Valid values to filter on are `inactive`, `pending` and `firing`. If omitted, no filtering is applied on alert states. Other filters may still apply.
1459+
:param data_source_id: If omitted, only alerts from the default scaleway data source will be listed.
14581460
:return: :class:`ListAlertsResponse <ListAlertsResponse>`
14591461
14601462
Usage:
@@ -1471,6 +1473,7 @@ def list_alerts(
14711473
"GET",
14721474
f"/cockpit/v1/regions/{param_region}/alerts",
14731475
params={
1476+
"data_source_id": data_source_id,
14741477
"is_enabled": is_enabled,
14751478
"is_preconfigured": is_preconfigured,
14761479
"project_id": project_id or self.client.default_project_id,

scaleway/scaleway/cockpit/v1/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ def unmarshal_Alert(data: Any) -> Alert:
509509
if field is not None:
510510
args["annotations"] = field
511511

512+
field = data.get("data_source_id", None)
513+
if field is not None:
514+
args["data_source_id"] = field
515+
512516
field = data.get("state", None)
513517
if field is not None:
514518
args["state"] = field

scaleway/scaleway/cockpit/v1/types.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ class Alert:
204204
Annotations for the alert, used to provide additional information about the alert.
205205
"""
206206

207+
data_source_id: str
208+
"""
209+
ID of the data source containing the alert rule.
210+
"""
211+
207212
state: Optional[AlertState]
208213
"""
209214
Current state of the alert. Possible states are `inactive`, `pending`, and `firing`.
@@ -1239,6 +1244,11 @@ class RegionalApiListAlertsRequest:
12391244
Valid values to filter on are `inactive`, `pending` and `firing`. If omitted, no filtering is applied on alert states. Other filters may still apply.
12401245
"""
12411246

1247+
data_source_id: Optional[str]
1248+
"""
1249+
If omitted, only alerts from the default scaleway data source will be listed.
1250+
"""
1251+
12421252

12431253
@dataclass
12441254
class RegionalApiListContactPointsRequest:

0 commit comments

Comments
 (0)