use of com.google.firestore.v1.DeleteDocumentRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class DeleteDocument method deleteDocumentCall.
public void deleteDocumentCall() {
Scanner sc = new Scanner(System.in);
System.out.println("\n :: Deleting a Document ::\n");
System.out.print("Enter Document Name: ");
String docName = "projects/firestoretestclient/databases/(default)/documents/GrpcTestData/" + sc.next();
FirestoreGrpc.FirestoreBlockingStub blockingStub = new GRPCFirebaseClientFactory().createFirebaseClient().getBlockingStub();
DeleteDocumentRequest delReq = DeleteDocumentRequest.newBuilder().setName(docName).build();
try {
blockingStub.deleteDocument(delReq);
System.out.println("Finished call...");
} catch (Exception e) {
System.out.println("Error executing blocking stub call: " + (e.getMessage() + "\n" + e.getCause().toString()));
}
Menu menu = new Menu();
menu.draw();
}
use of com.google.firestore.v1.DeleteDocumentRequest in project java-firestore by googleapis.
the class FirestoreClient method deleteDocument.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a document.
*
* <p>Sample code:
*
* <pre>{@code
* try (FirestoreClient firestoreClient = FirestoreClient.create()) {
* String name = "name3373707";
* firestoreClient.deleteDocument(name);
* }
* }</pre>
*
* @param name Required. The resource name of the Document to delete. In the format:
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteDocument(String name) {
DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build();
deleteDocument(request);
}
use of com.google.firestore.v1.DeleteDocumentRequest in project java-firestore by googleapis.
the class FirestoreClientTest method deleteDocumentTest.
@Test
public void deleteDocumentTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockFirestore.addResponse(expectedResponse);
String name = "name3373707";
client.deleteDocument(name);
List<AbstractMessage> actualRequests = mockFirestore.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteDocumentRequest actualRequest = ((DeleteDocumentRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations