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

hub.exec.boto3.client.codeguruprofiler.create_profiling_group
hub.exec.boto3.client.codeguruprofiler.delete_profiling_group
hub.exec.boto3.client.codeguruprofiler.describe_profiling_group
hub.exec.boto3.client.codeguruprofiler.list_profiling_groups
hub.exec.boto3.client.codeguruprofiler.update_profiling_group
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, client_token: Text, profiling_group_name: Text, agent_orchestration_config: Dict = None, compute_platform: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a profiling group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        agent_orchestration_config(Dict, optional):  Specifies whether profiling is enabled or disabled for the created profiling group. Defaults to None.
        client_token(Text):  Amazon CodeGuru Profiler uses this universally unique identifier (UUID) to prevent the
            accidental creation of duplicate profiling groups if there are failures and retries.
        compute_platform(Text, optional):  The compute platform of the profiling group. Use AWSLambda if your application runs on AWS
            Lambda. Use Default if your application runs on a compute platform that is not AWS Lambda, such
            an Amazon EC2 instance, an on-premises server, or a different platform. If not specified,
            Default is used. Defaults to None.
        profiling_group_name(Text): The name of the profiling group to create.
        tags(Dict, optional):  A list of tags to add to the created profiling group. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.codeguruprofiler.profiling_group.present:
                - name: value
                - client_token: value
                - profiling_group_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.codeguruprofiler.profiling_group.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.codeguruprofiler.describe_profiling_group(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.codeguruprofiler.create_profiling_group(
                ctx,
                
                
                **{"agentOrchestrationConfig": agent_orchestration_config, "clientToken": client_token, "computePlatform": compute_platform, "profilingGroupName": profiling_group_name, "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.codeguruprofiler.describe_profiling_group(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, profiling_group_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a profiling group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        profiling_group_name(Text): The name of the profiling group to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

