# coding=utf-8
# *** WARNING: this file was generated by pulumi-language-python. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import builtins as _builtins
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from .. import _utilities
from . import outputs

__all__ = [
    'GetPreconfiguredAlertResult',
    'AwaitableGetPreconfiguredAlertResult',
    'get_preconfigured_alert',
    'get_preconfigured_alert_output',
]

@pulumi.output_type
class GetPreconfiguredAlertResult:
    """
    A collection of values returned by getPreconfiguredAlert.
    """
    def __init__(__self__, alerts=None, data_source_id=None, id=None, project_id=None, region=None, rule_status=None):
        if alerts and not isinstance(alerts, list):
            raise TypeError("Expected argument 'alerts' to be a list")
        pulumi.set(__self__, "alerts", alerts)
        if data_source_id and not isinstance(data_source_id, str):
            raise TypeError("Expected argument 'data_source_id' to be a str")
        pulumi.set(__self__, "data_source_id", data_source_id)
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if project_id and not isinstance(project_id, str):
            raise TypeError("Expected argument 'project_id' to be a str")
        pulumi.set(__self__, "project_id", project_id)
        if region and not isinstance(region, str):
            raise TypeError("Expected argument 'region' to be a str")
        pulumi.set(__self__, "region", region)
        if rule_status and not isinstance(rule_status, str):
            raise TypeError("Expected argument 'rule_status' to be a str")
        pulumi.set(__self__, "rule_status", rule_status)

    @_builtins.property
    @pulumi.getter
    def alerts(self) -> Sequence['outputs.GetPreconfiguredAlertAlertResult']:
        """
        List of preconfigured alerts. Each alert contains:
        """
        return pulumi.get(self, "alerts")

    @_builtins.property
    @pulumi.getter(name="dataSourceId")
    def data_source_id(self) -> Optional[_builtins.str]:
        """
        ID of the data source containing the alert rule.
        """
        return pulumi.get(self, "data_source_id")

    @_builtins.property
    @pulumi.getter
    def id(self) -> _builtins.str:
        """
        The provider-assigned unique ID for this managed resource.
        """
        return pulumi.get(self, "id")

    @_builtins.property
    @pulumi.getter(name="projectId")
    def project_id(self) -> _builtins.str:
        return pulumi.get(self, "project_id")

    @_builtins.property
    @pulumi.getter
    def region(self) -> Optional[_builtins.str]:
        return pulumi.get(self, "region")

    @_builtins.property
    @pulumi.getter(name="ruleStatus")
    def rule_status(self) -> Optional[_builtins.str]:
        """
        Status of the alert rule (`enabled`, `disabled`, `enabling`, `disabling`).
        """
        return pulumi.get(self, "rule_status")


