diff --git a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingClient.java b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingClient.java
index f76530ec6763..9826c8334b15 100644
--- a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingClient.java
+++ b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingClient.java
@@ -17,13 +17,13 @@
package com.google.cloud.optimization.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.optimization.v1.stub.FleetRoutingStub;
import com.google.cloud.optimization.v1.stub.FleetRoutingStubSettings;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
@@ -120,13 +120,28 @@
* FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(fleetRoutingSettings);
* }
*
+ * 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.
+ * FleetRoutingSettings fleetRoutingSettings =
+ * FleetRoutingSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * FleetRoutingSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(fleetRoutingSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class FleetRoutingClient implements BackgroundResource {
private final FleetRoutingSettings settings;
private final FleetRoutingStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of FleetRoutingClient with default settings. */
public static final FleetRoutingClient create() throws IOException {
@@ -157,13 +172,17 @@ public static final FleetRoutingClient create(FleetRoutingStub stub) {
protected FleetRoutingClient(FleetRoutingSettings settings) throws IOException {
this.settings = settings;
this.stub = ((FleetRoutingStubSettings) 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 FleetRoutingClient(FleetRoutingStub 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 FleetRoutingSettings getSettings() {
@@ -178,10 +197,18 @@ public FleetRoutingStub 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.
/**
* Sends an `OptimizeToursRequest` containing a `ShipmentModel` and returns an
diff --git a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingSettings.java b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingSettings.java
index 93da45a9ae14..d945f644efb5 100644
--- a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingSettings.java
+++ b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/FleetRoutingSettings.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;
@@ -112,11 +113,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return FleetRoutingStubSettings.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 FleetRoutingStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return FleetRoutingStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return FleetRoutingStubSettings.defaultTransportChannelProvider();
}
@@ -126,11 +134,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return FleetRoutingStubSettings.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);
@@ -168,6 +182,11 @@ private static Builder createDefault() {
return new Builder(FleetRoutingStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(FleetRoutingStubSettings.newHttpJsonBuilder());
+ }
+
public FleetRoutingStubSettings.Builder getStubSettingsBuilder() {
return ((FleetRoutingStubSettings.Builder) getStubSettings());
}
diff --git a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStub.java b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStub.java
index 4d71d137fee6..a5b687b0808f 100644
--- a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStub.java
+++ b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStub.java
@@ -38,7 +38,11 @@
public abstract class FleetRoutingStub 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 UnaryCallable optimizeToursCallable() {
diff --git a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStubSettings.java b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStubSettings.java
index 6c642e92484a..c65e70c49a1e 100644
--- a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStubSettings.java
+++ b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/FleetRoutingStubSettings.java
@@ -25,6 +25,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;
@@ -121,6 +124,11 @@ public FleetRoutingStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcFleetRoutingStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonFleetRoutingStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -153,18 +161,25 @@ 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(FleetRoutingStubSettings.class))
@@ -172,11 +187,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
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(FleetRoutingStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return FleetRoutingStubSettings.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);
@@ -294,6 +328,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
.optimizeToursSettings()
diff --git a/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/HttpJsonFleetRoutingCallableFactory.java b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/HttpJsonFleetRoutingCallableFactory.java
new file mode 100644
index 000000000000..a72dc08dd9f3
--- /dev/null
+++ b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/HttpJsonFleetRoutingCallableFactory.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.optimization.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 FleetRouting service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonFleetRoutingCallableFactory
+ 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/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/HttpJsonFleetRoutingStub.java b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/HttpJsonFleetRoutingStub.java
new file mode 100644
index 000000000000..de95502e3e42
--- /dev/null
+++ b/java-optimization/google-cloud-optimization/src/main/java/com/google/cloud/optimization/v1/stub/HttpJsonFleetRoutingStub.java
@@ -0,0 +1,287 @@
+/*
+ * 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.optimization.v1.stub;
+
+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.optimization.v1.AsyncModelMetadata;
+import com.google.cloud.optimization.v1.BatchOptimizeToursRequest;
+import com.google.cloud.optimization.v1.BatchOptimizeToursResponse;
+import com.google.cloud.optimization.v1.OptimizeToursRequest;
+import com.google.cloud.optimization.v1.OptimizeToursResponse;
+import com.google.longrunning.Operation;
+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 FleetRouting service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonFleetRoutingStub extends FleetRoutingStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(BatchOptimizeToursResponse.getDescriptor())
+ .add(AsyncModelMetadata.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor
+ optimizeToursMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.optimization.v1.FleetRouting/OptimizeTours")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}:optimizeTours",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setAdditionalPaths("/v1/{parent=projects/*}:optimizeTours")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearParent().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(OptimizeToursResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ batchOptimizeToursMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.optimization.v1.FleetRouting/BatchOptimizeTours")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}:batchOptimizeTours",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setAdditionalPaths("/v1/{parent=projects/*}:batchOptimizeTours")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearParent().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (BatchOptimizeToursRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private final UnaryCallable optimizeToursCallable;
+ private final UnaryCallable batchOptimizeToursCallable;
+ private final OperationCallable<
+ BatchOptimizeToursRequest, BatchOptimizeToursResponse, AsyncModelMetadata>
+ batchOptimizeToursOperationCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonFleetRoutingStub create(FleetRoutingStubSettings settings)
+ throws IOException {
+ return new HttpJsonFleetRoutingStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonFleetRoutingStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonFleetRoutingStub(
+ FleetRoutingStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonFleetRoutingStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonFleetRoutingStub(
+ FleetRoutingStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonFleetRoutingStub, 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 HttpJsonFleetRoutingStub(FleetRoutingStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonFleetRoutingCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonFleetRoutingStub, 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 HttpJsonFleetRoutingStub(
+ FleetRoutingStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings
+ optimizeToursTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(optimizeToursMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings batchOptimizeToursTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(batchOptimizeToursMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.optimizeToursCallable =
+ callableFactory.createUnaryCallable(
+ optimizeToursTransportSettings, settings.optimizeToursSettings(), clientContext);
+ this.batchOptimizeToursCallable =
+ callableFactory.createUnaryCallable(
+ batchOptimizeToursTransportSettings,
+ settings.batchOptimizeToursSettings(),
+ clientContext);
+ this.batchOptimizeToursOperationCallable =
+ callableFactory.createOperationCallable(
+ batchOptimizeToursTransportSettings,
+ settings.batchOptimizeToursOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(optimizeToursMethodDescriptor);
+ methodDescriptors.add(batchOptimizeToursMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable optimizeToursCallable() {
+ return optimizeToursCallable;
+ }
+
+ @Override
+ public UnaryCallable batchOptimizeToursCallable() {
+ return batchOptimizeToursCallable;
+ }
+
+ @Override
+ public OperationCallable<
+ BatchOptimizeToursRequest, BatchOptimizeToursResponse, AsyncModelMetadata>
+ batchOptimizeToursOperationCallable() {
+ return batchOptimizeToursOperationCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/java-optimization/google-cloud-optimization/src/test/java/com/google/cloud/optimization/v1/FleetRoutingClientHttpJsonTest.java b/java-optimization/google-cloud-optimization/src/test/java/com/google/cloud/optimization/v1/FleetRoutingClientHttpJsonTest.java
new file mode 100644
index 000000000000..3bdd6cb1dfde
--- /dev/null
+++ b/java-optimization/google-cloud-optimization/src/test/java/com/google/cloud/optimization/v1/FleetRoutingClientHttpJsonTest.java
@@ -0,0 +1,217 @@
+/*
+ * 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.optimization.v1;
+
+import com.google.api.gax.core.NoCredentialsProvider;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.testing.MockHttpService;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ApiException;
+import com.google.api.gax.rpc.ApiExceptionFactory;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.testing.FakeStatusCode;
+import com.google.cloud.optimization.v1.stub.HttpJsonFleetRoutingStub;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Any;
+import com.google.protobuf.Duration;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import javax.annotation.Generated;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@Generated("by gapic-generator-java")
+public class FleetRoutingClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static FleetRoutingClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonFleetRoutingStub.getMethodDescriptors(),
+ FleetRoutingSettings.getDefaultEndpoint());
+ FleetRoutingSettings settings =
+ FleetRoutingSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ FleetRoutingSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = FleetRoutingClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void optimizeToursTest() throws Exception {
+ OptimizeToursResponse expectedResponse =
+ OptimizeToursResponse.newBuilder()
+ .addAllRoutes(new ArrayList())
+ .setRequestLabel("requestLabel1285152165")
+ .addAllSkippedShipments(new ArrayList())
+ .addAllValidationErrors(new ArrayList())
+ .setMetrics(OptimizeToursResponse.Metrics.newBuilder().build())
+ .setTotalCost(-705890328)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ OptimizeToursRequest request =
+ OptimizeToursRequest.newBuilder()
+ .setParent("projects/project-5833/locations/location-5833")
+ .setTimeout(Duration.newBuilder().build())
+ .setModel(ShipmentModel.newBuilder().build())
+ .setMaxValidationErrors(-1367418922)
+ .addAllInjectedFirstSolutionRoutes(new ArrayList())
+ .setInjectedSolutionConstraint(InjectedSolutionConstraint.newBuilder().build())
+ .addAllRefreshDetailsRoutes(new ArrayList())
+ .setInterpretInjectedSolutionsUsingLabels(true)
+ .setConsiderRoadTraffic(true)
+ .setPopulatePolylines(true)
+ .setPopulateTransitionPolylines(true)
+ .setAllowLargeDeadlineDespiteInterruptionRisk(true)
+ .setUseGeodesicDistances(true)
+ .setGeodesicMetersPerSecond(-2129658905)
+ .setLabel("label102727412")
+ .setPopulateTravelStepPolylines(true)
+ .build();
+
+ OptimizeToursResponse actualResponse = client.optimizeTours(request);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void optimizeToursExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ OptimizeToursRequest request =
+ OptimizeToursRequest.newBuilder()
+ .setParent("projects/project-5833/locations/location-5833")
+ .setTimeout(Duration.newBuilder().build())
+ .setModel(ShipmentModel.newBuilder().build())
+ .setMaxValidationErrors(-1367418922)
+ .addAllInjectedFirstSolutionRoutes(new ArrayList())
+ .setInjectedSolutionConstraint(InjectedSolutionConstraint.newBuilder().build())
+ .addAllRefreshDetailsRoutes(new ArrayList())
+ .setInterpretInjectedSolutionsUsingLabels(true)
+ .setConsiderRoadTraffic(true)
+ .setPopulatePolylines(true)
+ .setPopulateTransitionPolylines(true)
+ .setAllowLargeDeadlineDespiteInterruptionRisk(true)
+ .setUseGeodesicDistances(true)
+ .setGeodesicMetersPerSecond(-2129658905)
+ .setLabel("label102727412")
+ .setPopulateTravelStepPolylines(true)
+ .build();
+ client.optimizeTours(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void batchOptimizeToursTest() throws Exception {
+ BatchOptimizeToursResponse expectedResponse = BatchOptimizeToursResponse.newBuilder().build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("batchOptimizeToursTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ BatchOptimizeToursRequest request =
+ BatchOptimizeToursRequest.newBuilder()
+ .setParent("projects/project-5833/locations/location-5833")
+ .addAllModelConfigs(new ArrayList())
+ .build();
+
+ BatchOptimizeToursResponse actualResponse = client.batchOptimizeToursAsync(request).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void batchOptimizeToursExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ BatchOptimizeToursRequest request =
+ BatchOptimizeToursRequest.newBuilder()
+ .setParent("projects/project-5833/locations/location-5833")
+ .addAllModelConfigs(new ArrayList())
+ .build();
+ client.batchOptimizeToursAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+}
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/AsyncBatchOptimizeTours.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/AsyncBatchOptimizeTours.java
new file mode 100644
index 000000000000..005ceb66c65d
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/AsyncBatchOptimizeTours.java
@@ -0,0 +1,48 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_batchoptimizetours_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.optimization.v1.BatchOptimizeToursRequest;
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import com.google.longrunning.Operation;
+import java.util.ArrayList;
+
+public class AsyncBatchOptimizeTours {
+
+ public static void main(String[] args) throws Exception {
+ asyncBatchOptimizeTours();
+ }
+
+ public static void asyncBatchOptimizeTours() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create()) {
+ BatchOptimizeToursRequest request =
+ BatchOptimizeToursRequest.newBuilder()
+ .setParent("parent-995424086")
+ .addAllModelConfigs(new ArrayList())
+ .build();
+ ApiFuture future =
+ fleetRoutingClient.batchOptimizeToursCallable().futureCall(request);
+ // Do something.
+ Operation response = future.get();
+ }
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_batchoptimizetours_async]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/AsyncBatchOptimizeToursLRO.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/AsyncBatchOptimizeToursLRO.java
new file mode 100644
index 000000000000..c940969c7095
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/AsyncBatchOptimizeToursLRO.java
@@ -0,0 +1,49 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_batchoptimizetours_lro_async]
+import com.google.api.gax.longrunning.OperationFuture;
+import com.google.cloud.optimization.v1.AsyncModelMetadata;
+import com.google.cloud.optimization.v1.BatchOptimizeToursRequest;
+import com.google.cloud.optimization.v1.BatchOptimizeToursResponse;
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import java.util.ArrayList;
+
+public class AsyncBatchOptimizeToursLRO {
+
+ public static void main(String[] args) throws Exception {
+ asyncBatchOptimizeToursLRO();
+ }
+
+ public static void asyncBatchOptimizeToursLRO() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create()) {
+ BatchOptimizeToursRequest request =
+ BatchOptimizeToursRequest.newBuilder()
+ .setParent("parent-995424086")
+ .addAllModelConfigs(new ArrayList())
+ .build();
+ OperationFuture future =
+ fleetRoutingClient.batchOptimizeToursOperationCallable().futureCall(request);
+ // Do something.
+ BatchOptimizeToursResponse response = future.get();
+ }
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_batchoptimizetours_lro_async]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/SyncBatchOptimizeTours.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/SyncBatchOptimizeTours.java
new file mode 100644
index 000000000000..f619b4617d5d
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/batchoptimizetours/SyncBatchOptimizeTours.java
@@ -0,0 +1,45 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_batchoptimizetours_sync]
+import com.google.cloud.optimization.v1.BatchOptimizeToursRequest;
+import com.google.cloud.optimization.v1.BatchOptimizeToursResponse;
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import java.util.ArrayList;
+
+public class SyncBatchOptimizeTours {
+
+ public static void main(String[] args) throws Exception {
+ syncBatchOptimizeTours();
+ }
+
+ public static void syncBatchOptimizeTours() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create()) {
+ BatchOptimizeToursRequest request =
+ BatchOptimizeToursRequest.newBuilder()
+ .setParent("parent-995424086")
+ .addAllModelConfigs(new ArrayList())
+ .build();
+ BatchOptimizeToursResponse response =
+ fleetRoutingClient.batchOptimizeToursAsync(request).get();
+ }
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_batchoptimizetours_sync]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetCredentialsProvider.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetCredentialsProvider.java
new file mode 100644
index 000000000000..a12b1325cd09
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetCredentialsProvider.java
@@ -0,0 +1,41 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_create_setcredentialsprovider_sync]
+import com.google.api.gax.core.FixedCredentialsProvider;
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import com.google.cloud.optimization.v1.FleetRoutingSettings;
+import com.google.cloud.optimization.v1.myCredentials;
+
+public class SyncCreateSetCredentialsProvider {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetCredentialsProvider();
+ }
+
+ public static void syncCreateSetCredentialsProvider() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ FleetRoutingSettings fleetRoutingSettings =
+ FleetRoutingSettings.newBuilder()
+ .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ .build();
+ FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(fleetRoutingSettings);
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_create_setcredentialsprovider_sync]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetCredentialsProvider1.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetCredentialsProvider1.java
new file mode 100644
index 000000000000..3e689855d4e3
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetCredentialsProvider1.java
@@ -0,0 +1,40 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_create_setcredentialsprovider1_sync]
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import com.google.cloud.optimization.v1.FleetRoutingSettings;
+
+public class SyncCreateSetCredentialsProvider1 {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetCredentialsProvider1();
+ }
+
+ public static void syncCreateSetCredentialsProvider1() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ FleetRoutingSettings fleetRoutingSettings =
+ FleetRoutingSettings.newBuilder()
+ .setTransportChannelProvider(
+ FleetRoutingSettings.defaultHttpJsonTransportProviderBuilder().build())
+ .build();
+ FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(fleetRoutingSettings);
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_create_setcredentialsprovider1_sync]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetEndpoint.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetEndpoint.java
new file mode 100644
index 000000000000..f26438373ca6
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/create/SyncCreateSetEndpoint.java
@@ -0,0 +1,38 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_create_setendpoint_sync]
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import com.google.cloud.optimization.v1.FleetRoutingSettings;
+import com.google.cloud.optimization.v1.myEndpoint;
+
+public class SyncCreateSetEndpoint {
+
+ public static void main(String[] args) throws Exception {
+ syncCreateSetEndpoint();
+ }
+
+ public static void syncCreateSetEndpoint() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ FleetRoutingSettings fleetRoutingSettings =
+ FleetRoutingSettings.newBuilder().setEndpoint(myEndpoint).build();
+ FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create(fleetRoutingSettings);
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_create_setendpoint_sync]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/optimizetours/AsyncOptimizeTours.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/optimizetours/AsyncOptimizeTours.java
new file mode 100644
index 000000000000..61eda2daf21e
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/optimizetours/AsyncOptimizeTours.java
@@ -0,0 +1,66 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_optimizetours_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import com.google.cloud.optimization.v1.InjectedSolutionConstraint;
+import com.google.cloud.optimization.v1.OptimizeToursRequest;
+import com.google.cloud.optimization.v1.OptimizeToursResponse;
+import com.google.cloud.optimization.v1.ShipmentModel;
+import com.google.cloud.optimization.v1.ShipmentRoute;
+import com.google.protobuf.Duration;
+import java.util.ArrayList;
+
+public class AsyncOptimizeTours {
+
+ public static void main(String[] args) throws Exception {
+ asyncOptimizeTours();
+ }
+
+ public static void asyncOptimizeTours() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create()) {
+ OptimizeToursRequest request =
+ OptimizeToursRequest.newBuilder()
+ .setParent("parent-995424086")
+ .setTimeout(Duration.newBuilder().build())
+ .setModel(ShipmentModel.newBuilder().build())
+ .setMaxValidationErrors(-1367418922)
+ .addAllInjectedFirstSolutionRoutes(new ArrayList())
+ .setInjectedSolutionConstraint(InjectedSolutionConstraint.newBuilder().build())
+ .addAllRefreshDetailsRoutes(new ArrayList())
+ .setInterpretInjectedSolutionsUsingLabels(true)
+ .setConsiderRoadTraffic(true)
+ .setPopulatePolylines(true)
+ .setPopulateTransitionPolylines(true)
+ .setAllowLargeDeadlineDespiteInterruptionRisk(true)
+ .setUseGeodesicDistances(true)
+ .setGeodesicMetersPerSecond(-2129658905)
+ .setLabel("label102727412")
+ .setPopulateTravelStepPolylines(true)
+ .build();
+ ApiFuture future =
+ fleetRoutingClient.optimizeToursCallable().futureCall(request);
+ // Do something.
+ OptimizeToursResponse response = future.get();
+ }
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_optimizetours_async]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/optimizetours/SyncOptimizeTours.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/optimizetours/SyncOptimizeTours.java
new file mode 100644
index 000000000000..ad5f8dad5860
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingclient/optimizetours/SyncOptimizeTours.java
@@ -0,0 +1,62 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingclient_optimizetours_sync]
+import com.google.cloud.optimization.v1.FleetRoutingClient;
+import com.google.cloud.optimization.v1.InjectedSolutionConstraint;
+import com.google.cloud.optimization.v1.OptimizeToursRequest;
+import com.google.cloud.optimization.v1.OptimizeToursResponse;
+import com.google.cloud.optimization.v1.ShipmentModel;
+import com.google.cloud.optimization.v1.ShipmentRoute;
+import com.google.protobuf.Duration;
+import java.util.ArrayList;
+
+public class SyncOptimizeTours {
+
+ public static void main(String[] args) throws Exception {
+ syncOptimizeTours();
+ }
+
+ public static void syncOptimizeTours() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (FleetRoutingClient fleetRoutingClient = FleetRoutingClient.create()) {
+ OptimizeToursRequest request =
+ OptimizeToursRequest.newBuilder()
+ .setParent("parent-995424086")
+ .setTimeout(Duration.newBuilder().build())
+ .setModel(ShipmentModel.newBuilder().build())
+ .setMaxValidationErrors(-1367418922)
+ .addAllInjectedFirstSolutionRoutes(new ArrayList())
+ .setInjectedSolutionConstraint(InjectedSolutionConstraint.newBuilder().build())
+ .addAllRefreshDetailsRoutes(new ArrayList())
+ .setInterpretInjectedSolutionsUsingLabels(true)
+ .setConsiderRoadTraffic(true)
+ .setPopulatePolylines(true)
+ .setPopulateTransitionPolylines(true)
+ .setAllowLargeDeadlineDespiteInterruptionRisk(true)
+ .setUseGeodesicDistances(true)
+ .setGeodesicMetersPerSecond(-2129658905)
+ .setLabel("label102727412")
+ .setPopulateTravelStepPolylines(true)
+ .build();
+ OptimizeToursResponse response = fleetRoutingClient.optimizeTours(request);
+ }
+ }
+}
+// [END optimization_v1_generated_fleetroutingclient_optimizetours_sync]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingsettings/optimizetours/SyncOptimizeTours.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingsettings/optimizetours/SyncOptimizeTours.java
new file mode 100644
index 000000000000..563228a3a344
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/fleetroutingsettings/optimizetours/SyncOptimizeTours.java
@@ -0,0 +1,45 @@
+/*
+ * 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.optimization.v1.samples;
+
+// [START optimization_v1_generated_fleetroutingsettings_optimizetours_sync]
+import com.google.cloud.optimization.v1.FleetRoutingSettings;
+import java.time.Duration;
+
+public class SyncOptimizeTours {
+
+ public static void main(String[] args) throws Exception {
+ syncOptimizeTours();
+ }
+
+ public static void syncOptimizeTours() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ FleetRoutingSettings.Builder fleetRoutingSettingsBuilder = FleetRoutingSettings.newBuilder();
+ fleetRoutingSettingsBuilder
+ .optimizeToursSettings()
+ .setRetrySettings(
+ fleetRoutingSettingsBuilder
+ .optimizeToursSettings()
+ .getRetrySettings()
+ .toBuilder()
+ .setTotalTimeout(Duration.ofSeconds(30))
+ .build());
+ FleetRoutingSettings fleetRoutingSettings = fleetRoutingSettingsBuilder.build();
+ }
+}
+// [END optimization_v1_generated_fleetroutingsettings_optimizetours_sync]
diff --git a/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/stub/fleetroutingstubsettings/optimizetours/SyncOptimizeTours.java b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/stub/fleetroutingstubsettings/optimizetours/SyncOptimizeTours.java
new file mode 100644
index 000000000000..931c07b5f981
--- /dev/null
+++ b/java-optimization/samples/snippets/generated/com/google/cloud/optimization/v1/stub/fleetroutingstubsettings/optimizetours/SyncOptimizeTours.java
@@ -0,0 +1,46 @@
+/*
+ * 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.optimization.v1.stub.samples;
+
+// [START optimization_v1_generated_fleetroutingstubsettings_optimizetours_sync]
+import com.google.cloud.optimization.v1.stub.FleetRoutingStubSettings;
+import java.time.Duration;
+
+public class SyncOptimizeTours {
+
+ public static void main(String[] args) throws Exception {
+ syncOptimizeTours();
+ }
+
+ public static void syncOptimizeTours() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ FleetRoutingStubSettings.Builder fleetRoutingSettingsBuilder =
+ FleetRoutingStubSettings.newBuilder();
+ fleetRoutingSettingsBuilder
+ .optimizeToursSettings()
+ .setRetrySettings(
+ fleetRoutingSettingsBuilder
+ .optimizeToursSettings()
+ .getRetrySettings()
+ .toBuilder()
+ .setTotalTimeout(Duration.ofSeconds(30))
+ .build());
+ FleetRoutingStubSettings fleetRoutingSettings = fleetRoutingSettingsBuilder.build();
+ }
+}
+// [END optimization_v1_generated_fleetroutingstubsettings_optimizetours_sync]