software.amazon.awssdk.services.bedrockagent.model.DataSource Maven / Gradle / Ivy
Show all versions of bedrockagent 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.bedrockagent.model;
import java.io.Serializable;
import java.time.Instant;
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 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.traits.TimestampFormatTrait;
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;
/**
*
* Contains details about a data source.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class DataSource implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CREATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("createdAt")
.getter(getter(DataSource::createdAt))
.setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField DATA_DELETION_POLICY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("dataDeletionPolicy").getter(getter(DataSource::dataDeletionPolicyAsString))
.setter(setter(Builder::dataDeletionPolicy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dataDeletionPolicy").build())
.build();
private static final SdkField DATA_SOURCE_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("dataSourceConfiguration")
.getter(getter(DataSource::dataSourceConfiguration)).setter(setter(Builder::dataSourceConfiguration))
.constructor(DataSourceConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dataSourceConfiguration").build())
.build();
private static final SdkField DATA_SOURCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("dataSourceId").getter(getter(DataSource::dataSourceId)).setter(setter(Builder::dataSourceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("dataSourceId").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(DataSource::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField> FAILURE_REASONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("failureReasons")
.getter(getter(DataSource::failureReasons))
.setter(setter(Builder::failureReasons))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("failureReasons").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 KNOWLEDGE_BASE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("knowledgeBaseId").getter(getter(DataSource::knowledgeBaseId)).setter(setter(Builder::knowledgeBaseId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("knowledgeBaseId").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(DataSource::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField SERVER_SIDE_ENCRYPTION_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("serverSideEncryptionConfiguration")
.getter(getter(DataSource::serverSideEncryptionConfiguration))
.setter(setter(Builder::serverSideEncryptionConfiguration))
.constructor(ServerSideEncryptionConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("serverSideEncryptionConfiguration")
.build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("status")
.getter(getter(DataSource::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("status").build()).build();
private static final SdkField UPDATED_AT_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("updatedAt")
.getter(getter(DataSource::updatedAt))
.setter(setter(Builder::updatedAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("updatedAt").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField VECTOR_INGESTION_CONFIGURATION_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("vectorIngestionConfiguration")
.getter(getter(DataSource::vectorIngestionConfiguration))
.setter(setter(Builder::vectorIngestionConfiguration))
.constructor(VectorIngestionConfiguration::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("vectorIngestionConfiguration")
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CREATED_AT_FIELD,
DATA_DELETION_POLICY_FIELD, DATA_SOURCE_CONFIGURATION_FIELD, DATA_SOURCE_ID_FIELD, DESCRIPTION_FIELD,
FAILURE_REASONS_FIELD, KNOWLEDGE_BASE_ID_FIELD, NAME_FIELD, SERVER_SIDE_ENCRYPTION_CONFIGURATION_FIELD, STATUS_FIELD,
UPDATED_AT_FIELD, VECTOR_INGESTION_CONFIGURATION_FIELD));
private static final long serialVersionUID = 1L;
private final Instant createdAt;
private final String dataDeletionPolicy;
private final DataSourceConfiguration dataSourceConfiguration;
private final String dataSourceId;
private final String description;
private final List failureReasons;
private final String knowledgeBaseId;
private final String name;
private final ServerSideEncryptionConfiguration serverSideEncryptionConfiguration;
private final String status;
private final Instant updatedAt;
private final VectorIngestionConfiguration vectorIngestionConfiguration;
private DataSource(BuilderImpl builder) {
this.createdAt = builder.createdAt;
this.dataDeletionPolicy = builder.dataDeletionPolicy;
this.dataSourceConfiguration = builder.dataSourceConfiguration;
this.dataSourceId = builder.dataSourceId;
this.description = builder.description;
this.failureReasons = builder.failureReasons;
this.knowledgeBaseId = builder.knowledgeBaseId;
this.name = builder.name;
this.serverSideEncryptionConfiguration = builder.serverSideEncryptionConfiguration;
this.status = builder.status;
this.updatedAt = builder.updatedAt;
this.vectorIngestionConfiguration = builder.vectorIngestionConfiguration;
}
/**
*
* The time at which the data source was created.
*
*
* @return The time at which the data source was created.
*/
public final Instant createdAt() {
return createdAt;
}
/**
*
* The data deletion policy for the data source.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #dataDeletionPolicy} will return {@link DataDeletionPolicy#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #dataDeletionPolicyAsString}.
*
*
* @return The data deletion policy for the data source.
* @see DataDeletionPolicy
*/
public final DataDeletionPolicy dataDeletionPolicy() {
return DataDeletionPolicy.fromValue(dataDeletionPolicy);
}
/**
*
* The data deletion policy for the data source.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #dataDeletionPolicy} will return {@link DataDeletionPolicy#UNKNOWN_TO_SDK_VERSION}. The raw value returned
* by the service is available from {@link #dataDeletionPolicyAsString}.
*
*
* @return The data deletion policy for the data source.
* @see DataDeletionPolicy
*/
public final String dataDeletionPolicyAsString() {
return dataDeletionPolicy;
}
/**
*
* The connection configuration for the data source.
*
*
* @return The connection configuration for the data source.
*/
public final DataSourceConfiguration dataSourceConfiguration() {
return dataSourceConfiguration;
}
/**
*
* The unique identifier of the data source.
*
*
* @return The unique identifier of the data source.
*/
public final String dataSourceId() {
return dataSourceId;
}
/**
*
* The description of the data source.
*
*
* @return The description of the data source.
*/
public final String description() {
return description;
}
/**
* For responses, this returns true if the service returned a value for the FailureReasons 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 hasFailureReasons() {
return failureReasons != null && !(failureReasons instanceof SdkAutoConstructList);
}
/**
*
* The detailed reasons on the failure to delete a 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 #hasFailureReasons} method.
*
*
* @return The detailed reasons on the failure to delete a data source.
*/
public final List failureReasons() {
return failureReasons;
}
/**
*
* The unique identifier of the knowledge base to which the data source belongs.
*
*
* @return The unique identifier of the knowledge base to which the data source belongs.
*/
public final String knowledgeBaseId() {
return knowledgeBaseId;
}
/**
*
* The name of the data source.
*
*
* @return The name of the data source.
*/
public final String name() {
return name;
}
/**
*
* Contains details about the configuration of the server-side encryption.
*
*
* @return Contains details about the configuration of the server-side encryption.
*/
public final ServerSideEncryptionConfiguration serverSideEncryptionConfiguration() {
return serverSideEncryptionConfiguration;
}
/**
*
* The status of the data source. The following statuses are possible:
*
*
* -
*
* Available – The data source has been created and is ready for ingestion into the knowledge base.
*
*
* -
*
* Deleting – The data source is being deleted.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link DataSourceStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the data source. The following statuses are possible:
*
* -
*
* Available – The data source has been created and is ready for ingestion into the knowledge base.
*
*
* -
*
* Deleting – The data source is being deleted.
*
*
* @see DataSourceStatus
*/
public final DataSourceStatus status() {
return DataSourceStatus.fromValue(status);
}
/**
*
* The status of the data source. The following statuses are possible:
*
*
* -
*
* Available – The data source has been created and is ready for ingestion into the knowledge base.
*
*
* -
*
* Deleting – The data source is being deleted.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link DataSourceStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #statusAsString}.
*
*
* @return The status of the data source. The following statuses are possible:
*
* -
*
* Available – The data source has been created and is ready for ingestion into the knowledge base.
*
*
* -
*
* Deleting – The data source is being deleted.
*
*
* @see DataSourceStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The time at which the data source was last updated.
*
*
* @return The time at which the data source was last updated.
*/
public final Instant updatedAt() {
return updatedAt;
}
/**
*
* Contains details about how to ingest the documents in the data source.
*
*
* @return Contains details about how to ingest the documents in the data source.
*/
public final VectorIngestionConfiguration vectorIngestionConfiguration() {
return vectorIngestionConfiguration;
}
@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(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(dataDeletionPolicyAsString());
hashCode = 31 * hashCode + Objects.hashCode(dataSourceConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(dataSourceId());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(hasFailureReasons() ? failureReasons() : null);
hashCode = 31 * hashCode + Objects.hashCode(knowledgeBaseId());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(serverSideEncryptionConfiguration());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(updatedAt());
hashCode = 31 * hashCode + Objects.hashCode(vectorIngestionConfiguration());
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 DataSource)) {
return false;
}
DataSource other = (DataSource) obj;
return Objects.equals(createdAt(), other.createdAt())
&& Objects.equals(dataDeletionPolicyAsString(), other.dataDeletionPolicyAsString())
&& Objects.equals(dataSourceConfiguration(), other.dataSourceConfiguration())
&& Objects.equals(dataSourceId(), other.dataSourceId()) && Objects.equals(description(), other.description())
&& hasFailureReasons() == other.hasFailureReasons() && Objects.equals(failureReasons(), other.failureReasons())
&& Objects.equals(knowledgeBaseId(), other.knowledgeBaseId()) && Objects.equals(name(), other.name())
&& Objects.equals(serverSideEncryptionConfiguration(), other.serverSideEncryptionConfiguration())
&& Objects.equals(statusAsString(), other.statusAsString()) && Objects.equals(updatedAt(), other.updatedAt())
&& Objects.equals(vectorIngestionConfiguration(), other.vectorIngestionConfiguration());
}
/**
* 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("DataSource").add("CreatedAt", createdAt())
.add("DataDeletionPolicy", dataDeletionPolicyAsString())
.add("DataSourceConfiguration", dataSourceConfiguration()).add("DataSourceId", dataSourceId())
.add("Description", description()).add("FailureReasons", hasFailureReasons() ? failureReasons() : null)
.add("KnowledgeBaseId", knowledgeBaseId()).add("Name", name())
.add("ServerSideEncryptionConfiguration", serverSideEncryptionConfiguration()).add("Status", statusAsString())
.add("UpdatedAt", updatedAt()).add("VectorIngestionConfiguration", vectorIngestionConfiguration()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "createdAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "dataDeletionPolicy":
return Optional.ofNullable(clazz.cast(dataDeletionPolicyAsString()));
case "dataSourceConfiguration":
return Optional.ofNullable(clazz.cast(dataSourceConfiguration()));
case "dataSourceId":
return Optional.ofNullable(clazz.cast(dataSourceId()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "failureReasons":
return Optional.ofNullable(clazz.cast(failureReasons()));
case "knowledgeBaseId":
return Optional.ofNullable(clazz.cast(knowledgeBaseId()));
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "serverSideEncryptionConfiguration":
return Optional.ofNullable(clazz.cast(serverSideEncryptionConfiguration()));
case "status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "updatedAt":
return Optional.ofNullable(clazz.cast(updatedAt()));
case "vectorIngestionConfiguration":
return Optional.ofNullable(clazz.cast(vectorIngestionConfiguration()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function