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

hub.exec.boto3.client.location.create_tracker
hub.exec.boto3.client.location.delete_tracker
hub.exec.boto3.client.location.describe_tracker
hub.exec.boto3.client.location.list_trackers
hub.exec.boto3.client.location.update_tracker
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, pricing_plan: Text, tracker_name: Text, description: Text = None, kms_key_id: Text = None, pricing_plan_data_source: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a tracker resource in your AWS account, which lets you retrieve current and historical location of
    devices.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        description(Text, optional): An optional description for the tracker resource. Defaults to None.
        kms_key_id(Text, optional): A key identifier for an AWS KMS customer managed key. Enter a key ID, key ARN, alias name, or
            alias ARN. Defaults to None.
        pricing_plan(Text): Specifies the pricing plan for the tracker resource. For additional details and restrictions on
            each pricing plan option, see the Amazon Location Service pricing page.
        pricing_plan_data_source(Text, optional): Specifies the data provider for the tracker resource.   Required value for the following pricing
            plans: MobileAssetTracking | MobileAssetManagement    For more information about Data Providers,
            and Pricing plans, see the Amazon Location Service product page.  Amazon Location Service only
            uses PricingPlanDataSource to calculate billing for your tracker resource. Your data will not be
            shared with the data provider, and will remain in your AWS account or Region unless you move it.
            Valid Values: Esri | Here. Defaults to None.
        tags(Dict, optional): Applies one or more tags to the tracker 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.
        tracker_name(Text): The name for the tracker resource. Requirements:   Contain only alphanumeric characters (A-Z,
            a-z, 0-9) , hyphens (-), periods (.), and underscores (_).   Must be a unique tracker resource
            name.   No spaces allowed. For example, ExampleTracker.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.location.create_tracker(
                ctx,
                
                
                **{"Description": description, "KmsKeyId": kms_key_id, "PricingPlan": pricing_plan, "PricingPlanDataSource": pricing_plan_data_source, "Tags": tags, "TrackerName": tracker_name}
            )
            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_tracker(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, tracker_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a tracker resource from your AWS account.  This operation deletes the resource permanently. If the
    tracker resource is in use, you may encounter an error. Make sure that the target resource isn't a dependency
    for your applications.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

