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

hub.exec.boto3.client.lightsail.attach_disk
hub.exec.boto3.client.lightsail.create_disk
hub.exec.boto3.client.lightsail.delete_disk
hub.exec.boto3.client.lightsail.detach_disk
hub.exec.boto3.client.lightsail.get_disks
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, disk_name: Text, availability_zone: Text, size_in_gb: int, tags: List = None, add_ons: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a block storage disk that can be attached to an Amazon Lightsail instance in the same Availability Zone
    (e.g., us-east-2a). The create disk operation supports tag-based access control via request tags. For more
    information, see the Amazon Lightsail Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        disk_name(Text): The unique Lightsail disk name (e.g., my-disk).
        availability_zone(Text): The Availability Zone where you want to create the disk (e.g., us-east-2a). Use the same
            Availability Zone as the Lightsail instance to which you want to attach the disk. Use the get
            regions operation to list the Availability Zones where Lightsail is currently available.
        size_in_gb(int): The size of the disk in GB (e.g., 32).
        tags(List, optional): The tag keys and optional values to add to the resource during create. Use the TagResource
            action to tag a resource after it's created. Defaults to None.
        add_ons(List, optional): An array of objects that represent the add-ons to enable for the new disk. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lightsail.disk.present:
                - name: value
                - disk_name: value
                - availability_zone: value
                - size_in_gb: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lightsail.disk.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.lightsail.get_disks(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lightsail.create_disk(
                ctx,
                
                
                **{"diskName": disk_name, "availabilityZone": availability_zone, "sizeInGb": size_in_gb, "tags": tags, "addOns": add_ons}
            )
            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.lightsail.get_disks(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, disk_name: Text, force_delete_add_ons: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified block storage disk. The disk must be in the available state (not attached to a Lightsail
    instance).  The disk may remain in the deleting state for several minutes.  The delete disk operation supports
    tag-based access control via resource tags applied to the resource identified by disk name. For more
    information, see the Amazon Lightsail Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        disk_name(Text): The unique name of the disk you want to delete (e.g., my-disk).
        force_delete_add_ons(bool, optional): A Boolean value to indicate whether to delete the enabled add-ons for the disk. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.lightsail.delete_disk(
                ctx,
                
                
                **{"diskName": disk_name, "forceDeleteAddOns": force_delete_add_ons}
            )
            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.lightsail.get_disks(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

