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

hub.exec.boto3.client.chime.create_voice_connector
hub.exec.boto3.client.chime.delete_voice_connector
hub.exec.boto3.client.chime.get_voice_connector
hub.exec.boto3.client.chime.list_voice_connectors
hub.exec.boto3.client.chime.update_voice_connector
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, require_encryption: bool, aws_region: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an Amazon Chime Voice Connector under the administrator's AWS account. You can choose to create an
    Amazon Chime Voice Connector in a specific AWS Region.  Enabling CreateVoiceConnectorRequest$RequireEncryption
    configures your Amazon Chime Voice Connector to use TLS transport for SIP signaling and Secure RTP (SRTP) for
    media. Inbound calls use TLS transport, and unencrypted outbound calls are blocked.

    Args:
        name(Text): The name of the Amazon Chime Voice Connector.
        aws_region(Text, optional):  The AWS Region in which the Amazon Chime Voice Connector is created. Default value: us-east-1 . Defaults to None.
        require_encryption(bool): When enabled, requires encryption for the Amazon Chime Voice Connector.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.create_voice_connector(
                ctx,
                
                
                **{"Name": name, "AwsRegion": aws_region, "RequireEncryption": require_encryption}
            )
            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(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 specified Amazon Chime Voice Connector. Any phone numbers associated with the Amazon Chime Voice
    Connector must be disassociated from it before it can be deleted.

    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.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.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(name)

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

