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

hub.exec.boto3.client.chime.delete_voice_connector_emergency_calling_configuration
hub.exec.boto3.client.chime.get_voice_connector_emergency_calling_configuration
hub.exec.boto3.client.chime.put_voice_connector_emergency_calling_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, voice_connector_id: Text, emergency_calling_configuration: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Puts emergency calling configuration details to the specified Amazon Chime Voice Connector, such as emergency
    phone numbers and calling countries. Origination and termination settings must be enabled for the Amazon Chime
    Voice Connector before emergency calling can be configured.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        voice_connector_id(Text): The Amazon Chime Voice Connector ID.
        emergency_calling_configuration(Dict): The emergency calling configuration details.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, voice_connector_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the emergency calling configuration details 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.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

