# 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__ = ['OrganizationArgs', 'Organization']

@pulumi.input_type
class OrganizationArgs:
    def __init__(__self__, *,
                 domains: pulumi.Input[Sequence[pulumi.Input['OrganizationDomainArgs']]],
                 realm: pulumi.Input[_builtins.str],
                 alias: Optional[pulumi.Input[_builtins.str]] = None,
                 attributes: Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 enabled: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 redirect_url: Optional[pulumi.Input[_builtins.str]] = None):
        """
        The set of arguments for constructing a Organization resource.
        :param pulumi.Input[Sequence[pulumi.Input['OrganizationDomainArgs']]] domains: A list of domains. At least one domain is required.
        :param pulumi.Input[_builtins.str] realm: The realm this organization exists in.
        :param pulumi.Input[_builtins.str] alias: The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        :param pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]] attributes: A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        :param pulumi.Input[_builtins.str] description: The description of the organization.
        :param pulumi.Input[_builtins.bool] enabled: Enable/disable this organization.
        :param pulumi.Input[_builtins.str] name: The name of the organization.
        :param pulumi.Input[_builtins.str] redirect_url: The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        pulumi.set(__self__, "domains", domains)
        pulumi.set(__self__, "realm", realm)
        if alias is not None:
            pulumi.set(__self__, "alias", alias)
        if attributes is not None:
            pulumi.set(__self__, "attributes", attributes)
        if description is not None:
            pulumi.set(__self__, "description", description)
        if enabled is not None:
            pulumi.set(__self__, "enabled", enabled)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if redirect_url is not None:
            pulumi.set(__self__, "redirect_url", redirect_url)

    @_builtins.property
    @pulumi.getter
    def domains(self) -> pulumi.Input[Sequence[pulumi.Input['OrganizationDomainArgs']]]:
        """
        A list of domains. At least one domain is required.
        """
        return pulumi.get(self, "domains")

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

    @_builtins.property
    @pulumi.getter
    def realm(self) -> pulumi.Input[_builtins.str]:
        """
        The realm this organization exists in.
        """
        return pulumi.get(self, "realm")

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

    @_builtins.property
    @pulumi.getter
    def alias(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        """
        return pulumi.get(self, "alias")

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

    @_builtins.property
    @pulumi.getter
    def attributes(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]]:
        """
        A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        """
        return pulumi.get(self, "attributes")

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

    @_builtins.property
    @pulumi.getter
    def description(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The description of the organization.
        """
        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 enabled(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        Enable/disable this organization.
        """
        return pulumi.get(self, "enabled")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The name of the organization.
        """
        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="redirectUrl")
    def redirect_url(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        return pulumi.get(self, "redirect_url")

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


@pulumi.input_type
class _OrganizationState:
    def __init__(__self__, *,
                 alias: Optional[pulumi.Input[_builtins.str]] = None,
                 attributes: Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 domains: Optional[pulumi.Input[Sequence[pulumi.Input['OrganizationDomainArgs']]]] = None,
                 enabled: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 realm: Optional[pulumi.Input[_builtins.str]] = None,
                 redirect_url: Optional[pulumi.Input[_builtins.str]] = None):
        """
        Input properties used for looking up and filtering Organization resources.
        :param pulumi.Input[_builtins.str] alias: The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        :param pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]] attributes: A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        :param pulumi.Input[_builtins.str] description: The description of the organization.
        :param pulumi.Input[Sequence[pulumi.Input['OrganizationDomainArgs']]] domains: A list of domains. At least one domain is required.
        :param pulumi.Input[_builtins.bool] enabled: Enable/disable this organization.
        :param pulumi.Input[_builtins.str] name: The name of the organization.
        :param pulumi.Input[_builtins.str] realm: The realm this organization exists in.
        :param pulumi.Input[_builtins.str] redirect_url: The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        if alias is not None:
            pulumi.set(__self__, "alias", alias)
        if attributes is not None:
            pulumi.set(__self__, "attributes", attributes)
        if description is not None:
            pulumi.set(__self__, "description", description)
        if domains is not None:
            pulumi.set(__self__, "domains", domains)
        if enabled is not None:
            pulumi.set(__self__, "enabled", enabled)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if realm is not None:
            pulumi.set(__self__, "realm", realm)
        if redirect_url is not None:
            pulumi.set(__self__, "redirect_url", redirect_url)

    @_builtins.property
    @pulumi.getter
    def alias(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        """
        return pulumi.get(self, "alias")

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

    @_builtins.property
    @pulumi.getter
    def attributes(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]]:
        """
        A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        """
        return pulumi.get(self, "attributes")

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

    @_builtins.property
    @pulumi.getter
    def description(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The description of the organization.
        """
        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 domains(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['OrganizationDomainArgs']]]]:
        """
        A list of domains. At least one domain is required.
        """
        return pulumi.get(self, "domains")

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

    @_builtins.property
    @pulumi.getter
    def enabled(self) -> Optional[pulumi.Input[_builtins.bool]]:
        """
        Enable/disable this organization.
        """
        return pulumi.get(self, "enabled")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The name of the organization.
        """
        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
    def realm(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The realm this organization exists in.
        """
        return pulumi.get(self, "realm")

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

    @_builtins.property
    @pulumi.getter(name="redirectUrl")
    def redirect_url(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        return pulumi.get(self, "redirect_url")

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


@pulumi.type_token("keycloak:index/organization:Organization")
class Organization(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 alias: Optional[pulumi.Input[_builtins.str]] = None,
                 attributes: Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 domains: Optional[pulumi.Input[Sequence[pulumi.Input[Union['OrganizationDomainArgs', 'OrganizationDomainArgsDict']]]]] = None,
                 enabled: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 realm: Optional[pulumi.Input[_builtins.str]] = None,
                 redirect_url: Optional[pulumi.Input[_builtins.str]] = None,
                 __props__=None):
        """
        Allow for creating and managing Organizations within Keycloak.

        Attributes can also be defined on Groups.

        Linkage with identity providers is managed with the identity provider resources.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_keycloak as keycloak

        realm = keycloak.Realm("realm",
            realm="my-realm",
            enabled=True)
        this = keycloak.Organization("this",
            realm=realm.name,
            name="org",
            alias="org",
            enabled=True,
            domains=[{
                "name": "example.com",
            }])
        this_identity_provider = keycloak.oidc.IdentityProvider("this",
            realm=realm.name,
            alias="my-idp",
            authorization_url="https://authorizationurl.com",
            client_id="clientID",
            client_secret="clientSecret",
            token_url="https://tokenurl.com",
            organization_id=this.id,
            org_domain="example.com",
            org_redirect_mode_email_matches=True)
        ```

        ## Import

        Organizations can be imported using the format `{{realm_id}}/{{organization_id}}`, where `organization_id` is the unique ID that Keycloak

        assigns to the organizations upon creation. This value can be found in the URI when editing this organization in the GUI, and is typically a GUID.

        Example:

        bash

        ```sh
        $ pulumi import keycloak:index/organization:Organization this my-realm/cec54914-b702-4c7b-9431-b407817d059a
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[_builtins.str] alias: The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        :param pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]] attributes: A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        :param pulumi.Input[_builtins.str] description: The description of the organization.
        :param pulumi.Input[Sequence[pulumi.Input[Union['OrganizationDomainArgs', 'OrganizationDomainArgsDict']]]] domains: A list of domains. At least one domain is required.
        :param pulumi.Input[_builtins.bool] enabled: Enable/disable this organization.
        :param pulumi.Input[_builtins.str] name: The name of the organization.
        :param pulumi.Input[_builtins.str] realm: The realm this organization exists in.
        :param pulumi.Input[_builtins.str] redirect_url: The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: OrganizationArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        Allow for creating and managing Organizations within Keycloak.

        Attributes can also be defined on Groups.

        Linkage with identity providers is managed with the identity provider resources.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_keycloak as keycloak

        realm = keycloak.Realm("realm",
            realm="my-realm",
            enabled=True)
        this = keycloak.Organization("this",
            realm=realm.name,
            name="org",
            alias="org",
            enabled=True,
            domains=[{
                "name": "example.com",
            }])
        this_identity_provider = keycloak.oidc.IdentityProvider("this",
            realm=realm.name,
            alias="my-idp",
            authorization_url="https://authorizationurl.com",
            client_id="clientID",
            client_secret="clientSecret",
            token_url="https://tokenurl.com",
            organization_id=this.id,
            org_domain="example.com",
            org_redirect_mode_email_matches=True)
        ```

        ## Import

        Organizations can be imported using the format `{{realm_id}}/{{organization_id}}`, where `organization_id` is the unique ID that Keycloak

        assigns to the organizations upon creation. This value can be found in the URI when editing this organization in the GUI, and is typically a GUID.

        Example:

        bash

        ```sh
        $ pulumi import keycloak:index/organization:Organization this my-realm/cec54914-b702-4c7b-9431-b407817d059a
        ```

        :param str resource_name: The name of the resource.
        :param OrganizationArgs 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(OrganizationArgs, 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,
                 alias: Optional[pulumi.Input[_builtins.str]] = None,
                 attributes: Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]] = None,
                 description: Optional[pulumi.Input[_builtins.str]] = None,
                 domains: Optional[pulumi.Input[Sequence[pulumi.Input[Union['OrganizationDomainArgs', 'OrganizationDomainArgsDict']]]]] = None,
                 enabled: Optional[pulumi.Input[_builtins.bool]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 realm: Optional[pulumi.Input[_builtins.str]] = None,
                 redirect_url: Optional[pulumi.Input[_builtins.str]] = 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__ = OrganizationArgs.__new__(OrganizationArgs)

            __props__.__dict__["alias"] = alias
            __props__.__dict__["attributes"] = attributes
            __props__.__dict__["description"] = description
            if domains is None and not opts.urn:
                raise TypeError("Missing required property 'domains'")
            __props__.__dict__["domains"] = domains
            __props__.__dict__["enabled"] = enabled
            __props__.__dict__["name"] = name
            if realm is None and not opts.urn:
                raise TypeError("Missing required property 'realm'")
            __props__.__dict__["realm"] = realm
            __props__.__dict__["redirect_url"] = redirect_url
        super(Organization, __self__).__init__(
            'keycloak:index/organization:Organization',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            alias: Optional[pulumi.Input[_builtins.str]] = None,
            attributes: Optional[pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]]] = None,
            description: Optional[pulumi.Input[_builtins.str]] = None,
            domains: Optional[pulumi.Input[Sequence[pulumi.Input[Union['OrganizationDomainArgs', 'OrganizationDomainArgsDict']]]]] = None,
            enabled: Optional[pulumi.Input[_builtins.bool]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            realm: Optional[pulumi.Input[_builtins.str]] = None,
            redirect_url: Optional[pulumi.Input[_builtins.str]] = None) -> 'Organization':
        """
        Get an existing Organization 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[_builtins.str] alias: The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        :param pulumi.Input[Mapping[str, pulumi.Input[_builtins.str]]] attributes: A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        :param pulumi.Input[_builtins.str] description: The description of the organization.
        :param pulumi.Input[Sequence[pulumi.Input[Union['OrganizationDomainArgs', 'OrganizationDomainArgsDict']]]] domains: A list of domains. At least one domain is required.
        :param pulumi.Input[_builtins.bool] enabled: Enable/disable this organization.
        :param pulumi.Input[_builtins.str] name: The name of the organization.
        :param pulumi.Input[_builtins.str] realm: The realm this organization exists in.
        :param pulumi.Input[_builtins.str] redirect_url: The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _OrganizationState.__new__(_OrganizationState)

        __props__.__dict__["alias"] = alias
        __props__.__dict__["attributes"] = attributes
        __props__.__dict__["description"] = description
        __props__.__dict__["domains"] = domains
        __props__.__dict__["enabled"] = enabled
        __props__.__dict__["name"] = name
        __props__.__dict__["realm"] = realm
        __props__.__dict__["redirect_url"] = redirect_url
        return Organization(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter
    def alias(self) -> pulumi.Output[_builtins.str]:
        """
        The alias unique identifies the organization. Same as the name if not specified. The alias cannot be changed after the organization has been created.
        """
        return pulumi.get(self, "alias")

    @_builtins.property
    @pulumi.getter
    def attributes(self) -> pulumi.Output[Mapping[str, _builtins.str]]:
        """
        A map representing attributes for the group. In order to add multivalued attributes, use `##` to separate the values. Max length for each value is 255 chars.
        """
        return pulumi.get(self, "attributes")

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

    @_builtins.property
    @pulumi.getter
    def domains(self) -> pulumi.Output[Sequence['outputs.OrganizationDomain']]:
        """
        A list of domains. At least one domain is required.
        """
        return pulumi.get(self, "domains")

    @_builtins.property
    @pulumi.getter
    def enabled(self) -> pulumi.Output[Optional[_builtins.bool]]:
        """
        Enable/disable this organization.
        """
        return pulumi.get(self, "enabled")

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

    @_builtins.property
    @pulumi.getter
    def realm(self) -> pulumi.Output[_builtins.str]:
        """
        The realm this organization exists in.
        """
        return pulumi.get(self, "realm")

    @_builtins.property
    @pulumi.getter(name="redirectUrl")
    def redirect_url(self) -> pulumi.Output[Optional[_builtins.str]]:
        """
        The landing page after user completes registration or accepts an invitation to the organization. If left empty, the user will be redirected to the account console by default.
        """
        return pulumi.get(self, "redirect_url")

