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

hub.exec.boto3.client.mediaconvert.cancel_job
hub.exec.boto3.client.mediaconvert.create_job
hub.exec.boto3.client.mediaconvert.get_job
hub.exec.boto3.client.mediaconvert.list_jobs
"""



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

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        acceleration_settings(Dict, optional): 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.
        billing_tags_source(Text, optional): Optional. Choose a tag type that AWS Billing and Cost Management will use to sort your AWS
            Elemental MediaConvert costs on any billing report that you set up. Any transcoding outputs that
            don't have an associated tag will appear in your billing report unsorted. If you don't choose a
            valid value for this field, your job outputs will appear on the billing report unsorted. Defaults to None.
        client_request_token(Text, optional): Optional. Idempotency token for CreateJob operation. 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.
        job_template(Text, optional): Optional. When you create a job, you can either specify a job template or specify the
            transcoding settings individually. Defaults to None.
        priority(int, optional): 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. When you create a job, you can specify a queue to send it to. If you don't specify,
            the job will go to the default queue. For more about queues, see the User Guide topic at
            https://docs.aws.amazon.com/mediaconvert/latest/ug/what-is.html. Defaults to None.
        role(Text): Required. The IAM role you use for creating this job. For details about permissions, see the
            User Guide topic at the User Guide at https://docs.aws.amazon.com/mediaconvert/latest/ug/iam-
            role.html.
        settings(Dict): JobSettings contains all the transcode settings for a job.
        simulate_reserved_queue(Text, optional): Optional. Enable this setting when you run a test job to estimate how many reserved transcoding
            slots (RTS) you need. When this is enabled, MediaConvert runs your job from an on-demand queue
            with similar performance to what you will see with one RTS in a reserved queue. This setting is
            disabled by default. Defaults to None.
        status_update_interval(Text, optional): 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): 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.  Use standard AWS tags on your job for automatic integration with AWS
            services and for custom integrations and workflows. Defaults to None.
        user_metadata(Dict, optional): Optional. User-defined metadata that you want to associate with an MediaConvert job. You specify
            metadata in key/value pairs.  Use only for existing integrations or workflows that rely on job
            metadata tags. Otherwise, we recommend that you use standard AWS tags. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.mediaconvert.create_job(
                ctx,
                
                
                **{"AccelerationSettings": acceleration_settings, "BillingTagsSource": billing_tags_source, "ClientRequestToken": client_request_token, "HopDestinations": hop_destinations, "JobTemplate": job_template, "Priority": priority, "Queue": queue, "Role": role, "Settings": settings, "SimulateReservedQueue": simulate_reserved_queue, "StatusUpdateInterval": status_update_interval, "Tags": tags, "UserMetadata": user_metadata}
            )
            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(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**
    
    Permanently cancel a job. Once you have canceled a job, you can't start it again.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        id_(Text): The Job ID of the job to be cancelled.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

