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

software.amazon.awssdk.services.kendra.model.HookConfiguration Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Kendra module holds the client classes that are used for communicating with Kendra.

There is a newer version: 2.29.15
Show newest version
/*
 * 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 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 getter(Function g) { return obj -> g.apply((HookConfiguration) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* 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. *

* * @param invocationCondition * 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 Returns a reference to this object so that method calls can be chained together. */ Builder invocationCondition(DocumentAttributeCondition invocationCondition); /** *

* 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. *

* This is a convenience method that creates an instance of the {@link DocumentAttributeCondition.Builder} * avoiding the need to create one manually via {@link DocumentAttributeCondition#builder()}. * *

* When the {@link Consumer} completes, {@link DocumentAttributeCondition.Builder#build()} is called immediately * and its result is passed to {@link #invocationCondition(DocumentAttributeCondition)}. * * @param invocationCondition * a consumer that will call methods on {@link DocumentAttributeCondition.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #invocationCondition(DocumentAttributeCondition) */ default Builder invocationCondition(Consumer invocationCondition) { return invocationCondition(DocumentAttributeCondition.builder().applyMutation(invocationCondition).build()); } /** *

* 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. *

* * @param lambdaArn * 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 Returns a reference to this object so that method calls can be chained together. */ Builder lambdaArn(String 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. *

* * @param s3Bucket * 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 Returns a reference to this object so that method calls can be chained together. */ Builder s3Bucket(String s3Bucket); } static final class BuilderImpl implements Builder { private DocumentAttributeCondition invocationCondition; private String lambdaArn; private String s3Bucket; private BuilderImpl() { } private BuilderImpl(HookConfiguration model) { invocationCondition(model.invocationCondition); lambdaArn(model.lambdaArn); s3Bucket(model.s3Bucket); } public final DocumentAttributeCondition.Builder getInvocationCondition() { return invocationCondition != null ? invocationCondition.toBuilder() : null; } public final void setInvocationCondition(DocumentAttributeCondition.BuilderImpl invocationCondition) { this.invocationCondition = invocationCondition != null ? invocationCondition.build() : null; } @Override public final Builder invocationCondition(DocumentAttributeCondition invocationCondition) { this.invocationCondition = invocationCondition; return this; } public final String getLambdaArn() { return lambdaArn; } public final void setLambdaArn(String lambdaArn) { this.lambdaArn = lambdaArn; } @Override public final Builder lambdaArn(String lambdaArn) { this.lambdaArn = lambdaArn; return this; } public final String getS3Bucket() { return s3Bucket; } public final void setS3Bucket(String s3Bucket) { this.s3Bucket = s3Bucket; } @Override public final Builder s3Bucket(String s3Bucket) { this.s3Bucket = s3Bucket; return this; } @Override public HookConfiguration build() { return new HookConfiguration(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy