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

hub.exec.boto3.client.robomaker.create_world_template
hub.exec.boto3.client.robomaker.delete_world_template
hub.exec.boto3.client.robomaker.describe_world_template
hub.exec.boto3.client.robomaker.list_world_templates
hub.exec.boto3.client.robomaker.update_world_template
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text = None, client_request_token: Text = None, template_body: Text = None, template_location: Dict = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a world template.

    Args:
        name(Text, optional): The name of the world template. Defaults to None.
        client_request_token(Text, optional): Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Defaults to None.
        template_body(Text, optional): The world template body. Defaults to None.
        template_location(Dict, optional): The location of the world template. Defaults to None.
        tags(Dict, optional): A map that contains tag keys and tag values that are attached to the world template. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.robomaker.create_world_template(
                ctx,
                
                
                **{"Name": name, "clientRequestToken": client_request_token, "templateBody": template_body, "templateLocation": template_location, "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.robomaker.describe_world_template(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, template: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a world template.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        template(Text): The Amazon Resource Name (arn) of the world template you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

