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

hub.exec.boto3.client.kinesisvideo.create_signaling_channel
hub.exec.boto3.client.kinesisvideo.delete_signaling_channel
hub.exec.boto3.client.kinesisvideo.describe_signaling_channel
hub.exec.boto3.client.kinesisvideo.list_signaling_channels
hub.exec.boto3.client.kinesisvideo.update_signaling_channel
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, channel_name: Text, channel_type: Text = None, single_master_configuration: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a signaling channel.   CreateSignalingChannel is an asynchronous operation.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        channel_name(Text): A name for the signaling channel that you are creating. It must be unique for each AWS account
            and AWS Region.
        channel_type(Text, optional): A type of the signaling channel that you are creating. Currently, SINGLE_MASTER is the only
            supported channel type. Defaults to None.
        single_master_configuration(Dict, optional): A structure containing the configuration for the SINGLE_MASTER channel type. Defaults to None.
        tags(List, optional): A set of tags (key-value pairs) that you want to associate with this channel. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.kinesisvideo.create_signaling_channel(
                ctx,
                
                
                **{"ChannelName": channel_name, "ChannelType": channel_type, "SingleMasterConfiguration": single_master_configuration, "Tags": tags}
            )
            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.kinesisvideo.describe_signaling_channel(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, channel_arn: Text, current_version: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a specified signaling channel. DeleteSignalingChannel is an asynchronous operation. If you don't specify
    the channel's current version, the most recent version is deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        channel_arn(Text): The Amazon Resource Name (ARN) of the signaling channel that you want to delete.
        current_version(Text, optional): The current version of the signaling channel that you want to delete. You can obtain the current
            version by invoking the DescribeSignalingChannel or ListSignalingChannels API operations. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.kinesisvideo.delete_signaling_channel(
                ctx,
                
                
                **{"ChannelARN": channel_arn, "CurrentVersion": current_version}
            )
            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.kinesisvideo.describe_signaling_channel(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

