# 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
from ._inputs import *

__all__ = ['ClientAuthorizationClientScopePolicyArgs', 'ClientAuthorizationClientScopePolicy']

@pulumi.input_type
class ClientAuthorizationClientScopePolicyArgs:
    def __init__(__self__, *,
                 realm_id: pulumi.Input[_builtins.str],
                 resource_server_id: pulumi.Input[_builtins.str],
                 scopes: pulumi.Input[Sequence[pulumi.Input['ClientAuthorizationClientScopePolicyScopeArgs']]],
                 decision_strategy: Optional[pulumi.Input[_builtins.str]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 logic: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None):
        """
        The set of arguments for constructing a ClientAuthorizationClientScopePolicy resource.
        """
        pulumi.set(__self__, "realm_id", realm_id)
        pulumi.set(__self__, "resource_server_id", resource_server_id)
        pulumi.set(__self__, "scopes", scopes)
        if decision_strategy is not None:
            pulumi.set(__self__, "decision_strategy", decision_strategy)
        if description is not None:
            pulumi.set(__self__, "description", description)
        if logic is not None:
            pulumi.set(__self__, "logic", logic)
        if name is not None:
            pulumi.set(__self__, "name", name)

    @_builtins.property
    @pulumi.getter(name="realmId")
    def realm_id(self) -> pulumi.Input[_builtins.str]:
        return pulumi.get(self, "realm_id")

    @realm_id.setter
    def realm_id(self, value: pulumi.Input[_builtins.str]):
        pulumi.set(self, "realm_id", value)

    @_builtins.property
    @pulumi.getter(name="resourceServerId")
    def resource_server_id(self) -> pulumi.Input[_builtins.str]:
        return pulumi.get(self, "resource_server_id")

    @resource_server_id.setter
    def resource_server_id(self, value: pulumi.Input[_builtins.str]):
        pulumi.set(self, "resource_server_id", value)

    @_builtins.property
    @pulumi.getter
    def scopes(self) -> pulumi.Input[Sequence[pulumi.Input['ClientAuthorizationClientScopePolicyScopeArgs']]]:
        return pulumi.get(self, "scopes")

    @scopes.setter
    def scopes(self, value: pulumi.Input[Sequence[pulumi.Input['ClientAuthorizationClientScopePolicyScopeArgs']]]):
        pulumi.set(self, "scopes", value)

    @_builtins.property
    @pulumi.getter(name="decisionStrategy")
    def decision_strategy(self) -> Optional[pulumi.Input[_builtins.str]]:
        return pulumi.get(self, "decision_strategy")

    @decision_strategy.setter
    def decision_strategy(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "decision_strategy", value)

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

    @description.setter
    def description(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "description", value)

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

    @logic.setter
    def logic(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "logic", value)

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

    @name.setter
    def name(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "name", value)


@pulumi.input_type
class _ClientAuthorizationClientScopePolicyState:
    def __init__(__self__, *,
                 decision_strategy: Optional[pulumi.Input[_builtins.str]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 logic: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 realm_id: Optional[pulumi.Input[_builtins.str]] = None,
                 resource_server_id: Optional[pulumi.Input[_builtins.str]] = None,
                 scopes: Optional[pulumi.Input[Sequence[pulumi.Input['ClientAuthorizationClientScopePolicyScopeArgs']]]] = None):
        """
        Input properties used for looking up and filtering ClientAuthorizationClientScopePolicy resources.
        """
        if decision_strategy is not None:
            pulumi.set(__self__, "decision_strategy", decision_strategy)
        if description is not None:
            pulumi.set(__self__, "description", description)
        if logic is not None:
            pulumi.set(__self__, "logic", logic)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if realm_id is not None:
            pulumi.set(__self__, "realm_id", realm_id)
        if resource_server_id is not None:
            pulumi.set(__self__, "resource_server_id", resource_server_id)
        if scopes is not None:
            pulumi.set(__self__, "scopes", scopes)

    @_builtins.property
    @pulumi.getter(name="decisionStrategy")
    def decision_strategy(self) -> Optional[pulumi.Input[_builtins.str]]:
        return pulumi.get(self, "decision_strategy")

    @decision_strategy.setter
    def decision_strategy(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "decision_strategy", value)

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

    @description.setter
    def description(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "description", value)

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

    @logic.setter
    def logic(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "logic", value)

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

    @name.setter
    def name(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "name", value)

    @_builtins.property
    @pulumi.getter(name="realmId")
    def realm_id(self) -> Optional[pulumi.Input[_builtins.str]]:
        return pulumi.get(self, "realm_id")

    @realm_id.setter
    def realm_id(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "realm_id", value)

    @_builtins.property
    @pulumi.getter(name="resourceServerId")
    def resource_server_id(self) -> Optional[pulumi.Input[_builtins.str]]:
        return pulumi.get(self, "resource_server_id")

    @resource_server_id.setter
    def resource_server_id(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "resource_server_id", value)

    @_builtins.property
    @pulumi.getter
    def scopes(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ClientAuthorizationClientScopePolicyScopeArgs']]]]:
        return pulumi.get(self, "scopes")

    @scopes.setter
    def scopes(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['ClientAuthorizationClientScopePolicyScopeArgs']]]]):
        pulumi.set(self, "scopes", value)


