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

hub.exec.boto3.client.ec2.describe_fast_snapshot_restores
hub.exec.boto3.client.ec2.disable_fast_snapshot_restores
hub.exec.boto3.client.ec2.enable_fast_snapshot_restores
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, availability_zones: List, source_snapshot_ids: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Enables fast snapshot restores for the specified snapshots in the specified Availability Zones. You get the full
    benefit of fast snapshot restores after they enter the enabled state. To get the current state of fast snapshot
    restores, use DescribeFastSnapshotRestores. To disable fast snapshot restores, use DisableFastSnapshotRestores.
    For more information, see Amazon EBS fast snapshot restore in the Amazon Elastic Compute Cloud User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        availability_zones(List): One or more Availability Zones. For example, us-east-2a.
        source_snapshot_ids(List): The IDs of one or more snapshots. For example, snap-1234567890abcdef0. You can specify a
            snapshot that was shared with you from another Amazon Web Services account.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.ec2.fast_snapshot_restore.present:
                - name: value
                - availability_zones: value
                - source_snapshot_ids: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ec2.fast_snapshot_restore.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.ec2.describe_fast_snapshot_restores(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.enable_fast_snapshot_restores(
                ctx,
                DryRun=ctx.test,
                
                **{"AvailabilityZones": availability_zones, "SourceSnapshotIds": source_snapshot_ids}
            )
            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.ec2.describe_fast_snapshot_restores(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, availability_zones: List, source_snapshot_ids: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Disables fast snapshot restores for the specified snapshots in the specified Availability Zones.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        availability_zones(List): One or more Availability Zones. For example, us-east-2a.
        source_snapshot_ids(List): The IDs of one or more snapshots. For example, snap-1234567890abcdef0.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.ec2.fast_snapshot_restore.absent:
                - name: value
                - availability_zones: value
                - source_snapshot_ids: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ec2.fast_snapshot_restore.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.ec2.describe_fast_snapshot_restores(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.disable_fast_snapshot_restores(
                ctx,
                DryRun=ctx.test,
                
                **{"AvailabilityZones": availability_zones, "SourceSnapshotIds": source_snapshot_ids}
            )
            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.ec2.describe_fast_snapshot_restores(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

