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

hub.exec.boto3.client.location.create_geofence_collection
hub.exec.boto3.client.location.delete_geofence_collection
hub.exec.boto3.client.location.describe_geofence_collection
hub.exec.boto3.client.location.list_geofence_collections
hub.exec.boto3.client.location.update_geofence_collection
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, collection_name: Text, pricing_plan: 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 geofence collection, which manages and stores geofences.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        collection_name(Text): A custom name for the geofence collection. Requirements:   Contain only alphanumeric characters
            (A–Z, a–z, 0–9), hyphens (-), periods (.), and underscores (_).    Must be a unique geofence
            collection name.   No spaces allowed. For example, ExampleGeofenceCollection.
        description(Text, optional): An optional description for the geofence collection. 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 geofence collection. 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 geofence collection.   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 geofence collection. Your
            data won't 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 geofence collection. 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.geofence_collection.present:
                - name: value
                - collection_name: value
                - pricing_plan: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.location.geofence_collection.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_geofence_collection(name)

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

async def absent(hub, ctx, name: Text, collection_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a geofence collection from your AWS account.  This operation deletes the resource permanently. If the
    geofence collection is the target of a tracker resource, the devices will no longer be monitored.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

