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

hub.exec.boto3.client.lambda_.delete_function_code_signing_config
hub.exec.boto3.client.lambda_.get_function_code_signing_config
hub.exec.boto3.client.lambda_.put_function_code_signing_config
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, code_signing_config_arn: Text, function_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Update the code signing configuration for the function. Changes to the code signing configuration take effect
    the next time a user tries to deploy a code package to the function.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        code_signing_config_arn(Text): The The Amazon Resource Name (ARN) of the code signing configuration.
        function_name(Text): The name of the Lambda function.  Name formats     Function name - MyFunction.    Function ARN -
            arn:aws:lambda:us-west-2:123456789012:function:MyFunction.    Partial ARN -
            123456789012:function:MyFunction.   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_present:
              aws_auto.lambda_.function_code_signing_config.present:
                - name: value
                - code_signing_config_arn: value
                - function_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lambda_.function_code_signing_config.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_code_signing_config(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lambda_.put_function_code_signing_config(
                ctx,
                
                
                **{"CodeSigningConfigArn": code_signing_config_arn, "FunctionName": function_name}
            )
            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_code_signing_config(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 the code signing configuration from the 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 - MyFunction.    Function ARN -
            arn:aws:lambda:us-west-2:123456789012:function:MyFunction.    Partial ARN -
            123456789012:function:MyFunction.   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_code_signing_config.absent:
                - name: value
                - function_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lambda_.function_code_signing_config.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_code_signing_config(name)

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

