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

hub.exec.boto3.client.chime.delete_voice_connector_origination
hub.exec.boto3.client.chime.get_voice_connector_origination
hub.exec.boto3.client.chime.put_voice_connector_origination
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, voice_connector_id: Text, origination: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Adds origination settings for the specified Amazon Chime Voice Connector.  If emergency calling is configured
    for the Amazon Chime Voice Connector, it must be deleted prior to turning off origination settings.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        voice_connector_id(Text): The Amazon Chime Voice Connector ID.
        origination(Dict): The origination setting details to add.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.put_voice_connector_origination(
                ctx,
                
                
                **{"VoiceConnectorId": voice_connector_id, "Origination": origination}
            )
            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_origination(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 origination settings for the specified Amazon Chime Voice Connector.  If emergency calling is
    configured for the Amazon Chime Voice Connector, it must be deleted prior to deleting the origination settings.

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

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

