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

hub.exec.boto3.client.ec2.create_vpc_endpoint_service_configuration
hub.exec.boto3.client.ec2.delete_vpc_endpoint_service_configurations
hub.exec.boto3.client.ec2.describe_vpc_endpoint_service_configurations
hub.exec.boto3.client.ec2.modify_vpc_endpoint_service_configuration
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, acceptance_required: bool = None, private_dns_name: Text = None, network_load_balancer_arns: List = None, gateway_load_balancer_arns: List = None, tag_specifications: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a VPC endpoint service configuration to which service consumers (AWS accounts, IAM users, and IAM roles)
    can connect. To create an endpoint service configuration, you must first create one of the following for your
    service:   A Network Load Balancer. Service consumers connect to your service using an interface endpoint.   A
    Gateway Load Balancer. Service consumers connect to your service using a Gateway Load Balancer endpoint.   For
    more information, see VPC Endpoint Services in the Amazon Virtual Private Cloud User Guide.  If you set the
    private DNS name, you must prove that you own the private DNS domain name. For more information, see VPC
    Endpoint Service Private DNS Name Verification in the Amazon Virtual Private Cloud User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        acceptance_required(bool, optional): Indicates whether requests from service consumers to create an endpoint to your service must be
            accepted. To accept a request, use AcceptVpcEndpointConnections. Defaults to None.
        private_dns_name(Text, optional): (Interface endpoint configuration) The private DNS name to assign to the VPC endpoint service. Defaults to None.
        network_load_balancer_arns(List, optional): The Amazon Resource Names (ARNs) of one or more Network Load Balancers for your service. Defaults to None.
        gateway_load_balancer_arns(List, optional): The Amazon Resource Names (ARNs) of one or more Gateway Load Balancers. Defaults to None.
        tag_specifications(List, optional): The tags to associate with the service. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.create_vpc_endpoint_service_configuration(
                ctx,
                DryRun=ctx.test,
                ClientToken=name,
                **{"AcceptanceRequired": acceptance_required, "PrivateDnsName": private_dns_name, "NetworkLoadBalancerArns": network_load_balancer_arns, "GatewayLoadBalancerArns": gateway_load_balancer_arns, "TagSpecifications": tag_specifications}
            )
            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.ec2.describe_vpc_endpoint_service_configurations(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, service_ids: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes one or more VPC endpoint service configurations in your account. Before you delete the endpoint service
    configuration, you must reject any Available or PendingAcceptance interface endpoint connections that are
    attached to the service.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        service_ids(List): The IDs of one or more services.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.ec2.vpc_endpoint_service_configuration.absent:
                - name: value
                - service_ids: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ec2.vpc_endpoint_service_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.ec2.describe_vpc_endpoint_service_configurations(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.delete_vpc_endpoint_service_configurations(
                ctx,
                DryRun=ctx.test,
                
                **{"ServiceIds": service_ids}
            )
            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.ec2.describe_vpc_endpoint_service_configurations(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

