Class AbstractCommandRunner

java.lang.Object
com.datastax.astra.internal.command.AbstractCommandRunner
All Implemented Interfaces:
CommandRunner
Direct Known Subclasses:
Collection, DataAPIDatabaseAdmin, Database

public abstract class AbstractCommandRunner extends Object implements CommandRunner
Execute the command and parse results throwing DataApiResponseException when needed.
  • Field Details

    • httpClient

      protected RetryHttpClient httpClient
      Http client reused when properties not override.
    • commandOptions

      protected CommandOptions<?> commandOptions
      Default command options when not override
  • Constructor Details

    • AbstractCommandRunner

      protected AbstractCommandRunner()
      Default constructor.
  • Method Details

    • runCommand

      public ApiResponse runCommand(Command command, CommandOptions<?> overridingOptions)
      Command to return the payload as a Map.
      Specified by:
      runCommand in interface CommandRunner
      Parameters:
      command - command to execute
      overridingOptions - options when running the command
      Returns:
      result as a document map
    • runCommand

      public <T> T runCommand(Command command, CommandOptions<?> options, Class<T> documentClass)
      Extension point to run any command with typing constraints.
      Specified by:
      runCommand in interface CommandRunner
      Type Parameters:
      T - document type to use
      Parameters:
      command - command as a json Payload
      options - options when running the command
      documentClass - document class to use for marshalling
      Returns:
      instance of expecting type.
    • mapAsDocument

      protected <T> T mapAsDocument(ApiResponse api, Class<T> documentClass)
      Document Mapping.
      Type Parameters:
      T - document type
      Parameters:
      api - api response
      documentClass - document class
      Returns:
      document
    • getApiEndpoint

      protected abstract String getApiEndpoint()
      The subclass should provide the endpoint, url to post request.
      Returns:
      url on which to post the request