Search in sources :

Example 1 with DeleteIndexRequest

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();
}
Also used : Scanner(java.util.Scanner) FirestoreAdminBlockingStub(com.google.firestore.admin.v1beta1.FirestoreAdminGrpc.FirestoreAdminBlockingStub) DeleteIndexRequest(com.google.firestore.admin.v1beta1.DeleteIndexRequest) Menu(org.roguewave.grpc.util.gfx.Menu) GRPCFirebaseAdminClientFactory(org.roguewave.grpc.util.GRPCFirebaseAdminClientFactory)

Example 2 with DeleteIndexRequest

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()));
}
Also used : IndexName(com.google.firestore.admin.v1.IndexName) Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteIndexRequest(com.google.firestore.admin.v1.DeleteIndexRequest) Test(org.junit.Test)

Example 3 with DeleteIndexRequest

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()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteIndexRequest(com.google.firestore.admin.v1.DeleteIndexRequest) Test(org.junit.Test)

Example 4 with DeleteIndexRequest

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);
}
Also used : DeleteIndexRequest(com.google.firestore.admin.v1.DeleteIndexRequest)

Example 5 with DeleteIndexRequest

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);
}
Also used : DeleteIndexRequest(com.google.firestore.admin.v1.DeleteIndexRequest)

Aggregations

DeleteIndexRequest (com.google.firestore.admin.v1.DeleteIndexRequest)4 Test (org.junit.Test)4 AbstractMessage (com.google.protobuf.AbstractMessage)3 DeleteIndexRequest (com.google.datastore.admin.v1.DeleteIndexRequest)2 Empty (com.google.protobuf.Empty)2 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)1 Index (com.google.datastore.admin.v1.Index)1 IndexName (com.google.firestore.admin.v1.IndexName)1 DeleteIndexRequest (com.google.firestore.admin.v1beta1.DeleteIndexRequest)1 FirestoreAdminBlockingStub (com.google.firestore.admin.v1beta1.FirestoreAdminGrpc.FirestoreAdminBlockingStub)1 Operation (com.google.longrunning.Operation)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 ArrayList (java.util.ArrayList)1 Scanner (java.util.Scanner)1 ExecutionException (java.util.concurrent.ExecutionException)1 GRPCFirebaseAdminClientFactory (org.roguewave.grpc.util.GRPCFirebaseAdminClientFactory)1 Menu (org.roguewave.grpc.util.gfx.Menu)1