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

hub.exec.boto3.client.applicationcostprofiler.delete_report_definition
hub.exec.boto3.client.applicationcostprofiler.get_report_definition
hub.exec.boto3.client.applicationcostprofiler.list_report_definitions
hub.exec.boto3.client.applicationcostprofiler.put_report_definition
hub.exec.boto3.client.applicationcostprofiler.update_report_definition
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, report_id: Text, report_description: Text, report_frequency: Text, format_: Text, destination_s3_location: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates the report definition for a report in Application Cost Profiler.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        report_id(Text): Required. ID of the report. You can choose any valid string matching the pattern for the ID.
        report_description(Text): Required. Description of the report.
        report_frequency(Text): Required. The cadence to generate the report.
        format_(Text): Required. The format to use for the generated report.
        destination_s3_location(Dict): Required. Amazon Simple Storage Service (Amazon S3) location where Application Cost Profiler
            uploads the report.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.applicationcostprofiler.report_definition.present:
                - name: value
                - report_id: value
                - report_description: value
                - report_frequency: value
                - format_: value
                - destination_s3_location: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.applicationcostprofiler.report_definition.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.applicationcostprofiler.get_report_definition(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.applicationcostprofiler.put_report_definition(
                ctx,
                
                
                **{"reportId": report_id, "reportDescription": report_description, "reportFrequency": report_frequency, "format": format_, "destinationS3Location": destination_s3_location}
            )
            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.applicationcostprofiler.get_report_definition(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, report_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified report definition in AWS Application Cost Profiler. This stops the report from being
    generated.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        report_id(Text): Required. ID of the report to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

