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

hub.exec.boto3.client.medialive.create_channel
hub.exec.boto3.client.medialive.delete_channel
hub.exec.boto3.client.medialive.describe_channel
hub.exec.boto3.client.medialive.list_channels
hub.exec.boto3.client.medialive.start_channel
hub.exec.boto3.client.medialive.stop_channel
hub.exec.boto3.client.medialive.update_channel
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text = None, cdi_input_specification: Dict = None, channel_class: Text = None, destinations: List = None, encoder_settings: Dict = None, input_attachments: List = None, input_specification: Dict = None, log_level: Text = None, request_id: Text = None, reserved: Text = None, role_arn: Text = None, tags: Dict = None, vpc: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new channel

    Args:
        name(Text, optional): Name of channel. Defaults to None.
        cdi_input_specification(Dict, optional): Specification of CDI inputs for this channel. Defaults to None.
        channel_class(Text, optional): The class for this channel. STANDARD for a channel with two pipelines or SINGLE_PIPELINE for a
            channel with one pipeline. Defaults to None.
        destinations(List, optional): Placeholder documentation for __listOfOutputDestination. Defaults to None.
        encoder_settings(Dict, optional): Encoder Settings. Defaults to None.
        input_attachments(List, optional): List of input attachments for channel. Defaults to None.
        input_specification(Dict, optional): Specification of network and file inputs for this channel. Defaults to None.
        log_level(Text, optional): The log level to write to CloudWatch Logs. Defaults to None.
        request_id(Text, optional): Unique request ID to be specified. This is needed to prevent retries from creating multiple
            resources. Defaults to None.
        reserved(Text, optional): Deprecated field that's only usable by whitelisted customers. Defaults to None.
        role_arn(Text, optional): An optional Amazon Resource Name (ARN) of the role to assume when running the Channel. Defaults to None.
        tags(Dict, optional): A collection of key-value pairs. Defaults to None.
        vpc(Dict, optional): Settings for VPC output. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.medialive.create_channel(
                ctx,
                
                
                **{"Name": name, "CdiInputSpecification": cdi_input_specification, "ChannelClass": channel_class, "Destinations": destinations, "EncoderSettings": encoder_settings, "InputAttachments": input_attachments, "InputSpecification": input_specification, "LogLevel": log_level, "RequestId": request_id, "Reserved": reserved, "RoleArn": role_arn, "Tags": tags, "Vpc": vpc}
            )
            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.medialive.describe_channel(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, channel_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Starts deletion of channel. The associated outputs are also deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        channel_id(Text): Unique ID of the channel.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

