diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsClient.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsClient.java
index a2f96dc..66c447e 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsClient.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsClient.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.run.v2.stub.RevisionsStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -100,13 +100,28 @@
* RevisionsClient revisionsClient = RevisionsClient.create(revisionsSettings);
* }
*
+ * 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.
+ * RevisionsSettings revisionsSettings =
+ * RevisionsSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * RevisionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * RevisionsClient revisionsClient = RevisionsClient.create(revisionsSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class RevisionsClient implements BackgroundResource {
private final RevisionsSettings settings;
private final RevisionsStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of RevisionsClient with default settings. */
public static final RevisionsClient create() throws IOException {
@@ -136,13 +151,17 @@ public static final RevisionsClient create(RevisionsStub stub) {
protected RevisionsClient(RevisionsSettings settings) throws IOException {
this.settings = settings;
this.stub = ((RevisionsStubSettings) 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 RevisionsClient(RevisionsStub 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 RevisionsSettings getSettings() {
@@ -157,10 +176,18 @@ public RevisionsStub 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.
/**
* Gets information about a Revision.
diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsSettings.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsSettings.java
index 2b6cfcf..c89ef86 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsSettings.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/RevisionsSettings.java
@@ -23,6 +23,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;
@@ -118,11 +119,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return RevisionsStubSettings.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 RevisionsStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return RevisionsStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return RevisionsStubSettings.defaultTransportChannelProvider();
}
@@ -132,11 +140,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return RevisionsStubSettings.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);
@@ -174,6 +188,11 @@ private static Builder createDefault() {
return new Builder(RevisionsStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(RevisionsStubSettings.newHttpJsonBuilder());
+ }
+
public RevisionsStubSettings.Builder getStubSettingsBuilder() {
return ((RevisionsStubSettings.Builder) getStubSettings());
}
diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesClient.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesClient.java
index 0b771f6..0d10699 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesClient.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesClient.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;
@@ -35,7 +36,6 @@
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -105,13 +105,28 @@
* ServicesClient servicesClient = ServicesClient.create(servicesSettings);
* }
*
+ *
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.
+ * ServicesSettings servicesSettings =
+ * ServicesSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * ServicesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * ServicesClient servicesClient = ServicesClient.create(servicesSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class ServicesClient implements BackgroundResource {
private final ServicesSettings settings;
private final ServicesStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of ServicesClient with default settings. */
public static final ServicesClient create() throws IOException {
@@ -141,13 +156,17 @@ public static final ServicesClient create(ServicesStub stub) {
protected ServicesClient(ServicesSettings settings) throws IOException {
this.settings = settings;
this.stub = ((ServicesStubSettings) 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 ServicesClient(ServicesStub 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 ServicesSettings getSettings() {
@@ -162,10 +181,18 @@ public ServicesStub 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 new Service in a given project and location.
diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesSettings.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesSettings.java
index 569d60e..9433cf1 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesSettings.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/ServicesSettings.java
@@ -23,6 +23,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;
@@ -161,11 +162,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return ServicesStubSettings.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 ServicesStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return ServicesStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return ServicesStubSettings.defaultTransportChannelProvider();
}
@@ -175,11 +183,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return ServicesStubSettings.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);
@@ -217,6 +231,11 @@ private static Builder createDefault() {
return new Builder(ServicesStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(ServicesStubSettings.newHttpJsonBuilder());
+ }
+
public ServicesStubSettings.Builder getStubSettingsBuilder() {
return ((ServicesStubSettings.Builder) getStubSettings());
}
diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonRevisionsCallableFactory.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonRevisionsCallableFactory.java
new file mode 100644
index 0000000..aea8d91
--- /dev/null
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonRevisionsCallableFactory.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.run.v2.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 Revisions service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonRevisionsCallableFactory
+ 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-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonRevisionsStub.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonRevisionsStub.java
new file mode 100644
index 0000000..c01acd4
--- /dev/null
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonRevisionsStub.java
@@ -0,0 +1,339 @@
+/*
+ * 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.run.v2.stub;
+
+import static com.google.cloud.run.v2.RevisionsClient.ListRevisionsPagedResponse;
+
+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.run.v2.DeleteRevisionRequest;
+import com.google.cloud.run.v2.GetRevisionRequest;
+import com.google.cloud.run.v2.ListRevisionsRequest;
+import com.google.cloud.run.v2.ListRevisionsResponse;
+import com.google.cloud.run.v2.Revision;
+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 Revisions service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonRevisionsStub extends RevisionsStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder().add(Revision.getDescriptor()).build();
+
+ private static final ApiMethodDescriptor
+ getRevisionMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Revisions/GetRevision")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/services/*/revisions/*}",
+ 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(Revision.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listRevisionsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Revisions/ListRevisions")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*/services/*}/revisions",
+ 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, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ serializer.putQueryParam(
+ fields, "showDeleted", request.getShowDeleted());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListRevisionsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteRevisionMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Revisions/DeleteRevision")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/services/*/revisions/*}",
+ 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();
+ serializer.putQueryParam(fields, "etag", request.getEtag());
+ serializer.putQueryParam(
+ fields, "validateOnly", request.getValidateOnly());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeleteRevisionRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private final UnaryCallable getRevisionCallable;
+ private final UnaryCallable listRevisionsCallable;
+ private final UnaryCallable
+ listRevisionsPagedCallable;
+ private final UnaryCallable deleteRevisionCallable;
+ private final OperationCallable
+ deleteRevisionOperationCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonRevisionsStub create(RevisionsStubSettings settings)
+ throws IOException {
+ return new HttpJsonRevisionsStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonRevisionsStub create(ClientContext clientContext) throws IOException {
+ return new HttpJsonRevisionsStub(
+ RevisionsStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonRevisionsStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonRevisionsStub(
+ RevisionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonRevisionsStub, 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 HttpJsonRevisionsStub(RevisionsStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonRevisionsCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonRevisionsStub, 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 HttpJsonRevisionsStub(
+ RevisionsStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings getRevisionTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getRevisionMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listRevisionsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listRevisionsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteRevisionTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteRevisionMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.getRevisionCallable =
+ callableFactory.createUnaryCallable(
+ getRevisionTransportSettings, settings.getRevisionSettings(), clientContext);
+ this.listRevisionsCallable =
+ callableFactory.createUnaryCallable(
+ listRevisionsTransportSettings, settings.listRevisionsSettings(), clientContext);
+ this.listRevisionsPagedCallable =
+ callableFactory.createPagedCallable(
+ listRevisionsTransportSettings, settings.listRevisionsSettings(), clientContext);
+ this.deleteRevisionCallable =
+ callableFactory.createUnaryCallable(
+ deleteRevisionTransportSettings, settings.deleteRevisionSettings(), clientContext);
+ this.deleteRevisionOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteRevisionTransportSettings,
+ settings.deleteRevisionOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(getRevisionMethodDescriptor);
+ methodDescriptors.add(listRevisionsMethodDescriptor);
+ methodDescriptors.add(deleteRevisionMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable getRevisionCallable() {
+ return getRevisionCallable;
+ }
+
+ @Override
+ public UnaryCallable listRevisionsCallable() {
+ return listRevisionsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listRevisionsPagedCallable() {
+ return listRevisionsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteRevisionCallable() {
+ return deleteRevisionCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deleteRevisionOperationCallable() {
+ return deleteRevisionOperationCallable;
+ }
+
+ @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/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonServicesCallableFactory.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonServicesCallableFactory.java
new file mode 100644
index 0000000..50fd833
--- /dev/null
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonServicesCallableFactory.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.run.v2.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 Services service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonServicesCallableFactory
+ 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-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonServicesStub.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonServicesStub.java
new file mode 100644
index 0000000..e339e7d
--- /dev/null
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/HttpJsonServicesStub.java
@@ -0,0 +1,641 @@
+/*
+ * 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.run.v2.stub;
+
+import static com.google.cloud.run.v2.ServicesClient.ListServicesPagedResponse;
+
+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.run.v2.CreateServiceRequest;
+import com.google.cloud.run.v2.DeleteServiceRequest;
+import com.google.cloud.run.v2.GetServiceRequest;
+import com.google.cloud.run.v2.ListServicesRequest;
+import com.google.cloud.run.v2.ListServicesResponse;
+import com.google.cloud.run.v2.Service;
+import com.google.cloud.run.v2.UpdateServiceRequest;
+import com.google.iam.v1.GetIamPolicyRequest;
+import com.google.iam.v1.Policy;
+import com.google.iam.v1.SetIamPolicyRequest;
+import com.google.iam.v1.TestIamPermissionsRequest;
+import com.google.iam.v1.TestIamPermissionsResponse;
+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 Services service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonServicesStub extends ServicesStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder().add(Service.getDescriptor()).build();
+
+ private static final ApiMethodDescriptor
+ createServiceMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/CreateService")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*}/services",
+ 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, "serviceId", request.getServiceId());
+ serializer.putQueryParam(
+ fields, "validateOnly", request.getValidateOnly());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("service", request.getService()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateServiceRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor getServiceMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/GetService")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/services/*}",
+ 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(Service.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listServicesMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/ListServices")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*}/services",
+ 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, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ serializer.putQueryParam(
+ fields, "showDeleted", request.getShowDeleted());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListServicesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateServiceMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/UpdateService")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{service.name=projects/*/locations/*/services/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "service.name", request.getService().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(
+ fields, "allowMissing", request.getAllowMissing());
+ serializer.putQueryParam(
+ fields, "validateOnly", request.getValidateOnly());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("service", request.getService()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (UpdateServiceRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteServiceMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/DeleteService")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/services/*}",
+ 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();
+ serializer.putQueryParam(fields, "etag", request.getEtag());
+ serializer.putQueryParam(
+ fields, "validateOnly", request.getValidateOnly());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeleteServiceRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ getIamPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/GetIamPolicy")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{resource=projects/*/locations/*/services/*}:getIamPolicy",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "resource", request.getResource());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "options", request.getOptions());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Policy.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ setIamPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/SetIamPolicy")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{resource=projects/*/locations/*/services/*}:setIamPolicy",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "resource", request.getResource());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearResource().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Policy.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ testIamPermissionsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.run.v2.Services/TestIamPermissions")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{resource=projects/*/locations/*/services/*}:testIamPermissions",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "resource", request.getResource());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearResource().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable createServiceCallable;
+ private final OperationCallable
+ createServiceOperationCallable;
+ private final UnaryCallable getServiceCallable;
+ private final UnaryCallable listServicesCallable;
+ private final UnaryCallable
+ listServicesPagedCallable;
+ private final UnaryCallable updateServiceCallable;
+ private final OperationCallable
+ updateServiceOperationCallable;
+ private final UnaryCallable deleteServiceCallable;
+ private final OperationCallable
+ deleteServiceOperationCallable;
+ private final UnaryCallable getIamPolicyCallable;
+ private final UnaryCallable setIamPolicyCallable;
+ private final UnaryCallable
+ testIamPermissionsCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonServicesStub create(ServicesStubSettings settings)
+ throws IOException {
+ return new HttpJsonServicesStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonServicesStub create(ClientContext clientContext) throws IOException {
+ return new HttpJsonServicesStub(
+ ServicesStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonServicesStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonServicesStub(
+ ServicesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonServicesStub, 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 HttpJsonServicesStub(ServicesStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonServicesCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonServicesStub, 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 HttpJsonServicesStub(
+ ServicesStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings createServiceTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createServiceMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getServiceTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getServiceMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings listServicesTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listServicesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateServiceTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateServiceMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteServiceTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteServiceMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getIamPolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getIamPolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings setIamPolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(setIamPolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ testIamPermissionsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(testIamPermissionsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.createServiceCallable =
+ callableFactory.createUnaryCallable(
+ createServiceTransportSettings, settings.createServiceSettings(), clientContext);
+ this.createServiceOperationCallable =
+ callableFactory.createOperationCallable(
+ createServiceTransportSettings,
+ settings.createServiceOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.getServiceCallable =
+ callableFactory.createUnaryCallable(
+ getServiceTransportSettings, settings.getServiceSettings(), clientContext);
+ this.listServicesCallable =
+ callableFactory.createUnaryCallable(
+ listServicesTransportSettings, settings.listServicesSettings(), clientContext);
+ this.listServicesPagedCallable =
+ callableFactory.createPagedCallable(
+ listServicesTransportSettings, settings.listServicesSettings(), clientContext);
+ this.updateServiceCallable =
+ callableFactory.createUnaryCallable(
+ updateServiceTransportSettings, settings.updateServiceSettings(), clientContext);
+ this.updateServiceOperationCallable =
+ callableFactory.createOperationCallable(
+ updateServiceTransportSettings,
+ settings.updateServiceOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.deleteServiceCallable =
+ callableFactory.createUnaryCallable(
+ deleteServiceTransportSettings, settings.deleteServiceSettings(), clientContext);
+ this.deleteServiceOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteServiceTransportSettings,
+ settings.deleteServiceOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.getIamPolicyCallable =
+ callableFactory.createUnaryCallable(
+ getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext);
+ this.setIamPolicyCallable =
+ callableFactory.createUnaryCallable(
+ setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext);
+ this.testIamPermissionsCallable =
+ callableFactory.createUnaryCallable(
+ testIamPermissionsTransportSettings,
+ settings.testIamPermissionsSettings(),
+ clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(createServiceMethodDescriptor);
+ methodDescriptors.add(getServiceMethodDescriptor);
+ methodDescriptors.add(listServicesMethodDescriptor);
+ methodDescriptors.add(updateServiceMethodDescriptor);
+ methodDescriptors.add(deleteServiceMethodDescriptor);
+ methodDescriptors.add(getIamPolicyMethodDescriptor);
+ methodDescriptors.add(setIamPolicyMethodDescriptor);
+ methodDescriptors.add(testIamPermissionsMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable createServiceCallable() {
+ return createServiceCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createServiceOperationCallable() {
+ return createServiceOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable getServiceCallable() {
+ return getServiceCallable;
+ }
+
+ @Override
+ public UnaryCallable listServicesCallable() {
+ return listServicesCallable;
+ }
+
+ @Override
+ public UnaryCallable listServicesPagedCallable() {
+ return listServicesPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable updateServiceCallable() {
+ return updateServiceCallable;
+ }
+
+ @Override
+ public OperationCallable
+ updateServiceOperationCallable() {
+ return updateServiceOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteServiceCallable() {
+ return deleteServiceCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deleteServiceOperationCallable() {
+ return deleteServiceOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable getIamPolicyCallable() {
+ return getIamPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable setIamPolicyCallable() {
+ return setIamPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ testIamPermissionsCallable() {
+ return testIamPermissionsCallable;
+ }
+
+ @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/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStub.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStub.java
index a0cb6a8..7f41e3c 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStub.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStub.java
@@ -40,7 +40,11 @@
public abstract class RevisionsStub 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 getRevisionCallable() {
diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStubSettings.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStubSettings.java
index 7caabae..af7f5b1 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStubSettings.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/RevisionsStubSettings.java
@@ -28,6 +28,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;
@@ -187,6 +190,11 @@ public RevisionsStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcRevisionsStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonRevisionsStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -219,29 +227,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(RevisionsStubSettings.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(RevisionsStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return RevisionsStubSettings.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);
@@ -336,6 +369,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
.getRevisionSettings()
diff --git a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStub.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStub.java
index 48ef344..8a7a3e5 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStub.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStub.java
@@ -47,7 +47,11 @@
public abstract class ServicesStub 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-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStubSettings.java b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStubSettings.java
index dba2cba..2abf68f 100644
--- a/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStubSettings.java
+++ b/google-cloud-run/src/main/java/com/google/cloud/run/v2/stub/ServicesStubSettings.java
@@ -28,6 +28,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;
@@ -242,6 +245,11 @@ public ServicesStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcServicesStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonServicesStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -274,29 +282,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(ServicesStubSettings.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(ServicesStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return ServicesStubSettings.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);
@@ -469,6 +502,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
.createServiceSettings()
diff --git a/google-cloud-run/src/test/java/com/google/cloud/run/v2/RevisionsClientHttpJsonTest.java b/google-cloud-run/src/test/java/com/google/cloud/run/v2/RevisionsClientHttpJsonTest.java
new file mode 100644
index 0000000..a9757ce
--- /dev/null
+++ b/google-cloud-run/src/test/java/com/google/cloud/run/v2/RevisionsClientHttpJsonTest.java
@@ -0,0 +1,474 @@
+/*
+ * 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.run.v2;
+
+import static com.google.cloud.run.v2.RevisionsClient.ListRevisionsPagedResponse;
+
+import com.google.api.LaunchStage;
+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.run.v2.stub.HttpJsonRevisionsStub;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Any;
+import com.google.protobuf.Duration;
+import com.google.protobuf.Timestamp;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+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 RevisionsClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static RevisionsClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonRevisionsStub.getMethodDescriptors(), RevisionsSettings.getDefaultEndpoint());
+ RevisionsSettings settings =
+ RevisionsSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ RevisionsSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = RevisionsClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void getRevisionTest() throws Exception {
+ Revision expectedResponse =
+ Revision.newBuilder()
+ .setName(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setService(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setScaling(RevisionScaling.newBuilder().build())
+ .setVpcAccess(VpcAccess.newBuilder().build())
+ .setMaxInstanceRequestConcurrency(117250100)
+ .setTimeout(Duration.newBuilder().build())
+ .setServiceAccount("serviceAccount1079137720")
+ .addAllContainers(new ArrayList())
+ .addAllVolumes(new ArrayList())
+ .setExecutionEnvironment(ExecutionEnvironment.forNumber(0))
+ .setEncryptionKey("encryptionKey-36224036")
+ .setReconciling(true)
+ .addAllConditions(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setLogUri("logUri-1097354360")
+ .setEtag("etag3123477")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ RevisionName name = RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]");
+
+ Revision actualResponse = client.getRevision(name);
+ 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 getRevisionExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ RevisionName name = RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]");
+ client.getRevision(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getRevisionTest2() throws Exception {
+ Revision expectedResponse =
+ Revision.newBuilder()
+ .setName(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setService(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setScaling(RevisionScaling.newBuilder().build())
+ .setVpcAccess(VpcAccess.newBuilder().build())
+ .setMaxInstanceRequestConcurrency(117250100)
+ .setTimeout(Duration.newBuilder().build())
+ .setServiceAccount("serviceAccount1079137720")
+ .addAllContainers(new ArrayList())
+ .addAllVolumes(new ArrayList())
+ .setExecutionEnvironment(ExecutionEnvironment.forNumber(0))
+ .setEncryptionKey("encryptionKey-36224036")
+ .setReconciling(true)
+ .addAllConditions(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setLogUri("logUri-1097354360")
+ .setEtag("etag3123477")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name =
+ "projects/project-7778/locations/location-7778/services/service-7778/revisions/revision-7778";
+
+ Revision actualResponse = client.getRevision(name);
+ 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 getRevisionExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-7778/locations/location-7778/services/service-7778/revisions/revision-7778";
+ client.getRevision(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listRevisionsTest() throws Exception {
+ Revision responsesElement = Revision.newBuilder().build();
+ ListRevisionsResponse expectedResponse =
+ ListRevisionsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllRevisions(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
+
+ ListRevisionsPagedResponse pagedListResponse = client.listRevisions(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getRevisionsList().get(0), resources.get(0));
+
+ 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 listRevisionsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ ServiceName parent = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
+ client.listRevisions(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listRevisionsTest2() throws Exception {
+ Revision responsesElement = Revision.newBuilder().build();
+ ListRevisionsResponse expectedResponse =
+ ListRevisionsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllRevisions(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "projects/project-4913/locations/location-4913/services/service-4913";
+
+ ListRevisionsPagedResponse pagedListResponse = client.listRevisions(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getRevisionsList().get(0), resources.get(0));
+
+ 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 listRevisionsExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "projects/project-4913/locations/location-4913/services/service-4913";
+ client.listRevisions(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteRevisionTest() throws Exception {
+ Revision expectedResponse =
+ Revision.newBuilder()
+ .setName(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setService(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setScaling(RevisionScaling.newBuilder().build())
+ .setVpcAccess(VpcAccess.newBuilder().build())
+ .setMaxInstanceRequestConcurrency(117250100)
+ .setTimeout(Duration.newBuilder().build())
+ .setServiceAccount("serviceAccount1079137720")
+ .addAllContainers(new ArrayList())
+ .addAllVolumes(new ArrayList())
+ .setExecutionEnvironment(ExecutionEnvironment.forNumber(0))
+ .setEncryptionKey("encryptionKey-36224036")
+ .setReconciling(true)
+ .addAllConditions(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setLogUri("logUri-1097354360")
+ .setEtag("etag3123477")
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("deleteRevisionTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ RevisionName name = RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]");
+
+ Revision actualResponse = client.deleteRevisionAsync(name).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 deleteRevisionExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ RevisionName name = RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]");
+ client.deleteRevisionAsync(name).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void deleteRevisionTest2() throws Exception {
+ Revision expectedResponse =
+ Revision.newBuilder()
+ .setName(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setService(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setScaling(RevisionScaling.newBuilder().build())
+ .setVpcAccess(VpcAccess.newBuilder().build())
+ .setMaxInstanceRequestConcurrency(117250100)
+ .setTimeout(Duration.newBuilder().build())
+ .setServiceAccount("serviceAccount1079137720")
+ .addAllContainers(new ArrayList())
+ .addAllVolumes(new ArrayList())
+ .setExecutionEnvironment(ExecutionEnvironment.forNumber(0))
+ .setEncryptionKey("encryptionKey-36224036")
+ .setReconciling(true)
+ .addAllConditions(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setLogUri("logUri-1097354360")
+ .setEtag("etag3123477")
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("deleteRevisionTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ String name =
+ "projects/project-7778/locations/location-7778/services/service-7778/revisions/revision-7778";
+
+ Revision actualResponse = client.deleteRevisionAsync(name).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 deleteRevisionExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-7778/locations/location-7778/services/service-7778/revisions/revision-7778";
+ client.deleteRevisionAsync(name).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+}
diff --git a/google-cloud-run/src/test/java/com/google/cloud/run/v2/ServicesClientHttpJsonTest.java b/google-cloud-run/src/test/java/com/google/cloud/run/v2/ServicesClientHttpJsonTest.java
new file mode 100644
index 0000000..2806f80
--- /dev/null
+++ b/google-cloud-run/src/test/java/com/google/cloud/run/v2/ServicesClientHttpJsonTest.java
@@ -0,0 +1,963 @@
+/*
+ * 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.run.v2;
+
+import static com.google.cloud.run.v2.ServicesClient.ListServicesPagedResponse;
+
+import com.google.api.LaunchStage;
+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.run.v2.stub.HttpJsonServicesStub;
+import com.google.common.collect.Lists;
+import com.google.iam.v1.AuditConfig;
+import com.google.iam.v1.Binding;
+import com.google.iam.v1.GetIamPolicyRequest;
+import com.google.iam.v1.GetPolicyOptions;
+import com.google.iam.v1.Policy;
+import com.google.iam.v1.SetIamPolicyRequest;
+import com.google.iam.v1.TestIamPermissionsRequest;
+import com.google.iam.v1.TestIamPermissionsResponse;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Any;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.Timestamp;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+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 ServicesClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static ServicesClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonServicesStub.getMethodDescriptors(), ServicesSettings.getDefaultEndpoint());
+ ServicesSettings settings =
+ ServicesSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ ServicesSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = ServicesClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void createServiceTest() throws Exception {
+ Service expectedResponse =
+ Service.newBuilder()
+ .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setDescription("description-1724546052")
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .setLastModifier("lastModifier1959003021")
+ .setClient("client-1357712437")
+ .setClientVersion("clientVersion771880589")
+ .setIngress(IngressTraffic.forNumber(0))
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setBinaryAuthorization(BinaryAuthorization.newBuilder().build())
+ .setTemplate(RevisionTemplate.newBuilder().build())
+ .addAllTraffic(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setTerminalCondition(Condition.newBuilder().build())
+ .addAllConditions(new ArrayList())
+ .setLatestReadyRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setLatestCreatedRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .addAllTrafficStatuses(new ArrayList())
+ .setUri("uri116076")
+ .setReconciling(true)
+ .setEtag("etag3123477")
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createServiceTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ Service service = Service.newBuilder().build();
+ String serviceId = "serviceId-194185552";
+
+ Service actualResponse = client.createServiceAsync(parent, service, serviceId).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 createServiceExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ Service service = Service.newBuilder().build();
+ String serviceId = "serviceId-194185552";
+ client.createServiceAsync(parent, service, serviceId).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void createServiceTest2() throws Exception {
+ Service expectedResponse =
+ Service.newBuilder()
+ .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setDescription("description-1724546052")
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .setLastModifier("lastModifier1959003021")
+ .setClient("client-1357712437")
+ .setClientVersion("clientVersion771880589")
+ .setIngress(IngressTraffic.forNumber(0))
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setBinaryAuthorization(BinaryAuthorization.newBuilder().build())
+ .setTemplate(RevisionTemplate.newBuilder().build())
+ .addAllTraffic(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setTerminalCondition(Condition.newBuilder().build())
+ .addAllConditions(new ArrayList())
+ .setLatestReadyRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setLatestCreatedRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .addAllTrafficStatuses(new ArrayList())
+ .setUri("uri116076")
+ .setReconciling(true)
+ .setEtag("etag3123477")
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createServiceTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ String parent = "projects/project-5833/locations/location-5833";
+ Service service = Service.newBuilder().build();
+ String serviceId = "serviceId-194185552";
+
+ Service actualResponse = client.createServiceAsync(parent, service, serviceId).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 createServiceExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "projects/project-5833/locations/location-5833";
+ Service service = Service.newBuilder().build();
+ String serviceId = "serviceId-194185552";
+ client.createServiceAsync(parent, service, serviceId).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void getServiceTest() throws Exception {
+ Service expectedResponse =
+ Service.newBuilder()
+ .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setDescription("description-1724546052")
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .setLastModifier("lastModifier1959003021")
+ .setClient("client-1357712437")
+ .setClientVersion("clientVersion771880589")
+ .setIngress(IngressTraffic.forNumber(0))
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setBinaryAuthorization(BinaryAuthorization.newBuilder().build())
+ .setTemplate(RevisionTemplate.newBuilder().build())
+ .addAllTraffic(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setTerminalCondition(Condition.newBuilder().build())
+ .addAllConditions(new ArrayList())
+ .setLatestReadyRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setLatestCreatedRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .addAllTrafficStatuses(new ArrayList())
+ .setUri("uri116076")
+ .setReconciling(true)
+ .setEtag("etag3123477")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
+
+ Service actualResponse = client.getService(name);
+ 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 getServiceExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ ServiceName name = ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]");
+ client.getService(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getServiceTest2() throws Exception {
+ Service expectedResponse =
+ Service.newBuilder()
+ .setName(ServiceName.of("[PROJECT]", "[LOCATION]", "[SERVICE]").toString())
+ .setDescription("description-1724546052")
+ .setUid("uid115792")
+ .setGeneration(305703192)
+ .putAllLabels(new HashMap())
+ .putAllAnnotations(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setDeleteTime(Timestamp.newBuilder().build())
+ .setExpireTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .setLastModifier("lastModifier1959003021")
+ .setClient("client-1357712437")
+ .setClientVersion("clientVersion771880589")
+ .setIngress(IngressTraffic.forNumber(0))
+ .setLaunchStage(LaunchStage.forNumber(0))
+ .setBinaryAuthorization(BinaryAuthorization.newBuilder().build())
+ .setTemplate(RevisionTemplate.newBuilder().build())
+ .addAllTraffic(new ArrayList())
+ .setObservedGeneration(900833007)
+ .setTerminalCondition(Condition.newBuilder().build())
+ .addAllConditions(new ArrayList())
+ .setLatestReadyRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .setLatestCreatedRevision(
+ RevisionName.of("[PROJECT]", "[LOCATION]", "[SERVICE]", "[REVISION]").toString())
+ .addAllTrafficStatuses(new ArrayList())
+ .setUri("uri116076")
+ .setReconciling(true)
+ .setEtag("etag3123477")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "projects/project-7842/locations/location-7842/services/service-7842";
+
+ Service actualResponse = client.getService(name);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List