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

hub.exec.boto3.client.proton.create_environment_template
hub.exec.boto3.client.proton.delete_environment_template
hub.exec.boto3.client.proton.get_environment_template
hub.exec.boto3.client.proton.list_environment_templates
hub.exec.boto3.client.proton.update_environment_template
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, description: Text = None, display_name: Text = None, encryption_key: Text = None, provisioning: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create an environment template for AWS Proton. For more information, see Environment Templates in the AWS Proton
    Administrator Guide. You can create an environment template in one of the two following ways:   Register and
    publish a standard environment template that instructs AWS Proton to deploy and manage environment
    infrastructure.   Register and publish a customer managed environment template that connects AWS Proton to your
    existing provisioned infrastructure that you manage. AWS Proton doesn't manage your existing provisioned
    infrastructure. To create an environment template for customer provisioned and managed infrastructure, include
    the provisioning parameter and set the value to CUSTOMER_MANAGED. For more information, see Register and publish
    an environment template in the AWS Proton Administrator Guide.

    Args:
        name(Text): The name of the environment template.
        description(Text, optional): A description of the environment template. Defaults to None.
        display_name(Text, optional): The environment template name as displayed in the developer interface. Defaults to None.
        encryption_key(Text, optional): A customer provided encryption key that AWS Proton uses to encrypt data. Defaults to None.
        provisioning(Text, optional): When included, indicates that the environment template is for customer provisioned and managed
            infrastructure. Defaults to None.
        tags(List, optional): Create tags for your environment template. For more information, see AWS Proton resources and
            tagging in the AWS Proton Administrator Guide or AWS Proton User Guide. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.proton.create_environment_template(
                ctx,
                
                
                **{"Name": name, "description": description, "displayName": display_name, "encryptionKey": encryption_key, "provisioning": provisioning, "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.proton.get_environment_template(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    If no other major or minor versions of an environment template exist, delete the environment template.

    Args:
        name(Text): The name of the environment template to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

