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

hub.exec.boto3.client.location.create_map
hub.exec.boto3.client.location.delete_map
hub.exec.boto3.client.location.describe_map
hub.exec.boto3.client.location.list_maps
hub.exec.boto3.client.location.update_map
"""



from typing import *
import dict_tools.differ as differ


__virtualname__ = "map"
async def present(hub, ctx, name: Text, configuration: Dict, map_name: Text, pricing_plan: Text, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a map resource in your AWS account, which provides map tiles of different styles sourced from global
    location data providers.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        configuration(Dict): Specifies the map style selected from an available data provider.
        description(Text, optional): An optional description for the map resource. Defaults to None.
        map_name(Text): The name for the map resource. Requirements:   Must contain only alphanumeric characters (A–Z,
            a–z, 0–9), hyphens (-), periods (.), and underscores (_).    Must be a unique map resource name.
            No spaces allowed. For example, ExampleMap.
        pricing_plan(Text): Specifies the pricing plan for your map resource. For additional details and restrictions on
            each pricing plan option, see the Amazon Location Service pricing page.
        tags(Dict, optional): Applies one or more tags to the map resource. A tag is a key-value pair helps manage, identify,
            search, and filter your resources by labelling them. Format: "key" : "value"  Restrictions:
            Maximum 50 tags per resource   Each resource tag must be unique with a maximum of one value.
            Maximum key length: 128 Unicode characters in UTF-8   Maximum value length: 256 Unicode
            characters in UTF-8   Can use alphanumeric characters (A–Z, a–z, 0–9), and the following
            characters: + - = . _ : / @. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.location.map_.present:
                - name: value
                - configuration: value
                - map_name: value
                - pricing_plan: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.location.map.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.location.describe_map(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.location.create_map(
                ctx,
                
                
                **{"Configuration": configuration, "Description": description, "MapName": map_name, "PricingPlan": pricing_plan, "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.location.describe_map(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, map_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a map resource from your AWS account.  This operation deletes the resource permanently. If the map is
    being used in an application, the map may not render.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        map_name(Text): The name of the map resource to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

