FirestoreAdminClient

FirestoreAdminClient

The Cloud Firestore Admin API.

This API provides several administrative services for Cloud Firestore.

Project, Database, Namespace, Collection, Collection Group, and Document are used as defined in the Google Cloud Firestore API.

Operation: An Operation represents work being performed in the background.

The index service manages Cloud Firestore indexes.

Index creation is performed asynchronously. An Operation resource is created for each such asynchronous operation. The state of the operation (including any errors encountered) may be queried via the Operation resource.

The Operations collection provides a record of actions performed for the specified Project (including any Operations in progress). Operations are not created directly but through calls on other collections or resources.

An Operation that is done may be deleted so that it is no longer listed as part of the Operation collection. Operations are garbage collected after 30 days. By default, ListOperations will only return in progress and failed operations. To list completed operation, issue a ListOperations request with the filter done: true.

Operations are created by service FirestoreAdmin, but are accessed via service google.longrunning.Operations.

Constructor

new FirestoreAdminClient(optionsopt, gaxInstanceopt)

Construct an instance of FirestoreAdminClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. The options accepted by the constructor are described in detail in this document. The common options are:

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean <optional>

Use HTTP/1.1 REST mode. For more information, please check the documentation.

gaxInstance gax <optional>

loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new FirestoreAdminClient({fallback: true}, gax);

Members

apiEndpoint

The DNS address for this API service.

apiEndpoint

The DNS address for this API service - same as servicePath.

port

The port for this API service.

scopes

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

The DNS address for this API service.

Methods

backupPath(project, location, backup) → {string}

Return a fully-qualified backup resource name string.

Parameters:
Name Type Description
project string
location string
backup string
Returns:
Type Description
string

Resource name string.

backupSchedulePath(project, database, backup_schedule) → {string}

Return a fully-qualified backupSchedule resource name string.

Parameters:
Name Type Description
project string
database string
backup_schedule string
Returns:
Type Description
string

Resource name string.

cancelOperation(request, optionsopt, callbackopt) → {Promise}

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the operation resource to be cancelled.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Returns:
Type Description
Promise
  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
Example
```
const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});
```

(async) checkBulkDeleteDocumentsProgress(name) → {Promise}

Check the status of the long running operation returned by bulkDeleteDocuments().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.bulk_delete_documents.js

region_tag:firestore_v1_generated_FirestoreAdmin_BulkDeleteDocuments_async

(async) checkCreateDatabaseProgress(name) → {Promise}

Check the status of the long running operation returned by createDatabase().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.create_database.js

region_tag:firestore_v1_generated_FirestoreAdmin_CreateDatabase_async

(async) checkCreateIndexProgress(name) → {Promise}

Check the status of the long running operation returned by createIndex().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.create_index.js

region_tag:firestore_v1_generated_FirestoreAdmin_CreateIndex_async

(async) checkDeleteDatabaseProgress(name) → {Promise}

Check the status of the long running operation returned by deleteDatabase().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.delete_database.js

region_tag:firestore_v1_generated_FirestoreAdmin_DeleteDatabase_async

(async) checkExportDocumentsProgress(name) → {Promise}

Check the status of the long running operation returned by exportDocuments().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.export_documents.js

region_tag:firestore_v1_generated_FirestoreAdmin_ExportDocuments_async

(async) checkImportDocumentsProgress(name) → {Promise}

Check the status of the long running operation returned by importDocuments().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.import_documents.js

region_tag:firestore_v1_generated_FirestoreAdmin_ImportDocuments_async

(async) checkRestoreDatabaseProgress(name) → {Promise}

Check the status of the long running operation returned by restoreDatabase().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.restore_database.js

region_tag:firestore_v1_generated_FirestoreAdmin_RestoreDatabase_async

(async) checkUpdateDatabaseProgress(name) → {Promise}

Check the status of the long running operation returned by updateDatabase().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.update_database.js

region_tag:firestore_v1_generated_FirestoreAdmin_UpdateDatabase_async

(async) checkUpdateFieldProgress(name) → {Promise}

Check the status of the long running operation returned by updateField().

Parameters:
Name Type Description
name String

The operation name that will be passed.

Returns:
Type Description
Promise
  • The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.
Example

include:samples/generated/v1/firestore_admin.update_field.js

region_tag:firestore_v1_generated_FirestoreAdmin_UpdateField_async

close() → {Promise}

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns:
Type Description
Promise

A promise that resolves when the client is closed.

collectionGroupPath(project, database, collection) → {string}

Return a fully-qualified collectionGroup resource name string.

Parameters:
Name Type Description
project string
database string
collection string
Returns:
Type Description
string

Resource name string.

databasePath(project, database) → {string}

Return a fully-qualified database resource name string.

Parameters:
Name Type Description
project string
database string
Returns:
Type Description
string

Resource name string.

deleteOperation(request, optionsopt, callbackopt) → {Promise}

Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the operation resource to be deleted.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Returns:
Type Description
Promise
  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
Example
```
const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});
```

fieldPath(project, database, collection, field) → {string}

Return a fully-qualified field resource name string.

Parameters:
Name Type Description
project string
database string
collection string
field string
Returns:
Type Description
string

Resource name string.

getLocation(request, optionsopt) → {Promise}

Gets information about a location.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Resource name for the location.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Location. Please see the documentation for more details and examples.
Example
```
const [response] = await client.getLocation(request);
```

getOperation(request, optionsopt, callbackopt) → {Promise}

Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The name of the operation resource.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing google.longrunning.Operation.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing google.longrunning.Operation. The promise has a method named "cancel" which cancels the ongoing API call.
Example
```
const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)
```

getProjectId() → {Promise}

Return the project ID used by this class.

Returns:
Type Description
Promise

A promise that resolves to string containing the project ID.

