Class AbstractCommandRunner<OPTIONS extends BaseOptions<?>>
java.lang.Object
com.datastax.astra.internal.command.AbstractCommandRunner<OPTIONS>
- Type Parameters:
OPTIONS- the type of options used by the command runner, extendingBaseOptionsExample usage:public class MyCommandRunner extends AbstractCommandRunner<MyOptions> { @Override protected void runCommand(MyOptions options) { // Implement the command execution logic here } @Override protected void parseResults() { // Implement result parsing logic here } } MyCommandRunner runner = new MyCommandRunner(); runner.execute(new MyOptions());
- All Implemented Interfaces:
CommandRunner
- Direct Known Subclasses:
AstraDBDatabaseAdmin,Collection,DataAPIDatabaseAdmin,Database,Table
public abstract class AbstractCommandRunner<OPTIONS extends BaseOptions<?>>
extends Object
implements CommandRunner
Abstract base class for executing commands and handling their results.
This class provides a template for implementing a command runner that executes commands
with specific options and parses their results. It ensures consistent error handling by
throwing a DataAPIResponseException when necessary.
Subclasses must implement the command execution logic as required by the specific context.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringApi Endpoint for the API.protected static final Stringparameters names.protected static final Stringparameters names.protected static final Stringparameters names.protected static final Stringparameters names.protected RetryHttpClientHttp client reused when properties not override.protected OPTIONSDefault command options when not override.protected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringjson inputsprotected static final Stringparsing output jsonprotected static final Stringparsing output jsonprotected static final Stringparameters names.protected static final Stringparsing output jsonprotected static final Stringparsing output jsonprotected static final Stringparsing output jsonprotected static final Stringparsing output json -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor.AbstractCommandRunner(String apiEndpoint, OPTIONS options) Constructor with the API endpoint and default options. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidValidates that the current options are configured for Astra.Gets apiEndpointGets commandOptionsprotected DataAPISerializerGets the serializer currently in place to parse inputs and outputs.runCommand(Command command, BaseOptions<?> overridingOptions) Command to return the payload as a Map.<DOC> DOCrunCommand(Command command, BaseOptions<?> options, Class<DOC> documentClass) Extension point to run any command with typing constraints.protected <DOC> DOCunmarshall(DataAPIResponse api, Class<DOC> documentClass) Document Mapping.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.datastax.astra.client.core.commands.CommandRunner
runCommand, runCommand
-
Field Details
-
ARG_DATABASE
parameters names.- See Also:
-
ARG_OPTIONS
parameters names.- See Also:
-
ARG_UPDATE
parameters names.- See Also:
-
ARG_CLAZZ
parameters names.- See Also:
-
RESULT_INSERTED_IDS
parameters names.- See Also:
-
RESULT_DELETED_COUNT
parsing output json- See Also:
-
RESULT_MATCHED_COUNT
parsing output json- See Also:
-
RESULT_MODIFIED_COUNT
parsing output json- See Also:
-
RESULT_UPSERTED_ID
parsing output json- See Also:
-
RESULT_MORE_DATA
parsing output json- See Also:
-
RESULT_COUNT
parsing output json- See Also:
-
OPTIONS_UPSERT
json inputs- See Also:
-
OPTIONS_RETURN_DOCUMENT
json inputs- See Also:
-
OPTIONS_ORDERED
json inputs- See Also:
-
OPTIONS_RETURN_DOCUMENT_RESPONSES
json inputs- See Also:
-
OPTIONS_PAGE_STATE
json inputs- See Also:
-
OPTIONS_LIMIT
json inputs- See Also:
-
OPTIONS_HYBRID_LIMITS
json inputs- See Also:
-
OPTIONS_RERANK_QUERY
json inputs- See Also:
-
OPTIONS_RERANK_ON
json inputs- See Also:
-
OPTIONS_INCLUDE_SORT_VECTOR
json inputs- See Also:
-
OPTIONS_INCLUDE_SCORES
json inputs- See Also:
-
OPTIONS_INCLUDE_SIMILARITY
json inputs- See Also:
-
httpClient
Http client reused when properties not override. -
apiEndpoint
Api Endpoint for the API. -
options
Default command options when not override.
-
-
Constructor Details
-
AbstractCommandRunner
protected AbstractCommandRunner()Default constructor. -
AbstractCommandRunner
Constructor with the API endpoint and default options.- Parameters:
apiEndpoint- the API endpointoptions- the default options
-
-
Method Details
-
runCommand
Command to return the payload as a Map.- Specified by:
runCommandin interfaceCommandRunner- Parameters:
command- command to executeoverridingOptions- options when running the command- Returns:
- result as a document map
-
runCommand
Extension point to run any command with typing constraints.- Specified by:
runCommandin interfaceCommandRunner- Type Parameters:
DOC- document type to use- Parameters:
command- command as a json Payloadoptions- options when running the commanddocumentClass- document class to use for marshalling- Returns:
- instance of expecting type.
-
assertIsAstra
protected void assertIsAstra()Validates that the current options are configured for Astra.This method ensures that the operation is being performed in an Astra environment. If the options are not set for Astra, it throws an exception with details about the restriction.
- Throws:
IllegalStateException- if the configuration is not set for Astra
-
getSerializer
Gets the serializer currently in place to parse inputs and outputs.- Returns:
- the serializer
-
unmarshall
Document Mapping.- Type Parameters:
DOC- document type- Parameters:
api- api responsedocumentClass- document class- Returns:
- document
-
getApiEndpoint
Gets apiEndpoint- Returns:
- value of apiEndpoint
-
getOptions
Gets commandOptions- Returns:
- value of commandOptions
-