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

hub.exec.boto3.client.lambda_.delete_function_concurrency
hub.exec.boto3.client.lambda_.get_function_concurrency
hub.exec.boto3.client.lambda_.put_function_concurrency
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, function_name: Text, reserved_concurrent_executions: int)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Sets the maximum number of simultaneous executions for a function, and reserves capacity for that concurrency
    level. Concurrency settings apply to the function as a whole, including all published versions and the
    unpublished version. Reserving concurrency both ensures that your function has capacity to process the specified
    number of events simultaneously, and prevents it from scaling beyond that level. Use GetFunction to see the
    current setting for a function. Use GetAccountSettings to see your Regional concurrency limit. You can reserve
    concurrency for as many functions as you like, as long as you leave at least 100 simultaneous executions
    unreserved for functions that aren't configured with a per-function limit. For more information, see Managing
    Concurrency.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        function_name(Text): The name of the Lambda function.  Name formats     Function name - my-function.    Function ARN
            - arn:aws:lambda:us-west-2:123456789012:function:my-function.    Partial ARN -
            123456789012:function:my-function.   The length constraint applies only to the full ARN. If you
            specify only the function name, it is limited to 64 characters in length.
        reserved_concurrent_executions(int): The number of simultaneous executions to reserve for the function.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lambda_.function_concurrency.present:
                - name: value
                - function_name: value
                - reserved_concurrent_executions: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lambda_.function_concurrency.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.lambda_.get_function_concurrency(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lambda_.put_function_concurrency(
                ctx,
                
                
                **{"FunctionName": function_name, "ReservedConcurrentExecutions": reserved_concurrent_executions}
            )
            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.lambda_.get_function_concurrency(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, function_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes a concurrent execution limit from a function.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        function_name(Text): The name of the Lambda function.  Name formats     Function name - my-function.    Function ARN
            - arn:aws:lambda:us-west-2:123456789012:function:my-function.    Partial ARN -
            123456789012:function:my-function.   The length constraint applies only to the full ARN. If you
            specify only the function name, it is limited to 64 characters in length.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

