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

hub.exec.boto3.client.location.create_place_index
hub.exec.boto3.client.location.delete_place_index
hub.exec.boto3.client.location.describe_place_index
hub.exec.boto3.client.location.list_place_indexes
hub.exec.boto3.client.location.update_place_index
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, data_source: Text, index_name: Text, pricing_plan: Text, data_source_configuration: Dict = None, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a place index resource in your AWS account, which supports functions with geospatial data sourced from
    your chosen data provider.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        data_source(Text): Specifies the data provider of geospatial data.  This field is case-sensitive. Enter the valid
            values as shown. For example, entering HERE returns an error.  Valid values include:    Esri –
            For additional information about Esri's coverage in your region of interest, see Esri details on
            geocoding coverage.    Here – For additional information about HERE Technologies's coverage in
            your region of interest, see HERE details on goecoding coverage.  Place index resources using
            HERE Technologies as a data provider can't store results for locations in Japan. For more
            information, see the AWS Service Terms for Amazon Location Service.    For additional
            information , see Data providers on the Amazon Location Service Developer Guide.
        data_source_configuration(Dict, optional): Specifies the data storage option requesting Places. Defaults to None.
        description(Text, optional): The optional description for the place index resource. Defaults to None.
        index_name(Text): The name of the place index resource.  Requirements:   Contain only alphanumeric characters
            (A–Z, a–z, 0–9), hyphens (-), periods (.), and underscores (_).   Must be a unique place index
            resource name.   No spaces allowed. For example, ExamplePlaceIndex.
        pricing_plan(Text): Specifies the pricing plan for your place index 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 place index 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.place_index.present:
                - name: value
                - data_source: value
                - index_name: value
                - pricing_plan: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.location.place_index.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_place_index(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.location.create_place_index(
                ctx,
                
                
                **{"DataSource": data_source, "DataSourceConfiguration": data_source_configuration, "Description": description, "IndexName": index_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_place_index(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, index_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a place index resource from your AWS account.  This operation deletes the resource permanently.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