class AwaitableGetPreconfiguredAlertResult(GetPreconfiguredAlertResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetPreconfiguredAlertResult(
            alerts=self.alerts,
            data_source_id=self.data_source_id,
            id=self.id,
            project_id=self.project_id,
            region=self.region,
            rule_status=self.rule_status)


def get_preconfigured_alert(data_source_id: Optional[_builtins.str] = None,
                            project_id: Optional[_builtins.str] = None,
                            region: Optional[_builtins.str] = None,
                            rule_status: Optional[_builtins.str] = None,
                            opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetPreconfiguredAlertResult:
    """
    Gets information about preconfigured alert rules available in Scaleway Cockpit.

    Preconfigured alerts are ready-to-use alert rules that monitor common metrics for Scaleway services.
    You can enable these alerts in your Alert Manager using the `observability.AlertManager` resource.

    For more information, refer to Cockpit's [product documentation](https://www.scaleway.com/en/docs/observability/cockpit/concepts/) and [API documentation](https://www.scaleway.com/en/developers/api/cockpit/regional-api).

    ## Example Usage

    ### Basic usage

    ```python
    import pulumi
    import pulumi_scaleway as scaleway

    main = scaleway.observability.get_preconfigured_alert(project_id=project["id"])
    pulumi.export("availableAlerts", main.alerts)
    ```

    ### Filter by status

    ```python
    import pulumi
    import pulumi_scaleway as scaleway

    enabled = scaleway.observability.get_preconfigured_alert(project_id=project["id"],
        rule_status="enabled")
    disabled = scaleway.observability.get_preconfigured_alert(project_id=project["id"],
        rule_status="disabled")
    ```

    ### Use with Alert Manager

    ```python
    import pulumi
    import pulumi_scaleway as scaleway
    import pulumiverse_scaleway as scaleway

    project = scaleway.account.Project("project", name="my-observability-project")
    main = scaleway.observability.Cockpit("main", project_id=project.id)
    all = scaleway.observability.get_preconfigured_alert_output(project_id=main.project_id)
    main_alert_manager = scaleway.observability.AlertManager("main",
        project_id=main.project_id,
        preconfigured_alert_ids=all.apply(lambda all: [alert.preconfigured_rule_id for alert in all.alerts if alert.product_name == "instance" and alert.rule_status == "disabled"]),
        contact_points=[{
            "email": "alerts@example.com",
        }])
    ```


    :param _builtins.str data_source_id: Filter alerts by data source ID.
    :param _builtins.str project_id: The ID of the project the alerts are associated with. If not provided, the default project configured in the provider is used.
    :param _builtins.str region: The region in which the alerts exist.
    :param _builtins.str rule_status: Filter alerts by rule status. Valid values are `enabled` or `disabled`.
    """
    __args__ = dict()
    __args__['dataSourceId'] = data_source_id
    __args__['projectId'] = project_id
    __args__['region'] = region
    __args__['ruleStatus'] = rule_status
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('scaleway:observability/getPreconfiguredAlert:getPreconfiguredAlert', __args__, opts=opts, typ=GetPreconfiguredAlertResult).value

    return AwaitableGetPreconfiguredAlertResult(
        alerts=pulumi.get(__ret__, 'alerts'),
        data_source_id=pulumi.get(__ret__, 'data_source_id'),
        id=pulumi.get(__ret__, 'id'),
        project_id=pulumi.get(__ret__, 'project_id'),
        region=pulumi.get(__ret__, 'region'),
        rule_status=pulumi.get(__ret__, 'rule_status'))
def get_preconfigured_alert_output(data_source_id: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                                   project_id: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                                   region: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                                   rule_status: Optional[pulumi.Input[Optional[_builtins.str]]] = None,
                                   opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetPreconfiguredAlertResult]:
    """
    Gets information about preconfigured alert rules available in Scaleway Cockpit.

    Preconfigured alerts are ready-to-use alert rules that monitor common metrics for Scaleway services.
    You can enable these alerts in your Alert Manager using the `observability.AlertManager` resource.

    For more information, refer to Cockpit's [product documentation](https://www.scaleway.com/en/docs/observability/cockpit/concepts/) and [API documentation](https://www.scaleway.com/en/developers/api/cockpit/regional-api).

    ## Example Usage

    ### Basic usage

    ```python
    import pulumi
    import pulumi_scaleway as scaleway

    main = scaleway.observability.get_preconfigured_alert(project_id=project["id"])
    pulumi.export("availableAlerts", main.alerts)
    ```

    ### Filter by status

    ```python
    import pulumi
    import pulumi_scaleway as scaleway

    enabled = scaleway.observability.get_preconfigured_alert(project_id=project["id"],
        rule_status="enabled")
    disabled = scaleway.observability.get_preconfigured_alert(project_id=project["id"],
        rule_status="disabled")
    ```

    ### Use with Alert Manager

    ```python
    import pulumi
    import pulumi_scaleway as scaleway
    import pulumiverse_scaleway as scaleway

    project = scaleway.account.Project("project", name="my-observability-project")
    main = scaleway.observability.Cockpit("main", project_id=project.id)
    all = scaleway.observability.get_preconfigured_alert_output(project_id=main.project_id)
    main_alert_manager = scaleway.observability.AlertManager("main",
        project_id=main.project_id,
        preconfigured_alert_ids=all.apply(lambda all: [alert.preconfigured_rule_id for alert in all.alerts if alert.product_name == "instance" and alert.rule_status == "disabled"]),
        contact_points=[{
            "email": "alerts@example.com",
        }])
    ```


    :param _builtins.str data_source_id: Filter alerts by data source ID.
    :param _builtins.str project_id: The ID of the project the alerts are associated with. If not provided, the default project configured in the provider is used.
    :param _builtins.str region: The region in which the alerts exist.
    :param _builtins.str rule_status: Filter alerts by rule status. Valid values are `enabled` or `disabled`.
    """
    __args__ = dict()
    __args__['dataSourceId'] = data_source_id
    __args__['projectId'] = project_id
    __args__['region'] = region
    __args__['ruleStatus'] = rule_status
    opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke_output('scaleway:observability/getPreconfiguredAlert:getPreconfiguredAlert', __args__, opts=opts, typ=GetPreconfiguredAlertResult)
    return __ret__.apply(lambda __response__: GetPreconfiguredAlertResult(
        alerts=pulumi.get(__response__, 'alerts'),
        data_source_id=pulumi.get(__response__, 'data_source_id'),
        id=pulumi.get(__response__, 'id'),
        project_id=pulumi.get(__response__, 'project_id'),
        region=pulumi.get(__response__, 'region'),
        rule_status=pulumi.get(__response__, 'rule_status')))
