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

hub.exec.boto3.client.alexaforbusiness.create_business_report_schedule
hub.exec.boto3.client.alexaforbusiness.delete_business_report_schedule
hub.exec.boto3.client.alexaforbusiness.list_business_report_schedules
hub.exec.boto3.client.alexaforbusiness.update_business_report_schedule
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, format_: Text, content_range: Dict, schedule_name: Text = None, s3_bucket_name: Text = None, s3_key_prefix: Text = None, recurrence: Dict = None, client_request_token: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a recurring schedule for usage reports to deliver to the specified S3 location with a specified daily or
    weekly interval.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        schedule_name(Text, optional): The name identifier of the schedule. Defaults to None.
        s3_bucket_name(Text, optional): The S3 bucket name of the output reports. If this isn't specified, the report can be retrieved
            from a download link by calling ListBusinessReportSchedule. Defaults to None.
        s3_key_prefix(Text, optional): The S3 key where the report is delivered. Defaults to None.
        format_(Text): The format of the generated report (individual CSV files or zipped files of individual files).
        content_range(Dict): The content range of the reports.
        recurrence(Dict, optional): The recurrence of the reports. If this isn't specified, the report will only be delivered one
            time when the API is called. Defaults to None.
        client_request_token(Text, optional): The client request token. Defaults to None.
        tags(List, optional): The tags for the business report schedule. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.alexaforbusiness.create_business_report_schedule(
                ctx,
                
                
                **{"ScheduleName": schedule_name, "S3BucketName": s3_bucket_name, "S3KeyPrefix": s3_key_prefix, "Format": format_, "ContentRange": content_range, "Recurrence": recurrence, "ClientRequestToken": client_request_token, "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.alexaforbusiness.list_business_report_schedules(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, schedule_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the recurring report delivery schedule with the specified schedule ARN.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        schedule_arn(Text): The ARN of the business report schedule.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

