Class ApiResponse

java.lang.Object
com.datastax.astra.internal.api.ApiResponse
All Implemented Interfaces:
Serializable

public class ApiResponse extends Object implements Serializable
Represents the generic response structure for API calls. This class encapsulates different segments of the response, such as status information, error details, and data returned by 'find' operations. It provides flexibility to handle various types of responses within a unified framework.
See Also:
  • Constructor Details

    • ApiResponse

      public ApiResponse()
      Default constructor for ApiResponse. Initializes a new instance of the class without setting any properties.
  • Method Details

    • getStatusKeyAsStringStream

      public Stream<String> getStatusKeyAsStringStream(@NonNull @NonNull String key)
      Retrieves a stream of String values from the 'status' map based on the provided key. This method is useful for processing multiple values associated with a single key in the status information.
      Parameters:
      key - The key for which to retrieve the values.
      Returns:
      A Stream of String values associated with the specified key; an empty stream if the key does not exist.
    • getStatusKeyAsList

      public <T> List<T> getStatusKeyAsList(@NonNull @NonNull String key, Class<T> targetClass)
      Retrieves a list of objects from the 'status' map based on the provided key, casting them to the specified class. This method is suitable for cases where the status information contains lists of objects under a single key.
      Type Parameters:
      T - The type of the objects in the list to be returned.
      Parameters:
      key - The key for which to retrieve the list.
      targetClass - The class to which the objects in the list should be cast.
      Returns:
      The list of objects associated with the specified key, cast to the specified class; null if the key does not exist.
    • getStatusKeyAsMap

      public <T> Map<String,T> getStatusKeyAsMap(@NonNull @NonNull String key, Class<T> targetClass)
      Retrieves a list of objects from the 'status' map based on the provided key, casting them to the specified class. This method is suitable for cases where the status information contains lists of objects under a single key.
      Type Parameters:
      T - The type of the objects in the list to be returned.
      Parameters:
      key - The key for which to retrieve the list.
      targetClass - The class to which the objects in the list should be cast.
      Returns:
      The list of objects associated with the specified key, cast to the specified class; null if the key does not exist.