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

hub.exec.boto3.client.connect.create_hours_of_operation
hub.exec.boto3.client.connect.delete_hours_of_operation
hub.exec.boto3.client.connect.describe_hours_of_operation
hub.exec.boto3.client.connect.list_hours_of_operations
hub.exec.boto3.client.connect.update_hours_of_operation
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, instance_id: Text, time_zone: Text, config: List, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    This API is in preview release for Amazon Connect and is subject to change. Creates hours of operation.

    Args:
        name(Text): The name of the hours of operation.
        instance_id(Text): The identifier of the Amazon Connect instance. You can find the instanceId in the ARN of the
            instance.
        description(Text, optional): The description of the hours of operation. Defaults to None.
        time_zone(Text): The time zone of the hours of operation.
        config(List): Configuration information for the hours of operation: day, start time, and end time.
        tags(Dict, optional): One or more tags. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.connect.create_hours_of_operation(
                ctx,
                
                
                **{"Name": name, "InstanceId": instance_id, "Description": description, "TimeZone": time_zone, "Config": 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.connect.describe_hours_of_operation(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, instance_id: Text, hours_of_operation_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    This API is in preview release for Amazon Connect and is subject to change. Deletes an hours of operation.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        instance_id(Text): The identifier of the Amazon Connect instance. You can find the instanceId in the ARN of the
            instance.
        hours_of_operation_id(Text): The identifier for the hours of operation.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.connect.delete_hours_of_operation(
                ctx,
                
                
                **{"InstanceId": instance_id, "HoursOfOperationId": hours_of_operation_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.connect.describe_hours_of_operation(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

