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

hub.exec.boto3.client.apigateway.create_vpc_link
hub.exec.boto3.client.apigateway.delete_vpc_link
hub.exec.boto3.client.apigateway.get_vpc_links
hub.exec.boto3.client.apigateway.update_vpc_link
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, target_arns: List, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a VPC link, under the caller's account in a selected region, in an asynchronous operation that typically
    takes 2-4 minutes to complete and become operational. The caller must have permissions to create and update VPC
    Endpoint services.

    Args:
        name(Text): [Required] The name used to label and identify the VPC link.
        description(Text, optional): The description of the VPC link. Defaults to None.
        target_arns(List): [Required] The ARN of the network load balancer of the VPC targeted by the VPC link. The network
            load balancer must be owned by the same AWS account of the API owner.
        tags(Dict, optional): The key-value map of strings. The valid character set is [a-zA-Z+-=._:/]. The tag key can be up
            to 128 characters and must not start with aws:. The tag value can be up to 256 characters. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.apigateway.vpc_link.present:
                - name: value
                - target_arns: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.apigateway.vpc_link.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.apigateway.get_vpc_links(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.apigateway.create_vpc_link(
                ctx,
                
                
                **{"Name": name, "description": description, "targetArns": target_arns, "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.apigateway.get_vpc_links(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, vpc_link_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an existing VpcLink of a specified identifier.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        vpc_link_id(Text): [Required] The identifier of the VpcLink. It is used in an Integration to reference this
            VpcLink.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

