All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.kendra.model.DocumentAttributeCondition.kt Maven / Gradle / Ivy

// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.kendra.model



/**
 * The condition used for the target document attribute or metadata field when ingesting documents into Amazon Kendra. You use this with [DocumentAttributeTarget to apply the condition](https://docs.aws.amazon.com/kendra/latest/dg/API_DocumentAttributeTarget.html).
 *
 * For example, you can create the 'Department' target field and have it prefill department names associated with the documents based on information in the 'Source_URI' field. Set the condition that if the 'Source_URI' field contains 'financial' in its URI value, then prefill the target field 'Department' with the target value 'Finance' for the document.
 *
 * Amazon Kendra cannot create a target field if it has not already been created as an index field. After you create your index field, you can create a document metadata field using `DocumentAttributeTarget`. Amazon Kendra then will map your newly created metadata field to your index field.
 */
public class DocumentAttributeCondition private constructor(builder: Builder) {
    /**
     * The identifier of the document attribute used for the condition.
     *
     * For example, 'Source_URI' could be an identifier for the attribute or metadata field that contains source URIs associated with the documents.
     *
     * Amazon Kendra currently does not support `_document_body` as an attribute key used for the condition.
     */
    public val conditionDocumentAttributeKey: kotlin.String = requireNotNull(builder.conditionDocumentAttributeKey) { "A non-null value must be provided for conditionDocumentAttributeKey" }
    /**
     * The value used by the operator.
     *
     * For example, you can specify the value 'financial' for strings in the 'Source_URI' field that partially match or contain this value.
     */
    public val conditionOnValue: aws.sdk.kotlin.services.kendra.model.DocumentAttributeValue? = builder.conditionOnValue
    /**
     * The condition operator.
     *
     * For example, you can use 'Contains' to partially match a string.
     */
    public val operator: aws.sdk.kotlin.services.kendra.model.ConditionOperator = requireNotNull(builder.operator) { "A non-null value must be provided for operator" }

    public companion object {
        public operator fun invoke(block: Builder.() -> kotlin.Unit): aws.sdk.kotlin.services.kendra.model.DocumentAttributeCondition = Builder().apply(block).build()
    }

    override fun toString(): kotlin.String = buildString {
        append("DocumentAttributeCondition(")
        append("conditionDocumentAttributeKey=$conditionDocumentAttributeKey,")
        append("conditionOnValue=$conditionOnValue,")
        append("operator=$operator")
        append(")")
    }

    override fun hashCode(): kotlin.Int {
        var result = conditionDocumentAttributeKey.hashCode()
        result = 31 * result + (conditionOnValue?.hashCode() ?: 0)
        result = 31 * result + (operator.hashCode())
        return result
    }

    override fun equals(other: kotlin.Any?): kotlin.Boolean {
        if (this === other) return true
        if (other == null || this::class != other::class) return false

        other as DocumentAttributeCondition

        if (conditionDocumentAttributeKey != other.conditionDocumentAttributeKey) return false
        if (conditionOnValue != other.conditionOnValue) return false
        if (operator != other.operator) return false

        return true
    }

    public inline fun copy(block: Builder.() -> kotlin.Unit = {}): aws.sdk.kotlin.services.kendra.model.DocumentAttributeCondition = Builder(this).apply(block).build()

    public class Builder {
        /**
         * The identifier of the document attribute used for the condition.
         *
         * For example, 'Source_URI' could be an identifier for the attribute or metadata field that contains source URIs associated with the documents.
         *
         * Amazon Kendra currently does not support `_document_body` as an attribute key used for the condition.
         */
        public var conditionDocumentAttributeKey: kotlin.String? = null
        /**
         * The value used by the operator.
         *
         * For example, you can specify the value 'financial' for strings in the 'Source_URI' field that partially match or contain this value.
         */
        public var conditionOnValue: aws.sdk.kotlin.services.kendra.model.DocumentAttributeValue? = null
        /**
         * The condition operator.
         *
         * For example, you can use 'Contains' to partially match a string.
         */
        public var operator: aws.sdk.kotlin.services.kendra.model.ConditionOperator? = null

        @PublishedApi
        internal constructor()
        @PublishedApi
        internal constructor(x: aws.sdk.kotlin.services.kendra.model.DocumentAttributeCondition) : this() {
            this.conditionDocumentAttributeKey = x.conditionDocumentAttributeKey
            this.conditionOnValue = x.conditionOnValue
            this.operator = x.operator
        }

        @PublishedApi
        internal fun build(): aws.sdk.kotlin.services.kendra.model.DocumentAttributeCondition = DocumentAttributeCondition(this)

        /**
         * construct an [aws.sdk.kotlin.services.kendra.model.DocumentAttributeValue] inside the given [block]
         */
        public fun conditionOnValue(block: aws.sdk.kotlin.services.kendra.model.DocumentAttributeValue.Builder.() -> kotlin.Unit) {
            this.conditionOnValue = aws.sdk.kotlin.services.kendra.model.DocumentAttributeValue.invoke(block)
        }

        internal fun correctErrors(): Builder {
            if (conditionDocumentAttributeKey == null) conditionDocumentAttributeKey = ""
            if (operator == null) operator = ConditionOperator.SdkUnknown("no value provided")
            return this
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy