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

hub.exec.boto3.client.comprehend.create_document_classifier
hub.exec.boto3.client.comprehend.delete_document_classifier
hub.exec.boto3.client.comprehend.describe_document_classifier
hub.exec.boto3.client.comprehend.list_document_classifiers
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, document_classifier_name: Text, data_access_role_arn: Text, input_data_config: Dict, language_code: Text, tags: List = None, output_data_config: Dict = None, client_request_token: Text = None, volume_kms_key_id: Text = None, vpc_config: Dict = None, mode: Text = None, model_kms_key_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new document classifier that you can use to categorize documents. To create a classifier, you provide
    a set of training documents that labeled with the categories that you want to use. After the classifier is
    trained you can use it to categorize a set of labeled documents into the categories. For more information, see
    how-document-classification.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        document_classifier_name(Text): The name of the document classifier.
        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 document classifier 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 for the job.
        output_data_config(Dict, optional): Enables the addition of output results configuration parameters for custom classifier jobs. Defaults to None.
        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): The language of the input documents. You can specify any of the following languages supported by
            Amazon Comprehend: German ("de"), English ("en"), Spanish ("es"), French ("fr"), Italian ("it"),
            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 classifier. For more information, see Amazon VPC. Defaults to None.
        mode(Text, optional): Indicates the mode in which the classifier will be trained. The classifier can be trained in
            multi-class mode, which identifies one and only one class for each document, or multi-label
            mode, which identifies one or more labels for each document. In multi-label mode, multiple
            labels for an individual document are separated by a delimiter. The default delimiter between
            labels is a pipe (|). 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.document_classifier.present:
                - name: value
                - document_classifier_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.document_classifier.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_document_classifier(name)

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

async def absent(hub, ctx, name: Text, document_classifier_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a previously created document classifier Only those classifiers 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 classifier into a DELETING state, and it is then removed
    by a background job. Once removed, the classifier 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.
        document_classifier_arn(Text): The Amazon Resource Name (ARN) that identifies the document classifier.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

