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

hub.exec.boto3.client.chime.create_voice_connector_group
hub.exec.boto3.client.chime.delete_voice_connector_group
hub.exec.boto3.client.chime.get_voice_connector_group
hub.exec.boto3.client.chime.list_voice_connector_groups
hub.exec.boto3.client.chime.update_voice_connector_group
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, voice_connector_items: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an Amazon Chime Voice Connector group under the administrator's AWS account. You can associate Amazon
    Chime Voice Connectors with the Amazon Chime Voice Connector group by including VoiceConnectorItems in the
    request. You can include Amazon Chime Voice Connectors from different AWS Regions in your group. This creates a
    fault tolerant mechanism for fallback in case of availability events.

    Args:
        name(Text): The name of the Amazon Chime Voice Connector group.
        voice_connector_items(List, optional): The Amazon Chime Voice Connectors to route inbound calls to. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, voice_connector_group_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified Amazon Chime Voice Connector group. Any VoiceConnectorItems and phone numbers associated
    with the group must be removed before it can be deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        voice_connector_group_id(Text): The Amazon Chime Voice Connector group ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

