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

hub.exec.boto3.client.efs.create_tags
hub.exec.boto3.client.efs.delete_tags
hub.exec.boto3.client.efs.describe_tags
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, file_system_id: Text, tags: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     DEPRECATED - CreateTags is deprecated and not maintained. Please use the API action to create tags for EFS
    resources.  Creates or overwrites tags associated with a file system. Each tag is a key-value pair. If a tag key
    specified in the request already exists on the file system, this operation overwrites its value with the value
    provided in the request. If you add the Name tag to your file system, Amazon EFS returns it in the response to
    the DescribeFileSystems operation.  This operation requires permission for the elasticfilesystem:CreateTags
    action.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        file_system_id(Text): The ID of the file system whose tags you want to modify (String). This operation modifies the
            tags only, not the file system.
        tags(List): An array of Tag objects to add. Each Tag object is a key-value pair.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.efs.tag.present:
                - name: value
                - file_system_id: value
                - tags: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.efs.tag.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.efs.describe_tags(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.efs.create_tags(
                ctx,
                
                
                **{"FileSystemId": file_system_id, "Tags": 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.efs.describe_tags(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, file_system_id: Text, tag_keys: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     DEPRECATED - DeleteTags is deprecated and not maintained. Please use the API action to remove tags from EFS
    resources.  Deletes the specified tags from a file system. If the DeleteTags request includes a tag key that
    doesn't exist, Amazon EFS ignores it and doesn't cause an error. For more information about tags and related
    restrictions, see Tag Restrictions in the AWS Billing and Cost Management User Guide. This operation requires
    permissions for the elasticfilesystem:DeleteTags action.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        file_system_id(Text): The ID of the file system whose tags you want to delete (String).
        tag_keys(List): A list of tag keys to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.efs.tag.absent:
                - name: value
                - file_system_id: value
                - tag_keys: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.efs.tag.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.efs.describe_tags(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.efs.delete_tags(
                ctx,
                
                
                **{"FileSystemId": file_system_id, "TagKeys": tag_keys}
            )
            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.efs.describe_tags(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

