diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java
index fcebb2600..54ea22982 100644
--- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlClient.java
@@ -19,6 +19,7 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
@@ -30,7 +31,6 @@
import com.google.cloud.automl.v1.stub.AutoMlStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
@@ -113,13 +113,28 @@
* AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings);
* }
*
+ * To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
+ * the wire:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * AutoMlSettings autoMlSettings =
+ * AutoMlSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * AutoMlSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * AutoMlClient autoMlClient = AutoMlClient.create(autoMlSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class AutoMlClient implements BackgroundResource {
private final AutoMlSettings settings;
private final AutoMlStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of AutoMlClient with default settings. */
public static final AutoMlClient create() throws IOException {
@@ -149,13 +164,17 @@ public static final AutoMlClient create(AutoMlStub stub) {
protected AutoMlClient(AutoMlSettings settings) throws IOException {
this.settings = settings;
this.stub = ((AutoMlStubSettings) settings.getStubSettings()).createStub();
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected AutoMlClient(AutoMlStub stub) {
this.settings = null;
this.stub = stub;
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final AutoMlSettings getSettings() {
@@ -170,10 +189,18 @@ public AutoMlStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
- public final OperationsClient getOperationsClient() {
+ public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a dataset.
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java
index ce8f3a4cb..e2ad1e9eb 100644
--- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/AutoMlSettings.java
@@ -25,6 +25,7 @@
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
@@ -250,11 +251,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return AutoMlStubSettings.defaultCredentialsProviderBuilder();
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return AutoMlStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return AutoMlStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return AutoMlStubSettings.defaultTransportChannelProvider();
}
@@ -264,11 +272,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return AutoMlStubSettings.defaultApiClientHeaderProviderBuilder();
}
- /** Returns a new builder for this class. */
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ @BetaApi
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -306,6 +320,11 @@ private static Builder createDefault() {
return new Builder(AutoMlStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(AutoMlStubSettings.newHttpJsonBuilder());
+ }
+
public AutoMlStubSettings.Builder getStubSettingsBuilder() {
return ((AutoMlStubSettings.Builder) getStubSettings());
}
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java
index b3032e530..395ba9116 100644
--- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceClient.java
@@ -17,13 +17,13 @@
package com.google.cloud.automl.v1;
import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.automl.v1.stub.PredictionServiceStub;
import com.google.cloud.automl.v1.stub.PredictionServiceStubSettings;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -101,13 +101,29 @@
* PredictionServiceClient.create(predictionServiceSettings);
* }
*
+ *
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
+ * the wire:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PredictionServiceSettings predictionServiceSettings =
+ * PredictionServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * PredictionServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * PredictionServiceClient predictionServiceClient =
+ * PredictionServiceClient.create(predictionServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class PredictionServiceClient implements BackgroundResource {
private final PredictionServiceSettings settings;
private final PredictionServiceStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of PredictionServiceClient with default settings. */
public static final PredictionServiceClient create() throws IOException {
@@ -139,13 +155,17 @@ public static final PredictionServiceClient create(PredictionServiceStub stub) {
protected PredictionServiceClient(PredictionServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((PredictionServiceStubSettings) settings.getStubSettings()).createStub();
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected PredictionServiceClient(PredictionServiceStub stub) {
this.settings = null;
this.stub = stub;
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final PredictionServiceSettings getSettings() {
@@ -160,10 +180,18 @@ public PredictionServiceStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
- public final OperationsClient getOperationsClient() {
+ public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Perform an online prediction. The prediction result is directly returned in the response.
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java
index 140a27c74..30502b271 100644
--- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/PredictionServiceSettings.java
@@ -21,6 +21,7 @@
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
@@ -111,11 +112,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return PredictionServiceStubSettings.defaultCredentialsProviderBuilder();
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return PredictionServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return PredictionServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return PredictionServiceStubSettings.defaultTransportChannelProvider();
}
@@ -125,11 +133,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return PredictionServiceStubSettings.defaultApiClientHeaderProviderBuilder();
}
- /** Returns a new builder for this class. */
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ @BetaApi
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -167,6 +181,11 @@ private static Builder createDefault() {
return new Builder(PredictionServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(PredictionServiceStubSettings.newHttpJsonBuilder());
+ }
+
public PredictionServiceStubSettings.Builder getStubSettingsBuilder() {
return ((PredictionServiceStubSettings.Builder) getStubSettings());
}
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java
index 7382172f4..0b72d45fb 100644
--- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStub.java
@@ -64,7 +64,11 @@
public abstract class AutoMlStub implements BackgroundResource {
public OperationsStub getOperationsStub() {
- throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
}
public OperationCallable
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java
index 06996c634..a40656381 100644
--- a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/AutoMlStubSettings.java
@@ -30,6 +30,9 @@
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.grpc.ProtoOperationTransformers;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.HttpJsonTransportChannel;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.longrunning.OperationSnapshot;
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
import com.google.api.gax.retrying.RetrySettings;
@@ -496,6 +499,11 @@ public AutoMlStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcAutoMlStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonAutoMlStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -528,29 +536,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
.setUseJwtAccessWithScope(true);
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE);
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
- public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AutoMlStubSettings.class))
.setTransportToken(
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- /** Returns a new builder for this class. */
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(AutoMlStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return AutoMlStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new gRPC builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
+ /** Returns a new REST builder for this class. */
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
@@ -810,6 +843,19 @@ private static Builder createDefault() {
return initDefaults(builder);
}
+ private static Builder createHttpJsonDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
private static Builder initDefaults(Builder builder) {
builder
.createDatasetSettings()
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.java
new file mode 100644
index 000000000..7b109379d
--- /dev/null
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlCallableFactory.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.automl.v1.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonCallableFactory;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST callable factory implementation for the AutoMl service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonAutoMlCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java
new file mode 100644
index 000000000..8eecc6b64
--- /dev/null
+++ b/google-cloud-automl/src/main/java/com/google/cloud/automl/v1/stub/HttpJsonAutoMlStub.java
@@ -0,0 +1,1281 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.automl.v1.stub;
+
+import static com.google.cloud.automl.v1.AutoMlClient.ListDatasetsPagedResponse;
+import static com.google.cloud.automl.v1.AutoMlClient.ListModelEvaluationsPagedResponse;
+import static com.google.cloud.automl.v1.AutoMlClient.ListModelsPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.core.InternalApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.httpjson.ApiMethodDescriptor;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshot;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
+import com.google.api.gax.httpjson.ProtoMessageResponseParser;
+import com.google.api.gax.httpjson.ProtoRestSerializer;
+import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.automl.v1.AnnotationSpec;
+import com.google.cloud.automl.v1.CreateDatasetRequest;
+import com.google.cloud.automl.v1.CreateModelRequest;
+import com.google.cloud.automl.v1.Dataset;
+import com.google.cloud.automl.v1.DeleteDatasetRequest;
+import com.google.cloud.automl.v1.DeleteModelRequest;
+import com.google.cloud.automl.v1.DeployModelRequest;
+import com.google.cloud.automl.v1.ExportDataRequest;
+import com.google.cloud.automl.v1.ExportModelRequest;
+import com.google.cloud.automl.v1.GetAnnotationSpecRequest;
+import com.google.cloud.automl.v1.GetDatasetRequest;
+import com.google.cloud.automl.v1.GetModelEvaluationRequest;
+import com.google.cloud.automl.v1.GetModelRequest;
+import com.google.cloud.automl.v1.ImportDataRequest;
+import com.google.cloud.automl.v1.ListDatasetsRequest;
+import com.google.cloud.automl.v1.ListDatasetsResponse;
+import com.google.cloud.automl.v1.ListModelEvaluationsRequest;
+import com.google.cloud.automl.v1.ListModelEvaluationsResponse;
+import com.google.cloud.automl.v1.ListModelsRequest;
+import com.google.cloud.automl.v1.ListModelsResponse;
+import com.google.cloud.automl.v1.Model;
+import com.google.cloud.automl.v1.ModelEvaluation;
+import com.google.cloud.automl.v1.OperationMetadata;
+import com.google.cloud.automl.v1.UndeployModelRequest;
+import com.google.cloud.automl.v1.UpdateDatasetRequest;
+import com.google.cloud.automl.v1.UpdateModelRequest;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+import com.google.protobuf.TypeRegistry;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST stub implementation for the AutoMl service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonAutoMlStub extends AutoMlStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(Dataset.getDescriptor())
+ .add(Empty.getDescriptor())
+ .add(Model.getDescriptor())
+ .add(OperationMetadata.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createDatasetMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/CreateDataset")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}/datasets",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("dataset", request.getDataset()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateDatasetRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor getDatasetMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/GetDataset")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/datasets/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Dataset.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listDatasetsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/ListDatasets")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}/datasets",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListDatasetsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateDatasetMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/UpdateDataset")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{dataset.name=projects/*/locations/*/datasets/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "dataset.name", request.getDataset().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("dataset", request.getDataset()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Dataset.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteDatasetMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/DeleteDataset")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/datasets/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeleteDatasetRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ importDataMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/ImportData")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/datasets/*}:importData",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (ImportDataRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ exportDataMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/ExportData")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/datasets/*}:exportData",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (ExportDataRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ getAnnotationSpecMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/GetAnnotationSpec")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/datasets/*/annotationSpecs/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(AnnotationSpec.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/CreateModel")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}/models",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("model", request.getModel()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateModelRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor getModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/GetModel")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/models/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Model.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listModelsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/ListModels")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}/models",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListModelsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/DeleteModel")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/models/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeleteModelRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor updateModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/UpdateModel")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{model.name=projects/*/locations/*/models/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "model.name", request.getModel().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request -> ProtoRestSerializer.create().toBody("model", request.getModel()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Model.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deployModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/DeployModel")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/models/*}:deploy",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeployModelRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ undeployModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/UndeployModel")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/models/*}:undeploy",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (UndeployModelRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ exportModelMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/ExportModel")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/models/*}:export",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (ExportModelRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ getModelEvaluationMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/GetModelEvaluation")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/models/*/modelEvaluations/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ModelEvaluation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ ListModelEvaluationsRequest, ListModelEvaluationsResponse>
+ listModelEvaluationsMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.cloud.automl.v1.AutoMl/ListModelEvaluations")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*/models/*}/modelEvaluations",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListModelEvaluationsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable createDatasetCallable;
+ private final OperationCallable
+ createDatasetOperationCallable;
+ private final UnaryCallable getDatasetCallable;
+ private final UnaryCallable listDatasetsCallable;
+ private final UnaryCallable
+ listDatasetsPagedCallable;
+ private final UnaryCallable updateDatasetCallable;
+ private final UnaryCallable deleteDatasetCallable;
+ private final OperationCallable
+ deleteDatasetOperationCallable;
+ private final UnaryCallable importDataCallable;
+ private final OperationCallable
+ importDataOperationCallable;
+ private final UnaryCallable exportDataCallable;
+ private final OperationCallable
+ exportDataOperationCallable;
+ private final UnaryCallable getAnnotationSpecCallable;
+ private final UnaryCallable createModelCallable;
+ private final OperationCallable
+ createModelOperationCallable;
+ private final UnaryCallable getModelCallable;
+ private final UnaryCallable listModelsCallable;
+ private final UnaryCallable listModelsPagedCallable;
+ private final UnaryCallable deleteModelCallable;
+ private final OperationCallable
+ deleteModelOperationCallable;
+ private final UnaryCallable updateModelCallable;
+ private final UnaryCallable deployModelCallable;
+ private final OperationCallable
+ deployModelOperationCallable;
+ private final UnaryCallable undeployModelCallable;
+ private final OperationCallable
+ undeployModelOperationCallable;
+ private final UnaryCallable exportModelCallable;
+ private final OperationCallable
+ exportModelOperationCallable;
+ private final UnaryCallable
+ getModelEvaluationCallable;
+ private final UnaryCallable
+ listModelEvaluationsCallable;
+ private final UnaryCallable
+ listModelEvaluationsPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonAutoMlStub create(AutoMlStubSettings settings) throws IOException {
+ return new HttpJsonAutoMlStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonAutoMlStub create(ClientContext clientContext) throws IOException {
+ return new HttpJsonAutoMlStub(AutoMlStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonAutoMlStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonAutoMlStub(
+ AutoMlStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAutoMlStub, using the given settings. This is protected so
+ * that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected HttpJsonAutoMlStub(AutoMlStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonAutoMlCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAutoMlStub, using the given settings. This is protected so
+ * that it is easy to make a subclass, but otherwise, the static factory methods should be
+ * preferred.
+ */
+ protected HttpJsonAutoMlStub(
+ AutoMlStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings createDatasetTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createDatasetMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getDatasetTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getDatasetMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings listDatasetsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listDatasetsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateDatasetTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateDatasetMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteDatasetTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteDatasetMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings importDataTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(importDataMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings exportDataTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(exportDataMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ getAnnotationSpecTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getAnnotationSpecMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings createModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings listModelsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listModelsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deployModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deployModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings undeployModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(undeployModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings exportModelTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(exportModelMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ getModelEvaluationTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getModelEvaluationMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listModelEvaluationsTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listModelEvaluationsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.createDatasetCallable =
+ callableFactory.createUnaryCallable(
+ createDatasetTransportSettings, settings.createDatasetSettings(), clientContext);
+ this.createDatasetOperationCallable =
+ callableFactory.createOperationCallable(
+ createDatasetTransportSettings,
+ settings.createDatasetOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.getDatasetCallable =
+ callableFactory.createUnaryCallable(
+ getDatasetTransportSettings, settings.getDatasetSettings(), clientContext);
+ this.listDatasetsCallable =
+ callableFactory.createUnaryCallable(
+ listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext);
+ this.listDatasetsPagedCallable =
+ callableFactory.createPagedCallable(
+ listDatasetsTransportSettings, settings.listDatasetsSettings(), clientContext);
+ this.updateDatasetCallable =
+ callableFactory.createUnaryCallable(
+ updateDatasetTransportSettings, settings.updateDatasetSettings(), clientContext);
+ this.deleteDatasetCallable =
+ callableFactory.createUnaryCallable(
+ deleteDatasetTransportSettings, settings.deleteDatasetSettings(), clientContext);
+ this.deleteDatasetOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteDatasetTransportSettings,
+ settings.deleteDatasetOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.importDataCallable =
+ callableFactory.createUnaryCallable(
+ importDataTransportSettings, settings.importDataSettings(), clientContext);
+ this.importDataOperationCallable =
+ callableFactory.createOperationCallable(
+ importDataTransportSettings,
+ settings.importDataOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.exportDataCallable =
+ callableFactory.createUnaryCallable(
+ exportDataTransportSettings, settings.exportDataSettings(), clientContext);
+ this.exportDataOperationCallable =
+ callableFactory.createOperationCallable(
+ exportDataTransportSettings,
+ settings.exportDataOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.getAnnotationSpecCallable =
+ callableFactory.createUnaryCallable(
+ getAnnotationSpecTransportSettings,
+ settings.getAnnotationSpecSettings(),
+ clientContext);
+ this.createModelCallable =
+ callableFactory.createUnaryCallable(
+ createModelTransportSettings, settings.createModelSettings(), clientContext);
+ this.createModelOperationCallable =
+ callableFactory.createOperationCallable(
+ createModelTransportSettings,
+ settings.createModelOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.getModelCallable =
+ callableFactory.createUnaryCallable(
+ getModelTransportSettings, settings.getModelSettings(), clientContext);
+ this.listModelsCallable =
+ callableFactory.createUnaryCallable(
+ listModelsTransportSettings, settings.listModelsSettings(), clientContext);
+ this.listModelsPagedCallable =
+ callableFactory.createPagedCallable(
+ listModelsTransportSettings, settings.listModelsSettings(), clientContext);
+ this.deleteModelCallable =
+ callableFactory.createUnaryCallable(
+ deleteModelTransportSettings, settings.deleteModelSettings(), clientContext);
+ this.deleteModelOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteModelTransportSettings,
+ settings.deleteModelOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.updateModelCallable =
+ callableFactory.createUnaryCallable(
+ updateModelTransportSettings, settings.updateModelSettings(), clientContext);
+ this.deployModelCallable =
+ callableFactory.createUnaryCallable(
+ deployModelTransportSettings, settings.deployModelSettings(), clientContext);
+ this.deployModelOperationCallable =
+ callableFactory.createOperationCallable(
+ deployModelTransportSettings,
+ settings.deployModelOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.undeployModelCallable =
+ callableFactory.createUnaryCallable(
+ undeployModelTransportSettings, settings.undeployModelSettings(), clientContext);
+ this.undeployModelOperationCallable =
+ callableFactory.createOperationCallable(
+ undeployModelTransportSettings,
+ settings.undeployModelOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.exportModelCallable =
+ callableFactory.createUnaryCallable(
+ exportModelTransportSettings, settings.exportModelSettings(), clientContext);
+ this.exportModelOperationCallable =
+ callableFactory.createOperationCallable(
+ exportModelTransportSettings,
+ settings.exportModelOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.getModelEvaluationCallable =
+ callableFactory.createUnaryCallable(
+ getModelEvaluationTransportSettings,
+ settings.getModelEvaluationSettings(),
+ clientContext);
+ this.listModelEvaluationsCallable =
+ callableFactory.createUnaryCallable(
+ listModelEvaluationsTransportSettings,
+ settings.listModelEvaluationsSettings(),
+ clientContext);
+ this.listModelEvaluationsPagedCallable =
+ callableFactory.createPagedCallable(
+ listModelEvaluationsTransportSettings,
+ settings.listModelEvaluationsSettings(),
+ clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(createDatasetMethodDescriptor);
+ methodDescriptors.add(getDatasetMethodDescriptor);
+ methodDescriptors.add(listDatasetsMethodDescriptor);
+ methodDescriptors.add(updateDatasetMethodDescriptor);
+ methodDescriptors.add(deleteDatasetMethodDescriptor);
+ methodDescriptors.add(importDataMethodDescriptor);
+ methodDescriptors.add(exportDataMethodDescriptor);
+ methodDescriptors.add(getAnnotationSpecMethodDescriptor);
+ methodDescriptors.add(createModelMethodDescriptor);
+ methodDescriptors.add(getModelMethodDescriptor);
+ methodDescriptors.add(listModelsMethodDescriptor);
+ methodDescriptors.add(deleteModelMethodDescriptor);
+ methodDescriptors.add(updateModelMethodDescriptor);
+ methodDescriptors.add(deployModelMethodDescriptor);
+ methodDescriptors.add(undeployModelMethodDescriptor);
+ methodDescriptors.add(exportModelMethodDescriptor);
+ methodDescriptors.add(getModelEvaluationMethodDescriptor);
+ methodDescriptors.add(listModelEvaluationsMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable createDatasetCallable() {
+ return createDatasetCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createDatasetOperationCallable() {
+ return createDatasetOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable getDatasetCallable() {
+ return getDatasetCallable;
+ }
+
+ @Override
+ public UnaryCallable listDatasetsCallable() {
+ return listDatasetsCallable;
+ }
+
+ @Override
+ public UnaryCallable listDatasetsPagedCallable() {
+ return listDatasetsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable updateDatasetCallable() {
+ return updateDatasetCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteDatasetCallable() {
+ return deleteDatasetCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deleteDatasetOperationCallable() {
+ return deleteDatasetOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable importDataCallable() {
+ return importDataCallable;
+ }
+
+ @Override
+ public OperationCallable
+ importDataOperationCallable() {
+ return importDataOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable exportDataCallable() {
+ return exportDataCallable;
+ }
+
+ @Override
+ public OperationCallable
+ exportDataOperationCallable() {
+ return exportDataOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable getAnnotationSpecCallable() {
+ return getAnnotationSpecCallable;
+ }
+
+ @Override
+ public UnaryCallable createModelCallable() {
+ return createModelCallable;
+ }
+
+ @Override
+ public OperationCallable