diff --git a/scaleway-async/scaleway_async/cockpit/v1/__init__.py b/scaleway-async/scaleway_async/cockpit/v1/__init__.py index babe78261..bc463917a 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/__init__.py +++ b/scaleway-async/scaleway_async/cockpit/v1/__init__.py @@ -1,6 +1,7 @@ # 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 AlertState +from .types import AlertStatus from .types import DataSourceOrigin from .types import DataSourceType from .types import GrafanaUserRole @@ -78,6 +79,7 @@ __all__ = [ "AlertState", + "AlertStatus", "DataSourceOrigin", "DataSourceType", "GrafanaUserRole", diff --git a/scaleway-async/scaleway_async/cockpit/v1/api.py b/scaleway-async/scaleway_async/cockpit/v1/api.py index 01351468c..3b906aedf 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/api.py +++ b/scaleway-async/scaleway_async/cockpit/v1/api.py @@ -13,6 +13,7 @@ ) from .types import ( AlertState, + AlertStatus, DataSourceOrigin, DataSourceType, GrafanaUserRole, @@ -1473,7 +1474,7 @@ async def list_alerts( *, region: Optional[ScwRegion] = None, project_id: Optional[str] = None, - is_enabled: Optional[bool] = None, + rule_status: Optional[AlertStatus] = None, is_preconfigured: Optional[bool] = None, state: Optional[AlertState] = None, data_source_id: Optional[str] = None, @@ -1483,7 +1484,7 @@ async def list_alerts( List preconfigured and/or custom alerts for the specified Project and data source. :param region: Region to target. If none is passed will use default region from the config. :param project_id: Project ID to filter for, only alerts from this Project will be returned. - :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. + :param rule_status: Returns only alerts with the given activation status. If omitted, no alert filtering is applied. Other filters may still apply. :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. :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. :param data_source_id: If omitted, only alerts from the default Scaleway metrics data source will be listed. @@ -1504,9 +1505,9 @@ async def list_alerts( f"/cockpit/v1/regions/{param_region}/alerts", params={ "data_source_id": data_source_id, - "is_enabled": is_enabled, "is_preconfigured": is_preconfigured, "project_id": project_id or self.client.default_project_id, + "rule_status": rule_status, "state": state, }, ) diff --git a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py index 4ea03b6c3..3bea9a117 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/marshalling.py +++ b/scaleway-async/scaleway_async/cockpit/v1/marshalling.py @@ -559,9 +559,9 @@ def unmarshal_Alert(data: Any) -> Alert: if field is not None: args["duration"] = field - field = data.get("enabled", None) + field = data.get("rule_status", None) if field is not None: - args["enabled"] = field + args["rule_status"] = field field = data.get("annotations", None) if field is not None: diff --git a/scaleway-async/scaleway_async/cockpit/v1/types.py b/scaleway-async/scaleway_async/cockpit/v1/types.py index 776b5d61a..b953f921c 100644 --- a/scaleway-async/scaleway_async/cockpit/v1/types.py +++ b/scaleway-async/scaleway_async/cockpit/v1/types.py @@ -25,6 +25,17 @@ def __str__(self) -> str: return str(self.value) +class AlertStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + ENABLED = "enabled" + DISABLED = "disabled" + ENABLING = "enabling" + DISABLING = "disabling" + + def __str__(self) -> str: + return str(self.value) + + class DataSourceOrigin(str, Enum, metaclass=StrEnumMeta): UNKNOWN_ORIGIN = "unknown_origin" SCALEWAY = "scaleway" @@ -222,9 +233,9 @@ class Alert: Duration for which the alert must be active before firing. The format of this duration follows the prometheus duration format. """ - enabled: bool + rule_status: AlertStatus """ - Indicates if the alert is enabled or disabled. Only preconfigured alerts can be disabled. + Indicates if the alert is enabled, enabling, disabled or disabling. Preconfigured alerts can have any of these values, whereas custom alerts can only have the status "enabled". """ annotations: Dict[str, str] @@ -1314,9 +1325,9 @@ class RegionalApiListAlertsRequest: Project ID to filter for, only alerts from this Project will be returned. """ - is_enabled: Optional[bool] + rule_status: Optional[AlertStatus] """ - True returns only enabled alerts. False returns only disabled alerts. If omitted, no alert filtering is applied. Other filters may still apply. + Returns only alerts with the given activation status. If omitted, no alert filtering is applied. Other filters may still apply. """ is_preconfigured: Optional[bool] diff --git a/scaleway-core/scaleway_core/utils/resolve_one_of.py b/scaleway-core/scaleway_core/utils/resolve_one_of.py index 98ab293f5..a829d602f 100644 --- a/scaleway-core/scaleway_core/utils/resolve_one_of.py +++ b/scaleway-core/scaleway_core/utils/resolve_one_of.py @@ -28,6 +28,13 @@ def resolve_one_of( # Get the first non-empty default for possibility in possibilities: if possibility.default is not None: + if possibility.marshal_func is not None: + # When no actual value, call with None as value + return { + possibility.param: possibility.marshal_func( + None, possibility.default + ) + } return {possibility.param: possibility.default} # If required, raise an error diff --git a/scaleway/scaleway/cockpit/v1/__init__.py b/scaleway/scaleway/cockpit/v1/__init__.py index babe78261..bc463917a 100644 --- a/scaleway/scaleway/cockpit/v1/__init__.py +++ b/scaleway/scaleway/cockpit/v1/__init__.py @@ -1,6 +1,7 @@ # 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 AlertState +from .types import AlertStatus from .types import DataSourceOrigin from .types import DataSourceType from .types import GrafanaUserRole @@ -78,6 +79,7 @@ __all__ = [ "AlertState", + "AlertStatus", "DataSourceOrigin", "DataSourceType", "GrafanaUserRole", diff --git a/scaleway/scaleway/cockpit/v1/api.py b/scaleway/scaleway/cockpit/v1/api.py index 083a4a535..4df33e311 100644 --- a/scaleway/scaleway/cockpit/v1/api.py +++ b/scaleway/scaleway/cockpit/v1/api.py @@ -13,6 +13,7 @@ ) from .types import ( AlertState, + AlertStatus, DataSourceOrigin, DataSourceType, GrafanaUserRole, @@ -1473,7 +1474,7 @@ def list_alerts( *, region: Optional[ScwRegion] = None, project_id: Optional[str] = None, - is_enabled: Optional[bool] = None, + rule_status: Optional[AlertStatus] = None, is_preconfigured: Optional[bool] = None, state: Optional[AlertState] = None, data_source_id: Optional[str] = None, @@ -1483,7 +1484,7 @@ def list_alerts( List preconfigured and/or custom alerts for the specified Project and data source. :param region: Region to target. If none is passed will use default region from the config. :param project_id: Project ID to filter for, only alerts from this Project will be returned. - :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. + :param rule_status: Returns only alerts with the given activation status. If omitted, no alert filtering is applied. Other filters may still apply. :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. :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. :param data_source_id: If omitted, only alerts from the default Scaleway metrics data source will be listed. @@ -1504,9 +1505,9 @@ def list_alerts( f"/cockpit/v1/regions/{param_region}/alerts", params={ "data_source_id": data_source_id, - "is_enabled": is_enabled, "is_preconfigured": is_preconfigured, "project_id": project_id or self.client.default_project_id, + "rule_status": rule_status, "state": state, }, ) diff --git a/scaleway/scaleway/cockpit/v1/marshalling.py b/scaleway/scaleway/cockpit/v1/marshalling.py index 4ea03b6c3..3bea9a117 100644 --- a/scaleway/scaleway/cockpit/v1/marshalling.py +++ b/scaleway/scaleway/cockpit/v1/marshalling.py @@ -559,9 +559,9 @@ def unmarshal_Alert(data: Any) -> Alert: if field is not None: args["duration"] = field - field = data.get("enabled", None) + field = data.get("rule_status", None) if field is not None: - args["enabled"] = field + args["rule_status"] = field field = data.get("annotations", None) if field is not None: diff --git a/scaleway/scaleway/cockpit/v1/types.py b/scaleway/scaleway/cockpit/v1/types.py index 776b5d61a..b953f921c 100644 --- a/scaleway/scaleway/cockpit/v1/types.py +++ b/scaleway/scaleway/cockpit/v1/types.py @@ -25,6 +25,17 @@ def __str__(self) -> str: return str(self.value) +class AlertStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + ENABLED = "enabled" + DISABLED = "disabled" + ENABLING = "enabling" + DISABLING = "disabling" + + def __str__(self) -> str: + return str(self.value) + + class DataSourceOrigin(str, Enum, metaclass=StrEnumMeta): UNKNOWN_ORIGIN = "unknown_origin" SCALEWAY = "scaleway" @@ -222,9 +233,9 @@ class Alert: Duration for which the alert must be active before firing. The format of this duration follows the prometheus duration format. """ - enabled: bool + rule_status: AlertStatus """ - Indicates if the alert is enabled or disabled. Only preconfigured alerts can be disabled. + Indicates if the alert is enabled, enabling, disabled or disabling. Preconfigured alerts can have any of these values, whereas custom alerts can only have the status "enabled". """ annotations: Dict[str, str] @@ -1314,9 +1325,9 @@ class RegionalApiListAlertsRequest: Project ID to filter for, only alerts from this Project will be returned. """ - is_enabled: Optional[bool] + rule_status: Optional[AlertStatus] """ - True returns only enabled alerts. False returns only disabled alerts. If omitted, no alert filtering is applied. Other filters may still apply. + Returns only alerts with the given activation status. If omitted, no alert filtering is applied. Other filters may still apply. """ is_preconfigured: Optional[bool]