diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java
index 4d289ca9e676..cf1c53d1f9e3 100644
--- a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksClient.java
@@ -18,7 +18,6 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
-import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
@@ -106,6 +105,20 @@
* CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
* }
*
+ * 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.
+ * CloudTasksSettings cloudTasksSettings =
+ * CloudTasksSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * CloudTasksSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
@@ -130,7 +143,6 @@ public static final CloudTasksClient create(CloudTasksSettings settings) throws
* Constructs an instance of CloudTasksClient, using the given stub for making calls. This is for
* advanced usage - prefer using create(CloudTasksSettings).
*/
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final CloudTasksClient create(CloudTasksStub stub) {
return new CloudTasksClient(stub);
}
@@ -144,7 +156,6 @@ protected CloudTasksClient(CloudTasksSettings settings) throws IOException {
this.stub = ((CloudTasksStubSettings) settings.getStubSettings()).createStub();
}
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected CloudTasksClient(CloudTasksStub stub) {
this.settings = null;
this.stub = stub;
@@ -154,7 +165,6 @@ public final CloudTasksSettings getSettings() {
return settings;
}
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public CloudTasksStub getStub() {
return stub;
}
@@ -300,7 +310,7 @@ public final UnaryCallable listQueue
* .build();
* while (true) {
* ListQueuesResponse response = cloudTasksClient.listQueuesCallable().call(request);
- * for (Queue element : response.getResponsesList()) {
+ * for (Queue element : response.getQueuesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
@@ -1785,7 +1795,7 @@ public final UnaryCallable listTasksPa
* .build();
* while (true) {
* ListTasksResponse response = cloudTasksClient.listTasksCallable().call(request);
- * for (Task element : response.getResponsesList()) {
+ * for (Task element : response.getTasksList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksSettings.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksSettings.java
index 433cfa77a076..5ba02bdf5a1d 100644
--- a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksSettings.java
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/CloudTasksSettings.java
@@ -24,6 +24,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;
@@ -184,11 +185,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return CloudTasksStubSettings.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 CloudTasksStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return CloudTasksStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return CloudTasksStubSettings.defaultTransportChannelProvider();
}
@@ -198,11 +206,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return CloudTasksStubSettings.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);
@@ -240,6 +254,11 @@ private static Builder createDefault() {
return new Builder(CloudTasksStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(CloudTasksStubSettings.newHttpJsonBuilder());
+ }
+
public CloudTasksStubSettings.Builder getStubSettingsBuilder() {
return ((CloudTasksStubSettings.Builder) getStubSettings());
}
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/CloudTasksStubSettings.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/CloudTasksStubSettings.java
index fcc4bf86e516..917761b9b803 100644
--- a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/CloudTasksStubSettings.java
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/CloudTasksStubSettings.java
@@ -28,6 +28,9 @@
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+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.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
@@ -321,13 +324,17 @@ public UnaryCallSettings runTaskSettings() {
return runTaskSettings;
}
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public CloudTasksStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcCloudTasksStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonCloudTasksStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -360,18 +367,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
.setUseJwtAccessWithScope(true);
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE);
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
- public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(CloudTasksStubSettings.class))
@@ -379,11 +393,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- /** Returns a new builder for this class. */
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(CloudTasksStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return CloudTasksStubSettings.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);
@@ -580,6 +613,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
.listQueuesSettings()
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/HttpJsonCloudTasksCallableFactory.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/HttpJsonCloudTasksCallableFactory.java
new file mode 100644
index 000000000000..df93d9fda7c1
--- /dev/null
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/HttpJsonCloudTasksCallableFactory.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.tasks.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 CloudTasks service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonCloudTasksCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/HttpJsonCloudTasksStub.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/HttpJsonCloudTasksStub.java
new file mode 100644
index 000000000000..79109ceb0b22
--- /dev/null
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2/stub/HttpJsonCloudTasksStub.java
@@ -0,0 +1,982 @@
+/*
+ * 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.tasks.v2.stub;
+
+import static com.google.cloud.tasks.v2.CloudTasksClient.ListQueuesPagedResponse;
+import static com.google.cloud.tasks.v2.CloudTasksClient.ListTasksPagedResponse;
+
+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.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.rpc.ClientContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.tasks.v2.CreateQueueRequest;
+import com.google.cloud.tasks.v2.CreateTaskRequest;
+import com.google.cloud.tasks.v2.DeleteQueueRequest;
+import com.google.cloud.tasks.v2.DeleteTaskRequest;
+import com.google.cloud.tasks.v2.GetQueueRequest;
+import com.google.cloud.tasks.v2.GetTaskRequest;
+import com.google.cloud.tasks.v2.ListQueuesRequest;
+import com.google.cloud.tasks.v2.ListQueuesResponse;
+import com.google.cloud.tasks.v2.ListTasksRequest;
+import com.google.cloud.tasks.v2.ListTasksResponse;
+import com.google.cloud.tasks.v2.PauseQueueRequest;
+import com.google.cloud.tasks.v2.PurgeQueueRequest;
+import com.google.cloud.tasks.v2.Queue;
+import com.google.cloud.tasks.v2.ResumeQueueRequest;
+import com.google.cloud.tasks.v2.RunTaskRequest;
+import com.google.cloud.tasks.v2.Task;
+import com.google.cloud.tasks.v2.UpdateQueueRequest;
+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.protobuf.Empty;
+import com.google.protobuf.TypeRegistry;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST stub implementation for the CloudTasks service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonCloudTasksStub extends CloudTasksStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor
+ listQueuesMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/ListQueues")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*}/queues",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListQueuesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor getQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/GetQueue")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*}",
+ 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(Queue.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor createQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/CreateQueue")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*}/queues",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request -> ProtoRestSerializer.create().toBody("queue", request.getQueue()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Queue.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor updateQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/UpdateQueue")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{queue.name=projects/*/locations/*/queues/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "queue.name", request.getQueue().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request -> ProtoRestSerializer.create().toBody("queue", request.getQueue()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Queue.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor deleteQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/DeleteQueue")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*}",
+ 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(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor purgeQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/PurgeQueue")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*}:purge",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Queue.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor pauseQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/PauseQueue")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*}:pause",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Queue.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor resumeQueueMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/ResumeQueue")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*}:resume",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Queue.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getIamPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/GetIamPolicy")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{resource=projects/*/locations/*/queues/*}: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();
+ 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
+ setIamPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/SetIamPolicy")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{resource=projects/*/locations/*/queues/*}: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.tasks.v2.CloudTasks/TestIamPermissions")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{resource=projects/*/locations/*/queues/*}: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 static final ApiMethodDescriptor
+ listTasksMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/ListTasks")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*/queues/*}/tasks",
+ 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, "responseView", request.getResponseView());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListTasksResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor getTaskMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/GetTask")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*/tasks/*}",
+ 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, "responseView", request.getResponseView());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Task.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor createTaskMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/CreateTask")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=projects/*/locations/*/queues/*}/tasks",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearParent().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Task.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor deleteTaskMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/DeleteTask")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*/tasks/*}",
+ 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(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor runTaskMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.tasks.v2.CloudTasks/RunTask")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=projects/*/locations/*/queues/*/tasks/*}:run",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Task.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable listQueuesCallable;
+ private final UnaryCallable listQueuesPagedCallable;
+ private final UnaryCallable getQueueCallable;
+ private final UnaryCallable createQueueCallable;
+ private final UnaryCallable updateQueueCallable;
+ private final UnaryCallable deleteQueueCallable;
+ private final UnaryCallable purgeQueueCallable;
+ private final UnaryCallable pauseQueueCallable;
+ private final UnaryCallable resumeQueueCallable;
+ private final UnaryCallable getIamPolicyCallable;
+ private final UnaryCallable setIamPolicyCallable;
+ private final UnaryCallable
+ testIamPermissionsCallable;
+ private final UnaryCallable listTasksCallable;
+ private final UnaryCallable listTasksPagedCallable;
+ private final UnaryCallable getTaskCallable;
+ private final UnaryCallable createTaskCallable;
+ private final UnaryCallable deleteTaskCallable;
+ private final UnaryCallable runTaskCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonCloudTasksStub create(CloudTasksStubSettings settings)
+ throws IOException {
+ return new HttpJsonCloudTasksStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonCloudTasksStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonCloudTasksStub(
+ CloudTasksStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonCloudTasksStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonCloudTasksStub(
+ CloudTasksStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonCloudTasksStub, 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 HttpJsonCloudTasksStub(CloudTasksStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonCloudTasksCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonCloudTasksStub, 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 HttpJsonCloudTasksStub(
+ CloudTasksStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+
+ HttpJsonCallSettings listQueuesTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listQueuesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getQueueMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings createQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createQueueMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateQueueMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteQueueMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings purgeQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(purgeQueueMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings pauseQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(pauseQueueMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings resumeQueueTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(resumeQueueMethodDescriptor)
+ .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();
+ HttpJsonCallSettings listTasksTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listTasksMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getTaskTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getTaskMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings createTaskTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createTaskMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteTaskTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteTaskMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings runTaskTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(runTaskMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.listQueuesCallable =
+ callableFactory.createUnaryCallable(
+ listQueuesTransportSettings, settings.listQueuesSettings(), clientContext);
+ this.listQueuesPagedCallable =
+ callableFactory.createPagedCallable(
+ listQueuesTransportSettings, settings.listQueuesSettings(), clientContext);
+ this.getQueueCallable =
+ callableFactory.createUnaryCallable(
+ getQueueTransportSettings, settings.getQueueSettings(), clientContext);
+ this.createQueueCallable =
+ callableFactory.createUnaryCallable(
+ createQueueTransportSettings, settings.createQueueSettings(), clientContext);
+ this.updateQueueCallable =
+ callableFactory.createUnaryCallable(
+ updateQueueTransportSettings, settings.updateQueueSettings(), clientContext);
+ this.deleteQueueCallable =
+ callableFactory.createUnaryCallable(
+ deleteQueueTransportSettings, settings.deleteQueueSettings(), clientContext);
+ this.purgeQueueCallable =
+ callableFactory.createUnaryCallable(
+ purgeQueueTransportSettings, settings.purgeQueueSettings(), clientContext);
+ this.pauseQueueCallable =
+ callableFactory.createUnaryCallable(
+ pauseQueueTransportSettings, settings.pauseQueueSettings(), clientContext);
+ this.resumeQueueCallable =
+ callableFactory.createUnaryCallable(
+ resumeQueueTransportSettings, settings.resumeQueueSettings(), clientContext);
+ 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.listTasksCallable =
+ callableFactory.createUnaryCallable(
+ listTasksTransportSettings, settings.listTasksSettings(), clientContext);
+ this.listTasksPagedCallable =
+ callableFactory.createPagedCallable(
+ listTasksTransportSettings, settings.listTasksSettings(), clientContext);
+ this.getTaskCallable =
+ callableFactory.createUnaryCallable(
+ getTaskTransportSettings, settings.getTaskSettings(), clientContext);
+ this.createTaskCallable =
+ callableFactory.createUnaryCallable(
+ createTaskTransportSettings, settings.createTaskSettings(), clientContext);
+ this.deleteTaskCallable =
+ callableFactory.createUnaryCallable(
+ deleteTaskTransportSettings, settings.deleteTaskSettings(), clientContext);
+ this.runTaskCallable =
+ callableFactory.createUnaryCallable(
+ runTaskTransportSettings, settings.runTaskSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listQueuesMethodDescriptor);
+ methodDescriptors.add(getQueueMethodDescriptor);
+ methodDescriptors.add(createQueueMethodDescriptor);
+ methodDescriptors.add(updateQueueMethodDescriptor);
+ methodDescriptors.add(deleteQueueMethodDescriptor);
+ methodDescriptors.add(purgeQueueMethodDescriptor);
+ methodDescriptors.add(pauseQueueMethodDescriptor);
+ methodDescriptors.add(resumeQueueMethodDescriptor);
+ methodDescriptors.add(getIamPolicyMethodDescriptor);
+ methodDescriptors.add(setIamPolicyMethodDescriptor);
+ methodDescriptors.add(testIamPermissionsMethodDescriptor);
+ methodDescriptors.add(listTasksMethodDescriptor);
+ methodDescriptors.add(getTaskMethodDescriptor);
+ methodDescriptors.add(createTaskMethodDescriptor);
+ methodDescriptors.add(deleteTaskMethodDescriptor);
+ methodDescriptors.add(runTaskMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ @Override
+ public UnaryCallable listQueuesCallable() {
+ return listQueuesCallable;
+ }
+
+ @Override
+ public UnaryCallable listQueuesPagedCallable() {
+ return listQueuesPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getQueueCallable() {
+ return getQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable createQueueCallable() {
+ return createQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable updateQueueCallable() {
+ return updateQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteQueueCallable() {
+ return deleteQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable purgeQueueCallable() {
+ return purgeQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable pauseQueueCallable() {
+ return pauseQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable resumeQueueCallable() {
+ return resumeQueueCallable;
+ }
+
+ @Override
+ public UnaryCallable getIamPolicyCallable() {
+ return getIamPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable setIamPolicyCallable() {
+ return setIamPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ testIamPermissionsCallable() {
+ return testIamPermissionsCallable;
+ }
+
+ @Override
+ public UnaryCallable listTasksCallable() {
+ return listTasksCallable;
+ }
+
+ @Override
+ public UnaryCallable listTasksPagedCallable() {
+ return listTasksPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getTaskCallable() {
+ return getTaskCallable;
+ }
+
+ @Override
+ public UnaryCallable createTaskCallable() {
+ return createTaskCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteTaskCallable() {
+ return deleteTaskCallable;
+ }
+
+ @Override
+ public UnaryCallable runTaskCallable() {
+ return runTaskCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java
index 09c3408dd54a..2fb0f9054f18 100644
--- a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksClient.java
@@ -108,6 +108,20 @@
* CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
* }
*
+ * 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.
+ * CloudTasksSettings cloudTasksSettings =
+ * CloudTasksSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * CloudTasksSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * CloudTasksClient cloudTasksClient = CloudTasksClient.create(cloudTasksSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
@@ -133,7 +147,6 @@ public static final CloudTasksClient create(CloudTasksSettings settings) throws
* Constructs an instance of CloudTasksClient, using the given stub for making calls. This is for
* advanced usage - prefer using create(CloudTasksSettings).
*/
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final CloudTasksClient create(CloudTasksStub stub) {
return new CloudTasksClient(stub);
}
@@ -147,7 +160,6 @@ protected CloudTasksClient(CloudTasksSettings settings) throws IOException {
this.stub = ((CloudTasksStubSettings) settings.getStubSettings()).createStub();
}
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected CloudTasksClient(CloudTasksStub stub) {
this.settings = null;
this.stub = stub;
@@ -157,7 +169,6 @@ public final CloudTasksSettings getSettings() {
return settings;
}
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public CloudTasksStub getStub() {
return stub;
}
@@ -306,7 +317,7 @@ public final UnaryCallable listQueue
* .build();
* while (true) {
* ListQueuesResponse response = cloudTasksClient.listQueuesCallable().call(request);
- * for (Queue element : response.getResponsesList()) {
+ * for (Queue element : response.getQueuesList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
@@ -1797,7 +1808,7 @@ public final UnaryCallable listTasksPa
* .build();
* while (true) {
* ListTasksResponse response = cloudTasksClient.listTasksCallable().call(request);
- * for (Task element : response.getResponsesList()) {
+ * for (Task element : response.getTasksList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksSettings.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksSettings.java
index 3f9c9be6102e..88d405e7da8b 100644
--- a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksSettings.java
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/CloudTasksSettings.java
@@ -24,6 +24,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;
@@ -205,11 +206,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return CloudTasksStubSettings.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 CloudTasksStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return CloudTasksStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return CloudTasksStubSettings.defaultTransportChannelProvider();
}
@@ -219,11 +227,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return CloudTasksStubSettings.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);
@@ -261,6 +275,11 @@ private static Builder createDefault() {
return new Builder(CloudTasksStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(CloudTasksStubSettings.newHttpJsonBuilder());
+ }
+
public CloudTasksStubSettings.Builder getStubSettingsBuilder() {
return ((CloudTasksStubSettings.Builder) getStubSettings());
}
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/CloudTasksStubSettings.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/CloudTasksStubSettings.java
index 59a0f2ba00a8..27411d787a8e 100644
--- a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/CloudTasksStubSettings.java
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/CloudTasksStubSettings.java
@@ -28,6 +28,9 @@
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+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.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
@@ -351,13 +354,17 @@ public UnaryCallSettings runTaskSettings() {
return runTaskSettings;
}
- @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public CloudTasksStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcCloudTasksStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonCloudTasksStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -390,18 +397,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
.setUseJwtAccessWithScope(true);
}
- /** Returns a builder for the default ChannelProvider for this service. */
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE);
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultGrpcTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
- public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(CloudTasksStubSettings.class))
@@ -409,11 +423,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
}
- /** Returns a new builder for this class. */
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(CloudTasksStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return CloudTasksStubSettings.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);
@@ -635,6 +668,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
.listQueuesSettings()
diff --git a/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/HttpJsonCloudTasksCallableFactory.java b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/HttpJsonCloudTasksCallableFactory.java
new file mode 100644
index 000000000000..3ea5df3ee72a
--- /dev/null
+++ b/java-tasks/google-cloud-tasks/src/main/java/com/google/cloud/tasks/v2beta2/stub/HttpJsonCloudTasksCallableFactory.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.tasks.v2beta2.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 CloudTasks service API.
+ *
+ * This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonCloudTasksCallableFactory
+ 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