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

hub.exec.boto3.client.glue.create_dev_endpoint
hub.exec.boto3.client.glue.delete_dev_endpoint
hub.exec.boto3.client.glue.get_dev_endpoints
hub.exec.boto3.client.glue.list_dev_endpoints
hub.exec.boto3.client.glue.update_dev_endpoint
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, endpoint_name: Text, role_arn: Text, security_group_ids: List = None, subnet_id: Text = None, public_key: Text = None, public_keys: List = None, number_of_nodes: int = None, worker_type: Text = None, glue_version: Text = None, number_of_workers: int = None, extra_python_libs_s3_path: Text = None, extra_jars_s3_path: Text = None, security_configuration: Text = None, tags: Dict = None, arguments: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new development endpoint.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        endpoint_name(Text): The name to be assigned to the new DevEndpoint.
        role_arn(Text): The IAM role for the DevEndpoint.
        security_group_ids(List, optional): Security group IDs for the security groups to be used by the new DevEndpoint. Defaults to None.
        subnet_id(Text, optional): The subnet ID for the new DevEndpoint to use. Defaults to None.
        public_key(Text, optional): The public key to be used by this DevEndpoint for authentication. This attribute is provided for
            backward compatibility because the recommended attribute to use is public keys. Defaults to None.
        public_keys(List, optional): A list of public keys to be used by the development endpoints for authentication. The use of
            this attribute is preferred over a single public key because the public keys allow you to have a
            different private key per client.  If you previously created an endpoint with a public key, you
            must remove that key to be able to set a list of public keys. Call the UpdateDevEndpoint API
            with the public key content in the deletePublicKeys attribute, and the list of new keys in the
            addPublicKeys attribute. Defaults to None.
        number_of_nodes(int, optional): The number of Glue Data Processing Units (DPUs) to allocate to this DevEndpoint. Defaults to None.
        worker_type(Text, optional): The type of predefined worker that is allocated to the development endpoint. Accepts a value of
            Standard, G.1X, or G.2X.   For the Standard worker type, each worker provides 4 vCPU, 16 GB of
            memory and a 50GB disk, and 2 executors per worker.   For the G.1X worker type, each worker maps
            to 1 DPU (4 vCPU, 16 GB of memory, 64 GB disk), and provides 1 executor per worker. We recommend
            this worker type for memory-intensive jobs.   For the G.2X worker type, each worker maps to 2
            DPU (8 vCPU, 32 GB of memory, 128 GB disk), and provides 1 executor per worker. We recommend
            this worker type for memory-intensive jobs.   Known issue: when a development endpoint is
            created with the G.2X WorkerType configuration, the Spark drivers for the development endpoint
            will run on 4 vCPU, 16 GB of memory, and a 64 GB disk. Defaults to None.
        glue_version(Text, optional): Glue version determines the versions of Apache Spark and Python that Glue supports. The Python
            version indicates the version supported for running your ETL scripts on development endpoints.
            For more information about the available Glue versions and corresponding Spark and Python
            versions, see Glue version in the developer guide. Development endpoints that are created
            without specifying a Glue version default to Glue 0.9. You can specify a version of Python
            support for development endpoints by using the Arguments parameter in the CreateDevEndpoint or
            UpdateDevEndpoint APIs. If no arguments are provided, the version defaults to Python 2. Defaults to None.
        number_of_workers(int, optional): The number of workers of a defined workerType that are allocated to the development endpoint.
            The maximum number of workers you can define are 299 for G.1X, and 149 for G.2X. Defaults to None.
        extra_python_libs_s3_path(Text, optional): The paths to one or more Python libraries in an Amazon S3 bucket that should be loaded in your
            DevEndpoint. Multiple values must be complete paths separated by a comma.  You can only use pure
            Python libraries with a DevEndpoint. Libraries that rely on C extensions, such as the pandas
            Python data analysis library, are not yet supported. Defaults to None.
        extra_jars_s3_path(Text, optional): The path to one or more Java .jar files in an S3 bucket that should be loaded in your
            DevEndpoint. Defaults to None.
        security_configuration(Text, optional): The name of the SecurityConfiguration structure to be used with this DevEndpoint. Defaults to None.
        tags(Dict, optional): The tags to use with this DevEndpoint. You may use tags to limit access to the DevEndpoint. For
            more information about tags in Glue, see Amazon Web Services Tags in Glue in the developer
            guide. Defaults to None.
        arguments(Dict, optional): A map of arguments used to configure the DevEndpoint. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.glue.dev_endpoint.present:
                - name: value
                - endpoint_name: value
                - role_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.glue.dev_endpoint.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.glue.get_dev_endpoints(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.glue.create_dev_endpoint(
                ctx,
                
                
                **{"EndpointName": endpoint_name, "RoleArn": role_arn, "SecurityGroupIds": security_group_ids, "SubnetId": subnet_id, "PublicKey": public_key, "PublicKeys": public_keys, "NumberOfNodes": number_of_nodes, "WorkerType": worker_type, "GlueVersion": glue_version, "NumberOfWorkers": number_of_workers, "ExtraPythonLibsS3Path": extra_python_libs_s3_path, "ExtraJarsS3Path": extra_jars_s3_path, "SecurityConfiguration": security_configuration, "Tags": tags, "Arguments": arguments}
            )
            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.glue.get_dev_endpoints(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, endpoint_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a specified development endpoint.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        endpoint_name(Text): The name of the DevEndpoint.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

