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

hub.exec.boto3.client.ec2.disable_ebs_encryption_by_default
hub.exec.boto3.client.ec2.enable_ebs_encryption_by_default
hub.exec.boto3.client.ec2.get_ebs_encryption_by_default
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Enables EBS encryption by default for your account in the current Region. After you enable encryption by
    default, the EBS volumes that you create are always encrypted, either using the default KMS key or the KMS key
    that you specified when you created each volume. For more information, see Amazon EBS encryption in the Amazon
    Elastic Compute Cloud User Guide. You can specify the default KMS key for encryption by default using
    ModifyEbsDefaultKmsKeyId or ResetEbsDefaultKmsKeyId. Enabling encryption by default has no effect on the
    encryption status of your existing volumes. After you enable encryption by default, you can no longer launch
    instances using instance types that do not support encryption. For more information, see Supported instance
    types.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Disables EBS encryption by default for your account in the current Region. After you disable encryption by
    default, you can still create encrypted volumes by enabling encryption when you create each volume. Disabling
    encryption by default does not change the encryption status of your existing volumes. For more information, see
    Amazon EBS encryption in the Amazon Elastic Compute Cloud User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

