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

hub.exec.boto3.client.mediaconvert.create_job_template
hub.exec.boto3.client.mediaconvert.delete_job_template
hub.exec.boto3.client.mediaconvert.get_job_template
hub.exec.boto3.client.mediaconvert.list_job_templates
hub.exec.boto3.client.mediaconvert.update_job_template
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, settings: Dict, acceleration_settings: Dict = None, category: Text = None, description: Text = None, hop_destinations: List = None, priority: int = None, queue: Text = None, status_update_interval: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new job template. For information about job templates see the User Guide at
    http://docs.aws.amazon.com/mediaconvert/latest/ug/what-is.html

    Args:
        name(Text): The name of the job template you are creating.
        acceleration_settings(Dict, optional): Accelerated transcoding can significantly speed up jobs with long, visually complex content.
            Outputs that use this feature incur pro-tier pricing. For information about feature limitations,
            see the AWS Elemental MediaConvert User Guide. Defaults to None.
        category(Text, optional): Optional. A category for the job template you are creating. Defaults to None.
        description(Text, optional): Optional. A description of the job template you are creating. Defaults to None.
        hop_destinations(List, optional): Optional. Use queue hopping to avoid overly long waits in the backlog of the queue that you
            submit your job to. Specify an alternate queue and the maximum time that your job will wait in
            the initial queue before hopping. For more information about this feature, see the AWS Elemental
            MediaConvert User Guide. Defaults to None.
        priority(int, optional): Specify the relative priority for this job. In any given queue, the service begins processing
            the job with the highest value first. When more than one job has the same priority, the service
            begins processing the job that you submitted first. If you don't specify a priority, the service
            uses the default value 0. Defaults to None.
        queue(Text, optional): Optional. The queue that jobs created from this template are assigned to. If you don't specify
            this, jobs will go to the default queue. Defaults to None.
        settings(Dict): JobTemplateSettings contains all the transcode settings saved in the template that will be
            applied to jobs created from it.
        status_update_interval(Text, optional): Specify how often MediaConvert sends STATUS_UPDATE events to Amazon CloudWatch Events. Set the
            interval, in seconds, between status updates. MediaConvert sends an update at this interval from
            the time the service begins processing your job to the time it completes the transcode or
            encounters an error. Defaults to None.
        tags(Dict, optional): The tags that you want to add to the resource. You can tag resources with a key-value pair or
            with only a key. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.mediaconvert.create_job_template(
                ctx,
                
                
                **{"Name": name, "AccelerationSettings": acceleration_settings, "Category": category, "Description": description, "HopDestinations": hop_destinations, "Priority": priority, "Queue": queue, "Settings": settings, "StatusUpdateInterval": status_update_interval, "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.mediaconvert.get_job_template(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Permanently delete a job template you have created.

    Args:
        name(Text): The name of the job template to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

