Search in sources :

Example 1 with DeleteDocumentRequest

use of com.google.firestore.v1beta1.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();
}
Also used : Scanner(java.util.Scanner) GRPCFirebaseClientFactory(org.roguewave.grpc.util.GRPCFirebaseClientFactory) DeleteDocumentRequest(com.google.firestore.v1beta1.DeleteDocumentRequest) Menu(org.roguewave.grpc.util.gfx.Menu) FirestoreGrpc(com.google.firestore.v1beta1.FirestoreGrpc)

Example 2 with DeleteDocumentRequest

use of com.google.firestore.v1beta1.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);
}
Also used : DeleteDocumentRequest(com.google.firestore.v1.DeleteDocumentRequest)

Example 3 with DeleteDocumentRequest

use of com.google.firestore.v1beta1.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()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteDocumentRequest(com.google.firestore.v1.DeleteDocumentRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

DeleteDocumentRequest (com.google.firestore.v1.DeleteDocumentRequest)2 DeleteDocumentRequest (com.google.firestore.v1beta1.DeleteDocumentRequest)1 FirestoreGrpc (com.google.firestore.v1beta1.FirestoreGrpc)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 ByteString (com.google.protobuf.ByteString)1 Empty (com.google.protobuf.Empty)1 Scanner (java.util.Scanner)1 Test (org.junit.Test)1 GRPCFirebaseClientFactory (org.roguewave.grpc.util.GRPCFirebaseClientFactory)1 Menu (org.roguewave.grpc.util.gfx.Menu)1