# 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, Mapping, Optional, Sequence, Union, overload
from . import _utilities

__all__ = [
    'GetPropertyRulesResult',
    'AwaitableGetPropertyRulesResult',
    'get_property_rules',
]

@pulumi.output_type
class GetPropertyRulesResult:
    """
    A collection of values returned by getPropertyRules.
    """
    def __init__(__self__, contract_id=None, errors=None, group_id=None, id=None, property_id=None, rules=None, version=None):
        if contract_id and not isinstance(contract_id, str):
            raise TypeError("Expected argument 'contract_id' to be a str")
        pulumi.set(__self__, "contract_id", contract_id)
        if errors and not isinstance(errors, str):
            raise TypeError("Expected argument 'errors' to be a str")
        pulumi.set(__self__, "errors", errors)
        if group_id and not isinstance(group_id, str):
            raise TypeError("Expected argument 'group_id' to be a str")
        pulumi.set(__self__, "group_id", group_id)
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if property_id and not isinstance(property_id, str):
            raise TypeError("Expected argument 'property_id' to be a str")
        pulumi.set(__self__, "property_id", property_id)
        if rules and not isinstance(rules, str):
            raise TypeError("Expected argument 'rules' to be a str")
        pulumi.set(__self__, "rules", rules)
        if version and not isinstance(version, int):
            raise TypeError("Expected argument 'version' to be a int")
        pulumi.set(__self__, "version", version)

    @property
    @pulumi.getter(name="contractId")
    def contract_id(self) -> str:
        return pulumi.get(self, "contract_id")

    @property
    @pulumi.getter
    def errors(self) -> str:
        return pulumi.get(self, "errors")

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> str:
        return pulumi.get(self, "group_id")

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

    @property
    @pulumi.getter(name="propertyId")
    def property_id(self) -> str:
        return pulumi.get(self, "property_id")

    @property
    @pulumi.getter
    def rules(self) -> str:
        return pulumi.get(self, "rules")

    @property
    @pulumi.getter
    def version(self) -> int:
        return pulumi.get(self, "version")


class AwaitableGetPropertyRulesResult(GetPropertyRulesResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetPropertyRulesResult(
            contract_id=self.contract_id,
            errors=self.errors,
            group_id=self.group_id,
            id=self.id,
            property_id=self.property_id,
            rules=self.rules,
            version=self.version)


def get_property_rules(contract_id: Optional[str] = None,
                       group_id: Optional[str] = None,
                       property_id: Optional[str] = None,
                       version: Optional[int] = None,
                       opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetPropertyRulesResult:
    """
    Use the `getPropertyRules` data source to query and retrieve the rule tree of
    an existing property version. This data source lets you search across the contracts
    and groups you have access to.

    ## Basic usage

    This example returns the rule tree for version 3 of a property based on the selected contract and group:

    ```python
    import pulumi

    pulumi.export("propertyMatch", data["akamai_property_rules"]["my-example"])
    ```

    ## Argument reference

    This data source supports these arguments:

    * `contract_id` - (Required) A contract's unique ID, including the `ctr_` prefix.
    * `group_id` - (Required) A group's unique ID, including the `grp_` prefix.
    * `property_id` - (Required) A property's unique ID, including the `prp_` prefix.
    * `version` - (Optional) The version to return. Returns the latest version by default.

    ## Attributes reference

    This data source returns these attributes:

    * `rules` - A JSON-encoded rule tree for the property.
    * `errors` - A list of validation errors for the rule tree object returned. For more information see [Errors](https://developer.akamai.com/api/core_features/property_manager/v1.html#errors) in the Property Manager API documentation.
    """
    __args__ = dict()
    __args__['contractId'] = contract_id
    __args__['groupId'] = group_id
    __args__['propertyId'] = property_id
    __args__['version'] = version
    if opts is None:
        opts = pulumi.InvokeOptions()
    if opts.version is None:
        opts.version = _utilities.get_version()
    __ret__ = pulumi.runtime.invoke('akamai:index/getPropertyRules:getPropertyRules', __args__, opts=opts, typ=GetPropertyRulesResult).value

    return AwaitableGetPropertyRulesResult(
        contract_id=__ret__.contract_id,
        errors=__ret__.errors,
        group_id=__ret__.group_id,
        id=__ret__.id,
        property_id=__ret__.property_id,
        rules=__ret__.rules,
        version=__ret__.version)
