Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions google-cloud-datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<groupId>com.google.cloud.datastore</groupId>
<artifactId>datastore-v1-protos</artifactId>
<version>1.3.0</version>
<exclusions>
<exclusion>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.cloud.datastore</groupId>
Expand All @@ -43,11 +49,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<version>${generatedProto.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>google-cloud-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.google.firestore.v1beta1.ArrayValue;
import com.google.firestore.v1beta1.BatchGetDocumentsRequest;
import com.google.firestore.v1beta1.BatchGetDocumentsResponse;
import com.google.firestore.v1beta1.DatabaseName;
import com.google.firestore.v1beta1.DatabaseRootName;
import com.google.firestore.v1beta1.MapValue;
import com.google.firestore.v1beta1.Value;
import com.google.protobuf.ByteString;
Expand Down Expand Up @@ -149,7 +149,7 @@ static Value encodeValue(@Nullable Object sanitizedObject) {
"Failed to detect Project ID. "
+ "Please explicitly set your Project ID in FirestoreOptions.");
this.databasePath =
ResourcePath.create(DatabaseName.create(options.getProjectId(), options.getDatabaseId()));
ResourcePath.create(DatabaseRootName.create(options.getProjectId(), options.getDatabaseId()));
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.firestore.v1beta1.DatabaseName;
import com.google.firestore.v1beta1.DatabaseRootName;
import java.util.Arrays;
import javax.annotation.Nullable;

Expand All @@ -32,7 +32,7 @@ abstract class ResourcePath extends BasePath<ResourcePath> {
* @param databaseName The Firestore database name.
* @param segments The segments of the path relative to the root collections.
*/
static ResourcePath create(DatabaseName databaseName, ImmutableList<String> segments) {
static ResourcePath create(DatabaseRootName databaseName, ImmutableList<String> segments) {
return new AutoValue_ResourcePath(segments, databaseName);
}

Expand All @@ -41,7 +41,7 @@ static ResourcePath create(DatabaseName databaseName, ImmutableList<String> segm
*
* @param databaseName The Firestore database name.
*/
static ResourcePath create(DatabaseName databaseName) {
static ResourcePath create(DatabaseRootName databaseName) {
return new AutoValue_ResourcePath(ImmutableList.<String>of(), databaseName);
}

Expand All @@ -56,19 +56,19 @@ static ResourcePath create(String resourceName) {
if (parts.length >= 6 && parts[0].equals("projects") && parts[2].equals("databases")) {
String[] path = Arrays.copyOfRange(parts, 5, parts.length);
return create(
DatabaseName.create(parts[1], parts[3]),
DatabaseRootName.create(parts[1], parts[3]),
ImmutableList.<String>builder().add(path).build());
}

return create(DatabaseName.parse(resourceName));
return create(DatabaseRootName.parse(resourceName));
}

/**
* Returns the database name.
*
* @return The Firestore database name.
*/
abstract DatabaseName getDatabaseName();
abstract DatabaseRootName getDatabaseName();

/** Returns whether this path points to a document. */
boolean isDocument() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import com.google.firestore.v1beta1.BeginTransactionResponse;
import com.google.firestore.v1beta1.CommitRequest;
import com.google.firestore.v1beta1.CommitResponse;
import com.google.firestore.v1beta1.DatabaseName;
import com.google.firestore.v1beta1.DatabaseRootName;
import com.google.firestore.v1beta1.ListCollectionIdsRequest;
import com.google.firestore.v1beta1.RollbackRequest;
import com.google.firestore.v1beta1.RunQueryRequest;
Expand Down Expand Up @@ -87,7 +87,7 @@ public GrpcFirestoreRpc(final FirestoreOptions options) throws IOException {
.setTransportContext(GrpcTransport.newBuilder().setChannel(managedChannel).build())
.build();
} else {
DatabaseName databaseName = DatabaseName
DatabaseRootName databaseName = DatabaseRootName
.create(options.getProjectId(), options.getDatabaseId());
Credentials credentials =
GrpcTransportOptions.setUpCredentialsProvider(options).getCredentials();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,62 +19,7 @@
*
* <p>The interfaces provided are listed below, along with usage samples.
*
* <p>==================== FirestoreAdminClient ====================
*
* <p>Service Description: The Cloud Firestore Admin API.
*
* <p>This API provides several administrative services for Cloud Firestore.
*
* <p># Concepts
*
* <p>Project, Database, Namespace, Collection, and Document are used as defined in the Google Cloud
* Firestore API.
*
* <p>Operation: An Operation represents work being performed in the background.
*
* <p># Services
*
* <p>## Index
*
* <p>The index service manages Cloud Firestore indexes.
*
* <p>Index creation is performed asynchronously. An Operation resource is created for each such
* asynchronous operation. The state of the operation (including any errors encountered) may be
* queried via the Operation resource.
*
* <p>## Metadata
*
* <p>Provides metadata and statistical information about data in Cloud Firestore. The data provided
* as part of this API may be stale.
*
* <p>## Operation
*
* <p>The Operations collection provides a record of actions performed for the specified Project
* (including any Operations in progress). Operations are not created directly but through calls on
* other collections or resources.
*
* <p>An Operation that is not yet done may be cancelled. The request to cancel is asynchronous and
* the Operation may continue to run for some time after the request to cancel is made.
*
* <p>An Operation that is done may be deleted so that it is no longer listed as part of the
* Operation collection.
*
* <p>Operations are created by service `FirestoreAdmin`, but are accessed via service
* `google.longrunning.Operations`.
*
* <p>Sample for FirestoreAdminClient:
*
* <pre>
* <code>
* try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
* String formattedParent = FirestoreAdminClient.formatDatabaseName("[PROJECT]", "[DATABASE]");
* Index index = Index.newBuilder().build();
* Operation response = firestoreAdminClient.createIndex(formattedParent, index);
* }
* </code>
* </pre>
*
* =============== FirestoreClient ===============
* <p>=============== FirestoreClient ===============
*
* <p>Service Description: The Cloud Firestore service.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.google.firestore.v1beta1.CommitRequest;
import com.google.firestore.v1beta1.CommitResponse;
import com.google.firestore.v1beta1.Cursor;
import com.google.firestore.v1beta1.DatabaseName;
import com.google.firestore.v1beta1.DatabaseRootName;
import com.google.firestore.v1beta1.Document;
import com.google.firestore.v1beta1.DocumentMask;
import com.google.firestore.v1beta1.DocumentTransform;
Expand Down Expand Up @@ -551,7 +551,7 @@ public boolean equals(Object o) {
null,
new DocumentReference(
null,
ResourcePath.create(DatabaseName.create("", ""), ImmutableList.of("coll", "doc"))),
ResourcePath.create(DatabaseRootName.create("", ""), ImmutableList.of("coll", "doc"))),
SINGLE_FIELD_PROTO,
Instant.ofEpochSecond(5, 6),
Instant.ofEpochSecond(3, 4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public class FirestoreClientTest {
public static void startStaticServer() {
mockFirestore = new MockFirestore();
serviceHelper =
new MockServiceHelper(
"in-process-1", Arrays.<MockGrpcService>asList(mockFirestore));
new MockServiceHelper("in-process-1", Arrays.<MockGrpcService>asList(mockFirestore));
serviceHelper.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,73 @@ public final UnaryCallable<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse> analyzeS
return stub.analyzeSyntaxCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Classifies a document into categories.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* ClassifyTextResponse response = languageServiceClient.classifyText(document);
* }
* </code></pre>
*
* @param document Input document.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ClassifyTextResponse classifyText(Document document) {

ClassifyTextRequest request = ClassifyTextRequest.newBuilder().setDocument(document).build();
return classifyText(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Classifies a document into categories.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* ClassifyTextRequest request = ClassifyTextRequest.newBuilder()
* .setDocument(document)
* .build();
* ClassifyTextResponse response = languageServiceClient.classifyText(request);
* }
* </code></pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ClassifyTextResponse classifyText(ClassifyTextRequest request) {
return classifyTextCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Classifies a document into categories.
*
* <p>Sample code:
*
* <pre><code>
* try (LanguageServiceClient languageServiceClient = LanguageServiceClient.create()) {
* Document document = Document.newBuilder().build();
* ClassifyTextRequest request = ClassifyTextRequest.newBuilder()
* .setDocument(document)
* .build();
* ApiFuture&lt;ClassifyTextResponse&gt; future = languageServiceClient.classifyTextCallable().futureCall(request);
* // Do something
* ClassifyTextResponse response = future.get();
* }
* </code></pre>
*/
public final UnaryCallable<ClassifyTextRequest, ClassifyTextResponse> classifyTextCallable() {
return stub.classifyTextCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* A convenience method that provides all the features that analyzeSentiment, analyzeEntities, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public class LanguageServiceSettings extends ClientSettings {
analyzeEntitySentimentSettings;
private final SimpleCallSettings<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse>
analyzeSyntaxSettings;
private final SimpleCallSettings<ClassifyTextRequest, ClassifyTextResponse> classifyTextSettings;
private final SimpleCallSettings<AnnotateTextRequest, AnnotateTextResponse> annotateTextSettings;

/** Returns the object with the settings used for calls to analyzeSentiment. */
Expand All @@ -119,6 +120,11 @@ public SimpleCallSettings<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse> analyzeSy
return analyzeSyntaxSettings;
}

/** Returns the object with the settings used for calls to classifyText. */
public SimpleCallSettings<ClassifyTextRequest, ClassifyTextResponse> classifyTextSettings() {
return classifyTextSettings;
}

/** Returns the object with the settings used for calls to annotateText. */
public SimpleCallSettings<AnnotateTextRequest, AnnotateTextResponse> annotateTextSettings() {
return annotateTextSettings;
Expand Down Expand Up @@ -221,6 +227,7 @@ private LanguageServiceSettings(Builder settingsBuilder) throws IOException {
analyzeEntitiesSettings = settingsBuilder.analyzeEntitiesSettings().build();
analyzeEntitySentimentSettings = settingsBuilder.analyzeEntitySentimentSettings().build();
analyzeSyntaxSettings = settingsBuilder.analyzeSyntaxSettings().build();
classifyTextSettings = settingsBuilder.classifyTextSettings().build();
annotateTextSettings = settingsBuilder.annotateTextSettings().build();
}

Expand All @@ -237,6 +244,8 @@ public static class Builder extends ClientSettings.Builder {
analyzeEntitySentimentSettings;
private final SimpleCallSettings.Builder<AnalyzeSyntaxRequest, AnalyzeSyntaxResponse>
analyzeSyntaxSettings;
private final SimpleCallSettings.Builder<ClassifyTextRequest, ClassifyTextResponse>
classifyTextSettings;
private final SimpleCallSettings.Builder<AnnotateTextRequest, AnnotateTextResponse>
annotateTextSettings;

Expand Down Expand Up @@ -288,6 +297,8 @@ private Builder(ClientContext clientContext) {

analyzeSyntaxSettings = SimpleCallSettings.newBuilder();

classifyTextSettings = SimpleCallSettings.newBuilder();

annotateTextSettings = SimpleCallSettings.newBuilder();

unaryMethodSettingsBuilders =
Expand All @@ -296,6 +307,7 @@ private Builder(ClientContext clientContext) {
analyzeEntitiesSettings,
analyzeEntitySentimentSettings,
analyzeSyntaxSettings,
classifyTextSettings,
annotateTextSettings);

initDefaults(this);
Expand Down Expand Up @@ -330,6 +342,11 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));

builder
.classifyTextSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));

builder
.annotateTextSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
Expand All @@ -345,6 +362,7 @@ private Builder(LanguageServiceSettings settings) {
analyzeEntitiesSettings = settings.analyzeEntitiesSettings.toBuilder();
analyzeEntitySentimentSettings = settings.analyzeEntitySentimentSettings.toBuilder();
analyzeSyntaxSettings = settings.analyzeSyntaxSettings.toBuilder();
classifyTextSettings = settings.classifyTextSettings.toBuilder();
annotateTextSettings = settings.annotateTextSettings.toBuilder();

unaryMethodSettingsBuilders =
Expand All @@ -353,6 +371,7 @@ private Builder(LanguageServiceSettings settings) {
analyzeEntitiesSettings,
analyzeEntitySentimentSettings,
analyzeSyntaxSettings,
classifyTextSettings,
annotateTextSettings);
}

Expand Down Expand Up @@ -409,6 +428,12 @@ public Builder applyToAllUnaryMethods(
return analyzeSyntaxSettings;
}

/** Returns the builder for the settings used for calls to classifyText. */
public SimpleCallSettings.Builder<ClassifyTextRequest, ClassifyTextResponse>
classifyTextSettings() {
return classifyTextSettings;
}

/** Returns the builder for the settings used for calls to annotateText. */
public SimpleCallSettings.Builder<AnnotateTextRequest, AnnotateTextResponse>
annotateTextSettings() {
Expand Down
Loading