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

hub.exec.boto3.client.apprunner.create_auto_scaling_configuration
hub.exec.boto3.client.apprunner.delete_auto_scaling_configuration
hub.exec.boto3.client.apprunner.describe_auto_scaling_configuration
hub.exec.boto3.client.apprunner.list_auto_scaling_configurations
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, auto_scaling_configuration_name: Text, max_concurrency: int = None, min_size: int = None, max_size: int = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create an AWS App Runner automatic scaling configuration resource. App Runner requires this resource when you
    create App Runner services that require non-default auto scaling settings. You can share an auto scaling
    configuration across multiple services. Create multiple revisions of a configuration by using the same
    AutoScalingConfigurationName and different AutoScalingConfigurationRevision values. When you create a service,
    you can set it to use the latest active revision of an auto scaling configuration or a specific revision.
    Configure a higher MinSize to increase the spread of your App Runner service over more Availability Zones in the
    AWS Region. The tradeoff is a higher minimal cost. Configure a lower MaxSize to control your cost. The tradeoff
    is lower responsiveness during peak demand.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        auto_scaling_configuration_name(Text): A name for the auto scaling configuration. When you use it for the first time in an AWS Region,
            App Runner creates revision number 1 of this name. When you use the same name in subsequent
            calls, App Runner creates incremental revisions of the configuration.
        max_concurrency(int, optional): The maximum number of concurrent requests that you want an instance to process. If the number of
            concurrent requests exceeds this limit, App Runner scales up your service. Default: 100. Defaults to None.
        min_size(int, optional): The minimum number of instances that App Runner provisions for your service. The service always
            has at least MinSize provisioned instances. Some of them actively serve traffic. The rest of
            them (provisioned and inactive instances) are a cost-effective compute capacity reserve and are
            ready to be quickly activated. You pay for memory usage of all the provisioned instances. You
            pay for CPU usage of only the active subset. App Runner temporarily doubles the number of
            provisioned instances during deployments, to maintain the same capacity for both old and new
            code. Default: 1. Defaults to None.
        max_size(int, optional): The maximum number of instances that your service scales up to. At most MaxSize instances
            actively serve traffic for your service. Default: 25. Defaults to None.
        tags(List, optional): A list of metadata items that you can associate with your auto scaling configuration resource. A
            tag is a key-value pair. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.apprunner.auto_scaling_configuration.present:
                - name: value
                - auto_scaling_configuration_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.apprunner.auto_scaling_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.apprunner.describe_auto_scaling_configuration(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.apprunner.create_auto_scaling_configuration(
                ctx,
                
                
                **{"AutoScalingConfigurationName": auto_scaling_configuration_name, "MaxConcurrency": max_concurrency, "MinSize": min_size, "MaxSize": max_size, "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.apprunner.describe_auto_scaling_configuration(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, auto_scaling_configuration_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete an AWS App Runner automatic scaling configuration resource. You can delete a specific revision or the
    latest active revision. You can't delete a configuration that's used by one or more App Runner services.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        auto_scaling_configuration_arn(Text): The Amazon Resource Name (ARN) of the App Runner auto scaling configuration that you want to
            delete. The ARN can be a full auto scaling configuration ARN, or a partial ARN ending with
            either .../name  or .../name/revision . If a revision isn't specified, the latest active
            revision is deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

