@Generated(value="by gapic-generator") @BetaApi public class FirestoreAdminClient extends Object implements BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
Index index = Index.newBuilder().build();
Operation response = firestoreAdminClient.createIndex(parent, index);
}
Note: close() needs to be called on the firestoreAdminClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of FirestoreAdminSettings to create(). For example:
To customize credentials:
FirestoreAdminSettings firestoreAdminSettings =
FirestoreAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
FirestoreAdminClient firestoreAdminClient =
FirestoreAdminClient.create(firestoreAdminSettings);
To customize the endpoint:
FirestoreAdminSettings firestoreAdminSettings =
FirestoreAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
FirestoreAdminClient firestoreAdminClient =
FirestoreAdminClient.create(firestoreAdminSettings);
Modifier and Type | Class and Description |
---|---|
static class |
FirestoreAdminClient.ListFieldsFixedSizeCollection |
static class |
FirestoreAdminClient.ListFieldsPage |
static class |
FirestoreAdminClient.ListFieldsPagedResponse |
static class |
FirestoreAdminClient.ListIndexesFixedSizeCollection |
static class |
FirestoreAdminClient.ListIndexesPage |
static class |
FirestoreAdminClient.ListIndexesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
FirestoreAdminClient(FirestoreAdminSettings settings)
Constructs an instance of FirestoreAdminClient, using the given settings.
|
protected |
FirestoreAdminClient(FirestoreAdminStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static FirestoreAdminClient |
create()
Constructs an instance of FirestoreAdminClient with default settings.
|
static FirestoreAdminClient |
create(FirestoreAdminSettings settings)
Constructs an instance of FirestoreAdminClient, using the given settings.
|
static FirestoreAdminClient |
create(FirestoreAdminStub stub)
Constructs an instance of FirestoreAdminClient, using the given stub for making calls.
|
Operation |
createIndex(com.google.firestore.admin.v1.CreateIndexRequest request)
Creates a composite index.
|
Operation |
createIndex(com.google.firestore.admin.v1.ParentName parent,
com.google.firestore.admin.v1.Index index)
Creates a composite index.
|
Operation |
createIndex(String parent,
com.google.firestore.admin.v1.Index index)
Creates a composite index.
|
UnaryCallable<com.google.firestore.admin.v1.CreateIndexRequest,Operation> |
createIndexCallable()
Creates a composite index.
|
void |
deleteIndex(com.google.firestore.admin.v1.DeleteIndexRequest request)
Deletes a composite index.
|
void |
deleteIndex(com.google.firestore.admin.v1.IndexName name)
Deletes a composite index.
|
void |
deleteIndex(String name)
Deletes a composite index.
|
UnaryCallable<com.google.firestore.admin.v1.DeleteIndexRequest,Empty> |
deleteIndexCallable()
Deletes a composite index.
|
Operation |
exportDocuments(com.google.firestore.admin.v1.DatabaseName name)
Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage
system, such as Google Cloud Storage.
|
Operation |
exportDocuments(com.google.firestore.admin.v1.ExportDocumentsRequest request)
Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage
system, such as Google Cloud Storage.
|
Operation |
exportDocuments(String name)
Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage
system, such as Google Cloud Storage.
|
UnaryCallable<com.google.firestore.admin.v1.ExportDocumentsRequest,Operation> |
exportDocumentsCallable()
Exports a copy of all or a subset of documents from Google Cloud Firestore to another storage
system, such as Google Cloud Storage.
|
com.google.firestore.admin.v1.Field |
getField(com.google.firestore.admin.v1.FieldName name)
Gets the metadata and configuration for a Field.
|
com.google.firestore.admin.v1.Field |
getField(com.google.firestore.admin.v1.GetFieldRequest request)
Gets the metadata and configuration for a Field.
|
com.google.firestore.admin.v1.Field |
getField(String name)
Gets the metadata and configuration for a Field.
|
UnaryCallable<com.google.firestore.admin.v1.GetFieldRequest,com.google.firestore.admin.v1.Field> |
getFieldCallable()
Gets the metadata and configuration for a Field.
|
com.google.firestore.admin.v1.Index |
getIndex(com.google.firestore.admin.v1.GetIndexRequest request)
Gets a composite index.
|
com.google.firestore.admin.v1.Index |
getIndex(com.google.firestore.admin.v1.IndexName name)
Gets a composite index.
|
com.google.firestore.admin.v1.Index |
getIndex(String name)
Gets a composite index.
|
UnaryCallable<com.google.firestore.admin.v1.GetIndexRequest,com.google.firestore.admin.v1.Index> |
getIndexCallable()
Gets a composite index.
|
FirestoreAdminSettings |
getSettings() |
FirestoreAdminStub |
getStub() |
Operation |
importDocuments(com.google.firestore.admin.v1.DatabaseName name)
Imports documents into Google Cloud Firestore.
|
Operation |
importDocuments(com.google.firestore.admin.v1.ImportDocumentsRequest request)
Imports documents into Google Cloud Firestore.
|
Operation |
importDocuments(String name)
Imports documents into Google Cloud Firestore.
|
UnaryCallable<com.google.firestore.admin.v1.ImportDocumentsRequest,Operation> |
importDocumentsCallable()
Imports documents into Google Cloud Firestore.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
FirestoreAdminClient.ListFieldsPagedResponse |
listFields(com.google.firestore.admin.v1.ListFieldsRequest request)
Lists the field configuration and metadata for this database.
|
FirestoreAdminClient.ListFieldsPagedResponse |
listFields(com.google.firestore.admin.v1.ParentName parent)
Lists the field configuration and metadata for this database.
|
FirestoreAdminClient.ListFieldsPagedResponse |
listFields(String parent)
Lists the field configuration and metadata for this database.
|
UnaryCallable<com.google.firestore.admin.v1.ListFieldsRequest,com.google.firestore.admin.v1.ListFieldsResponse> |
listFieldsCallable()
Lists the field configuration and metadata for this database.
|
UnaryCallable<com.google.firestore.admin.v1.ListFieldsRequest,FirestoreAdminClient.ListFieldsPagedResponse> |
listFieldsPagedCallable()
Lists the field configuration and metadata for this database.
|
FirestoreAdminClient.ListIndexesPagedResponse |
listIndexes(com.google.firestore.admin.v1.ListIndexesRequest request)
Lists composite indexes.
|
FirestoreAdminClient.ListIndexesPagedResponse |
listIndexes(com.google.firestore.admin.v1.ParentName parent)
Lists composite indexes.
|
FirestoreAdminClient.ListIndexesPagedResponse |
listIndexes(String parent)
Lists composite indexes.
|
UnaryCallable<com.google.firestore.admin.v1.ListIndexesRequest,com.google.firestore.admin.v1.ListIndexesResponse> |
listIndexesCallable()
Lists composite indexes.
|
UnaryCallable<com.google.firestore.admin.v1.ListIndexesRequest,FirestoreAdminClient.ListIndexesPagedResponse> |
listIndexesPagedCallable()
Lists composite indexes.
|
void |
shutdown() |
void |
shutdownNow() |
Operation |
updateField(com.google.firestore.admin.v1.Field field)
Updates a field configuration.
|
Operation |
updateField(com.google.firestore.admin.v1.UpdateFieldRequest request)
Updates a field configuration.
|
UnaryCallable<com.google.firestore.admin.v1.UpdateFieldRequest,Operation> |
updateFieldCallable()
Updates a field configuration.
|
protected FirestoreAdminClient(FirestoreAdminSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected FirestoreAdminClient(FirestoreAdminStub stub)
public static final FirestoreAdminClient create() throws IOException
IOException
public static final FirestoreAdminClient create(FirestoreAdminSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final FirestoreAdminClient create(FirestoreAdminStub stub)
public final FirestoreAdminSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public FirestoreAdminStub getStub()
public final Operation createIndex(com.google.firestore.admin.v1.ParentName parent, com.google.firestore.admin.v1.Index index)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
Index index = Index.newBuilder().build();
Operation response = firestoreAdminClient.createIndex(parent, index);
}
parent
- A parent name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`index
- The composite index to create.ApiException
- if the remote call failspublic final Operation createIndex(String parent, com.google.firestore.admin.v1.Index index)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
Index index = Index.newBuilder().build();
Operation response = firestoreAdminClient.createIndex(parent.toString(), index);
}
parent
- A parent name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`index
- The composite index to create.ApiException
- if the remote call failspublic final Operation createIndex(com.google.firestore.admin.v1.CreateIndexRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
Index index = Index.newBuilder().build();
CreateIndexRequest request = CreateIndexRequest.newBuilder()
.setParent(parent.toString())
.setIndex(index)
.build();
Operation response = firestoreAdminClient.createIndex(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.CreateIndexRequest,Operation> createIndexCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
Index index = Index.newBuilder().build();
CreateIndexRequest request = CreateIndexRequest.newBuilder()
.setParent(parent.toString())
.setIndex(index)
.build();
ApiFuture<Operation> future = firestoreAdminClient.createIndexCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final FirestoreAdminClient.ListIndexesPagedResponse listIndexes(com.google.firestore.admin.v1.ParentName parent)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
for (Index element : firestoreAdminClient.listIndexes(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- A parent name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`ApiException
- if the remote call failspublic final FirestoreAdminClient.ListIndexesPagedResponse listIndexes(String parent)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
for (Index element : firestoreAdminClient.listIndexes(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- A parent name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`ApiException
- if the remote call failspublic final FirestoreAdminClient.ListIndexesPagedResponse listIndexes(com.google.firestore.admin.v1.ListIndexesRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
ListIndexesRequest request = ListIndexesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Index element : firestoreAdminClient.listIndexes(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.ListIndexesRequest,FirestoreAdminClient.ListIndexesPagedResponse> listIndexesPagedCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
ListIndexesRequest request = ListIndexesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListIndexesPagedResponse> future = firestoreAdminClient.listIndexesPagedCallable().futureCall(request);
// Do something
for (Index element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.firestore.admin.v1.ListIndexesRequest,com.google.firestore.admin.v1.ListIndexesResponse> listIndexesCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
ListIndexesRequest request = ListIndexesRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListIndexesResponse response = firestoreAdminClient.listIndexesCallable().call(request);
for (Index element : response.getIndexesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.firestore.admin.v1.Index getIndex(com.google.firestore.admin.v1.IndexName name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
Index response = firestoreAdminClient.getIndex(name);
}
name
- A name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`ApiException
- if the remote call failspublic final com.google.firestore.admin.v1.Index getIndex(String name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
Index response = firestoreAdminClient.getIndex(name.toString());
}
name
- A name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`ApiException
- if the remote call failspublic final com.google.firestore.admin.v1.Index getIndex(com.google.firestore.admin.v1.GetIndexRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
GetIndexRequest request = GetIndexRequest.newBuilder()
.setName(name.toString())
.build();
Index response = firestoreAdminClient.getIndex(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.GetIndexRequest,com.google.firestore.admin.v1.Index> getIndexCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
GetIndexRequest request = GetIndexRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Index> future = firestoreAdminClient.getIndexCallable().futureCall(request);
// Do something
Index response = future.get();
}
public final void deleteIndex(com.google.firestore.admin.v1.IndexName name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
firestoreAdminClient.deleteIndex(name);
}
name
- A name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`ApiException
- if the remote call failspublic final void deleteIndex(String name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
firestoreAdminClient.deleteIndex(name.toString());
}
name
- A name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`ApiException
- if the remote call failspublic final void deleteIndex(com.google.firestore.admin.v1.DeleteIndexRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
DeleteIndexRequest request = DeleteIndexRequest.newBuilder()
.setName(name.toString())
.build();
firestoreAdminClient.deleteIndex(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.DeleteIndexRequest,Empty> deleteIndexCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[INDEX_ID]");
DeleteIndexRequest request = DeleteIndexRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = firestoreAdminClient.deleteIndexCallable().futureCall(request);
// Do something
future.get();
}
public final Operation importDocuments(com.google.firestore.admin.v1.DatabaseName name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
Operation response = firestoreAdminClient.importDocuments(name);
}
name
- Database to import into. Should be of the form:
`projects/{project_id}/databases/{database_id}`.ApiException
- if the remote call failspublic final Operation importDocuments(String name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
Operation response = firestoreAdminClient.importDocuments(name.toString());
}
name
- Database to import into. Should be of the form:
`projects/{project_id}/databases/{database_id}`.ApiException
- if the remote call failspublic final Operation importDocuments(com.google.firestore.admin.v1.ImportDocumentsRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder()
.setName(name.toString())
.build();
Operation response = firestoreAdminClient.importDocuments(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.ImportDocumentsRequest,Operation> importDocumentsCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Operation> future = firestoreAdminClient.importDocumentsCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final Operation exportDocuments(com.google.firestore.admin.v1.DatabaseName name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
Operation response = firestoreAdminClient.exportDocuments(name);
}
name
- Database to export. Should be of the form:
`projects/{project_id}/databases/{database_id}`.ApiException
- if the remote call failspublic final Operation exportDocuments(String name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
Operation response = firestoreAdminClient.exportDocuments(name.toString());
}
name
- Database to export. Should be of the form:
`projects/{project_id}/databases/{database_id}`.ApiException
- if the remote call failspublic final Operation exportDocuments(com.google.firestore.admin.v1.ExportDocumentsRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder()
.setName(name.toString())
.build();
Operation response = firestoreAdminClient.exportDocuments(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.ExportDocumentsRequest,Operation> exportDocumentsCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Operation> future = firestoreAdminClient.exportDocumentsCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final com.google.firestore.admin.v1.Field getField(com.google.firestore.admin.v1.FieldName name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]");
Field response = firestoreAdminClient.getField(name);
}
name
- A name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`ApiException
- if the remote call failspublic final com.google.firestore.admin.v1.Field getField(String name)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]");
Field response = firestoreAdminClient.getField(name.toString());
}
name
- A name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`ApiException
- if the remote call failspublic final com.google.firestore.admin.v1.Field getField(com.google.firestore.admin.v1.GetFieldRequest request)
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]");
GetFieldRequest request = GetFieldRequest.newBuilder()
.setName(name.toString())
.build();
Field response = firestoreAdminClient.getField(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.GetFieldRequest,com.google.firestore.admin.v1.Field> getFieldCallable()
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]");
GetFieldRequest request = GetFieldRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Field> future = firestoreAdminClient.getFieldCallable().futureCall(request);
// Do something
Field response = future.get();
}
public final FirestoreAdminClient.ListFieldsPagedResponse listFields(com.google.firestore.admin.v1.ParentName parent)
Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
for (Field element : firestoreAdminClient.listFields(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- A parent name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`ApiException
- if the remote call failspublic final FirestoreAdminClient.ListFieldsPagedResponse listFields(String parent)
Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
for (Field element : firestoreAdminClient.listFields(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- A parent name of the form
`projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`ApiException
- if the remote call failspublic final FirestoreAdminClient.ListFieldsPagedResponse listFields(com.google.firestore.admin.v1.ListFieldsRequest request)
Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
ListFieldsRequest request = ListFieldsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Field element : firestoreAdminClient.listFields(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.ListFieldsRequest,FirestoreAdminClient.ListFieldsPagedResponse> listFieldsPagedCallable()
Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
ListFieldsRequest request = ListFieldsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListFieldsPagedResponse> future = firestoreAdminClient.listFieldsPagedCallable().futureCall(request);
// Do something
for (Field element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.firestore.admin.v1.ListFieldsRequest,com.google.firestore.admin.v1.ListFieldsResponse> listFieldsCallable()
Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
ParentName parent = ParentName.of("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]");
ListFieldsRequest request = ListFieldsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListFieldsResponse response = firestoreAdminClient.listFieldsCallable().call(request);
for (Field element : response.getFieldsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Operation updateField(com.google.firestore.admin.v1.Field field)
This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the field update. The metadata for the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata].
To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
Field field = Field.newBuilder().build();
Operation response = firestoreAdminClient.updateField(field);
}
field
- The field to be updated.ApiException
- if the remote call failspublic final Operation updateField(com.google.firestore.admin.v1.UpdateFieldRequest request)
This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the field update. The metadata for the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata].
To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
Field field = Field.newBuilder().build();
UpdateFieldRequest request = UpdateFieldRequest.newBuilder()
.setField(field)
.build();
Operation response = firestoreAdminClient.updateField(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.firestore.admin.v1.UpdateFieldRequest,Operation> updateFieldCallable()
This call returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the field update. The metadata for the operation will be the type [FieldOperationMetadata][google.firestore.admin.v1.FieldOperationMetadata].
To configure the default field settings for the database, use the special `Field` with resource name: `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`.
Sample code:
try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
Field field = Field.newBuilder().build();
UpdateFieldRequest request = UpdateFieldRequest.newBuilder()
.setField(field)
.build();
ApiFuture<Operation> future = firestoreAdminClient.updateFieldCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.