# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
from .. import _utilities, _tables

__all__ = ['Rule']


class Rule(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 description: Optional[pulumi.Input[str]] = None,
                 input_parameters: Optional[pulumi.Input[Mapping[str, Any]]] = None,
                 member_id: Optional[pulumi.Input[float]] = None,
                 multi_account: Optional[pulumi.Input[bool]] = None,
                 risk_level: Optional[pulumi.Input[float]] = None,
                 rule_name: Optional[pulumi.Input[str]] = None,
                 scope_compliance_resource_id: Optional[pulumi.Input[str]] = None,
                 scope_compliance_resource_types: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
                 source_detail_message_type: Optional[pulumi.Input[str]] = None,
                 source_identifier: Optional[pulumi.Input[str]] = None,
                 source_maximum_execution_frequency: Optional[pulumi.Input[str]] = None,
                 source_owner: Optional[pulumi.Input[str]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Provides a a Alicloud Config Rule resource. Cloud Config checks the validity of resources based on rules. You can create rules to evaluate resources as needed.
        For information about Alicloud Config Rule and how to use it, see [What is Alicloud Config Rule](https://www.alibabacloud.com/help/en/doc-detail/127388.htm).

        > **NOTE:** Available in v1.99.0+.

        > **NOTE:** If you use custom rules, you need to create your own rule functions in advance. Please refer to the link for [Create a custom rule.](https://www.alibabacloud.com/help/en/doc-detail/127405.htm)

        ## Example Usage

        ```python
        import pulumi
        import pulumi_alicloud as alicloud

        # Audit ECS instances under VPC using preset rules
        example = alicloud.cfg.Rule("example",
            description="ecs instances in vpc",
            input_parameters={
                "vpc_ids": "vpc-uf6gksw4ctjd******",
            },
            risk_level=1,
            rule_name="instances-in-vpc",
            scope_compliance_resource_id="i-uf6j6rl141ps******",
            scope_compliance_resource_types=["ACS::ECS::Instance"],
            source_detail_message_type="ConfigurationItemChangeNotification",
            source_identifier="ecs-instances-in-vpc",
            source_maximum_execution_frequency="Twelve_Hours",
            source_owner="ALIYUN")
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] description: The description of the Config Rule.
        :param pulumi.Input[Mapping[str, Any]] input_parameters: Threshold value for managed rule triggering.
        :param pulumi.Input[float] member_id: The ID of the member account to which the rule to be created or modified belongs. The default is empty. When `multi_account` is set to true, this parameter is valid.
        :param pulumi.Input[bool] multi_account: Whether the enterprise management account is a member account to create or modify rules. Valid values: `true`: Enterprise management accounts create or modify rules for all member accounts in the resource directory. `false`:The enterprise management account creates or modifies rules for this account. Default value is `false`.
        :param pulumi.Input[float] risk_level: The risk level of the Config Rule. Valid values: `1`: Critical ,`2`: Warning , `3`: Info.
        :param pulumi.Input[str] rule_name: The name of the Config Rule.
        :param pulumi.Input[str] scope_compliance_resource_id: The ID of the resource to be evaluated. If not set, all resources are evaluated.
        :param pulumi.Input[List[pulumi.Input[str]]] scope_compliance_resource_types: Resource types to be evaluated. [Alibaba Cloud services that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)
        :param pulumi.Input[str] source_detail_message_type: Trigger mechanism of rules. Valid values: `ConfigurationItemChangeNotification`,`OversizedConfigurationItemChangeNotification` and `ScheduledNotification`.
        :param pulumi.Input[str] source_identifier: The name of the custom rule or managed rules. Using managed rules, refer to [List of Managed rules.](https://www.alibabacloud.com/help/en/doc-detail/127404.htm)
        :param pulumi.Input[str] source_maximum_execution_frequency: Rule execution cycle. Valid values: `One_Hour`, `Three_Hours`, `Six_Hours`, `Twelve_Hours` and `TwentyFour_Hours`.
        :param pulumi.Input[str] source_owner: The source owner of the Config Rule. Values: `CUSTOM_FC`: Custom rules, `ALIYUN`: Trusteeship rules.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            __props__['description'] = description
            __props__['input_parameters'] = input_parameters
            __props__['member_id'] = member_id
            __props__['multi_account'] = multi_account
            if risk_level is None:
                raise TypeError("Missing required property 'risk_level'")
            __props__['risk_level'] = risk_level
            if rule_name is None:
                raise TypeError("Missing required property 'rule_name'")
            __props__['rule_name'] = rule_name
            __props__['scope_compliance_resource_id'] = scope_compliance_resource_id
            if scope_compliance_resource_types is None:
                raise TypeError("Missing required property 'scope_compliance_resource_types'")
            __props__['scope_compliance_resource_types'] = scope_compliance_resource_types
            if source_detail_message_type is None:
                raise TypeError("Missing required property 'source_detail_message_type'")
            __props__['source_detail_message_type'] = source_detail_message_type
            if source_identifier is None:
                raise TypeError("Missing required property 'source_identifier'")
            __props__['source_identifier'] = source_identifier
            __props__['source_maximum_execution_frequency'] = source_maximum_execution_frequency
            if source_owner is None:
                raise TypeError("Missing required property 'source_owner'")
            __props__['source_owner'] = source_owner
        super(Rule, __self__).__init__(
            'alicloud:cfg/rule:Rule',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            description: Optional[pulumi.Input[str]] = None,
            input_parameters: Optional[pulumi.Input[Mapping[str, Any]]] = None,
            member_id: Optional[pulumi.Input[float]] = None,
            multi_account: Optional[pulumi.Input[bool]] = None,
            risk_level: Optional[pulumi.Input[float]] = None,
            rule_name: Optional[pulumi.Input[str]] = None,
            scope_compliance_resource_id: Optional[pulumi.Input[str]] = None,
            scope_compliance_resource_types: Optional[pulumi.Input[List[pulumi.Input[str]]]] = None,
            source_detail_message_type: Optional[pulumi.Input[str]] = None,
            source_identifier: Optional[pulumi.Input[str]] = None,
            source_maximum_execution_frequency: Optional[pulumi.Input[str]] = None,
            source_owner: Optional[pulumi.Input[str]] = None) -> 'Rule':
        """
        Get an existing Rule resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] description: The description of the Config Rule.
        :param pulumi.Input[Mapping[str, Any]] input_parameters: Threshold value for managed rule triggering.
        :param pulumi.Input[float] member_id: The ID of the member account to which the rule to be created or modified belongs. The default is empty. When `multi_account` is set to true, this parameter is valid.
        :param pulumi.Input[bool] multi_account: Whether the enterprise management account is a member account to create or modify rules. Valid values: `true`: Enterprise management accounts create or modify rules for all member accounts in the resource directory. `false`:The enterprise management account creates or modifies rules for this account. Default value is `false`.
        :param pulumi.Input[float] risk_level: The risk level of the Config Rule. Valid values: `1`: Critical ,`2`: Warning , `3`: Info.
        :param pulumi.Input[str] rule_name: The name of the Config Rule.
        :param pulumi.Input[str] scope_compliance_resource_id: The ID of the resource to be evaluated. If not set, all resources are evaluated.
        :param pulumi.Input[List[pulumi.Input[str]]] scope_compliance_resource_types: Resource types to be evaluated. [Alibaba Cloud services that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)
        :param pulumi.Input[str] source_detail_message_type: Trigger mechanism of rules. Valid values: `ConfigurationItemChangeNotification`,`OversizedConfigurationItemChangeNotification` and `ScheduledNotification`.
        :param pulumi.Input[str] source_identifier: The name of the custom rule or managed rules. Using managed rules, refer to [List of Managed rules.](https://www.alibabacloud.com/help/en/doc-detail/127404.htm)
        :param pulumi.Input[str] source_maximum_execution_frequency: Rule execution cycle. Valid values: `One_Hour`, `Three_Hours`, `Six_Hours`, `Twelve_Hours` and `TwentyFour_Hours`.
        :param pulumi.Input[str] source_owner: The source owner of the Config Rule. Values: `CUSTOM_FC`: Custom rules, `ALIYUN`: Trusteeship rules.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["description"] = description
        __props__["input_parameters"] = input_parameters
        __props__["member_id"] = member_id
        __props__["multi_account"] = multi_account
        __props__["risk_level"] = risk_level
        __props__["rule_name"] = rule_name
        __props__["scope_compliance_resource_id"] = scope_compliance_resource_id
        __props__["scope_compliance_resource_types"] = scope_compliance_resource_types
        __props__["source_detail_message_type"] = source_detail_message_type
        __props__["source_identifier"] = source_identifier
        __props__["source_maximum_execution_frequency"] = source_maximum_execution_frequency
        __props__["source_owner"] = source_owner
        return Rule(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter
    def description(self) -> pulumi.Output[Optional[str]]:
        """
        The description of the Config Rule.
        """
        return pulumi.get(self, "description")

    @property
    @pulumi.getter(name="inputParameters")
    def input_parameters(self) -> pulumi.Output[Optional[Mapping[str, Any]]]:
        """
        Threshold value for managed rule triggering.
        """
        return pulumi.get(self, "input_parameters")

    @property
    @pulumi.getter(name="memberId")
    def member_id(self) -> pulumi.Output[Optional[float]]:
        """
        The ID of the member account to which the rule to be created or modified belongs. The default is empty. When `multi_account` is set to true, this parameter is valid.
        """
        return pulumi.get(self, "member_id")

    @property
    @pulumi.getter(name="multiAccount")
    def multi_account(self) -> pulumi.Output[Optional[bool]]:
        """
        Whether the enterprise management account is a member account to create or modify rules. Valid values: `true`: Enterprise management accounts create or modify rules for all member accounts in the resource directory. `false`:The enterprise management account creates or modifies rules for this account. Default value is `false`.
        """
        return pulumi.get(self, "multi_account")

    @property
    @pulumi.getter(name="riskLevel")
    def risk_level(self) -> pulumi.Output[float]:
        """
        The risk level of the Config Rule. Valid values: `1`: Critical ,`2`: Warning , `3`: Info.
        """
        return pulumi.get(self, "risk_level")

    @property
    @pulumi.getter(name="ruleName")
    def rule_name(self) -> pulumi.Output[str]:
        """
        The name of the Config Rule.
        """
        return pulumi.get(self, "rule_name")

    @property
    @pulumi.getter(name="scopeComplianceResourceId")
    def scope_compliance_resource_id(self) -> pulumi.Output[Optional[str]]:
        """
        The ID of the resource to be evaluated. If not set, all resources are evaluated.
        """
        return pulumi.get(self, "scope_compliance_resource_id")

    @property
    @pulumi.getter(name="scopeComplianceResourceTypes")
    def scope_compliance_resource_types(self) -> pulumi.Output[List[str]]:
        """
        Resource types to be evaluated. [Alibaba Cloud services that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)
        """
        return pulumi.get(self, "scope_compliance_resource_types")

    @property
    @pulumi.getter(name="sourceDetailMessageType")
    def source_detail_message_type(self) -> pulumi.Output[str]:
        """
        Trigger mechanism of rules. Valid values: `ConfigurationItemChangeNotification`,`OversizedConfigurationItemChangeNotification` and `ScheduledNotification`.
        """
        return pulumi.get(self, "source_detail_message_type")

    @property
    @pulumi.getter(name="sourceIdentifier")
    def source_identifier(self) -> pulumi.Output[str]:
        """
        The name of the custom rule or managed rules. Using managed rules, refer to [List of Managed rules.](https://www.alibabacloud.com/help/en/doc-detail/127404.htm)
        """
        return pulumi.get(self, "source_identifier")

    @property
    @pulumi.getter(name="sourceMaximumExecutionFrequency")
    def source_maximum_execution_frequency(self) -> pulumi.Output[Optional[str]]:
        """
        Rule execution cycle. Valid values: `One_Hour`, `Three_Hours`, `Six_Hours`, `Twelve_Hours` and `TwentyFour_Hours`.
        """
        return pulumi.get(self, "source_maximum_execution_frequency")

    @property
    @pulumi.getter(name="sourceOwner")
    def source_owner(self) -> pulumi.Output[str]:
        """
        The source owner of the Config Rule. Values: `CUSTOM_FC`: Custom rules, `ALIYUN`: Trusteeship rules.
        """
        return pulumi.get(self, "source_owner")

    def translate_output_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

