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

hub.exec.boto3.client.chime.create_media_capture_pipeline
hub.exec.boto3.client.chime.delete_media_capture_pipeline
hub.exec.boto3.client.chime.get_media_capture_pipeline
hub.exec.boto3.client.chime.list_media_capture_pipelines
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, source_type: Text, source_arn: Text, sink_type: Text, sink_arn: Text, client_request_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a media capture pipeline.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        source_type(Text): Source type from which the media artifacts will be captured. A Chime SDK Meeting is the only
            supported source.
        source_arn(Text): ARN of the source from which the media artifacts are captured.
        sink_type(Text): Destination type to which the media artifacts are saved. You must use an S3 bucket.
        sink_arn(Text): The ARN of the sink type.
        client_request_token(Text, optional): The token assigned to the client making the pipeline request. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.create_media_capture_pipeline(
                ctx,
                
                
                **{"SourceType": source_type, "SourceArn": source_arn, "SinkType": sink_type, "SinkArn": sink_arn, "ClientRequestToken": client_request_token}
            )
            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_media_capture_pipeline(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, media_pipeline_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the media capture pipeline.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        media_pipeline_id(Text): The ID of the media capture pipeline being deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

