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

hub.exec.boto3.client.alexaforbusiness.create_profile
hub.exec.boto3.client.alexaforbusiness.delete_profile
hub.exec.boto3.client.alexaforbusiness.get_profile
hub.exec.boto3.client.alexaforbusiness.search_profiles
hub.exec.boto3.client.alexaforbusiness.update_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, profile_name: Text, timezone: Text, address: Text, distance_unit: Text, temperature_unit: Text, wake_word: Text, locale: Text = None, client_request_token: Text = None, setup_mode_disabled: bool = None, max_volume_limit: int = None, pstn_enabled: bool = None, data_retention_opt_in: bool = None, meeting_room_configuration: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new room profile with the specified details.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        profile_name(Text): The name of a room profile.
        timezone(Text): The time zone used by a room profile.
        address(Text): The valid address for the room.
        distance_unit(Text): The distance unit to be used by devices in the profile.
        temperature_unit(Text): The temperature unit to be used by devices in the profile.
        wake_word(Text): A wake word for Alexa, Echo, Amazon, or a computer.
        locale(Text, optional): The locale of the room profile. (This is currently only available to a limited preview
            audience.). Defaults to None.
        client_request_token(Text, optional): The user-specified token that is used during the creation of a profile. Defaults to None.
        setup_mode_disabled(bool, optional): Whether room profile setup is enabled. Defaults to None.
        max_volume_limit(int, optional): The maximum volume limit for a room profile. Defaults to None.
        pstn_enabled(bool, optional): Whether PSTN calling is enabled. Defaults to None.
        data_retention_opt_in(bool, optional): Whether data retention of the profile is enabled. Defaults to None.
        meeting_room_configuration(Dict, optional): The meeting room settings of a room profile. Defaults to None.
        tags(List, optional): The tags for the profile. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.alexaforbusiness.profile.present:
                - name: value
                - profile_name: value
                - timezone: value
                - address: value
                - distance_unit: value
                - temperature_unit: value
                - wake_word: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.alexaforbusiness.profile.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_profile(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.alexaforbusiness.create_profile(
                ctx,
                
                
                **{"ProfileName": profile_name, "Timezone": timezone, "Address": address, "DistanceUnit": distance_unit, "TemperatureUnit": temperature_unit, "WakeWord": wake_word, "Locale": locale, "ClientRequestToken": client_request_token, "SetupModeDisabled": setup_mode_disabled, "MaxVolumeLimit": max_volume_limit, "PSTNEnabled": pstn_enabled, "DataRetentionOptIn": data_retention_opt_in, "MeetingRoomConfiguration": meeting_room_configuration, "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_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

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

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

