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

hub.exec.boto3.client.config.delete_configuration_recorder
hub.exec.boto3.client.config.describe_configuration_recorders
hub.exec.boto3.client.config.put_configuration_recorder
hub.exec.boto3.client.config.start_configuration_recorder
hub.exec.boto3.client.config.stop_configuration_recorder
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, configuration_recorder: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new configuration recorder to record the selected resource configurations. You can use this action to
    change the role roleARN or the recordingGroup of an existing recorder. To change the role, call the action on
    the existing configuration recorder and specify a role.  Currently, you can specify only one configuration
    recorder per region in your account. If ConfigurationRecorder does not have the recordingGroup parameter
    specified, the default is to record all supported resource types.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        configuration_recorder(Dict): The configuration recorder object that records each configuration change made to the resources.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.config.put_configuration_recorder(
                ctx,
                
                
                **{"ConfigurationRecorder": configuration_recorder}
            )
            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.config.describe_configuration_recorders(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, configuration_recorder_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the configuration recorder. After the configuration recorder is deleted, AWS Config will not record
    resource configuration changes until you create a new configuration recorder. This action does not delete the
    configuration information that was previously recorded. You will be able to access the previously recorded
    information by using the GetResourceConfigHistory action, but you will not be able to access this information in
    the AWS Config console until you create a new configuration recorder.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        configuration_recorder_name(Text): The name of the configuration recorder to be deleted. You can retrieve the name of your
            configuration recorder by using the DescribeConfigurationRecorders action.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

