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

hub.exec.boto3.client.comprehend.create_endpoint
hub.exec.boto3.client.comprehend.delete_endpoint
hub.exec.boto3.client.comprehend.describe_endpoint
hub.exec.boto3.client.comprehend.list_endpoints
hub.exec.boto3.client.comprehend.update_endpoint
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, endpoint_name: Text, model_arn: Text, desired_inference_units: int, client_request_token: Text = None, tags: List = None, data_access_role_arn: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a model-specific endpoint for synchronous inference for a previously trained custom model

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        endpoint_name(Text): This is the descriptive suffix that becomes part of the EndpointArn used for all subsequent
            requests to this resource.
        model_arn(Text): The Amazon Resource Number (ARN) of the model to which the endpoint will be attached.
        desired_inference_units(int):  The desired number of inference units to be used by the model using this endpoint. Each
            inference unit represents of a throughput of 100 characters per second.
        client_request_token(Text, optional): An idempotency token provided by the customer. If this token matches a previous endpoint
            creation request, Amazon Comprehend will not return a ResourceInUseException. Defaults to None.
        tags(List, optional): Tags associated with the endpoint being created. A tag is a key-value pair that adds metadata to
            the endpoint. For example, a tag with "Sales" as the key might be added to an endpoint to
            indicate its use by the sales department. Defaults to None.
        data_access_role_arn(Text, optional): The Amazon Resource Name (ARN) of the AWS identity and Access Management (IAM) role that grants
            Amazon Comprehend read access to trained custom models encrypted with a customer managed key
            (ModelKmsKeyId). Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.comprehend.endpoint.present:
                - name: value
                - endpoint_name: value
                - model_arn: value
                - desired_inference_units: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.comprehend.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.comprehend.describe_endpoint(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.comprehend.create_endpoint(
                ctx,
                
                
                **{"EndpointName": endpoint_name, "ModelArn": model_arn, "DesiredInferenceUnits": desired_inference_units, "ClientRequestToken": client_request_token, "Tags": tags, "DataAccessRoleArn": data_access_role_arn}
            )
            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.comprehend.describe_endpoint(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, endpoint_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a model-specific endpoint for a previously-trained custom model. All endpoints must be deleted in order
    for the model to be deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        endpoint_arn(Text): The Amazon Resource Number (ARN) of the endpoint being deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

