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

hub.exec.boto3.client.chime.create_proxy_session
hub.exec.boto3.client.chime.delete_proxy_session
hub.exec.boto3.client.chime.get_proxy_session
hub.exec.boto3.client.chime.list_proxy_sessions
hub.exec.boto3.client.chime.update_proxy_session
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, voice_connector_id: Text, participant_phone_numbers: List, capabilities: List, name: Text = None, expiry_minutes: int = None, number_selection_behavior: Text = None, geo_match_level: Text = None, geo_match_params: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a proxy session on the specified Amazon Chime Voice Connector for the specified participant phone
    numbers.

    Args:
        name(Text, optional): The name of the proxy session. Defaults to None.
        voice_connector_id(Text): The Amazon Chime voice connector ID.
        participant_phone_numbers(List): The participant phone numbers.
        expiry_minutes(int, optional): The number of minutes allowed for the proxy session. Defaults to None.
        capabilities(List): The proxy session capabilities.
        number_selection_behavior(Text, optional): The preference for proxy phone number reuse, or stickiness, between the same participants across
            sessions. Defaults to None.
        geo_match_level(Text, optional): The preference for matching the country or area code of the proxy phone number with that of the
            first participant. Defaults to None.
        geo_match_params(Dict, optional): The country and area code for the proxy phone number. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.chime.proxy_session.present:
                - voice_connector_id: value
                - participant_phone_numbers: value
                - capabilities: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.chime.proxy_session.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.chime.get_proxy_session(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.create_proxy_session(
                ctx,
                
                
                **{"Name": name, "VoiceConnectorId": voice_connector_id, "ParticipantPhoneNumbers": participant_phone_numbers, "ExpiryMinutes": expiry_minutes, "Capabilities": capabilities, "NumberSelectionBehavior": number_selection_behavior, "GeoMatchLevel": geo_match_level, "GeoMatchParams": geo_match_params}
            )
            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.chime.get_proxy_session(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, voice_connector_id: Text, proxy_session_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified proxy session from the specified Amazon Chime Voice Connector.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        voice_connector_id(Text): The Amazon Chime voice connector ID.
        proxy_session_id(Text): The proxy session ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.delete_proxy_session(
                ctx,
                
                
                **{"VoiceConnectorId": voice_connector_id, "ProxySessionId": proxy_session_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.chime.get_proxy_session(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

