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

hub.exec.boto3.client.elastictranscoder.create_preset
hub.exec.boto3.client.elastictranscoder.delete_preset
hub.exec.boto3.client.elastictranscoder.list_presets
hub.exec.boto3.client.elastictranscoder.read_preset
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, container: Text, description: Text = None, video: Dict = None, audio: Dict = None, thumbnails: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    The CreatePreset operation creates a preset with settings that you specify.  Elastic Transcoder checks the
    CreatePreset settings to ensure that they meet Elastic Transcoder requirements and to determine whether they
    comply with H.264 standards. If your settings are not valid for Elastic Transcoder, Elastic Transcoder returns
    an HTTP 400 response (ValidationException) and does not create the preset. If the settings are valid for Elastic
    Transcoder but aren't strictly compliant with the H.264 standard, Elastic Transcoder creates the preset and
    returns a warning message in the response. This helps you determine whether your settings comply with the H.264
    standard while giving you greater flexibility with respect to the video that Elastic Transcoder produces.
    Elastic Transcoder uses the H.264 video-compression format. For more information, see the International
    Telecommunication Union publication Recommendation ITU-T H.264: Advanced video coding for generic audiovisual
    services.

    Args:
        name(Text): The name of the preset. We recommend that the name be unique within the AWS account, but
            uniqueness is not enforced.
        description(Text, optional): A description of the preset. Defaults to None.
        container(Text): The container type for the output file. Valid values include flac, flv, fmp4, gif, mp3, mp4,
            mpg, mxf, oga, ogg, ts, and webm.
        video(Dict, optional): A section of the request body that specifies the video parameters. Defaults to None.
        audio(Dict, optional): A section of the request body that specifies the audio parameters. Defaults to None.
        thumbnails(Dict, optional): A section of the request body that specifies the thumbnail parameters, if any. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.elastictranscoder.create_preset(
                ctx,
                
                
                **{"Name": name, "Description": description, "Container": container, "Video": video, "Audio": audio, "Thumbnails": thumbnails}
            )
            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.elastictranscoder.list_presets(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, id_: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    The DeletePreset operation removes a preset that you've added in an AWS region.  You can't delete the default
    presets that are included with Elastic Transcoder.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        id_(Text): The identifier of the preset for which you want to get detailed information.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

