use of com.google.firestore.admin.v1.DeleteIndexRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class DeleteIndex method deleteIndexCall.
public void deleteIndexCall() {
System.out.println("\n :: Deleting an Index :: \n");
FirestoreAdminBlockingStub blockingStub = new GRPCFirebaseAdminClientFactory().createFirebaseAdminClient().getBlockingStub();
Scanner sc = new Scanner(System.in);
System.out.print("Enter Index Name: ");
String indexName = "projects/firestoretestclient/databases/(default)/indexes/" + sc.next();
DeleteIndexRequest deleteIndexRequest = DeleteIndexRequest.newBuilder().setName(indexName).build();
try {
blockingStub.deleteIndex(deleteIndexRequest);
} catch (Exception e) {
System.out.println("Error during call: " + e.getMessage() + e.getCause());
return;
}
System.out.println("Successfully deleted index " + indexName);
Menu menu = new Menu();
menu.draw();
}
use of com.google.firestore.admin.v1.DeleteIndexRequest in project java-firestore by googleapis.
the class FirestoreAdminClientTest method deleteIndexTest.
@Test
public void deleteIndexTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockFirestoreAdmin.addResponse(expectedResponse);
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
client.deleteIndex(name);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.DeleteIndexRequest in project java-firestore by googleapis.
the class FirestoreAdminClientTest method deleteIndexTest2.
@Test
public void deleteIndexTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockFirestoreAdmin.addResponse(expectedResponse);
String name = "name3373707";
client.deleteIndex(name);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.DeleteIndexRequest in project java-firestore by googleapis.
the class FirestoreAdminClient method deleteIndex.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a composite index.
*
* <p>Sample code:
*
* <pre>{@code
* try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
* String name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString();
* firestoreAdminClient.deleteIndex(name);
* }
* }</pre>
*
* @param name Required. A name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteIndex(String name) {
DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setName(name).build();
deleteIndex(request);
}
use of com.google.firestore.admin.v1.DeleteIndexRequest in project java-firestore by googleapis.
the class FirestoreAdminClient method deleteIndex.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a composite index.
*
* <p>Sample code:
*
* <pre>{@code
* try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
* IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
* firestoreAdminClient.deleteIndex(name);
* }
* }</pre>
*
* @param name Required. A name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteIndex(IndexName name) {
DeleteIndexRequest request = DeleteIndexRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteIndex(request);
}
Aggregations