@Generated(value="by gapic-generator") @BetaApi public class FirestoreAdminClient extends Object implements com.google.api.gax.core.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.
|
com.google.longrunning.Operation |
createIndex(CreateIndexRequest request)
Creates a composite index.
|
com.google.longrunning.Operation |
createIndex(ParentName parent,
Index index)
Creates a composite index.
|
com.google.longrunning.Operation |
createIndex(String parent,
Index index)
Creates a composite index.
|
com.google.api.gax.rpc.UnaryCallable<CreateIndexRequest,com.google.longrunning.Operation> |
createIndexCallable()
Creates a composite index.
|
void |
deleteIndex(DeleteIndexRequest request)
Deletes a composite index.
|
void |
deleteIndex(IndexName name)
Deletes a composite index.
|
void |
deleteIndex(String name)
Deletes a composite index.
|
com.google.api.gax.rpc.UnaryCallable<DeleteIndexRequest,Empty> |
deleteIndexCallable()
Deletes a composite index.
|
com.google.longrunning.Operation |
exportDocuments(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.
|
com.google.longrunning.Operation |
exportDocuments(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.
|
com.google.longrunning.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.
|
com.google.api.gax.rpc.UnaryCallable<ExportDocumentsRequest,com.google.longrunning.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.
|
Field |
getField(FieldName name)
Gets the metadata and configuration for a Field.
|
Field |
getField(GetFieldRequest request)
Gets the metadata and configuration for a Field.
|
Field |
getField(String name)
Gets the metadata and configuration for a Field.
|
com.google.api.gax.rpc.UnaryCallable<GetFieldRequest,Field> |
getFieldCallable()
Gets the metadata and configuration for a Field.
|
Index |
getIndex(GetIndexRequest request)
Gets a composite index.
|
Index |
getIndex(IndexName name)
Gets a composite index.
|
Index |
getIndex(String name)
Gets a composite index.
|
com.google.api.gax.rpc.UnaryCallable<GetIndexRequest,Index> |
getIndexCallable()
Gets a composite index.
|
FirestoreAdminSettings |
getSettings() |
FirestoreAdminStub |
getStub() |
com.google.longrunning.Operation |
importDocuments(DatabaseName name)
Imports documents into Google Cloud Firestore.
|
com.google.longrunning.Operation |
importDocuments(ImportDocumentsRequest request)
Imports documents into Google Cloud Firestore.
|
com.google.longrunning.Operation |
importDocuments(String name)
Imports documents into Google Cloud Firestore.
|
com.google.api.gax.rpc.UnaryCallable<ImportDocumentsRequest,com.google.longrunning.Operation> |
importDocumentsCallable()
Imports documents into Google Cloud Firestore.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
FirestoreAdminClient.ListFieldsPagedResponse |
listFields(ListFieldsRequest request)
Lists the field configuration and metadata for this database.
|
FirestoreAdminClient.ListFieldsPagedResponse |
listFields(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.
|
com.google.api.gax.rpc.UnaryCallable<ListFieldsRequest,ListFieldsResponse> |
listFieldsCallable()
Lists the field configuration and metadata for this database.
|
com.google.api.gax.rpc.UnaryCallable<ListFieldsRequest,FirestoreAdminClient.ListFieldsPagedResponse> |
listFieldsPagedCallable()
Lists the field configuration and metadata for this database.
|
FirestoreAdminClient.ListIndexesPagedResponse |
listIndexes(ListIndexesRequest request)
Lists composite indexes.
|
FirestoreAdminClient.ListIndexesPagedResponse |
listIndexes(ParentName parent)
Lists composite indexes.
|
FirestoreAdminClient.ListIndexesPagedResponse |
listIndexes(String parent)
Lists composite indexes.
|
com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,ListIndexesResponse> |
listIndexesCallable()
Lists composite indexes.
|
com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,FirestoreAdminClient.ListIndexesPagedResponse> |
listIndexesPagedCallable()
Lists composite indexes.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.longrunning.Operation |
updateField(Field field)
Updates a field configuration.
|
com.google.longrunning.Operation |
updateField(UpdateFieldRequest request)
Updates a field configuration.
|
com.google.api.gax.rpc.UnaryCallable<UpdateFieldRequest,com.google.longrunning.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 com.google.longrunning.Operation createIndex(ParentName parent, 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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.Operation createIndex(String parent, 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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.Operation createIndex(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateIndexRequest,com.google.longrunning.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(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}`com.google.api.gax.rpc.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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final FirestoreAdminClient.ListIndexesPagedResponse listIndexes(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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 com.google.api.gax.rpc.UnaryCallable<ListIndexesRequest,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 Index getIndex(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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final 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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Index getIndex(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetIndexRequest,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(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}`com.google.api.gax.rpc.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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final void deleteIndex(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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 com.google.longrunning.Operation importDocuments(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}`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.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}`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.Operation importDocuments(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ImportDocumentsRequest,com.google.longrunning.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 com.google.longrunning.Operation exportDocuments(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}`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.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}`.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.Operation exportDocuments(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ExportDocumentsRequest,com.google.longrunning.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 Field getField(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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final 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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Field getField(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetFieldRequest,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(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}`com.google.api.gax.rpc.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}`com.google.api.gax.rpc.ApiException
- if the remote call failspublic final FirestoreAdminClient.ListFieldsPagedResponse listFields(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<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 com.google.api.gax.rpc.UnaryCallable<ListFieldsRequest,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 com.google.longrunning.Operation updateField(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.longrunning.Operation updateField(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.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateFieldRequest,com.google.longrunning.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 com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.