getTask method

Future<GetTaskResponse> getTask({
  1. required String indexName,
  2. required int taskID,
  3. RequestOptions? requestOptions,
})

Checks the status of a given task. Indexing tasks are asynchronous. When you add, update, or delete records or indices, a task is created on a queue and completed depending on the load on the server. The indexing tasks' responses include a task ID that you can use to check the status.

Required API Key ACLs:

  • addObject

Parameters:

  • indexName Name of the index on which to perform the operation.
  • taskID Unique task identifier.
  • requestOptions additional request configuration.

Implementation

Future<GetTaskResponse> getTask({
  required String indexName,
  required int taskID,
  RequestOptions? requestOptions,
}) async {
  assert(
    indexName.isNotEmpty,
    'Parameter `indexName` is required when calling `getTask`.',
  );
  final request = ApiRequest(
    method: RequestMethod.get,
    path: r'/1/indexes/{indexName}/task/{taskID}'
        .replaceAll(
            '{' r'indexName' '}', Uri.encodeComponent(indexName.toString()))
        .replaceAll(
            '{' r'taskID' '}', Uri.encodeComponent(taskID.toString())),
  );
  final response = await _retryStrategy.execute(
    request: request,
    options: requestOptions,
  );
  return deserialize<GetTaskResponse, GetTaskResponse>(
    response,
    'GetTaskResponse',
    growable: true,
  );
}