software.amazon.awssdk.services.kendra.model.HookConfiguration Maven / Gradle / Ivy
Show all versions of kendra Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.kendra.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Provides the configuration information for invoking a Lambda function in Lambda to alter document metadata and
* content when ingesting documents into Amazon Kendra. You can configure your Lambda function using PreExtractionHookConfiguration if you want to apply advanced alterations on the original or raw documents. If
* you want to apply advanced alterations on the Amazon Kendra structured documents, you must configure your Lambda
* function using
* PostExtractionHookConfiguration. You can only invoke one Lambda function. However, this function can invoke other
* functions it requires.
*
*
* For more information, see Customizing document metadata
* during the ingestion process.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class HookConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField INVOCATION_CONDITION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("InvocationCondition")
.getter(getter(HookConfiguration::invocationCondition)).setter(setter(Builder::invocationCondition))
.constructor(DocumentAttributeCondition::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InvocationCondition").build())
.build();
private static final SdkField LAMBDA_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LambdaArn").getter(getter(HookConfiguration::lambdaArn)).setter(setter(Builder::lambdaArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LambdaArn").build()).build();
private static final SdkField S3_BUCKET_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("S3Bucket").getter(getter(HookConfiguration::s3Bucket)).setter(setter(Builder::s3Bucket))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("S3Bucket").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INVOCATION_CONDITION_FIELD,
LAMBDA_ARN_FIELD, S3_BUCKET_FIELD));
private static final long serialVersionUID = 1L;
private final DocumentAttributeCondition invocationCondition;
private final String lambdaArn;
private final String s3Bucket;
private HookConfiguration(BuilderImpl builder) {
this.invocationCondition = builder.invocationCondition;
this.lambdaArn = builder.lambdaArn;
this.s3Bucket = builder.s3Bucket;
}
/**
*
* The condition used for when a Lambda function should be invoked.
*
*
* For example, you can specify a condition that if there are empty date-time values, then Amazon Kendra should
* invoke a function that inserts the current date-time.
*
*
* @return The condition used for when a Lambda function should be invoked.
*
* For example, you can specify a condition that if there are empty date-time values, then Amazon Kendra
* should invoke a function that inserts the current date-time.
*/
public final DocumentAttributeCondition invocationCondition() {
return invocationCondition;
}
/**
*
* The Amazon Resource Name (ARN) of a role with permission to run a Lambda function during ingestion. For more
* information, see IAM roles for Amazon
* Kendra.
*
*
* @return The Amazon Resource Name (ARN) of a role with permission to run a Lambda function during ingestion. For
* more information, see IAM roles for
* Amazon Kendra.
*/
public final String lambdaArn() {
return lambdaArn;
}
/**
*
* Stores the original, raw documents or the structured, parsed documents before and after altering them. For more
* information, see Data contracts for Lambda functions.
*
*
* @return Stores the original, raw documents or the structured, parsed documents before and after altering them.
* For more information, see Data contracts for Lambda functions.
*/
public final String s3Bucket() {
return s3Bucket;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(invocationCondition());
hashCode = 31 * hashCode + Objects.hashCode(lambdaArn());
hashCode = 31 * hashCode + Objects.hashCode(s3Bucket());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof HookConfiguration)) {
return false;
}
HookConfiguration other = (HookConfiguration) obj;
return Objects.equals(invocationCondition(), other.invocationCondition())
&& Objects.equals(lambdaArn(), other.lambdaArn()) && Objects.equals(s3Bucket(), other.s3Bucket());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("HookConfiguration").add("InvocationCondition", invocationCondition())
.add("LambdaArn", lambdaArn()).add("S3Bucket", s3Bucket()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "InvocationCondition":
return Optional.ofNullable(clazz.cast(invocationCondition()));
case "LambdaArn":
return Optional.ofNullable(clazz.cast(lambdaArn()));
case "S3Bucket":
return Optional.ofNullable(clazz.cast(s3Bucket()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function