com.google.appengine.api.datastore

## Class CloudDatastoreRemoteServiceConfig

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

-     public abstract class CloudDatastoreRemoteServiceConfig
      extends java.lang.Object

  User-configurable global properties of Cloud Datastore.

  Code not running in App Engine Standard can use the Cloud Datastore API by making a single call to `setConfig(com.google.appengine.api.datastore.CloudDatastoreRemoteServiceConfig)` before accessing any other classes from `com.google.appengine.api`. For example:

       public static void main(Strings[] args) {
         CloudDatastoreRemoteServiceConfig config = CloudDatastoreRemoteServiceConfig.builder()
             .appId(AppId.create(Location.US_CENTRAL, "my-project-id"))
             .build();
         CloudDatastoreRemoteServiceConfig.setConfig(config);
         DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
         ...
       }

  Outside of tests, the config should not be cleared once it has been set. In tests, the config can be cleared by calling `clear()`:

        @Before
       public void before() {
         CloudDatastoreRemoteServiceConfig config = CloudDatastoreRemoteServiceConfig.builder()
             .appId(AppId.create(Location.US_CENTRAL, "my-project-id"))
             .emulatorHost(...)
             .build();
         CloudDatastoreRemoteServiceConfig.setConfig(config);
       }

        @After
       public void after() {
         CloudDatastoreRemoteServiceConfig.clear();
       }

  By default, this configuration uses application-default credentials.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CloudDatastoreRemoteServiceConfig.AppId` An App Engine application ID.
    `static class` | `CloudDatastoreRemoteServiceConfig.Builder` Builder for `CloudDatastoreRemoteServiceConfig`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CloudDatastoreRemoteServiceConfig()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static CloudDatastoreRemoteServiceConfig.Builder` | `builder()` Returns a `CloudDatastoreRemoteServiceConfig.Builder`.
    `static void` | `clear()` Clears the `CloudDatastoreRemoteServiceConfig` instance (if one has been set) as well as the `ApiProxy`'s `ApiProxy.EnvironmentFactory` and the `ApiProxy.Environment` for the current thread.
    `static void` | `setConfig(CloudDatastoreRemoteServiceConfig config)` Sets the `CloudDatastoreRemoteServiceConfig` instance.

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

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

- - ### Constructor Detail

    - #### CloudDatastoreRemoteServiceConfig

          public CloudDatastoreRemoteServiceConfig()

  - ### Method Detail

    - #### setConfig

          public static void setConfig(CloudDatastoreRemoteServiceConfig config)

      Sets the `CloudDatastoreRemoteServiceConfig` instance.
      Throws:
        `java.lang.IllegalStateException` - if the `CloudDatastoreRemoteServiceConfig` instance has already been set and `clear()` has not been called
        `java.lang.IllegalStateException` - if the provided `CloudDatastoreRemoteServiceConfig` is not supported in this environment

    - #### clear

          public static void clear()

      Clears the `CloudDatastoreRemoteServiceConfig` instance (if one has been set) as well as the `ApiProxy`'s `ApiProxy.EnvironmentFactory` and the `ApiProxy.Environment` for the current thread.

      This method should only be called in tests.

    - #### builder

          public static CloudDatastoreRemoteServiceConfig.Builder builder()

      Returns a `CloudDatastoreRemoteServiceConfig.Builder`.