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

hub.exec.boto3.client.iot.create_dimension
hub.exec.boto3.client.iot.delete_dimension
hub.exec.boto3.client.iot.describe_dimension
hub.exec.boto3.client.iot.list_dimensions
hub.exec.boto3.client.iot.update_dimension
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, type_: Text, string_values: List, client_request_token: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a dimension that you can use to limit the scope of a metric used in a security profile for AWS IoT Device
    Defender. For example, using a TOPIC_FILTER dimension, you can narrow down the scope of the metric only to MQTT
    topics whose name match the pattern specified in the dimension.

    Args:
        name(Text): A unique identifier for the dimension. Choose something that describes the type and value to
            make it easy to remember what it does.
        type_(Text): Specifies the type of dimension. Supported types: TOPIC_FILTER.
        string_values(List): Specifies the value or list of values for the dimension. For TOPIC_FILTER dimensions, this is a
            pattern used to match the MQTT topic (for example, "admin/#").
        tags(List, optional): Metadata that can be used to manage the dimension. Defaults to None.
        client_request_token(Text): Each dimension must have a unique client request token. If you try to create a new dimension
            with the same token as a dimension that already exists, an exception occurs. If you omit this
            value, AWS SDKs will automatically generate a unique client request.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.iot.dimension.present:
                - name: value
                - type_: value
                - string_values: value
                - client_request_token: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.iot.dimension.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.iot.describe_dimension(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.iot.create_dimension(
                ctx,
                
                
                **{"Name": name, "type": type_, "stringValues": string_values, "tags": tags, "clientRequestToken": client_request_token}
            )
            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.iot.describe_dimension(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes the specified dimension from your AWS account.

    Args:
        name(Text): The unique identifier for the dimension that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

