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

hub.exec.boto3.client.comprehend.create_entity_recognizer
hub.exec.boto3.client.comprehend.delete_entity_recognizer
hub.exec.boto3.client.comprehend.describe_entity_recognizer
hub.exec.boto3.client.comprehend.list_entity_recognizers
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, recognizer_name: Text, data_access_role_arn: Text, input_data_config: Dict, language_code: Text, tags: List = None, client_request_token: Text = None, volume_kms_key_id: Text = None, vpc_config: Dict = None, model_kms_key_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an entity recognizer using submitted files. After your CreateEntityRecognizer request is submitted, you
    can check job status using the API.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        recognizer_name(Text): The name given to the newly created recognizer. Recognizer names can be a maximum of 256
            characters. Alphanumeric characters, hyphens (-) and underscores (_) are allowed. The name must
            be unique in the account/region.
        data_access_role_arn(Text): The Amazon Resource Name (ARN) of the AWS Identity and Management (IAM) role that grants Amazon
            Comprehend read access to your input data.
        tags(List, optional): Tags to be associated with the entity recognizer being created. A tag is a key-value pair that
            adds as a metadata to a resource used by Amazon Comprehend. For example, a tag with "Sales" as
            the key might be added to a resource to indicate its use by the sales department. Defaults to None.
        input_data_config(Dict): Specifies the format and location of the input data. The S3 bucket containing the input data
            must be located in the same region as the entity recognizer being created.
        client_request_token(Text, optional):  A unique identifier for the request. If you don't set the client request token, Amazon
            Comprehend generates one. Defaults to None.
        language_code(Text):  You can specify any of the following languages supported by Amazon Comprehend: English ("en"),
            Spanish ("es"), French ("fr"), Italian ("it"), German ("de"), or Portuguese ("pt"). All
            documents must be in the same language.
        volume_kms_key_id(Text, optional): ID for the AWS Key Management Service (KMS) key that Amazon Comprehend uses to encrypt data on
            the storage volume attached to the ML compute instance(s) that process the analysis job. The
            VolumeKmsKeyId can be either of the following formats:   KMS Key ID:
            "1234abcd-12ab-34cd-56ef-1234567890ab"    Amazon Resource Name (ARN) of a KMS Key:
            "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab". Defaults to None.
        vpc_config(Dict, optional): Configuration parameters for an optional private Virtual Private Cloud (VPC) containing the
            resources you are using for your custom entity recognizer. For more information, see Amazon VPC. Defaults to None.
        model_kms_key_id(Text, optional): ID for the AWS Key Management Service (KMS) key that Amazon Comprehend uses to encrypt trained
            custom models. The ModelKmsKeyId can be either of the following formats   KMS Key ID:
            "1234abcd-12ab-34cd-56ef-1234567890ab"    Amazon Resource Name (ARN) of a KMS Key:
            "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab". Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.comprehend.entity_recognizer.present:
                - name: value
                - recognizer_name: value
                - data_access_role_arn: value
                - input_data_config: value
                - language_code: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.comprehend.entity_recognizer.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_entity_recognizer(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.comprehend.create_entity_recognizer(
                ctx,
                
                
                **{"RecognizerName": recognizer_name, "DataAccessRoleArn": data_access_role_arn, "Tags": tags, "InputDataConfig": input_data_config, "ClientRequestToken": client_request_token, "LanguageCode": language_code, "VolumeKmsKeyId": volume_kms_key_id, "VpcConfig": vpc_config, "ModelKmsKeyId": model_kms_key_id}
            )
            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_entity_recognizer(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, entity_recognizer_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an entity recognizer. Only those recognizers that are in terminated states (IN_ERROR, TRAINED) will be
    deleted. If an active inference job is using the model, a ResourceInUseException will be returned. This is an
    asynchronous action that puts the recognizer into a DELETING state, and it is then removed by a background job.
    Once removed, the recognizer disappears from your account and is no longer available for use.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        entity_recognizer_arn(Text): The Amazon Resource Name (ARN) that identifies the entity recognizer.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

