Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.neptunegraph.model.ExecuteQueryRequest Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Neptune Graph module holds the client classes that are used for
communicating with Neptune Graph.
/*
* 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.neptunegraph.model;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
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.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.document.Document;
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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class ExecuteQueryRequest extends NeptuneGraphRequest implements
ToCopyableBuilder {
private static final SdkField GRAPH_IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("graphIdentifier").getter(getter(ExecuteQueryRequest::graphIdentifier))
.setter(setter(Builder::graphIdentifier))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("graphIdentifier").build()).build();
private static final SdkField QUERY_STRING_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("queryString").getter(getter(ExecuteQueryRequest::queryString)).setter(setter(Builder::queryString))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("query").build()).build();
private static final SdkField LANGUAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("language").getter(getter(ExecuteQueryRequest::languageAsString)).setter(setter(Builder::language))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("language").build()).build();
private static final SdkField> PARAMETERS_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("parameters")
.getter(getter(ExecuteQueryRequest::parameters))
.setter(setter(Builder::parameters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("parameters").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.DOCUMENT)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField PLAN_CACHE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("planCache").getter(getter(ExecuteQueryRequest::planCacheAsString)).setter(setter(Builder::planCache))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("planCache").build()).build();
private static final SdkField EXPLAIN_MODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("explainMode").getter(getter(ExecuteQueryRequest::explainModeAsString))
.setter(setter(Builder::explainMode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("explain").build()).build();
private static final SdkField QUERY_TIMEOUT_MILLISECONDS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("queryTimeoutMilliseconds").getter(getter(ExecuteQueryRequest::queryTimeoutMilliseconds))
.setter(setter(Builder::queryTimeoutMilliseconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("queryTimeoutMilliseconds").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(GRAPH_IDENTIFIER_FIELD,
QUERY_STRING_FIELD, LANGUAGE_FIELD, PARAMETERS_FIELD, PLAN_CACHE_FIELD, EXPLAIN_MODE_FIELD,
QUERY_TIMEOUT_MILLISECONDS_FIELD));
private final String graphIdentifier;
private final String queryString;
private final String language;
private final Map parameters;
private final String planCache;
private final String explainMode;
private final Integer queryTimeoutMilliseconds;
private ExecuteQueryRequest(BuilderImpl builder) {
super(builder);
this.graphIdentifier = builder.graphIdentifier;
this.queryString = builder.queryString;
this.language = builder.language;
this.parameters = builder.parameters;
this.planCache = builder.planCache;
this.explainMode = builder.explainMode;
this.queryTimeoutMilliseconds = builder.queryTimeoutMilliseconds;
}
/**
*
* The unique identifier of the Neptune Analytics graph.
*
*
* @return The unique identifier of the Neptune Analytics graph.
*/
public final String graphIdentifier() {
return graphIdentifier;
}
/**
*
* The query string to be executed.
*
*
* @return The query string to be executed.
*/
public final String queryString() {
return queryString;
}
/**
*
* The query language the query is written in. Currently only openCypher is supported.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #language} will
* return {@link QueryLanguage#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #languageAsString}.
*
*
* @return The query language the query is written in. Currently only openCypher is supported.
* @see QueryLanguage
*/
public final QueryLanguage language() {
return QueryLanguage.fromValue(language);
}
/**
*
* The query language the query is written in. Currently only openCypher is supported.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #language} will
* return {@link QueryLanguage#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #languageAsString}.
*
*
* @return The query language the query is written in. Currently only openCypher is supported.
* @see QueryLanguage
*/
public final String languageAsString() {
return language;
}
/**
* For responses, this returns true if the service returned a value for the Parameters 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 hasParameters() {
return parameters != null && !(parameters instanceof SdkAutoConstructMap);
}
/**
*
* The data parameters the query can use in JSON format. For example: {"name": "john", "age": 20}. (optional)
*
*
* 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 #hasParameters} method.
*
*
* @return The data parameters the query can use in JSON format. For example: {"name": "john", "age": 20}.
* (optional)
*/
public final Map parameters() {
return parameters;
}
/**
*
* Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same query.
* This reduces query latency, and works for both READ
and UPDATE
queries. The plan cache
* is an LRU cache with a 5 minute TTL and a capacity of 1000.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #planCache} will
* return {@link PlanCacheType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #planCacheAsString}.
*
*
* @return Query plan cache is a feature that saves the query plan and reuses it on successive executions of the
* same query. This reduces query latency, and works for both READ
and UPDATE
* queries. The plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.
* @see PlanCacheType
*/
public final PlanCacheType planCache() {
return PlanCacheType.fromValue(planCache);
}
/**
*
* Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same query.
* This reduces query latency, and works for both READ
and UPDATE
queries. The plan cache
* is an LRU cache with a 5 minute TTL and a capacity of 1000.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #planCache} will
* return {@link PlanCacheType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #planCacheAsString}.
*
*
* @return Query plan cache is a feature that saves the query plan and reuses it on successive executions of the
* same query. This reduces query latency, and works for both READ
and UPDATE
* queries. The plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.
* @see PlanCacheType
*/
public final String planCacheAsString() {
return planCache;
}
/**
*
* The explain mode parameter returns a query explain instead of the actual query results. A query explain can be
* used to gather insights about the query execution such as planning decisions, time spent on each operator,
* solutions flowing etc.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #explainMode} will
* return {@link ExplainMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #explainModeAsString}.
*
*
* @return The explain mode parameter returns a query explain instead of the actual query results. A query explain
* can be used to gather insights about the query execution such as planning decisions, time spent on each
* operator, solutions flowing etc.
* @see ExplainMode
*/
public final ExplainMode explainMode() {
return ExplainMode.fromValue(explainMode);
}
/**
*
* The explain mode parameter returns a query explain instead of the actual query results. A query explain can be
* used to gather insights about the query execution such as planning decisions, time spent on each operator,
* solutions flowing etc.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #explainMode} will
* return {@link ExplainMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #explainModeAsString}.
*
*
* @return The explain mode parameter returns a query explain instead of the actual query results. A query explain
* can be used to gather insights about the query execution such as planning decisions, time spent on each
* operator, solutions flowing etc.
* @see ExplainMode
*/
public final String explainModeAsString() {
return explainMode;
}
/**
*
* Specifies the query timeout duration, in milliseconds. (optional)
*
*
* @return Specifies the query timeout duration, in milliseconds. (optional)
*/
public final Integer queryTimeoutMilliseconds() {
return queryTimeoutMilliseconds;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(graphIdentifier());
hashCode = 31 * hashCode + Objects.hashCode(queryString());
hashCode = 31 * hashCode + Objects.hashCode(languageAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasParameters() ? parameters() : null);
hashCode = 31 * hashCode + Objects.hashCode(planCacheAsString());
hashCode = 31 * hashCode + Objects.hashCode(explainModeAsString());
hashCode = 31 * hashCode + Objects.hashCode(queryTimeoutMilliseconds());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ExecuteQueryRequest)) {
return false;
}
ExecuteQueryRequest other = (ExecuteQueryRequest) obj;
return Objects.equals(graphIdentifier(), other.graphIdentifier()) && Objects.equals(queryString(), other.queryString())
&& Objects.equals(languageAsString(), other.languageAsString()) && hasParameters() == other.hasParameters()
&& Objects.equals(parameters(), other.parameters())
&& Objects.equals(planCacheAsString(), other.planCacheAsString())
&& Objects.equals(explainModeAsString(), other.explainModeAsString())
&& Objects.equals(queryTimeoutMilliseconds(), other.queryTimeoutMilliseconds());
}
/**
* 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("ExecuteQueryRequest").add("GraphIdentifier", graphIdentifier())
.add("QueryString", queryString()).add("Language", languageAsString())
.add("Parameters", hasParameters() ? parameters() : null).add("PlanCache", planCacheAsString())
.add("ExplainMode", explainModeAsString()).add("QueryTimeoutMilliseconds", queryTimeoutMilliseconds()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "graphIdentifier":
return Optional.ofNullable(clazz.cast(graphIdentifier()));
case "queryString":
return Optional.ofNullable(clazz.cast(queryString()));
case "language":
return Optional.ofNullable(clazz.cast(languageAsString()));
case "parameters":
return Optional.ofNullable(clazz.cast(parameters()));
case "planCache":
return Optional.ofNullable(clazz.cast(planCacheAsString()));
case "explainMode":
return Optional.ofNullable(clazz.cast(explainModeAsString()));
case "queryTimeoutMilliseconds":
return Optional.ofNullable(clazz.cast(queryTimeoutMilliseconds()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((ExecuteQueryRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends NeptuneGraphRequest.Builder, SdkPojo, CopyableBuilder {
/**
*
* The unique identifier of the Neptune Analytics graph.
*
*
* @param graphIdentifier
* The unique identifier of the Neptune Analytics graph.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder graphIdentifier(String graphIdentifier);
/**
*
* The query string to be executed.
*
*
* @param queryString
* The query string to be executed.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder queryString(String queryString);
/**
*
* The query language the query is written in. Currently only openCypher is supported.
*
*
* @param language
* The query language the query is written in. Currently only openCypher is supported.
* @see QueryLanguage
* @return Returns a reference to this object so that method calls can be chained together.
* @see QueryLanguage
*/
Builder language(String language);
/**
*
* The query language the query is written in. Currently only openCypher is supported.
*
*
* @param language
* The query language the query is written in. Currently only openCypher is supported.
* @see QueryLanguage
* @return Returns a reference to this object so that method calls can be chained together.
* @see QueryLanguage
*/
Builder language(QueryLanguage language);
/**
*
* The data parameters the query can use in JSON format. For example: {"name": "john", "age": 20}. (optional)
*
*
* @param parameters
* The data parameters the query can use in JSON format. For example: {"name": "john", "age": 20}.
* (optional)
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder parameters(Map parameters);
/**
*
* Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same
* query. This reduces query latency, and works for both READ
and UPDATE
queries. The
* plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.
*
*
* @param planCache
* Query plan cache is a feature that saves the query plan and reuses it on successive executions of the
* same query. This reduces query latency, and works for both READ
and UPDATE
* queries. The plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.
* @see PlanCacheType
* @return Returns a reference to this object so that method calls can be chained together.
* @see PlanCacheType
*/
Builder planCache(String planCache);
/**
*
* Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same
* query. This reduces query latency, and works for both READ
and UPDATE
queries. The
* plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.
*
*
* @param planCache
* Query plan cache is a feature that saves the query plan and reuses it on successive executions of the
* same query. This reduces query latency, and works for both READ
and UPDATE
* queries. The plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.
* @see PlanCacheType
* @return Returns a reference to this object so that method calls can be chained together.
* @see PlanCacheType
*/
Builder planCache(PlanCacheType planCache);
/**
*
* The explain mode parameter returns a query explain instead of the actual query results. A query explain can
* be used to gather insights about the query execution such as planning decisions, time spent on each operator,
* solutions flowing etc.
*
*
* @param explainMode
* The explain mode parameter returns a query explain instead of the actual query results. A query
* explain can be used to gather insights about the query execution such as planning decisions, time
* spent on each operator, solutions flowing etc.
* @see ExplainMode
* @return Returns a reference to this object so that method calls can be chained together.
* @see ExplainMode
*/
Builder explainMode(String explainMode);
/**
*
* The explain mode parameter returns a query explain instead of the actual query results. A query explain can
* be used to gather insights about the query execution such as planning decisions, time spent on each operator,
* solutions flowing etc.
*
*
* @param explainMode
* The explain mode parameter returns a query explain instead of the actual query results. A query
* explain can be used to gather insights about the query execution such as planning decisions, time
* spent on each operator, solutions flowing etc.
* @see ExplainMode
* @return Returns a reference to this object so that method calls can be chained together.
* @see ExplainMode
*/
Builder explainMode(ExplainMode explainMode);
/**
*
* Specifies the query timeout duration, in milliseconds. (optional)
*
*
* @param queryTimeoutMilliseconds
* Specifies the query timeout duration, in milliseconds. (optional)
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder queryTimeoutMilliseconds(Integer queryTimeoutMilliseconds);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends NeptuneGraphRequest.BuilderImpl implements Builder {
private String graphIdentifier;
private String queryString;
private String language;
private Map parameters = DefaultSdkAutoConstructMap.getInstance();
private String planCache;
private String explainMode;
private Integer queryTimeoutMilliseconds;
private BuilderImpl() {
}
private BuilderImpl(ExecuteQueryRequest model) {
super(model);
graphIdentifier(model.graphIdentifier);
queryString(model.queryString);
language(model.language);
parameters(model.parameters);
planCache(model.planCache);
explainMode(model.explainMode);
queryTimeoutMilliseconds(model.queryTimeoutMilliseconds);
}
public final String getGraphIdentifier() {
return graphIdentifier;
}
public final void setGraphIdentifier(String graphIdentifier) {
this.graphIdentifier = graphIdentifier;
}
@Override
public final Builder graphIdentifier(String graphIdentifier) {
this.graphIdentifier = graphIdentifier;
return this;
}
public final String getQueryString() {
return queryString;
}
public final void setQueryString(String queryString) {
this.queryString = queryString;
}
@Override
public final Builder queryString(String queryString) {
this.queryString = queryString;
return this;
}
public final String getLanguage() {
return language;
}
public final void setLanguage(String language) {
this.language = language;
}
@Override
public final Builder language(String language) {
this.language = language;
return this;
}
@Override
public final Builder language(QueryLanguage language) {
this.language(language == null ? null : language.toString());
return this;
}
public final Map getParameters() {
if (parameters instanceof SdkAutoConstructMap) {
return null;
}
return parameters;
}
public final void setParameters(Map parameters) {
this.parameters = DocumentValuedMapCopier.copy(parameters);
}
@Override
public final Builder parameters(Map parameters) {
this.parameters = DocumentValuedMapCopier.copy(parameters);
return this;
}
public final String getPlanCache() {
return planCache;
}
public final void setPlanCache(String planCache) {
this.planCache = planCache;
}
@Override
public final Builder planCache(String planCache) {
this.planCache = planCache;
return this;
}
@Override
public final Builder planCache(PlanCacheType planCache) {
this.planCache(planCache == null ? null : planCache.toString());
return this;
}
public final String getExplainMode() {
return explainMode;
}
public final void setExplainMode(String explainMode) {
this.explainMode = explainMode;
}
@Override
public final Builder explainMode(String explainMode) {
this.explainMode = explainMode;
return this;
}
@Override
public final Builder explainMode(ExplainMode explainMode) {
this.explainMode(explainMode == null ? null : explainMode.toString());
return this;
}
public final Integer getQueryTimeoutMilliseconds() {
return queryTimeoutMilliseconds;
}
public final void setQueryTimeoutMilliseconds(Integer queryTimeoutMilliseconds) {
this.queryTimeoutMilliseconds = queryTimeoutMilliseconds;
}
@Override
public final Builder queryTimeoutMilliseconds(Integer queryTimeoutMilliseconds) {
this.queryTimeoutMilliseconds = queryTimeoutMilliseconds;
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public ExecuteQueryRequest build() {
return new ExecuteQueryRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}