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

hub.exec.boto3.client.location.create_route_calculator
hub.exec.boto3.client.location.delete_route_calculator
hub.exec.boto3.client.location.describe_route_calculator
hub.exec.boto3.client.location.list_route_calculators
hub.exec.boto3.client.location.update_route_calculator
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, calculator_name: Text, data_source: Text, pricing_plan: Text, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a route calculator resource in your AWS account. You can send requests to a route calculator resource to
    estimate travel time, distance, and get directions. A route calculator sources traffic and road network data
    from your chosen data provider.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        calculator_name(Text): The name of the route calculator resource.  Requirements:   Can use alphanumeric characters
            (A–Z, a–z, 0–9) , hyphens (-), periods (.), and underscores (_).   Must be a unique Route
            calculator resource name.   No spaces allowed. For example, ExampleRouteCalculator.
        data_source(Text): Specifies the data provider of traffic and road network 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 street networks and traffic coverage.    Here – For additional information
            about HERE Technologies's coverage in your region of interest, see HERE car routing coverage and
            HERE truck routing coverage.   For additional information , see Data providers on the Amazon
            Location Service Developer Guide.
        description(Text, optional): The optional description for the route calculator resource. Defaults to None.
        pricing_plan(Text): Specifies the pricing plan for your route calculator resource. For additional details and
            restrictions on each pricing plan option, see Amazon Location Service pricing.
        tags(Dict, optional): Applies one or more tags to the route calculator resource. A tag is a key-value pair helps
            manage, identify, search, and filter your resources by labelling them.   For example: { "tag1" :
            "value1", "tag2" : "value2"}   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.route_calculator.present:
                - name: value
                - calculator_name: value
                - data_source: value
                - pricing_plan: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.location.route_calculator.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_route_calculator(name)

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

async def absent(hub, ctx, name: Text, calculator_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a route calculator 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.
        calculator_name(Text): The name of the route calculator resource to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

