Skip to content

fix(cockpit): add return object for enable/disable alert endpoints #963

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
Apr 23, 2025
Merged
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
4 changes: 4 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
from .types import Token
from .types import Usage
from .types import AlertManager
from .types import DisableAlertRulesResponse
from .types import EnableAlertRulesResponse
from .types import GetConfigResponse
from .types import GlobalApiCreateGrafanaUserRequest
from .types import GlobalApiDeleteGrafanaUserRequest
@@ -95,6 +97,8 @@
"Token",
"Usage",
"AlertManager",
"DisableAlertRulesResponse",
"EnableAlertRulesResponse",
"GetConfigResponse",
"GlobalApiCreateGrafanaUserRequest",
"GlobalApiDeleteGrafanaUserRequest",
12 changes: 10 additions & 2 deletions scaleway-async/scaleway_async/cockpit/v1/api.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@
ContactPoint,
ContactPointEmail,
DataSource,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponse,
GlobalApiCreateGrafanaUserRequest,
GlobalApiResetGrafanaUserPasswordRequest,
@@ -66,6 +68,8 @@
unmarshal_Plan,
unmarshal_Token,
unmarshal_AlertManager,
unmarshal_DisableAlertRulesResponse,
unmarshal_EnableAlertRulesResponse,
unmarshal_GetConfigResponse,
unmarshal_Grafana,
unmarshal_ListAlertsResponse,
@@ -1559,12 +1563,13 @@ async def enable_alert_rules(
region: Optional[ScwRegion] = None,
project_id: Optional[str] = None,
rule_ids: Optional[List[str]] = None,
) -> None:
) -> EnableAlertRulesResponse:
"""
Enable preconfigured alert rules. Enable alert rules from the list of available preconfigured rules.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id:
:param rule_ids:
:return: :class:`EnableAlertRulesResponse <EnableAlertRulesResponse>`

Usage:
::
@@ -1590,19 +1595,21 @@ async def enable_alert_rules(
)

self._throw_on_error(res)
return unmarshal_EnableAlertRulesResponse(res.json())

async def disable_alert_rules(
self,
*,
region: Optional[ScwRegion] = None,
project_id: Optional[str] = None,
rule_ids: Optional[List[str]] = None,
) -> None:
) -> DisableAlertRulesResponse:
"""
Disable preconfigured alert rules. Disable alert rules from the list of available preconfigured rules.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id:
:param rule_ids:
:return: :class:`DisableAlertRulesResponse <DisableAlertRulesResponse>`

Usage:
::
@@ -1628,6 +1635,7 @@ async def disable_alert_rules(
)

self._throw_on_error(res)
return unmarshal_DisableAlertRulesResponse(res.json())

async def trigger_test_alert(
self,
32 changes: 32 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1/marshalling.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@
Plan,
Token,
AlertManager,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponseRetention,
GetConfigResponse,
Grafana,
@@ -339,6 +341,36 @@ def unmarshal_AlertManager(data: Any) -> AlertManager:
return AlertManager(**args)


def unmarshal_DisableAlertRulesResponse(data: Any) -> DisableAlertRulesResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'DisableAlertRulesResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("disabled_rule_ids", None)
if field is not None:
args["disabled_rule_ids"] = field

return DisableAlertRulesResponse(**args)


def unmarshal_EnableAlertRulesResponse(data: Any) -> EnableAlertRulesResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'EnableAlertRulesResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("enabled_rule_ids", None)
if field is not None:
args["enabled_rule_ids"] = field

return EnableAlertRulesResponse(**args)


def unmarshal_GetConfigResponseRetention(data: Any) -> GetConfigResponseRetention:
if not isinstance(data, dict):
raise TypeError(
10 changes: 10 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1/types.py
Original file line number Diff line number Diff line change
@@ -523,6 +523,16 @@ class AlertManager:
"""


@dataclass
class DisableAlertRulesResponse:
disabled_rule_ids: List[str]


@dataclass
class EnableAlertRulesResponse:
enabled_rule_ids: List[str]


@dataclass
class GetConfigResponse:
"""
4 changes: 4 additions & 0 deletions scaleway/scaleway/cockpit/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
from .types import Token
from .types import Usage
from .types import AlertManager
from .types import DisableAlertRulesResponse
from .types import EnableAlertRulesResponse
from .types import GetConfigResponse
from .types import GlobalApiCreateGrafanaUserRequest
from .types import GlobalApiDeleteGrafanaUserRequest
@@ -95,6 +97,8 @@
"Token",
"Usage",
"AlertManager",
"DisableAlertRulesResponse",
"EnableAlertRulesResponse",
"GetConfigResponse",
"GlobalApiCreateGrafanaUserRequest",
"GlobalApiDeleteGrafanaUserRequest",
12 changes: 10 additions & 2 deletions scaleway/scaleway/cockpit/v1/api.py
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@
ContactPoint,
ContactPointEmail,
DataSource,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponse,
GlobalApiCreateGrafanaUserRequest,
GlobalApiResetGrafanaUserPasswordRequest,
@@ -66,6 +68,8 @@
unmarshal_Plan,
unmarshal_Token,
unmarshal_AlertManager,
unmarshal_DisableAlertRulesResponse,
unmarshal_EnableAlertRulesResponse,
unmarshal_GetConfigResponse,
unmarshal_Grafana,
unmarshal_ListAlertsResponse,
@@ -1559,12 +1563,13 @@ def enable_alert_rules(
region: Optional[ScwRegion] = None,
project_id: Optional[str] = None,
rule_ids: Optional[List[str]] = None,
) -> None:
) -> EnableAlertRulesResponse:
"""
Enable preconfigured alert rules. Enable alert rules from the list of available preconfigured rules.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id:
:param rule_ids:
:return: :class:`EnableAlertRulesResponse <EnableAlertRulesResponse>`

Usage:
::
@@ -1590,19 +1595,21 @@ def enable_alert_rules(
)

self._throw_on_error(res)
return unmarshal_EnableAlertRulesResponse(res.json())

def disable_alert_rules(
self,
*,
region: Optional[ScwRegion] = None,
project_id: Optional[str] = None,
rule_ids: Optional[List[str]] = None,
) -> None:
) -> DisableAlertRulesResponse:
"""
Disable preconfigured alert rules. Disable alert rules from the list of available preconfigured rules.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id:
:param rule_ids:
:return: :class:`DisableAlertRulesResponse <DisableAlertRulesResponse>`

Usage:
::
@@ -1628,6 +1635,7 @@ def disable_alert_rules(
)

self._throw_on_error(res)
return unmarshal_DisableAlertRulesResponse(res.json())

def trigger_test_alert(
self,
32 changes: 32 additions & 0 deletions scaleway/scaleway/cockpit/v1/marshalling.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@
Plan,
Token,
AlertManager,
DisableAlertRulesResponse,
EnableAlertRulesResponse,
GetConfigResponseRetention,
GetConfigResponse,
Grafana,
@@ -339,6 +341,36 @@ def unmarshal_AlertManager(data: Any) -> AlertManager:
return AlertManager(**args)


def unmarshal_DisableAlertRulesResponse(data: Any) -> DisableAlertRulesResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'DisableAlertRulesResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("disabled_rule_ids", None)
if field is not None:
args["disabled_rule_ids"] = field

return DisableAlertRulesResponse(**args)


def unmarshal_EnableAlertRulesResponse(data: Any) -> EnableAlertRulesResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'EnableAlertRulesResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("enabled_rule_ids", None)
if field is not None:
args["enabled_rule_ids"] = field

return EnableAlertRulesResponse(**args)


def unmarshal_GetConfigResponseRetention(data: Any) -> GetConfigResponseRetention:
if not isinstance(data, dict):
raise TypeError(
10 changes: 10 additions & 0 deletions scaleway/scaleway/cockpit/v1/types.py
Original file line number Diff line number Diff line change
@@ -523,6 +523,16 @@ class AlertManager:
"""


@dataclass
class DisableAlertRulesResponse:
disabled_rule_ids: List[str]


@dataclass
class EnableAlertRulesResponse:
enabled_rule_ids: List[str]


@dataclass
class GetConfigResponse:
"""