Search in sources :

Example 41 with Key

use of com.google.recaptchaenterprise.v1.Key in project grpc-gcp-java by GoogleCloudPlatform.

the class DataStoreChecksumClient method commitTransaction.

private static void commitTransaction(DatastoreBlockingStub stub, String projectId) {
    int transactionBytes = 2000;
    String payload = new String(new char[transactionBytes]).replace('\0', 'x');
    Key key = Key.newBuilder().addPath(PathElement.newBuilder().setKind("Data").setName("data1").build()).build();
    Entity entity = Entity.newBuilder().setKey(key).putProperties("2kb", Value.newBuilder().setExcludeFromIndexes(true).setStringValue(payload).build()).build();
    Mutation mutation = Mutation.newBuilder().setUpdate(entity).build();
    CommitRequest commitRequest = CommitRequest.newBuilder().setProjectId(projectId).setMode(Mode.NON_TRANSACTIONAL).addMutations(mutation).build();
    CommitResponse commitResponse = stub.commit(commitRequest);
    System.out.println("index updates: " + commitResponse.getIndexUpdates());
}
Also used : CommitRequest(com.google.datastore.v1.CommitRequest) Entity(com.google.datastore.v1.Entity) CommitResponse(com.google.datastore.v1.CommitResponse) Mutation(com.google.datastore.v1.Mutation) Key(com.google.datastore.v1.Key)

Aggregations

Test (org.junit.Test)27 Key (com.google.datastore.v1.Key)17 AbstractMessage (com.google.protobuf.AbstractMessage)12 DatastoreHelper.makeKey (com.google.datastore.v1.client.DatastoreHelper.makeKey)11 Key (com.google.recaptchaenterprise.v1.Key)10 RecaptchaEnterpriseServiceClient (com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient)8 Entity (com.google.datastore.v1.Entity)7 DeleteKey (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteKey)7 DatastoreV1.isValidKey (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.isValidKey)7 Mutation (com.google.datastore.v1.Mutation)5 ArrayList (java.util.ArrayList)5 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)4 GetKeyRequest (com.google.recaptchaenterprise.v1.GetKeyRequest)4 Key (com.google.recaptchaenterprise.v1beta1.Key)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 HashMap (java.util.HashMap)4 Query (com.google.datastore.v1.Query)3 DeleteKeyRequest (com.google.recaptchaenterprise.v1.DeleteKeyRequest)3 GetMetricsRequest (com.google.recaptchaenterprise.v1.GetMetricsRequest)3 Metrics (com.google.recaptchaenterprise.v1.Metrics)3