@pulumi.type_token("keycloak:openid/clientAuthorizationClientScopePolicy:ClientAuthorizationClientScopePolicy")
class ClientAuthorizationClientScopePolicy(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 decision_strategy: Optional[pulumi.Input[_builtins.str]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 logic: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 realm_id: Optional[pulumi.Input[_builtins.str]] = None,
                 resource_server_id: Optional[pulumi.Input[_builtins.str]] = None,
                 scopes: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ClientAuthorizationClientScopePolicyScopeArgs', 'ClientAuthorizationClientScopePolicyScopeArgsDict']]]]] = None,
                 __props__=None):
        """
        Allows you to manage openid Client Authorization Client Scope type Policies.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_keycloak as keycloak

        realm = keycloak.Realm("realm",
            realm="my-realm",
            enabled=True)
        test = keycloak.openid.Client("test",
            client_id="client_id",
            realm_id=realm.id,
            access_type="CONFIDENTIAL",
            service_accounts_enabled=True,
            authorization={
                "policy_enforcement_mode": "ENFORCING",
            })
        test1 = keycloak.openid.ClientScope("test1",
            realm_id=realm.id,
            name="test1",
            description="test1")
        test2 = keycloak.openid.ClientScope("test2",
            realm_id=realm.id,
            name="test2",
            description="test2")
        test_client_authorization_client_scope_policy = keycloak.openid.ClientAuthorizationClientScopePolicy("test",
            resource_server_id=test.resource_server_id,
            realm_id=realm.id,
            name="test_policy_single",
            description="test",
            decision_strategy="AFFIRMATIVE",
            logic="POSITIVE",
            scopes=[{
                "id": test1.id,
                "required": False,
            }])
        test_multiple = keycloak.openid.ClientAuthorizationClientScopePolicy("test_multiple",
            resource_server_id=test.resource_server_id,
            realm_id=realm.id,
            name="test_policy_multiple",
            description="test",
            decision_strategy="AFFIRMATIVE",
            logic="POSITIVE",
            scopes=[
                {
                    "id": test1.id,
                    "required": False,
                },
                {
                    "id": test2.id,
                    "required": True,
                },
            ])
        ```

        ### Argument Reference

        The following arguments are supported:

        - `realm_id` - (Required) The realm this group exists in.
        - `resource_server_id` - (Required) The ID of the resource server.
        - `name` - (Required) The name of the policy.
        - `description` - (Optional) A description for the authorization policy.
        - `decision_strategy` - (Optional) The decision strategy, can be one of `UNANIMOUS`, `AFFIRMATIVE`, or `CONSENSUS`. Defaults to `UNANIMOUS`.
        - `logic` - (Optional) The logic, can be one of `POSITIVE` or `NEGATIVE`. Defaults to `POSITIVE`.
        - `scope` - An client scope to add client scope. At least one should be defined.

        ### Scope Arguments

        - `id` - (Required) Id of client scope.
        - `required` - (Optional) When `true`, then this client scope will be set as required. Defaults to `false`.

        ### Attributes Reference

        In addition to the arguments listed above, the following computed attributes are exported:

        - `id` - Policy ID representing the policy.

        ## Import

        Client authorization policies can be imported using the format: `{{realmId}}/{{resourceServerId}}/{{policyId}}`.

        Example:

        bash

        ```sh
        $ pulumi import keycloak:openid/clientAuthorizationClientScopePolicy:ClientAuthorizationClientScopePolicy test my-realm/3bd4a686-1062-4b59-97b8-e4e3f10b99da/63b3cde8-987d-4cd9-9306-1955579281d9
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: ClientAuthorizationClientScopePolicyArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        Allows you to manage openid Client Authorization Client Scope type Policies.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_keycloak as keycloak

        realm = keycloak.Realm("realm",
            realm="my-realm",
            enabled=True)
        test = keycloak.openid.Client("test",
            client_id="client_id",
            realm_id=realm.id,
            access_type="CONFIDENTIAL",
            service_accounts_enabled=True,
            authorization={
                "policy_enforcement_mode": "ENFORCING",
            })
        test1 = keycloak.openid.ClientScope("test1",
            realm_id=realm.id,
            name="test1",
            description="test1")
        test2 = keycloak.openid.ClientScope("test2",
            realm_id=realm.id,
            name="test2",
            description="test2")
        test_client_authorization_client_scope_policy = keycloak.openid.ClientAuthorizationClientScopePolicy("test",
            resource_server_id=test.resource_server_id,
            realm_id=realm.id,
            name="test_policy_single",
            description="test",
            decision_strategy="AFFIRMATIVE",
            logic="POSITIVE",
            scopes=[{
                "id": test1.id,
                "required": False,
            }])
        test_multiple = keycloak.openid.ClientAuthorizationClientScopePolicy("test_multiple",
            resource_server_id=test.resource_server_id,
            realm_id=realm.id,
            name="test_policy_multiple",
            description="test",
            decision_strategy="AFFIRMATIVE",
            logic="POSITIVE",
            scopes=[
                {
                    "id": test1.id,
                    "required": False,
                },
                {
                    "id": test2.id,
                    "required": True,
                },
            ])
        ```

        ### Argument Reference

        The following arguments are supported:

        - `realm_id` - (Required) The realm this group exists in.
        - `resource_server_id` - (Required) The ID of the resource server.
        - `name` - (Required) The name of the policy.
        - `description` - (Optional) A description for the authorization policy.
        - `decision_strategy` - (Optional) The decision strategy, can be one of `UNANIMOUS`, `AFFIRMATIVE`, or `CONSENSUS`. Defaults to `UNANIMOUS`.
        - `logic` - (Optional) The logic, can be one of `POSITIVE` or `NEGATIVE`. Defaults to `POSITIVE`.
        - `scope` - An client scope to add client scope. At least one should be defined.

        ### Scope Arguments

        - `id` - (Required) Id of client scope.
        - `required` - (Optional) When `true`, then this client scope will be set as required. Defaults to `false`.

        ### Attributes Reference

        In addition to the arguments listed above, the following computed attributes are exported:

        - `id` - Policy ID representing the policy.

        ## Import

        Client authorization policies can be imported using the format: `{{realmId}}/{{resourceServerId}}/{{policyId}}`.

        Example:

        bash

        ```sh
        $ pulumi import keycloak:openid/clientAuthorizationClientScopePolicy:ClientAuthorizationClientScopePolicy test my-realm/3bd4a686-1062-4b59-97b8-e4e3f10b99da/63b3cde8-987d-4cd9-9306-1955579281d9
        ```

        :param str resource_name: The name of the resource.
        :param ClientAuthorizationClientScopePolicyArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(ClientAuthorizationClientScopePolicyArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 decision_strategy: Optional[pulumi.Input[_builtins.str]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 logic: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 realm_id: Optional[pulumi.Input[_builtins.str]] = None,
                 resource_server_id: Optional[pulumi.Input[_builtins.str]] = None,
                 scopes: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ClientAuthorizationClientScopePolicyScopeArgs', 'ClientAuthorizationClientScopePolicyScopeArgsDict']]]]] = None,
                 __props__=None):
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        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__ = ClientAuthorizationClientScopePolicyArgs.__new__(ClientAuthorizationClientScopePolicyArgs)

            __props__.__dict__["decision_strategy"] = decision_strategy
            __props__.__dict__["description"] = description
            __props__.__dict__["logic"] = logic
            __props__.__dict__["name"] = name
            if realm_id is None and not opts.urn:
                raise TypeError("Missing required property 'realm_id'")
            __props__.__dict__["realm_id"] = realm_id
            if resource_server_id is None and not opts.urn:
                raise TypeError("Missing required property 'resource_server_id'")
            __props__.__dict__["resource_server_id"] = resource_server_id
            if scopes is None and not opts.urn:
                raise TypeError("Missing required property 'scopes'")
            __props__.__dict__["scopes"] = scopes
        super(ClientAuthorizationClientScopePolicy, __self__).__init__(
            'keycloak:openid/clientAuthorizationClientScopePolicy:ClientAuthorizationClientScopePolicy',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            decision_strategy: Optional[pulumi.Input[_builtins.str]] = None,
            description: Optional[pulumi.Input[_builtins.str]] = None,
            logic: Optional[pulumi.Input[_builtins.str]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            realm_id: Optional[pulumi.Input[_builtins.str]] = None,
            resource_server_id: Optional[pulumi.Input[_builtins.str]] = None,
            scopes: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ClientAuthorizationClientScopePolicyScopeArgs', 'ClientAuthorizationClientScopePolicyScopeArgsDict']]]]] = None) -> 'ClientAuthorizationClientScopePolicy':
        """
        Get an existing ClientAuthorizationClientScopePolicy 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.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _ClientAuthorizationClientScopePolicyState.__new__(_ClientAuthorizationClientScopePolicyState)

        __props__.__dict__["decision_strategy"] = decision_strategy
        __props__.__dict__["description"] = description
        __props__.__dict__["logic"] = logic
        __props__.__dict__["name"] = name
        __props__.__dict__["realm_id"] = realm_id
        __props__.__dict__["resource_server_id"] = resource_server_id
        __props__.__dict__["scopes"] = scopes
        return ClientAuthorizationClientScopePolicy(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter(name="decisionStrategy")
    def decision_strategy(self) -> pulumi.Output[Optional[_builtins.str]]:
        return pulumi.get(self, "decision_strategy")

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

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

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

    @_builtins.property
    @pulumi.getter(name="realmId")
    def realm_id(self) -> pulumi.Output[_builtins.str]:
        return pulumi.get(self, "realm_id")

    @_builtins.property
    @pulumi.getter(name="resourceServerId")
    def resource_server_id(self) -> pulumi.Output[_builtins.str]:
        return pulumi.get(self, "resource_server_id")

    @_builtins.property
    @pulumi.getter
    def scopes(self) -> pulumi.Output[Sequence['outputs.ClientAuthorizationClientScopePolicyScope']]:
        return pulumi.get(self, "scopes")

