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

hub.exec.boto3.client.codebuild.create_report_group
hub.exec.boto3.client.codebuild.delete_report_group
hub.exec.boto3.client.codebuild.list_report_groups
hub.exec.boto3.client.codebuild.update_report_group
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, type_: Text, export_config: Dict, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a report group. A report group contains a collection of reports.

    Args:
        name(Text):  The name of the report group.
        type_(Text):  The type of report group.
        export_config(Dict):  A ReportExportConfig object that contains information about where the report group test results
            are exported.
        tags(List, optional):  A list of tag key and value pairs associated with this report group.  These tags are available
            for use by Amazon Web Services services that support CodeBuild report group tags. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.codebuild.report_group.present:
                - name: value
                - type_: value
                - export_config: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.codebuild.report_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.codebuild.list_report_groups(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.codebuild.create_report_group(
                ctx,
                
                
                **{"Name": name, "type": type_, "exportConfig": export_config, "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.codebuild.list_report_groups(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, arn: Text, delete_reports: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a report group. Before you delete a report group, you must delete its reports.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        arn(Text): The ARN of the report group to delete.
        delete_reports(bool, optional): If true, deletes any reports that belong to a report group before deleting the report group.  If
            false, you must delete any reports in the report group. Use ListReportsForReportGroup to get the
            reports in a report group. Use DeleteReport to delete the reports. If you call DeleteReportGroup
            for a report group that contains one or more reports, an exception is thrown. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

