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

hub.exec.boto3.client.resource_groups.create_group
hub.exec.boto3.client.resource_groups.delete_group
hub.exec.boto3.client.resource_groups.get_group
hub.exec.boto3.client.resource_groups.list_groups
hub.exec.boto3.client.resource_groups.update_group
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, description: Text = None, resource_query: Dict = None, tags: Dict = None, configuration: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a resource group with the specified name and description. You can optionally include a resource query,
    or a service configuration. For more information about constructing a resource query, see Create a tag-based
    group in Resource Groups. For more information about service configurations, see Service configurations for
    resource groups.  Minimum permissions  To run this command, you must have the following permissions:
    resource-groups:CreateGroup

    Args:
        name(Text): The name of the group, which is the identifier of the group in other operations. You can't
            change the name of a resource group after you create it. A resource group name can consist of
            letters, numbers, hyphens, periods, and underscores. The name cannot start with AWS or aws;
            these are reserved. A resource group name must be unique within each AWS Region in your AWS
            account.
        description(Text, optional): The description of the resource group. Descriptions can consist of letters, numbers, hyphens,
            underscores, periods, and spaces. Defaults to None.
        resource_query(Dict, optional): The resource query that determines which AWS resources are members of this group. For more
            information about resource queries, see Create a tag-based group in Resource Groups.   A
            resource group can contain either a ResourceQuery or a Configuration, but not both. Defaults to None.
        tags(Dict, optional): The tags to add to the group. A tag is key-value pair string. Defaults to None.
        configuration(List, optional): A configuration associates the resource group with an AWS service and specifies how the service
            can interact with the resources in the group. A configuration is an array of
            GroupConfigurationItem elements. For details about the syntax of service configurations, see
            Service configurations for resource groups.  A resource group can contain either a Configuration
            or a ResourceQuery, but not both. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.resource_groups.create_group(
                ctx,
                
                
                **{"Name": name, "Description": description, "ResourceQuery": resource_query, "Tags": tags, "Configuration": configuration}
            )
            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.resource_groups.get_group(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, group_name: Text = None, group: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified resource group. Deleting a resource group does not delete any resources that are members
    of the group; it only deletes the group structure.  Minimum permissions  To run this command, you must have the
    following permissions:    resource-groups:DeleteGroup

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        group_name(Text, optional): Deprecated - don't use this parameter. Use Group instead. Defaults to None.
        group(Text, optional): The name or the ARN of the resource group to delete. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

