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

hub.exec.boto3.client.s3.delete_bucket_intelligent_tiering_configuration
hub.exec.boto3.client.s3.get_bucket_intelligent_tiering_configuration
hub.exec.boto3.client.s3.list_bucket_intelligent_tiering_configurations
hub.exec.boto3.client.s3.put_bucket_intelligent_tiering_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bucket: Text, id_: Text, intelligent_tiering_configuration: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Puts a S3 Intelligent-Tiering configuration to the specified bucket. You can have up to 1,000 S3 Intelligent-
    Tiering configurations per bucket. The S3 Intelligent-Tiering storage class is designed to optimize storage
    costs by automatically moving data to the most cost-effective storage access tier, without additional
    operational overhead. S3 Intelligent-Tiering delivers automatic cost savings by moving data between access
    tiers, when access patterns change. The S3 Intelligent-Tiering storage class is suitable for objects larger than
    128 KB that you plan to store for at least 30 days. If the size of an object is less than 128 KB, it is not
    eligible for auto-tiering. Smaller objects can be stored, but they are always charged at the frequent access
    tier rates in the S3 Intelligent-Tiering storage class.  If you delete an object before the end of the 30-day
    minimum storage duration period, you are charged for 30 days. For more information, see Storage class for
    automatically optimizing frequently and infrequently accessed objects. Operations related to
    PutBucketIntelligentTieringConfiguration include:     DeleteBucketIntelligentTieringConfiguration
    GetBucketIntelligentTieringConfiguration     ListBucketIntelligentTieringConfigurations     You only need S3
    Intelligent-Tiering enabled on a bucket if you want to automatically move objects stored in the S3 Intelligent-
    Tiering storage class to the Archive Access or Deep Archive Access tier.   Special Errors     HTTP 400 Bad
    Request Error     Code: InvalidArgument    Cause: Invalid Argument      HTTP 400 Bad Request Error     Code:
    TooManyConfigurations    Cause: You are attempting to create a new configuration but have already reached the
    1,000-configuration limit.       HTTP 403 Forbidden Error     Code: AccessDenied    Cause: You are not the owner
    of the specified bucket, or you do not have the s3:PutIntelligentTieringConfiguration bucket permission to set
    the configuration on the bucket.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bucket(Text): The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.
        id_(Text): The ID used to identify the S3 Intelligent-Tiering configuration.
        intelligent_tiering_configuration(Dict): Container for S3 Intelligent-Tiering configuration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.s3.bucket_intelligent_tiering_configuration.present:
                - name: value
                - bucket: value
                - id_: value
                - intelligent_tiering_configuration: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.s3.bucket_intelligent_tiering_configuration.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.s3.get_bucket_intelligent_tiering_configuration(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.s3.put_bucket_intelligent_tiering_configuration(
                ctx,
                
                
                **{"Bucket": bucket, "Id": id_, "IntelligentTieringConfiguration": intelligent_tiering_configuration}
            )
            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.s3.get_bucket_intelligent_tiering_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bucket: Text, id_: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the S3 Intelligent-Tiering configuration from the specified bucket. The S3 Intelligent-Tiering storage
    class is designed to optimize storage costs by automatically moving data to the most cost-effective storage
    access tier, without additional operational overhead. S3 Intelligent-Tiering delivers automatic cost savings by
    moving data between access tiers, when access patterns change. The S3 Intelligent-Tiering storage class is
    suitable for objects larger than 128 KB that you plan to store for at least 30 days. If the size of an object is
    less than 128 KB, it is not eligible for auto-tiering. Smaller objects can be stored, but they are always
    charged at the frequent access tier rates in the S3 Intelligent-Tiering storage class.  If you delete an object
    before the end of the 30-day minimum storage duration period, you are charged for 30 days. For more information,
    see Storage class for automatically optimizing frequently and infrequently accessed objects. Operations related
    to DeleteBucketIntelligentTieringConfiguration include:     GetBucketIntelligentTieringConfiguration
    PutBucketIntelligentTieringConfiguration     ListBucketIntelligentTieringConfigurations

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bucket(Text): The name of the Amazon S3 bucket whose configuration you want to modify or retrieve.
        id_(Text): The ID used to identify the S3 Intelligent-Tiering configuration.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

