Modifier and Type | Field and Description |
---|---|
static String |
KEY_PROPERTY_NAME
The property used in the Datastore to get the key of the entity.
|
static String |
LOCAL_HOST_ENV_VAR
Name of the environment variable used to set the local host.
|
static String |
PRIVATE_KEY_FILE_ENV_VAR
Name of the environment variable used to set the private key file.
|
static String |
PROJECT_ID_ENV_VAR
Name of the environment variable used to set the project ID.
|
static String |
SCATTER_PROPERTY_NAME
The property used in the Datastore to give us a random distribution.
|
static String |
SERVICE_ACCOUNT_ENV_VAR
Name of the environment variable used to set the service account.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
getBoolean(Value value) |
static com.google.protobuf.ByteString |
getByteString(Value value) |
static Datastore |
getDatastoreFromEnv() |
static double |
getDouble(Value value) |
static Entity |
getEntity(Value value) |
static Key |
getKey(Value value) |
static Comparator<Key> |
getKeyComparator() |
static List<Value> |
getList(Value value) |
static long |
getLong(Value value) |
static DatastoreOptions.Builder |
getOptionsFromEnv()
Constructs a
Datastore from environment variables and/or the Compute Engine metadata
server. |
static String |
getProjectIdFromComputeEngine()
Gets the project ID from the Compute Engine metadata server.
|
static QuerySplitter |
getQuerySplitter()
Gets a
QuerySplitter . |
static com.google.api.client.auth.oauth2.Credential |
getServiceAccountCredential(String serviceAccountId,
PrivateKey privateKey,
Collection<String> serviceAccountScopes)
Constructs credentials for the given account and key.
|
static com.google.api.client.auth.oauth2.Credential |
getServiceAccountCredential(String serviceAccountId,
String privateKeyFile)
Constructs credentials for the given account and key.
|
static com.google.api.client.auth.oauth2.Credential |
getServiceAccountCredential(String serviceAccountId,
String privateKeyFile,
Collection<String> serviceAccountScopes)
Constructs credentials for the given account and key file.
|
static String |
getString(Value value) |
static long |
getTimestamp(Value value) |
static Filter.Builder |
makeAncestorFilter(Key ancestor)
Makes an ancestor filter.
|
static Filter.Builder |
makeAndFilter(Filter... subfilters)
Make a composite filter from the given sub-filters using AND to combine filters.
|
static Filter.Builder |
makeAndFilter(Iterable<Filter> subfilters)
Make a composite filter from the given sub-filters using AND to combine filters.
|
static Mutation.Builder |
makeDelete(Key key) |
static Filter.Builder |
makeFilter(String property,
PropertyFilter.Operator operator,
Value.Builder value)
Make a filter on a property for use in a query.
|
static Filter.Builder |
makeFilter(String property,
PropertyFilter.Operator operator,
Value value)
Make a filter on a property for use in a query.
|
static Mutation.Builder |
makeInsert(Entity entity) |
static Key.Builder |
makeKey(Object... elements)
Make a key from the specified path of kind/id-or-name pairs and/or Keys.
|
static PropertyOrder.Builder |
makeOrder(String property,
PropertyOrder.Direction direction)
Make a sort order for use in a query.
|
static PropertyReference.Builder |
makePropertyReference(String propertyName)
Make a property reference for use in a query.
|
static Mutation.Builder |
makeUpdate(Entity entity) |
static Mutation.Builder |
makeUpsert(Entity entity) |
static Value.Builder |
makeValue(boolean value)
Make a boolean value.
|
static Value.Builder |
makeValue(com.google.protobuf.ByteString blob)
Make a ByteString value.
|
static Value.Builder |
makeValue(Date date)
Make a timestamp value given a date.
|
static Value.Builder |
makeValue(double value)
Make a floating point value.
|
static Value.Builder |
makeValue(Entity.Builder entity)
Make a entity value.
|
static Value.Builder |
makeValue(Entity entity)
Make an entity value.
|
static Value.Builder |
makeValue(Iterable<Value> values)
Make an array value containing the specified values.
|
static Value.Builder |
makeValue(Key.Builder key)
Make a key value.
|
static Value.Builder |
makeValue(Key key)
Make a key value.
|
static Value.Builder |
makeValue(com.google.type.LatLng.Builder value)
Makes a GeoPoint value.
|
static Value.Builder |
makeValue(com.google.type.LatLng value)
Makes a GeoPoint value.
|
static Value.Builder |
makeValue(long key)
Make an integer value.
|
static Value.Builder |
makeValue(String value)
Make a string value.
|
static Value.Builder |
makeValue(Value.Builder value1,
Value.Builder value2,
Value.Builder... rest)
Make an array value containing the specified values.
|
static Value.Builder |
makeValue(Value value1,
Value value2,
Value... rest)
Make a list value containing the specified values.
|
static Date |
toDate(Value value)
Convert a timestamp value into a
Date clipping off the microseconds. |
public static final String SCATTER_PROPERTY_NAME
public static final String KEY_PROPERTY_NAME
public static final String PROJECT_ID_ENV_VAR
public static final String LOCAL_HOST_ENV_VAR
public static final String SERVICE_ACCOUNT_ENV_VAR
public static final String PRIVATE_KEY_FILE_ENV_VAR
public static com.google.api.client.auth.oauth2.Credential getServiceAccountCredential(String serviceAccountId, String privateKeyFile) throws GeneralSecurityException, IOException
serviceAccountId
- service account ID (typically an e-mail address).privateKeyFile
- the file name from which to get the private key.null
GeneralSecurityException
IOException
public static com.google.api.client.auth.oauth2.Credential getServiceAccountCredential(String serviceAccountId, String privateKeyFile, Collection<String> serviceAccountScopes) throws GeneralSecurityException, IOException
serviceAccountId
- service account ID (typically an e-mail address).privateKeyFile
- the file name from which to get the private key.serviceAccountScopes
- Collection of OAuth scopes to use with the the service account flow
or null
if not.null
GeneralSecurityException
IOException
public static com.google.api.client.auth.oauth2.Credential getServiceAccountCredential(String serviceAccountId, PrivateKey privateKey, Collection<String> serviceAccountScopes) throws GeneralSecurityException, IOException
serviceAccountId
- service account ID (typically an e-mail address).privateKey
- the private key for the given account.serviceAccountScopes
- Collection of OAuth scopes to use with the the service account flow
or null
if not.null
GeneralSecurityException
IOException
public static DatastoreOptions.Builder getOptionsFromEnv() throws GeneralSecurityException, IOException
Datastore
from environment variables and/or the Compute Engine metadata
server.
The project ID is determined from, in order of preference:
Credentials are taken from, in order of preference:
GeneralSecurityException
IOException
@Nullable public static String getProjectIdFromComputeEngine()
null
if the
project ID cannot be determined (because, for instance, the code is not running on Compute
Engine).public static Datastore getDatastoreFromEnv() throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
getOptionsFromEnv()
public static QuerySplitter getQuerySplitter()
QuerySplitter
.
The returned QuerySplitter.getSplits(com.google.datastore.v1.Query, com.google.datastore.v1.PartitionId, int, com.google.datastore.v1.client.Datastore)
cannot accept a query that contains inequality
filters, a sort filter, or a missing kind.
public static Comparator<Key> getKeyComparator()
public static PropertyOrder.Builder makeOrder(String property, PropertyOrder.Direction direction)
public static Filter.Builder makeAncestorFilter(Key ancestor)
public static Filter.Builder makeFilter(String property, PropertyFilter.Operator operator, Value value)
public static Filter.Builder makeFilter(String property, PropertyFilter.Operator operator, Value.Builder value)
public static Filter.Builder makeAndFilter(Filter... subfilters)
public static Filter.Builder makeAndFilter(Iterable<Filter> subfilters)
public static PropertyReference.Builder makePropertyReference(String propertyName)
public static Value.Builder makeValue(Iterable<Value> values)
public static Value.Builder makeValue(Value value1, Value value2, Value... rest)
public static Value.Builder makeValue(Value.Builder value1, Value.Builder value2, Value.Builder... rest)
public static Value.Builder makeValue(Key key)
public static Value.Builder makeValue(Key.Builder key)
public static Value.Builder makeValue(long key)
public static Value.Builder makeValue(double value)
public static Value.Builder makeValue(boolean value)
public static Value.Builder makeValue(String value)
public static Value.Builder makeValue(Entity entity)
public static Value.Builder makeValue(Entity.Builder entity)
public static Value.Builder makeValue(com.google.protobuf.ByteString blob)
public static Value.Builder makeValue(Date date)
public static Value.Builder makeValue(com.google.type.LatLng value)
public static Value.Builder makeValue(com.google.type.LatLng.Builder value)
public static Key.Builder makeKey(Object... elements)
The id-or-name values must be either String, Long, Integer or Short.
The last id-or-name value may be omitted, in which case an entity without an id is created (for use with automatic id allocation).
The PartitionIds of all Keys in the path must be equal. The returned Key.Builder will use this PartitionId.
public static double getDouble(Value value)
IllegalArgumentException
- if the value does not contain a double.public static Key getKey(Value value)
IllegalArgumentException
- if the value does not contain a key.public static com.google.protobuf.ByteString getByteString(Value value)
IllegalArgumentException
- if the value does not contain a blob.public static Entity getEntity(Value value)
IllegalArgumentException
- if the value does not contain an entity.public static String getString(Value value)
IllegalArgumentException
- if the value does not contain a string.public static boolean getBoolean(Value value)
IllegalArgumentException
- if the value does not contain a boolean.public static long getLong(Value value)
IllegalArgumentException
- if the value does not contain a long.public static long getTimestamp(Value value)
IllegalArgumentException
- if the value does not contain a timestamp.public static List<Value> getList(Value value)
IllegalArgumentException
- if the value does not contain an array.public static Date toDate(Value value)
Date
clipping off the microseconds.value
- a timestamp value to convertDate
IllegalArgumentException
- if the value does not contain a timestamp.public static Mutation.Builder makeInsert(Entity entity)
entity
- the entity to insertpublic static Mutation.Builder makeUpdate(Entity entity)
entity
- the entity to updatepublic static Mutation.Builder makeUpsert(Entity entity)
entity
- the entity to upsertpublic static Mutation.Builder makeDelete(Key key)
key
- the key of the entity to deleteCopyright © 2023 Google LLC. All rights reserved.