com.google.appengine.api.datastore

## Class AdminDatastoreService

- java.lang.Object
- - com.google.appengine.api.datastore.AdminDatastoreService

- All Implemented Interfaces:
    AsyncDatastoreService, BaseDatastoreService

      public final class AdminDatastoreService
      extends java.lang.Object
      implements AsyncDatastoreService

  An AsyncDatastoreService implementation that is pinned to a specific appId and namesapce. This implementation ignores the "current" appId provided by `ApiProxy.getCurrentEnvironment().getAppId()` and the "current" namespace provided by `NamespaceManager.get()`. Note, this is particularly important in the following methods:
  - `AsyncDatastoreService.getIndexes()`
  - `AsyncDatastoreService.getDatastoreAttributes()`
  - `AsyncDatastoreService.allocateIds(String, long)`
  In addition this class provides ways to create `Query`, `Entity` and `Key` that are pinned to the same appId/namespace.

  Note: users should not access this class directly.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AdminDatastoreService.EntityBuilder` An `Entity` builder that pins it to the AdminUtils `appId` and `namespace`.
    `static class` | `AdminDatastoreService.KeyBuilder` A `Key` builder that pins it to the AdminUtils `appId` and `namespace`.
    `static class` | `AdminDatastoreService.QueryBuilder` A `Query` builder that pins it to the AdminUtils `appId` and `namespace`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.concurrent.Future<KeyRange>` | `allocateIds(Key parent, java.lang.String kind, long num)` See `DatastoreService.allocateIds(Key, String, long)`.
    `java.util.concurrent.Future<KeyRange>` | `allocateIds(java.lang.String kind, long num)` See `DatastoreService.allocateIds(String, long)`.
    `java.util.concurrent.Future<Transaction>` | `beginTransaction()` See `DatastoreService.beginTransaction()`.
    `java.util.concurrent.Future<Transaction>` | `beginTransaction(TransactionOptions options)` See `DatastoreService.beginTransaction(TransactionOptions)`.
    `java.util.Set<Index>` | `compositeIndexesForQuery(Query query)`
    `Index` | `compositeIndexForQuery(Query query)`
    `java.util.concurrent.Future<java.lang.Void>` | `delete(java.lang.Iterable<Key> keys)` See `DatastoreService.delete(Iterable)`.
    `java.util.concurrent.Future<java.lang.Void>` | `delete(Key... keys)` See `DatastoreService.delete(Key...)`.
    `java.util.concurrent.Future<java.lang.Void>` | `delete(Transaction txn, java.lang.Iterable<Key> keys)` See `DatastoreService.delete(Transaction, Iterable)`.
    `java.util.concurrent.Future<java.lang.Void>` | `delete(Transaction txn, Key... keys)` See `DatastoreService.delete(Transaction, Iterable)`.
    `java.util.concurrent.Future<java.util.Map<Key,Entity>>` | `get(java.lang.Iterable<Key> keys)` See `DatastoreService.get(Iterable)`.
    `java.util.concurrent.Future<Entity>` | `get(Key key)` See `DatastoreService.get(Key)`.
    `java.util.concurrent.Future<java.util.Map<Key,Entity>>` | `get(Transaction txn, java.lang.Iterable<Key> keys)` See `DatastoreService.get(Transaction, Iterable)`.
    `java.util.concurrent.Future<Entity>` | `get(Transaction txn, Key key)` See `DatastoreService.get(Transaction, Key)`.
    `java.util.Collection<Transaction>` | `getActiveTransactions()` Returns all `Transaction`s started by this thread upon which no attempt to commit or rollback has been made.
    `java.lang.String` | `getAppId()`
    `Transaction` | `getCurrentTransaction()` Returns the current transaction for this thread, or throws an exception if there is no current transaction.
    `Transaction` | `getCurrentTransaction(Transaction returnedIfNoTxn)` Returns the current transaction for this thread, or returns the parameter if there is no current transaction.
    `java.util.concurrent.Future<DatastoreAttributes>` | `getDatastoreAttributes()` See `DatastoreService.getDatastoreAttributes()`.
    `java.util.concurrent.Future<java.util.Map<Index,Index.IndexState>>` | `getIndexes()` See `DatastoreService.getIndexes()`.
    `static AdminDatastoreService` | `getInstance(DatastoreServiceConfig config, java.lang.String appId)` Returns an AdminUtils instance for the given `appId` and the "" (empty) namespace.
    `static AdminDatastoreService` | `getInstance(DatastoreServiceConfig config, java.lang.String appId, java.lang.String namespace)` Returns an AdminUtils instance for the given `appId` and `namespace`.
    `static AdminDatastoreService` | `getInstance(java.lang.String appId)` Returns an AdminUtils instance for the given `appId` and the "" (empty) namespace.
    `static AdminDatastoreService` | `getInstance(java.lang.String appId, java.lang.String namespace)` Returns an AdminUtils instance for the given `appId` and `namespace`.
    `java.lang.String` | `getNamespace()`
    `java.util.Set<Index>` | `minimumCompositeIndexesForQuery(Query query, java.util.Collection<Index> indexes)`
    `Index` | `minimumCompositeIndexForQuery(Query query, java.util.Collection<Index> indexes)`
    `AdminDatastoreService.EntityBuilder` | `newEntityBuilder(java.lang.String kind)`
    `AdminDatastoreService.KeyBuilder` | `newKeyBuilder(java.lang.String kind)`
    `AdminDatastoreService.QueryBuilder` | `newQueryBuilder()`
    `AdminDatastoreService.QueryBuilder` | `newQueryBuilder(java.lang.String kind)`
    `PreparedQuery` | `prepare(Query query)` Prepares a query for execution.
    `PreparedQuery` | `prepare(Transaction txn, Query query)` Exhibits the same behavior as `BaseDatastoreService.prepare(Query)`, but executes within the provided transaction.
    `java.util.concurrent.Future<Key>` | `put(Entity entity)` See `DatastoreService.put(Entity)`.
    `java.util.concurrent.Future<java.util.List<Key>>` | `put(java.lang.Iterable<Entity> entities)` See `DatastoreService.put(Iterable)`.
    `java.util.concurrent.Future<Key>` | `put(Transaction txn, Entity entity)` See `DatastoreService.put(Transaction, Entity)`.
    `java.util.concurrent.Future<java.util.List<Key>>` | `put(Transaction txn, java.lang.Iterable<Entity> entities)` See `DatastoreService.put(Transaction, Iterable)`.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getInstance

          public static AdminDatastoreService getInstance(java.lang.String appId)

      Returns an AdminUtils instance for the given `appId` and the "" (empty) namespace.

    - #### getInstance

          public static AdminDatastoreService getInstance(java.lang.String appId,
                                                          java.lang.String namespace)

      Returns an AdminUtils instance for the given `appId` and `namespace`.

    - #### getInstance

          public static AdminDatastoreService getInstance(DatastoreServiceConfig config,
                                                          java.lang.String appId)

      Returns an AdminUtils instance for the given `appId` and the "" (empty) namespace.

    - #### getInstance

          public static AdminDatastoreService getInstance(DatastoreServiceConfig config,
                                                          java.lang.String appId,
                                                          java.lang.String namespace)

      Returns an AdminUtils instance for the given `appId` and `namespace`.

    - #### getAppId

          public java.lang.String getAppId()

    - #### getNamespace

          public java.lang.String getNamespace()

    - #### newQueryBuilder

          public AdminDatastoreService.QueryBuilder newQueryBuilder()

    - #### newQueryBuilder

          public AdminDatastoreService.QueryBuilder newQueryBuilder(java.lang.String kind)

    - #### newKeyBuilder

          public AdminDatastoreService.KeyBuilder newKeyBuilder(java.lang.String kind)

    - #### newEntityBuilder

          public AdminDatastoreService.EntityBuilder newEntityBuilder(java.lang.String kind)

    - #### compositeIndexForQuery

          public Index compositeIndexForQuery(Query query)

    - #### compositeIndexesForQuery

          public java.util.Set<Index> compositeIndexesForQuery(Query query)

    - #### minimumCompositeIndexForQuery

          public Index minimumCompositeIndexForQuery(Query query,
                                                     java.util.Collection<Index> indexes)

    - #### minimumCompositeIndexesForQuery

          public java.util.Set<Index> minimumCompositeIndexesForQuery(Query query,
                                                                      java.util.Collection<Index> indexes)

    - #### prepare

          public PreparedQuery prepare(Query query)

      Description copied from interface: `BaseDatastoreService`
      Prepares a query for execution.

      This method returns a `PreparedQuery` which can be used to execute and retrieve results from the datastore for `query`.

      This operation will not execute in a transaction even if there is a current transaction and the provided query is an ancestor query. This operation also ignores the `ImplicitTransactionManagementPolicy`. If you are preparing an ancestory query and you want it to execute in a transaction, use `BaseDatastoreService.prepare(Transaction, Query)`.

      Specified by:
        `prepare` in interface `BaseDatastoreService`
      Parameters:
        `query` - a not `null Query`.
      Returns:
        a not `null PreparedQuery`.

    - #### prepare

          public PreparedQuery prepare(Transaction txn,
                                       Query query)

      Description copied from interface: `BaseDatastoreService`
      Exhibits the same behavior as `BaseDatastoreService.prepare(Query)`, but executes within the provided transaction. It is up to the caller to commit or rollback. Transaction can be null.
      Specified by:
        `prepare` in interface `BaseDatastoreService`

    - #### getCurrentTransaction

          public Transaction getCurrentTransaction()

      Description copied from interface: `BaseDatastoreService`
      Returns the current transaction for this thread, or throws an exception if there is no current transaction. The current transaction is defined as the result of the most recent, same-thread invocation of beginTransaction() that has not been committed or rolled back.

      Use this method for when you expect there to be a current transaction and consider it an error if there isn't.

      Specified by:
        `getCurrentTransaction` in interface `BaseDatastoreService`
      Returns:
        The current transaction.

    - #### getCurrentTransaction

          public Transaction getCurrentTransaction(Transaction returnedIfNoTxn)

      Description copied from interface: `BaseDatastoreService`
      Returns the current transaction for this thread, or returns the parameter if there is no current transaction. You can use `null` or provide your own object to represent null. See `BaseDatastoreService.getCurrentTransaction()` for a definition of "current transaction."

      Use this method when you're not sure if there is a current transaction.

      Specified by:
        `getCurrentTransaction` in interface `BaseDatastoreService`
      Parameters:
        `returnedIfNoTxn` - The return value of this method if there is no current transaction. Can be null.
      Returns:
        The current transaction, or the parameter that was passed in if there is no current transaction.

    - #### getActiveTransactions

          public java.util.Collection<Transaction> getActiveTransactions()

      Description copied from interface: `BaseDatastoreService`
      Returns all `Transaction`s started by this thread upon which no attempt to commit or rollback has been made.
      Specified by:
        `getActiveTransactions` in interface `BaseDatastoreService`

    - #### beginTransaction

          public java.util.concurrent.Future<Transaction> beginTransaction()

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.beginTransaction()`.
      Specified by:
        `beginTransaction` in interface `AsyncDatastoreService`

    - #### beginTransaction

          public java.util.concurrent.Future<Transaction> beginTransaction(TransactionOptions options)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.beginTransaction(TransactionOptions)`.
      Specified by:
        `beginTransaction` in interface `AsyncDatastoreService`

    - #### get

          public java.util.concurrent.Future<Entity> get(Key key)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.get(Key)`.
      Specified by:
        `get` in interface `AsyncDatastoreService`

    - #### get

          public java.util.concurrent.Future<Entity> get(Transaction txn,
                                                         Key key)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.get(Transaction, Key)`.
      Specified by:
        `get` in interface `AsyncDatastoreService`

    - #### get

          public java.util.concurrent.Future<java.util.Map<Key,Entity>> get(java.lang.Iterable<Key> keys)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.get(Iterable)`.
      Specified by:
        `get` in interface `AsyncDatastoreService`

    - #### get

          public java.util.concurrent.Future<java.util.Map<Key,Entity>> get(Transaction txn,
                                                                            java.lang.Iterable<Key> keys)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.get(Transaction, Iterable)`.
      Specified by:
        `get` in interface `AsyncDatastoreService`

    - #### put

          public java.util.concurrent.Future<Key> put(Entity entity)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.put(Entity)`.
      Specified by:
        `put` in interface `AsyncDatastoreService`

    - #### put

          public java.util.concurrent.Future<Key> put(Transaction txn,
                                                      Entity entity)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.put(Transaction, Entity)`.
      Specified by:
        `put` in interface `AsyncDatastoreService`

    - #### put

          public java.util.concurrent.Future<java.util.List<Key>> put(java.lang.Iterable<Entity> entities)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.put(Iterable)`.
      Specified by:
        `put` in interface `AsyncDatastoreService`

    - #### put

          public java.util.concurrent.Future<java.util.List<Key>> put(Transaction txn,
                                                                      java.lang.Iterable<Entity> entities)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.put(Transaction, Iterable)`.
      Specified by:
        `put` in interface `AsyncDatastoreService`

    - #### delete

          public java.util.concurrent.Future<java.lang.Void> delete(Key... keys)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.delete(Key...)`.
      Specified by:
        `delete` in interface `AsyncDatastoreService`

    - #### delete

          public java.util.concurrent.Future<java.lang.Void> delete(Transaction txn,
                                                                    Key... keys)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.delete(Transaction, Iterable)`.
      Specified by:
        `delete` in interface `AsyncDatastoreService`

    - #### delete

          public java.util.concurrent.Future<java.lang.Void> delete(java.lang.Iterable<Key> keys)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.delete(Iterable)`.
      Specified by:
        `delete` in interface `AsyncDatastoreService`

    - #### delete

          public java.util.concurrent.Future<java.lang.Void> delete(Transaction txn,
                                                                    java.lang.Iterable<Key> keys)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.delete(Transaction, Iterable)`.
      Specified by:
        `delete` in interface `AsyncDatastoreService`

    - #### allocateIds

          public java.util.concurrent.Future<KeyRange> allocateIds(java.lang.String kind,
                                                                   long num)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.allocateIds(String, long)`.
      Specified by:
        `allocateIds` in interface `AsyncDatastoreService`

    - #### allocateIds

          public java.util.concurrent.Future<KeyRange> allocateIds(Key parent,
                                                                   java.lang.String kind,
                                                                   long num)

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.allocateIds(Key, String, long)`.
      Specified by:
        `allocateIds` in interface `AsyncDatastoreService`

    - #### getDatastoreAttributes

          public java.util.concurrent.Future<DatastoreAttributes> getDatastoreAttributes()

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.getDatastoreAttributes()`.
      Specified by:
        `getDatastoreAttributes` in interface `AsyncDatastoreService`

    - #### getIndexes

          public java.util.concurrent.Future<java.util.Map<Index,Index.IndexState>> getIndexes()

      Description copied from interface: `AsyncDatastoreService`
      See `DatastoreService.getIndexes()`.
      Specified by:
        `getIndexes` in interface `AsyncDatastoreService`