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

hub.exec.boto3.client.alexaforbusiness.create_room
hub.exec.boto3.client.alexaforbusiness.delete_room
hub.exec.boto3.client.alexaforbusiness.get_room
hub.exec.boto3.client.alexaforbusiness.resolve_room
hub.exec.boto3.client.alexaforbusiness.search_rooms
hub.exec.boto3.client.alexaforbusiness.update_room
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, room_name: Text, description: Text = None, profile_arn: Text = None, provider_calendar_id: Text = None, client_request_token: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a room with the specified details.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        room_name(Text): The name for the room.
        description(Text, optional): The description for the room. Defaults to None.
        profile_arn(Text, optional): The profile ARN for the room. This is required. Defaults to None.
        provider_calendar_id(Text, optional): The calendar ARN for the room. Defaults to None.
        client_request_token(Text, optional): A unique, user-specified identifier for this request that ensures idempotency. Defaults to None.
        tags(List, optional): The tags for the room. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.alexaforbusiness.create_room(
                ctx,
                
                
                **{"RoomName": room_name, "Description": description, "ProfileArn": profile_arn, "ProviderCalendarId": provider_calendar_id, "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.get_room(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, room_arn: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a room by the room ARN.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        room_arn(Text, optional): The ARN of the room to delete. Required. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

