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

hub.exec.boto3.client.s3control.delete_job_tagging
hub.exec.boto3.client.s3control.get_job_tagging
hub.exec.boto3.client.s3control.put_job_tagging
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, account_id: Text, job_id: Text, tags: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Sets the supplied tag-set on an S3 Batch Operations job. A tag is a key-value pair. You can associate S3 Batch
    Operations tags with any job by sending a PUT request against the tagging subresource that is associated with
    the job. To modify the existing tag set, you can either replace the existing tag set entirely, or make changes
    within the existing tag set by retrieving the existing tag set using GetJobTagging, modify that tag set, and use
    this action to replace the tag set with the one you modified. For more information, see Controlling access and
    labeling jobs using tags in the Amazon S3 User Guide.      If you send this request with an empty tag set,
    Amazon S3 deletes the existing tag set on the Batch Operations job. If you use this method, you are charged for
    a Tier 1 Request (PUT). For more information, see Amazon S3 pricing.   For deleting existing tags for your Batch
    Operations job, a DeleteJobTagging request is preferred because it achieves the same result without incurring
    charges.   A few things to consider about using tags:   Amazon S3 limits the maximum number of tags to 50 tags
    per job.   You can associate up to 50 tags with a job as long as they have unique tag keys.   A tag key can be
    up to 128 Unicode characters in length, and tag values can be up to 256 Unicode characters in length.   The key
    and values are case sensitive.   For tagging-related restrictions related to characters and encodings, see User-
    Defined Tag Restrictions in the Billing and Cost Management User Guide.       To use this action, you must have
    permission to perform the s3:PutJobTagging action. Related actions include:    CreatJob     GetJobTagging
    DeleteJobTagging

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        account_id(Text): The account ID associated with the S3 Batch Operations job.
        job_id(Text): The ID for the S3 Batch Operations job whose tags you want to replace.
        tags(List): The set of tags to associate with the S3 Batch Operations job.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.s3control.job_tagging.present:
                - name: value
                - account_id: value
                - job_id: value
                - tags: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.s3control.job_tagging.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.s3control.get_job_tagging(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.s3control.put_job_tagging(
                ctx,
                
                
                **{"AccountId": account_id, "JobId": job_id, "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.s3control.get_job_tagging(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, account_id: Text, job_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes the entire tag set from the specified S3 Batch Operations job. To use this operation, you must have
    permission to perform the s3:DeleteJobTagging action. For more information, see Controlling access and labeling
    jobs using tags in the Amazon S3 User Guide.  Related actions include:    CreateJob     GetJobTagging
    PutJobTagging

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        account_id(Text): The account ID associated with the S3 Batch Operations job.
        job_id(Text): The ID for the S3 Batch Operations job whose tags you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

