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

hub.exec.boto3.client.eks.associate_identity_provider_config
hub.exec.boto3.client.eks.describe_identity_provider_config
hub.exec.boto3.client.eks.disassociate_identity_provider_config
hub.exec.boto3.client.eks.list_identity_provider_configs
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, cluster_name: Text, oidc: Dict, tags: Dict = None, client_request_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Associate an identity provider configuration to a cluster. If you want to authenticate identities using an
    identity provider, you can create an identity provider configuration and associate it to your cluster. After
    configuring authentication to your cluster you can create Kubernetes roles and clusterroles to assign
    permissions to the roles, and then bind the roles to the identities using Kubernetes rolebindings and
    clusterrolebindings. For more information see Using RBAC Authorization in the Kubernetes documentation.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cluster_name(Text): The name of the cluster to associate the configuration to.
        oidc(Dict): An object that represents an OpenID Connect (OIDC) identity provider configuration.
        tags(Dict, optional): The metadata to apply to the configuration to assist with categorization and organization. Each
            tag consists of a key and an optional value, both of which you define. Defaults to None.
        client_request_token(Text, optional): Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.eks.identity_provider_config.present:
                - name: value
                - cluster_name: value
                - oidc: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.eks.identity_provider_config.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.eks.describe_identity_provider_config(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.eks.associate_identity_provider_config(
                ctx,
                
                
                **{"clusterName": cluster_name, "oidc": oidc, "tags": tags, "clientRequestToken": client_request_token}
            )
            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.eks.describe_identity_provider_config(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, cluster_name: Text, identity_provider_config: Dict, client_request_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Disassociates an identity provider configuration from a cluster. If you disassociate an identity provider from
    your cluster, users included in the provider can no longer access the cluster. However, you can still access the
    cluster with Amazon Web Services IAM users.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cluster_name(Text): The name of the cluster to disassociate an identity provider from.
        identity_provider_config(Dict): An object that represents an identity provider configuration.
        client_request_token(Text, optional): A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.eks.identity_provider_config.absent:
                - name: value
                - cluster_name: value
                - identity_provider_config: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.eks.identity_provider_config.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.eks.describe_identity_provider_config(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.eks.disassociate_identity_provider_config(
                ctx,
                
                
                **{"clusterName": cluster_name, "identityProviderConfig": identity_provider_config, "clientRequestToken": client_request_token}
            )
            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.eks.describe_identity_provider_config(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

