software.amazon.awssdk.services.kendra.model.GoogleDriveConfiguration 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.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Provides the configuration information to connect to Google Drive as your data source.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class GoogleDriveConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField SECRET_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SecretArn").getter(getter(GoogleDriveConfiguration::secretArn)).setter(setter(Builder::secretArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SecretArn").build()).build();
private static final SdkField> INCLUSION_PATTERNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("InclusionPatterns")
.getter(getter(GoogleDriveConfiguration::inclusionPatterns))
.setter(setter(Builder::inclusionPatterns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InclusionPatterns").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> EXCLUSION_PATTERNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ExclusionPatterns")
.getter(getter(GoogleDriveConfiguration::exclusionPatterns))
.setter(setter(Builder::exclusionPatterns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExclusionPatterns").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> FIELD_MAPPINGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("FieldMappings")
.getter(getter(GoogleDriveConfiguration::fieldMappings))
.setter(setter(Builder::fieldMappings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FieldMappings").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(DataSourceToIndexFieldMapping::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> EXCLUDE_MIME_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ExcludeMimeTypes")
.getter(getter(GoogleDriveConfiguration::excludeMimeTypes))
.setter(setter(Builder::excludeMimeTypes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExcludeMimeTypes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> EXCLUDE_USER_ACCOUNTS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ExcludeUserAccounts")
.getter(getter(GoogleDriveConfiguration::excludeUserAccounts))
.setter(setter(Builder::excludeUserAccounts))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExcludeUserAccounts").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> EXCLUDE_SHARED_DRIVES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ExcludeSharedDrives")
.getter(getter(GoogleDriveConfiguration::excludeSharedDrives))
.setter(setter(Builder::excludeSharedDrives))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ExcludeSharedDrives").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SECRET_ARN_FIELD,
INCLUSION_PATTERNS_FIELD, EXCLUSION_PATTERNS_FIELD, FIELD_MAPPINGS_FIELD, EXCLUDE_MIME_TYPES_FIELD,
EXCLUDE_USER_ACCOUNTS_FIELD, EXCLUDE_SHARED_DRIVES_FIELD));
private static final long serialVersionUID = 1L;
private final String secretArn;
private final List inclusionPatterns;
private final List exclusionPatterns;
private final List fieldMappings;
private final List excludeMimeTypes;
private final List excludeUserAccounts;
private final List excludeSharedDrives;
private GoogleDriveConfiguration(BuilderImpl builder) {
this.secretArn = builder.secretArn;
this.inclusionPatterns = builder.inclusionPatterns;
this.exclusionPatterns = builder.exclusionPatterns;
this.fieldMappings = builder.fieldMappings;
this.excludeMimeTypes = builder.excludeMimeTypes;
this.excludeUserAccounts = builder.excludeUserAccounts;
this.excludeSharedDrives = builder.excludeSharedDrives;
}
/**
*
* The Amazon Resource Name (ARN) of a Secrets Managersecret that contains the credentials required to connect to
* Google Drive. For more information, see Using a Google Workspace Drive
* data source.
*
*
* @return The Amazon Resource Name (ARN) of a Secrets Managersecret that contains the credentials required to
* connect to Google Drive. For more information, see Using a Google
* Workspace Drive data source.
*/
public final String secretArn() {
return secretArn;
}
/**
* For responses, this returns true if the service returned a value for the InclusionPatterns property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasInclusionPatterns() {
return inclusionPatterns != null && !(inclusionPatterns instanceof SdkAutoConstructList);
}
/**
*
* A list of regular expression patterns to include certain items in your Google Drive, including shared drives and
* users' My Drives. Items that match the patterns are included in the index. Items that don't match the patterns
* are excluded from the index. If an item matches both an inclusion and exclusion pattern, the exclusion pattern
* takes precedence and the item isn't included in the index.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasInclusionPatterns} method.
*
*
* @return A list of regular expression patterns to include certain items in your Google Drive, including shared
* drives and users' My Drives. Items that match the patterns are included in the index. Items that don't
* match the patterns are excluded from the index. If an item matches both an inclusion and exclusion
* pattern, the exclusion pattern takes precedence and the item isn't included in the index.
*/
public final List inclusionPatterns() {
return inclusionPatterns;
}
/**
* For responses, this returns true if the service returned a value for the ExclusionPatterns property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasExclusionPatterns() {
return exclusionPatterns != null && !(exclusionPatterns instanceof SdkAutoConstructList);
}
/**
*
* A list of regular expression patterns to exclude certain items in your Google Drive, including shared drives and
* users' My Drives. Items that match the patterns are excluded from the index. Items that don't match the patterns
* are included in the index. If an item matches both an inclusion and exclusion pattern, the exclusion pattern
* takes precedence and the item isn't included in the index.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExclusionPatterns} method.
*
*
* @return A list of regular expression patterns to exclude certain items in your Google Drive, including shared
* drives and users' My Drives. Items that match the patterns are excluded from the index. Items that don't
* match the patterns are included in the index. If an item matches both an inclusion and exclusion pattern,
* the exclusion pattern takes precedence and the item isn't included in the index.
*/
public final List exclusionPatterns() {
return exclusionPatterns;
}
/**
* For responses, this returns true if the service returned a value for the FieldMappings property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasFieldMappings() {
return fieldMappings != null && !(fieldMappings instanceof SdkAutoConstructList);
}
/**
*
* Maps Google Drive data source attributes or field names to Amazon Kendra index field names. To create custom
* fields, use the UpdateIndex
API before you map to Google Drive fields. For more information, see Mapping data source fields. The Google
* Drive data source field names must exist in your Google Drive custom metadata.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasFieldMappings} method.
*
*
* @return Maps Google Drive data source attributes or field names to Amazon Kendra index field names. To create
* custom fields, use the UpdateIndex
API before you map to Google Drive fields. For more
* information, see Mapping data
* source fields. The Google Drive data source field names must exist in your Google Drive custom
* metadata.
*/
public final List fieldMappings() {
return fieldMappings;
}
/**
* For responses, this returns true if the service returned a value for the ExcludeMimeTypes property. This DOES NOT
* check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasExcludeMimeTypes() {
return excludeMimeTypes != null && !(excludeMimeTypes instanceof SdkAutoConstructList);
}
/**
*
* A list of MIME types to exclude from the index. All documents matching the specified MIME type are excluded.
*
*
* For a list of MIME types, see Using a Google Workspace Drive
* data source.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExcludeMimeTypes} method.
*
*
* @return A list of MIME types to exclude from the index. All documents matching the specified MIME type are
* excluded.
*
* For a list of MIME types, see Using a Google
* Workspace Drive data source.
*/
public final List excludeMimeTypes() {
return excludeMimeTypes;
}
/**
* For responses, this returns true if the service returned a value for the ExcludeUserAccounts property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasExcludeUserAccounts() {
return excludeUserAccounts != null && !(excludeUserAccounts instanceof SdkAutoConstructList);
}
/**
*
* A list of email addresses of the users. Documents owned by these users are excluded from the index. Documents
* shared with excluded users are indexed unless they are excluded in another way.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExcludeUserAccounts} method.
*
*
* @return A list of email addresses of the users. Documents owned by these users are excluded from the index.
* Documents shared with excluded users are indexed unless they are excluded in another way.
*/
public final List excludeUserAccounts() {
return excludeUserAccounts;
}
/**
* For responses, this returns true if the service returned a value for the ExcludeSharedDrives property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasExcludeSharedDrives() {
return excludeSharedDrives != null && !(excludeSharedDrives instanceof SdkAutoConstructList);
}
/**
*
* A list of identifiers or shared drives to exclude from the index. All files and folders stored on the shared
* drive are excluded.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasExcludeSharedDrives} method.
*
*
* @return A list of identifiers or shared drives to exclude from the index. All files and folders stored on the
* shared drive are excluded.
*/
public final List excludeSharedDrives() {
return excludeSharedDrives;
}
@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(secretArn());
hashCode = 31 * hashCode + Objects.hashCode(hasInclusionPatterns() ? inclusionPatterns() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExclusionPatterns() ? exclusionPatterns() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasFieldMappings() ? fieldMappings() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExcludeMimeTypes() ? excludeMimeTypes() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExcludeUserAccounts() ? excludeUserAccounts() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExcludeSharedDrives() ? excludeSharedDrives() : null);
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 GoogleDriveConfiguration)) {
return false;
}
GoogleDriveConfiguration other = (GoogleDriveConfiguration) obj;
return Objects.equals(secretArn(), other.secretArn()) && hasInclusionPatterns() == other.hasInclusionPatterns()
&& Objects.equals(inclusionPatterns(), other.inclusionPatterns())
&& hasExclusionPatterns() == other.hasExclusionPatterns()
&& Objects.equals(exclusionPatterns(), other.exclusionPatterns())
&& hasFieldMappings() == other.hasFieldMappings() && Objects.equals(fieldMappings(), other.fieldMappings())
&& hasExcludeMimeTypes() == other.hasExcludeMimeTypes()
&& Objects.equals(excludeMimeTypes(), other.excludeMimeTypes())
&& hasExcludeUserAccounts() == other.hasExcludeUserAccounts()
&& Objects.equals(excludeUserAccounts(), other.excludeUserAccounts())
&& hasExcludeSharedDrives() == other.hasExcludeSharedDrives()
&& Objects.equals(excludeSharedDrives(), other.excludeSharedDrives());
}
/**
* 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("GoogleDriveConfiguration").add("SecretArn", secretArn())
.add("InclusionPatterns", hasInclusionPatterns() ? inclusionPatterns() : null)
.add("ExclusionPatterns", hasExclusionPatterns() ? exclusionPatterns() : null)
.add("FieldMappings", hasFieldMappings() ? fieldMappings() : null)
.add("ExcludeMimeTypes", hasExcludeMimeTypes() ? excludeMimeTypes() : null)
.add("ExcludeUserAccounts", hasExcludeUserAccounts() ? excludeUserAccounts() : null)
.add("ExcludeSharedDrives", hasExcludeSharedDrives() ? excludeSharedDrives() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SecretArn":
return Optional.ofNullable(clazz.cast(secretArn()));
case "InclusionPatterns":
return Optional.ofNullable(clazz.cast(inclusionPatterns()));
case "ExclusionPatterns":
return Optional.ofNullable(clazz.cast(exclusionPatterns()));
case "FieldMappings":
return Optional.ofNullable(clazz.cast(fieldMappings()));
case "ExcludeMimeTypes":
return Optional.ofNullable(clazz.cast(excludeMimeTypes()));
case "ExcludeUserAccounts":
return Optional.ofNullable(clazz.cast(excludeUserAccounts()));
case "ExcludeSharedDrives":
return Optional.ofNullable(clazz.cast(excludeSharedDrives()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function