Skip to content

Commit edcaafb

Browse files
authoredApr 23, 2025··
fix(cockpit): add return object for enable/disable alert endpoints (scaleway#963)
1 parent 1b76029 commit edcaafb

File tree

8 files changed

+112
-4
lines changed

8 files changed

+112
-4
lines changed
 

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from .types import Token
2424
from .types import Usage
2525
from .types import AlertManager
26+
from .types import DisableAlertRulesResponse
27+
from .types import EnableAlertRulesResponse
2628
from .types import GetConfigResponse
2729
from .types import GlobalApiCreateGrafanaUserRequest
2830
from .types import GlobalApiDeleteGrafanaUserRequest
@@ -95,6 +97,8 @@
9597
"Token",
9698
"Usage",
9799
"AlertManager",
100+
"DisableAlertRulesResponse",
101+
"EnableAlertRulesResponse",
98102
"GetConfigResponse",
99103
"GlobalApiCreateGrafanaUserRequest",
100104
"GlobalApiDeleteGrafanaUserRequest",

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
ContactPoint,
2727
ContactPointEmail,
2828
DataSource,
29+
DisableAlertRulesResponse,
30+
EnableAlertRulesResponse,
2931
GetConfigResponse,
3032
GlobalApiCreateGrafanaUserRequest,
3133
GlobalApiResetGrafanaUserPasswordRequest,
@@ -66,6 +68,8 @@
6668
unmarshal_Plan,
6769
unmarshal_Token,
6870
unmarshal_AlertManager,
71+
unmarshal_DisableAlertRulesResponse,
72+
unmarshal_EnableAlertRulesResponse,
6973
unmarshal_GetConfigResponse,
7074
unmarshal_Grafana,
7175
unmarshal_ListAlertsResponse,
@@ -1559,12 +1563,13 @@ async def enable_alert_rules(
15591563
region: Optional[ScwRegion] = None,
15601564
project_id: Optional[str] = None,
15611565
rule_ids: Optional[List[str]] = None,
1562-
) -> None:
1566+
) -> EnableAlertRulesResponse:
15631567
"""
15641568
Enable preconfigured alert rules. Enable alert rules from the list of available preconfigured rules.
15651569
:param region: Region to target. If none is passed will use default region from the config.
15661570
:param project_id:
15671571
:param rule_ids:
1572+
:return: :class:`EnableAlertRulesResponse <EnableAlertRulesResponse>`
15681573
15691574
Usage:
15701575
::
@@ -1590,19 +1595,21 @@ async def enable_alert_rules(
15901595
)
15911596

15921597
self._throw_on_error(res)
1598+
return unmarshal_EnableAlertRulesResponse(res.json())
15931599

15941600
async def disable_alert_rules(
15951601
self,
15961602
*,
15971603
region: Optional[ScwRegion] = None,
15981604
project_id: Optional[str] = None,
15991605
rule_ids: Optional[List[str]] = None,
1600-
) -> None:
1606+
) -> DisableAlertRulesResponse:
16011607
"""
16021608
Disable preconfigured alert rules. Disable alert rules from the list of available preconfigured rules.
16031609
:param region: Region to target. If none is passed will use default region from the config.
16041610
:param project_id:
16051611
:param rule_ids:
1612+
:return: :class:`DisableAlertRulesResponse <DisableAlertRulesResponse>`
16061613
16071614
Usage:
16081615
::
@@ -1628,6 +1635,7 @@ async def disable_alert_rules(
16281635
)
16291636

16301637
self._throw_on_error(res)
1638+
return unmarshal_DisableAlertRulesResponse(res.json())
16311639

16321640
async def trigger_test_alert(
16331641
self,

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
Plan,
2020
Token,
2121
AlertManager,
22+
DisableAlertRulesResponse,
23+
EnableAlertRulesResponse,
2224
GetConfigResponseRetention,
2325
GetConfigResponse,
2426
Grafana,
@@ -339,6 +341,36 @@ def unmarshal_AlertManager(data: Any) -> AlertManager:
339341
return AlertManager(**args)
340342

341343

344+
def unmarshal_DisableAlertRulesResponse(data: Any) -> DisableAlertRulesResponse:
345+
if not isinstance(data, dict):
346+
raise TypeError(
347+
"Unmarshalling the type 'DisableAlertRulesResponse' failed as data isn't a dictionary."
348+
)
349+
350+
args: Dict[str, Any] = {}
351+
352+
field = data.get("disabled_rule_ids", None)
353+
if field is not None:
354+
args["disabled_rule_ids"] = field
355+
356+
return DisableAlertRulesResponse(**args)
357+
358+
359+
def unmarshal_EnableAlertRulesResponse(data: Any) -> EnableAlertRulesResponse:
360+
if not isinstance(data, dict):
361+
raise TypeError(
362+
"Unmarshalling the type 'EnableAlertRulesResponse' failed as data isn't a dictionary."
363+
)
364+
365+
args: Dict[str, Any] = {}
366+
367+
field = data.get("enabled_rule_ids", None)
368+
if field is not None:
369+
args["enabled_rule_ids"] = field
370+
371+
return EnableAlertRulesResponse(**args)
372+
373+
342374
def unmarshal_GetConfigResponseRetention(data: Any) -> GetConfigResponseRetention:
343375
if not isinstance(data, dict):
344376
raise TypeError(

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,16 @@ class AlertManager:
523523
"""
524524

525525

526+
@dataclass
527+
class DisableAlertRulesResponse:
528+
disabled_rule_ids: List[str]
529+
530+
531+
@dataclass
532+
class EnableAlertRulesResponse:
533+
enabled_rule_ids: List[str]
534+
535+
526536
@dataclass
527537
class GetConfigResponse:
528538
"""

‎scaleway/scaleway/cockpit/v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from .types import Token
2424
from .types import Usage
2525
from .types import AlertManager
26+
from .types import DisableAlertRulesResponse
27+
from .types import EnableAlertRulesResponse
2628
from .types import GetConfigResponse
2729
from .types import GlobalApiCreateGrafanaUserRequest
2830
from .types import GlobalApiDeleteGrafanaUserRequest
@@ -95,6 +97,8 @@
9597
"Token",
9698
"Usage",
9799
"AlertManager",
100+
"DisableAlertRulesResponse",
101+
"EnableAlertRulesResponse",
98102
"GetConfigResponse",
99103
"GlobalApiCreateGrafanaUserRequest",
100104
"GlobalApiDeleteGrafanaUserRequest",

‎scaleway/scaleway/cockpit/v1/api.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
ContactPoint,
2727
ContactPointEmail,
2828
DataSource,
29+
DisableAlertRulesResponse,
30+
EnableAlertRulesResponse,
2931
GetConfigResponse,
3032
GlobalApiCreateGrafanaUserRequest,
3133
GlobalApiResetGrafanaUserPasswordRequest,
@@ -66,6 +68,8 @@
6668
unmarshal_Plan,
6769
unmarshal_Token,
6870
unmarshal_AlertManager,
71+
unmarshal_DisableAlertRulesResponse,
72+
unmarshal_EnableAlertRulesResponse,
6973
unmarshal_GetConfigResponse,
7074
unmarshal_Grafana,
7175
unmarshal_ListAlertsResponse,
@@ -1559,12 +1563,13 @@ def enable_alert_rules(
15591563
region: Optional[ScwRegion] = None,
15601564
project_id: Optional[str] = None,
15611565
rule_ids: Optional[List[str]] = None,
1562-
) -> None:
1566+
) -> EnableAlertRulesResponse:
15631567
"""
15641568
Enable preconfigured alert rules. Enable alert rules from the list of available preconfigured rules.
15651569
:param region: Region to target. If none is passed will use default region from the config.
15661570
:param project_id:
15671571
:param rule_ids:
1572+
:return: :class:`EnableAlertRulesResponse <EnableAlertRulesResponse>`
15681573
15691574
Usage:
15701575
::
@@ -1590,19 +1595,21 @@ def enable_alert_rules(
15901595
)
15911596

15921597
self._throw_on_error(res)
1598+
return unmarshal_EnableAlertRulesResponse(res.json())
15931599

15941600
def disable_alert_rules(
15951601
self,
15961602
*,
15971603
region: Optional[ScwRegion] = None,
15981604
project_id: Optional[str] = None,
15991605
rule_ids: Optional[List[str]] = None,
1600-
) -> None:
1606+
) -> DisableAlertRulesResponse:
16011607
"""
16021608
Disable preconfigured alert rules. Disable alert rules from the list of available preconfigured rules.
16031609
:param region: Region to target. If none is passed will use default region from the config.
16041610
:param project_id:
16051611
:param rule_ids:
1612+
:return: :class:`DisableAlertRulesResponse <DisableAlertRulesResponse>`
16061613
16071614
Usage:
16081615
::
@@ -1628,6 +1635,7 @@ def disable_alert_rules(
16281635
)
16291636

16301637
self._throw_on_error(res)
1638+
return unmarshal_DisableAlertRulesResponse(res.json())
16311639

16321640
def trigger_test_alert(
16331641
self,

‎scaleway/scaleway/cockpit/v1/marshalling.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
Plan,
2020
Token,
2121
AlertManager,
22+
DisableAlertRulesResponse,
23+
EnableAlertRulesResponse,
2224
GetConfigResponseRetention,
2325
GetConfigResponse,
2426
Grafana,
@@ -339,6 +341,36 @@ def unmarshal_AlertManager(data: Any) -> AlertManager:
339341
return AlertManager(**args)
340342

341343

344+
def unmarshal_DisableAlertRulesResponse(data: Any) -> DisableAlertRulesResponse:
345+
if not isinstance(data, dict):
346+
raise TypeError(
347+
"Unmarshalling the type 'DisableAlertRulesResponse' failed as data isn't a dictionary."
348+
)
349+
350+
args: Dict[str, Any] = {}
351+
352+
field = data.get("disabled_rule_ids", None)
353+
if field is not None:
354+
args["disabled_rule_ids"] = field
355+
356+
return DisableAlertRulesResponse(**args)
357+
358+
359+
def unmarshal_EnableAlertRulesResponse(data: Any) -> EnableAlertRulesResponse:
360+
if not isinstance(data, dict):
361+
raise TypeError(
362+
"Unmarshalling the type 'EnableAlertRulesResponse' failed as data isn't a dictionary."
363+
)
364+
365+
args: Dict[str, Any] = {}
366+
367+
field = data.get("enabled_rule_ids", None)
368+
if field is not None:
369+
args["enabled_rule_ids"] = field
370+
371+
return EnableAlertRulesResponse(**args)
372+
373+
342374
def unmarshal_GetConfigResponseRetention(data: Any) -> GetConfigResponseRetention:
343375
if not isinstance(data, dict):
344376
raise TypeError(

‎scaleway/scaleway/cockpit/v1/types.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,16 @@ class AlertManager:
523523
"""
524524

525525

526+
@dataclass
527+
class DisableAlertRulesResponse:
528+
disabled_rule_ids: List[str]
529+
530+
531+
@dataclass
532+
class EnableAlertRulesResponse:
533+
enabled_rule_ids: List[str]
534+
535+
526536
@dataclass
527537
class GetConfigResponse:
528538
"""

0 commit comments

Comments
 (0)
Please sign in to comment.