indexPath(project, database, collection, index) → {string}

Return a fully-qualified index resource name string.

Parameters:
Name Type Description
project string
database string
collection string
index string
Returns:
Type Description
string

Resource name string.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

listFieldsAsync(request, optionsopt) → {Object}

Equivalent to listFields, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with a filter that includes indexConfig.usesAncestorConfig:false or ttlConfig:*.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListFields, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Field. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

include:samples/generated/v1/firestore_admin.list_fields.js

region_tag:firestore_v1_generated_FirestoreAdmin_ListFields_async

listFieldsStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results. Currently, FirestoreAdmin.ListFields only supports listing fields that have been explicitly overridden. To issue this query, call FirestoreAdmin.ListFields with a filter that includes indexConfig.usesAncestorConfig:false or ttlConfig:*.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListFields, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Field on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listFieldsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listIndexesAsync(request, optionsopt) → {Object}

Equivalent to listIndexes, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListIndexes, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Index. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

include:samples/generated/v1/firestore_admin.list_indexes.js

region_tag:firestore_v1_generated_FirestoreAdmin_ListIndexes_async

listIndexesStream(request, optionsopt) → {Stream}

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. A parent name of the form projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}

filter string

The filter to apply to list results.

pageSize number

The number of results to return.

pageToken string

A page token, returned from a previous call to FirestoreAdmin.ListIndexes, that may be used to get the next page of results.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Stream

An object stream which emits an object representing Index on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listIndexesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listLocationsAsync(request, optionsopt) → {Object}

Lists information about the supported locations for this service. Returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The resource that owns the locations collection, if applicable.

filter string

The standard list filter.

pageSize number

The standard list page size.

pageToken string

The standard list page token.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Object

An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Location. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example
```
const iterable = client.listLocationsAsync(request);
for await (const response of iterable) {
  // process response
}
```

listOperationsAsync(request, optionsopt) → {Object}

Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. Returns an iterable object.

For-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The name of the operation collection.

filter string

The standard list filter.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Returns:
Type Description
Object

An iterable Object that conforms to iteration protocols.

Example
```
const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)
```

locationPath(project, location) → {string}

Return a fully-qualified location resource name string.

Parameters:
Name Type Description
project string
location string
Returns:
Type Description
string

Resource name string.

matchBackupFromBackupName(backupName) → {string}

Parse the backup from Backup resource.

Parameters:
Name Type Description
backupName string

A fully-qualified path representing Backup resource.

Returns:
Type Description
string

A string representing the backup.

matchBackupScheduleFromBackupScheduleName(backupScheduleName) → {string}

Parse the backup_schedule from BackupSchedule resource.

Parameters:
Name Type Description
backupScheduleName string

A fully-qualified path representing BackupSchedule resource.

Returns:
Type Description
string

A string representing the backup_schedule.

matchCollectionFromCollectionGroupName(collectionGroupName) → {string}

Parse the collection from CollectionGroup resource.

Parameters:
Name Type Description
collectionGroupName string

A fully-qualified path representing CollectionGroup resource.

Returns:
Type Description
string

A string representing the collection.

matchCollectionFromFieldName(fieldName) → {string}

Parse the collection from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the collection.

matchCollectionFromIndexName(indexName) → {string}

Parse the collection from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the collection.

matchDatabaseFromBackupScheduleName(backupScheduleName) → {string}

Parse the database from BackupSchedule resource.

Parameters:
Name Type Description
backupScheduleName string

A fully-qualified path representing BackupSchedule resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromCollectionGroupName(collectionGroupName) → {string}

Parse the database from CollectionGroup resource.

Parameters:
Name Type Description
collectionGroupName string

A fully-qualified path representing CollectionGroup resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromDatabaseName(databaseName) → {string}

Parse the database from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromFieldName(fieldName) → {string}

Parse the database from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the database.

matchDatabaseFromIndexName(indexName) → {string}

Parse the database from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the database.

matchFieldFromFieldName(fieldName) → {string}

Parse the field from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the field.

matchIndexFromIndexName(indexName) → {string}

Parse the index from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the index.

matchLocationFromBackupName(backupName) → {string}

Parse the location from Backup resource.

Parameters:
Name Type Description
backupName string

A fully-qualified path representing Backup resource.

Returns:
Type Description
string

A string representing the location.

matchLocationFromLocationName(locationName) → {string}

Parse the location from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

Returns:
Type Description
string

A string representing the location.

matchProjectFromBackupName(backupName) → {string}

Parse the project from Backup resource.

Parameters:
Name Type Description
backupName string

A fully-qualified path representing Backup resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromBackupScheduleName(backupScheduleName) → {string}

Parse the project from BackupSchedule resource.

Parameters:
Name Type Description
backupScheduleName string

A fully-qualified path representing BackupSchedule resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromCollectionGroupName(collectionGroupName) → {string}

Parse the project from CollectionGroup resource.

Parameters:
Name Type Description
collectionGroupName string

A fully-qualified path representing CollectionGroup resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromDatabaseName(databaseName) → {string}

Parse the project from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromFieldName(fieldName) → {string}

Parse the project from Field resource.

Parameters:
Name Type Description
fieldName string

A fully-qualified path representing Field resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromIndexName(indexName) → {string}

Parse the project from Index resource.

Parameters:
Name Type Description
indexName string

A fully-qualified path representing Index resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromLocationName(locationName) → {string}

Parse the project from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

Returns:
Type Description
string

A string representing the project.

matchProjectFromProjectName(projectName) → {string}

Parse the project from Project resource.

Parameters:
Name Type Description
projectName string

A fully-qualified path representing Project resource.

Returns:
Type Description
string

A string representing the project.

projectPath(project) → {string}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project string
Returns:
Type Description
string

Resource name string.