Class CloudDatastoreRemoteServiceConfig
java.lang.Object
com.google.appengine.api.datastore.CloudDatastoreRemoteServiceConfig
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()
:
{@literal @}Before
public void before() {
CloudDatastoreRemoteServiceConfig config = CloudDatastoreRemoteServiceConfig.builder()
.appId(AppId.create(Location.US_CENTRAL, "my-project-id"))
.emulatorHost(...)
.build();
CloudDatastoreRemoteServiceConfig.setConfig(config);
}
{@literal @}After
public void after() {
CloudDatastoreRemoteServiceConfig.clear();
}
By default, this configuration uses application-default
credentials.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
An App Engine application ID.static class
Builder forCloudDatastoreRemoteServiceConfig
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Returns aCloudDatastoreRemoteServiceConfig.Builder
.static void
clear()
Clears theCloudDatastoreRemoteServiceConfig
instance (if one has been set) as well as theApiProxy
'sApiProxy.EnvironmentFactory
and theApiProxy.Environment
for the current thread.static void
Sets theCloudDatastoreRemoteServiceConfig
instance.
-
Constructor Details
-
CloudDatastoreRemoteServiceConfig
public CloudDatastoreRemoteServiceConfig()
-
-
Method Details
-
setConfig
Sets theCloudDatastoreRemoteServiceConfig
instance.- Throws:
IllegalStateException
- if theCloudDatastoreRemoteServiceConfig
instance has already been set andclear()
has not been calledIllegalStateException
- if the providedCloudDatastoreRemoteServiceConfig
is not supported in this environment
-
clear
public static void clear()Clears theCloudDatastoreRemoteServiceConfig
instance (if one has been set) as well as theApiProxy
'sApiProxy.EnvironmentFactory
and theApiProxy.Environment
for the current thread.This method should only be called in tests.
-
builder
Returns aCloudDatastoreRemoteServiceConfig.Builder
.
-