"""
Autogenerated state module using `pop-create-idem <https://gitlab.com/saltstack/pop/pop-create-idem>`__

hub.exec.boto3.client.cognito_identity.create_identity_pool
hub.exec.boto3.client.cognito_identity.delete_identity_pool
hub.exec.boto3.client.cognito_identity.describe_identity_pool
hub.exec.boto3.client.cognito_identity.list_identity_pools
hub.exec.boto3.client.cognito_identity.update_identity_pool
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, identity_pool_name: Text, allow_unauthenticated_identities: bool, allow_classic_flow: bool = None, supported_login_providers: Dict = None, developer_provider_name: Text = None, open_id_connect_provider_ar_ns: List = None, cognito_identity_providers: List = None, saml_provider_ar_ns: List = None, identity_pool_tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new identity pool. The identity pool is a store of user identity information that is specific to your
    AWS account. The keys for SupportedLoginProviders are as follows:   Facebook: graph.facebook.com    Google:
    accounts.google.com    Amazon: www.amazon.com    Twitter: api.twitter.com    Digits: www.digits.com    You must
    use AWS Developer credentials to call this API.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        identity_pool_name(Text): A string that you provide.
        allow_unauthenticated_identities(bool): TRUE if the identity pool supports unauthenticated logins.
        allow_classic_flow(bool, optional): Enables or disables the Basic (Classic) authentication flow. For more information, see Identity
            Pools (Federated Identities) Authentication Flow in the Amazon Cognito Developer Guide. Defaults to None.
        supported_login_providers(Dict, optional): Optional key:value pairs mapping provider names to provider app IDs. Defaults to None.
        developer_provider_name(Text, optional): The "domain" by which Cognito will refer to your users. This name acts as a placeholder that
            allows your backend and the Cognito service to communicate about the developer provider. For the
            DeveloperProviderName, you can use letters as well as period (.), underscore (_), and dash (-).
            Once you have set a developer provider name, you cannot change it. Please take care in setting
            this parameter. Defaults to None.
        open_id_connect_provider_ar_ns(List, optional): The Amazon Resource Names (ARN) of the OpenID Connect providers. Defaults to None.
        cognito_identity_providers(List, optional): An array of Amazon Cognito user pools and their client IDs. Defaults to None.
        saml_provider_ar_ns(List, optional): An array of Amazon Resource Names (ARNs) of the SAML provider for your identity pool. Defaults to None.
        identity_pool_tags(Dict, optional): Tags to assign to the identity pool. A tag is a label that you can apply to identity pools to
            categorize and manage them in different ways, such as by purpose, owner, environment, or other
            criteria. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.cognito_identity.identity_pool.present:
                - name: value
                - identity_pool_name: value
                - allow_unauthenticated_identities: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.cognito_identity.identity_pool.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    
    before = await hub.exec.boto3.client.cognito_identity.describe_identity_pool(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.cognito_identity.create_identity_pool(
                ctx,
                
                
                **{"IdentityPoolName": identity_pool_name, "AllowUnauthenticatedIdentities": allow_unauthenticated_identities, "AllowClassicFlow": allow_classic_flow, "SupportedLoginProviders": supported_login_providers, "DeveloperProviderName": developer_provider_name, "OpenIdConnectProviderARNs": open_id_connect_provider_ar_ns, "CognitoIdentityProviders": cognito_identity_providers, "SamlProviderARNs": saml_provider_ar_ns, "IdentityPoolTags": identity_pool_tags}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            ret["comment"] = f"Created '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    
    # TODO perform other modifications as needed here
    ...

    after = await hub.exec.boto3.client.cognito_identity.describe_identity_pool(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, identity_pool_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an identity pool. Once a pool is deleted, users will not be able to authenticate with the pool. You must
    use AWS Developer credentials to call this API.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        identity_pool_id(Text): An identity pool ID in the format REGION:GUID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.cognito_identity.identity_pool.absent:
                - name: value
                - identity_pool_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.cognito_identity.identity_pool.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    

    before = await hub.exec.boto3.client.cognito_identity.describe_identity_pool(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.cognito_identity.delete_identity_pool(
                ctx,
                
                
                **{"IdentityPoolId": identity_pool_id}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            result["comment"] = f"Deleted '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    

    after = await hub.exec.boto3.client.cognito_identity.describe_identity_pool(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

