@@ -46,6 +46,24 @@ public interface Datastore extends Service<DatastoreOptions>, DatastoreReaderWri
4646 */
4747 Transaction newTransaction ();
4848
49+ /**
50+ * Returns a new Datastore transaction with specified {@link DatastoreExecutionOptions}.
51+ *
52+ * @throws DatastoreException upon failure
53+ */
54+ @ BetaApi
55+ Transaction newTransaction (DatastoreExecutionOptions executionOptions );
56+
57+ /**
58+ * Returns a new Datastore transaction with specified {@link TransactionOptions} and {@link
59+ * DatastoreExecutionOptions}.
60+ *
61+ * @throws DatastoreException upon failure
62+ */
63+ @ BetaApi
64+ Transaction newTransaction (
65+ TransactionOptions options , DatastoreExecutionOptions executionOptions );
66+
4967 /**
5068 * A callback for running with a transactional {@link
5169 * com.google.cloud.datastore.DatastoreReaderWriter}. The associated transaction will be committed
@@ -181,6 +199,23 @@ interface TransactionCallable<T> {
181199 */
182200 List <Key > allocateId (IncompleteKey ... keys );
183201
202+ /**
203+ * Allocate a unique id for the given key with specified {@link DatastoreExecutionOptions}.
204+ *
205+ * @throws DatastoreException upon failure
206+ */
207+ @ BetaApi
208+ Key allocateId (IncompleteKey key , DatastoreExecutionOptions executionOptions );
209+
210+ /**
211+ * Returns a list of keys using the allocated ids with specified {@link
212+ * DatastoreExecutionOptions}.
213+ *
214+ * @throws DatastoreException upon failure
215+ */
216+ @ BetaApi
217+ List <Key > allocateId (DatastoreExecutionOptions executionOptions , IncompleteKey ... keys );
218+
184219 /**
185220 * Reserve one or more keys, preventing them from being automatically allocated by Datastore.
186221 *
@@ -198,6 +233,14 @@ interface TransactionCallable<T> {
198233 */
199234 List <Key > reserveIds (Key ... keys );
200235
236+ /**
237+ * Reserve one or more keys with specified {@link DatastoreExecutionOptions}.
238+ *
239+ * @throws DatastoreException upon failure
240+ */
241+ @ BetaApi
242+ List <Key > reserveIds (DatastoreExecutionOptions executionOptions , Key ... keys );
243+
201244 /**
202245 * {@inheritDoc}
203246 *
@@ -311,31 +354,24 @@ interface TransactionCallable<T> {
311354 @ Override
312355 Entity put (FullEntity <?> entity );
313356
357+ @ Override
358+ List <Entity > put (FullEntity <?>... entities );
359+
314360 /**
315- * {@inheritDoc}
316- *
317- * <p>Example of putting multiple entities.
318- *
319- * <pre>{@code
320- * String keyName1 = "my_key_name1";
321- * String keyName2 = "my_key_name2";
322- * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
323- * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
324- * entityBuilder1.set("propertyName", "value1");
325- * Entity entity1 = entityBuilder1.build();
361+ * {@inheritDoc} with specified {@link DatastoreExecutionOptions}.
326362 *
327- * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
328- * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
329- * entityBuilder2.set("propertyName", "value2");
330- * Entity entity2 = entityBuilder2.build( );
331- *
332- * datastore.put(entity1, entity2);
333- * }</pre>
363+ * @throws DatastoreException upon failure
364+ */
365+ @ BetaApi
366+ Entity put ( FullEntity <?> entity , DatastoreExecutionOptions executionOptions );
367+
368+ /**
369+ * {@inheritDoc} with specified {@link DatastoreExecutionOptions}.
334370 *
335371 * @throws DatastoreException upon failure
336372 */
337- @ Override
338- List <Entity > put (FullEntity <?>... entities );
373+ @ BetaApi
374+ List <Entity > put (DatastoreExecutionOptions executionOptions , FullEntity <?>... entities );
339375
340376 /**
341377 * {@inheritDoc}
@@ -355,6 +391,14 @@ interface TransactionCallable<T> {
355391 @ Override
356392 void delete (Key ... keys );
357393
394+ /**
395+ * A datastore delete operation with specified {@link DatastoreExecutionOptions}.
396+ *
397+ * @throws DatastoreException upon failure
398+ */
399+ @ BetaApi
400+ void delete (DatastoreExecutionOptions executionOptions , Key ... keys );
401+
358402 /**
359403 * Returns a new KeyFactory for this service
360404 *
@@ -383,6 +427,15 @@ interface TransactionCallable<T> {
383427 */
384428 Entity get (Key key , ReadOption ... options );
385429
430+ /**
431+ * Returns an {@link Entity} for the given {@link Key} with specified {@link
432+ * DatastoreExecutionOptions}.
433+ *
434+ * @throws DatastoreException upon failure
435+ */
436+ @ BetaApi
437+ Entity get (Key key , DatastoreExecutionOptions executionOptions );
438+
386439 /**
387440 * Returns an {@link Entity} for each given {@link Key} that exists in the Datastore. The order of
388441 * the result is unspecified. Results are loaded lazily, so it is possible to get a {@code
@@ -411,6 +464,15 @@ interface TransactionCallable<T> {
411464 */
412465 Iterator <Entity > get (Iterable <Key > keys , ReadOption ... options );
413466
467+ /**
468+ * Returns an {@link Entity} for each given {@link Key} with specified {@link
469+ * DatastoreExecutionOptions}.
470+ *
471+ * @throws DatastoreException upon failure
472+ */
473+ @ BetaApi
474+ Iterator <Entity > get (DatastoreExecutionOptions executionOptions , Key ... keys );
475+
414476 /**
415477 * Returns a list with a value for each given key (ordered by input). {@code null} values are
416478 * returned for nonexistent keys. When possible prefer using {@link #get(Key...)} to avoid eagerly
@@ -432,6 +494,13 @@ interface TransactionCallable<T> {
432494 */
433495 List <Entity > fetch (Iterable <Key > keys , ReadOption ... options );
434496
497+ /**
498+ * Returns a list with a value for each given key with specified {@link
499+ * DatastoreExecutionOptions}.
500+ */
501+ @ BetaApi
502+ List <Entity > fetch (DatastoreExecutionOptions executionOptions , Key ... keys );
503+
435504 /**
436505 * Submits a {@link Query} and returns its result. {@link ReadOption}s can be specified if
437506 * desired.
@@ -495,28 +564,10 @@ interface TransactionCallable<T> {
495564 <T > QueryResults <T > run (Query <T > query , ExplainOptions explainOptions , ReadOption ... options );
496565
497566 /**
498- * Submits a {@link Query} with specified {@link com.google.datastore.v1.RequestOptions} and
499- * returns its result.
500- */
501- <T > QueryResults <T > run (Query <T > query , RequestOptions requestOptions );
502-
503- /**
504- * Submits a {@link Query} with specified {@link com.google.datastore.v1.RequestOptions} and
505- * returns its result. {@link ReadOption}s can be specified if desired.
506- */
507- <T > QueryResults <T > run (Query <T > query , RequestOptions requestOptions , ReadOption ... options );
508-
509- /**
510- * Submits a {@link Query} with specified {@link com.google.cloud.datastore.models.ExplainOptions}
511- * and {@link com.google.datastore.v1.RequestOptions} and returns its result. {@link ReadOption}s
512- * can be specified if desired.
567+ * Submits a {@link Query} with specified {@link DatastoreExecutionOptions} and returns its result.
513568 */
514569 @ BetaApi
515- <T > QueryResults <T > run (
516- Query <T > query ,
517- ExplainOptions explainOptions ,
518- RequestOptions requestOptions ,
519- ReadOption ... options );
570+ <T > QueryResults <T > run (Query <T > query , DatastoreExecutionOptions executionOptions );
520571
521572 /**
522573 * Submits a {@link AggregationQuery} and returns {@link AggregationResults}. {@link ReadOption}s
@@ -563,20 +614,6 @@ <T> QueryResults<T> run(
563614 */
564615 AggregationResults runAggregation (AggregationQuery query , ReadOption ... options );
565616
566- /**
567- * Submits an {@link AggregationQuery} with specified {@link
568- * com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}.
569- */
570- AggregationResults runAggregation (AggregationQuery query , RequestOptions requestOptions );
571-
572- /**
573- * Submits an {@link AggregationQuery} with specified {@link
574- * com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}. {@link
575- * ReadOption}s can be specified if desired.
576- */
577- AggregationResults runAggregation (
578- AggregationQuery query , RequestOptions requestOptions , ReadOption ... options );
579-
580617 /**
581618 * Submits a {@link AggregationQuery} with specified {@link
582619 * com.google.cloud.datastore.models.ExplainOptions} and returns {@link AggregationResults}.
@@ -605,26 +642,12 @@ AggregationResults runAggregation(
605642 AggregationQuery query , ExplainOptions explainOptions , ReadOption ... options );
606643
607644 /**
608- * Submits an {@link AggregationQuery} with specified {@link
609- * com.google.cloud.datastore.models.ExplainOptions} and {@link
610- * com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}.
645+ * Submits an {@link AggregationQuery} with specified {@link DatastoreExecutionOptions} and returns
646+ * {@link AggregationResults}.
611647 */
612648 @ BetaApi
613649 AggregationResults runAggregation (
614- AggregationQuery query , ExplainOptions explainOptions , RequestOptions requestOptions );
615-
616- /**
617- * Submits an {@link AggregationQuery} with specified {@link
618- * com.google.cloud.datastore.models.ExplainOptions} and {@link
619- * com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}. {@link
620- * ReadOption}s can be specified if desired.
621- */
622- @ BetaApi
623- AggregationResults runAggregation (
624- AggregationQuery query ,
625- ExplainOptions explainOptions ,
626- RequestOptions requestOptions ,
627- ReadOption ... options );
650+ AggregationQuery query , DatastoreExecutionOptions executionOptions );
628651
629652 /**
630653 * Closes the gRPC channels associated with this instance and frees up their resources. This
@@ -636,16 +659,4 @@ AggregationResults runAggregation(
636659
637660 /** Returns true if this background resource has been shut down. */
638661 boolean isClosed ();
639-
640- /**
641- * Returns a new Datastore client with the specified request tags added.
642- *
643- * @param requestTags the request tags to append to existing ones
644- */
645- default Datastore withRequestTags (List <String > requestTags ) {
646- ImmutableList .Builder <String > builder = ImmutableList .builder ();
647- builder .addAll (getOptions ().getRequestTags ());
648- builder .addAll (requestTags );
649- return getOptions ().toBuilder ().setRequestTags (builder .build ()).build ().getService ();
650- }
651662}
0 commit comments