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

hub.exec.boto3.client.storagegateway.assign_tape_pool
hub.exec.boto3.client.storagegateway.create_tape_pool
hub.exec.boto3.client.storagegateway.delete_tape_pool
hub.exec.boto3.client.storagegateway.list_tape_pools
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, pool_name: Text, storage_class: Text, retention_lock_type: Text = None, retention_lock_time_in_days: int = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new custom tape pool. You can use custom tape pool to enable tape retention lock on tapes that are
    archived in the custom pool.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        pool_name(Text): The name of the new custom tape pool.
        storage_class(Text): The storage class that is associated with the new custom pool. When you use your backup
            application to eject the tape, the tape is archived directly into the storage class (S3 Glacier
            or S3 Glacier Deep Archive) that corresponds to the pool.
        retention_lock_type(Text, optional): Tape retention lock can be configured in two modes. When configured in governance mode, accounts
            with specific IAM permissions are authorized to remove the tape retention lock from archived
            virtual tapes. When configured in compliance mode, the tape retention lock cannot be removed by
            any user, including the root account. Defaults to None.
        retention_lock_time_in_days(int, optional): Tape retention lock time is set in days. Tape retention lock can be enabled for up to 100 years
            (36,500 days). Defaults to None.
        tags(List, optional): A list of up to 50 tags that can be assigned to tape pool. Each tag is a key-value pair.  Valid
            characters for key and value are letters, spaces, and numbers representable in UTF-8 format, and
            the following special characters: + - = . _ : / @. The maximum length of a tag's key is 128
            characters, and the maximum length for a tag's value is 256. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.storagegateway.tape_pool.present:
                - name: value
                - pool_name: value
                - storage_class: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.storagegateway.tape_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.storagegateway.list_tape_pools(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.storagegateway.create_tape_pool(
                ctx,
                
                
                **{"PoolName": pool_name, "StorageClass": storage_class, "RetentionLockType": retention_lock_type, "RetentionLockTimeInDays": retention_lock_time_in_days, "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.storagegateway.list_tape_pools(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, pool_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete a custom tape pool. A custom tape pool can only be deleted if there are no tapes in the pool and if there
    are no automatic tape creation policies that reference the custom tape pool.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        pool_arn(Text): The Amazon Resource Name (ARN) of the custom tape pool to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.storagegateway.tape_pool.absent:
                - name: value
                - pool_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.storagegateway.tape_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.storagegateway.list_tape_pools(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.storagegateway.delete_tape_pool(
                ctx,
                
                
                **{"PoolARN": pool_arn}
            )
            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.storagegateway.list_tape_pools(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

