diff --git a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClient.java b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClient.java
index 77dd4fcb11a6..580ef5e7269b 100644
--- a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClient.java
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClient.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;
@@ -28,7 +29,6 @@
import com.google.api.gax.rpc.UnaryCallable;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import com.google.storagetransfer.v1.proto.stub.StorageTransferServiceStub;
@@ -111,13 +111,29 @@
* StorageTransferServiceClient.create(storageTransferServiceSettings);
* }
*
+ * 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.
+ * StorageTransferServiceSettings storageTransferServiceSettings =
+ * StorageTransferServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * StorageTransferServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * StorageTransferServiceClient storageTransferServiceClient =
+ * StorageTransferServiceClient.create(storageTransferServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class StorageTransferServiceClient implements BackgroundResource {
private final StorageTransferServiceSettings settings;
private final StorageTransferServiceStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of StorageTransferServiceClient with default settings. */
public static final StorageTransferServiceClient create() throws IOException {
@@ -150,13 +166,17 @@ protected StorageTransferServiceClient(StorageTransferServiceSettings settings)
throws IOException {
this.settings = settings;
this.stub = ((StorageTransferServiceStubSettings) 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 StorageTransferServiceClient(StorageTransferServiceStub 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 StorageTransferServiceSettings getSettings() {
@@ -171,10 +191,18 @@ public StorageTransferServiceStub 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.
/**
* Returns the Google service account that is used by Storage Transfer Service to access buckets
diff --git a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceSettings.java b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceSettings.java
index 7339e0cdb3b1..416b45b5a98c 100644
--- a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceSettings.java
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/StorageTransferServiceSettings.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;
@@ -197,11 +198,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return StorageTransferServiceStubSettings.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 StorageTransferServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return StorageTransferServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return StorageTransferServiceStubSettings.defaultTransportChannelProvider();
}
@@ -211,11 +219,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return StorageTransferServiceStubSettings.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);
@@ -254,6 +268,11 @@ private static Builder createDefault() {
return new Builder(StorageTransferServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(StorageTransferServiceStubSettings.newHttpJsonBuilder());
+ }
+
public StorageTransferServiceStubSettings.Builder getStubSettingsBuilder() {
return ((StorageTransferServiceStubSettings.Builder) getStubSettings());
}
diff --git a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/HttpJsonStorageTransferServiceCallableFactory.java b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/HttpJsonStorageTransferServiceCallableFactory.java
new file mode 100644
index 000000000000..5ab905a39daa
--- /dev/null
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/HttpJsonStorageTransferServiceCallableFactory.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.storagetransfer.v1.proto.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 StorageTransferService service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonStorageTransferServiceCallableFactory
+ 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-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/HttpJsonStorageTransferServiceStub.java b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/HttpJsonStorageTransferServiceStub.java
new file mode 100644
index 000000000000..6c54b9352761
--- /dev/null
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/HttpJsonStorageTransferServiceStub.java
@@ -0,0 +1,955 @@
+/*
+ * 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.storagetransfer.v1.proto.stub;
+
+import static com.google.storagetransfer.v1.proto.StorageTransferServiceClient.ListAgentPoolsPagedResponse;
+import static com.google.storagetransfer.v1.proto.StorageTransferServiceClient.ListTransferJobsPagedResponse;
+
+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.longrunning.Operation;
+import com.google.protobuf.Empty;
+import com.google.protobuf.TypeRegistry;
+import com.google.storagetransfer.v1.proto.TransferProto;
+import com.google.storagetransfer.v1.proto.TransferTypes;
+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 StorageTransferService service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonStorageTransferServiceStub extends StorageTransferServiceStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(Empty.getDescriptor())
+ .add(TransferTypes.TransferOperation.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.GetGoogleServiceAccountRequest, TransferTypes.GoogleServiceAccount>
+ getGoogleServiceAccountMethodDescriptor =
+ ApiMethodDescriptor
+ .
+ newBuilder()
+ .setFullMethodName(
+ "google.storagetransfer.v1.StorageTransferService/GetGoogleServiceAccount")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter
+ .newBuilder()
+ .setPath(
+ "/v1/googleServiceAccounts/{projectId}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer
+ serializer = ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer
+ serializer = ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TransferTypes.GoogleServiceAccount.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.CreateTransferJobRequest, TransferTypes.TransferJob>
+ createTransferJobMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName(
+ "google.storagetransfer.v1.StorageTransferService/CreateTransferJob")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/transferJobs",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("transferJob", request.getTransferJob()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TransferTypes.TransferJob.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.UpdateTransferJobRequest, TransferTypes.TransferJob>
+ updateTransferJobMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName(
+ "google.storagetransfer.v1.StorageTransferService/UpdateTransferJob")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{jobName=transferJobs/**}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "jobName", request.getJobName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearJobName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TransferTypes.TransferJob.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.GetTransferJobRequest, TransferTypes.TransferJob>
+ getTransferJobMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/GetTransferJob")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{jobName=transferJobs/**}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "jobName", request.getJobName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TransferTypes.TransferJob.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.ListTransferJobsRequest, TransferProto.ListTransferJobsResponse>
+ listTransferJobsMethodDescriptor =
+ ApiMethodDescriptor
+ .
+ newBuilder()
+ .setFullMethodName(
+ "google.storagetransfer.v1.StorageTransferService/ListTransferJobs")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/transferJobs",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ 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(
+ TransferProto.ListTransferJobsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ pauseTransferOperationMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.storagetransfer.v1.StorageTransferService/PauseTransferOperation")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter
+ .newBuilder()
+ .setPath(
+ "/v1/{name=transferOperations/**}: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(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ resumeTransferOperationMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.storagetransfer.v1.StorageTransferService/ResumeTransferOperation")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter
+ .newBuilder()
+ .setPath(
+ "/v1/{name=transferOperations/**}: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(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ runTransferJobMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/RunTransferJob")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{jobName=transferJobs/**}:run",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "jobName", request.getJobName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearJobName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (TransferProto.RunTransferJobRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.CreateAgentPoolRequest, TransferTypes.AgentPool>
+ createAgentPoolMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/CreateAgentPool")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId=*}/agentPools",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(
+ fields, "agentPoolId", request.getAgentPoolId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("agentPool", request.getAgentPool()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TransferTypes.AgentPool.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.UpdateAgentPoolRequest, TransferTypes.AgentPool>
+ updateAgentPoolMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/UpdateAgentPool")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{agentPool.name=projects/*/agentPools/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "agentPool.name", request.getAgentPool().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("agentPool", request.getAgentPool()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TransferTypes.AgentPool.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.GetAgentPoolRequest, TransferTypes.AgentPool>
+ getAgentPoolMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/GetAgentPool")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/agentPools/*}",
+ 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(TransferTypes.AgentPool.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ TransferProto.ListAgentPoolsRequest, TransferProto.ListAgentPoolsResponse>
+ listAgentPoolsMethodDescriptor =
+ ApiMethodDescriptor
+ .
+ newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/ListAgentPools")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/projects/{projectId=*}/agentPools",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "projectId", request.getProjectId());
+ 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(TransferProto.ListAgentPoolsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteAgentPoolMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.storagetransfer.v1.StorageTransferService/DeleteAgentPool")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/agentPools/*}",
+ 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 final UnaryCallable<
+ TransferProto.GetGoogleServiceAccountRequest, TransferTypes.GoogleServiceAccount>
+ getGoogleServiceAccountCallable;
+ private final UnaryCallable
+ createTransferJobCallable;
+ private final UnaryCallable
+ updateTransferJobCallable;
+ private final UnaryCallable
+ getTransferJobCallable;
+ private final UnaryCallable<
+ TransferProto.ListTransferJobsRequest, TransferProto.ListTransferJobsResponse>
+ listTransferJobsCallable;
+ private final UnaryCallable
+ listTransferJobsPagedCallable;
+ private final UnaryCallable
+ pauseTransferOperationCallable;
+ private final UnaryCallable
+ resumeTransferOperationCallable;
+ private final UnaryCallable
+ runTransferJobCallable;
+ private final OperationCallable<
+ TransferProto.RunTransferJobRequest, Empty, TransferTypes.TransferOperation>
+ runTransferJobOperationCallable;
+ private final UnaryCallable
+ createAgentPoolCallable;
+ private final UnaryCallable
+ updateAgentPoolCallable;
+ private final UnaryCallable
+ getAgentPoolCallable;
+ private final UnaryCallable<
+ TransferProto.ListAgentPoolsRequest, TransferProto.ListAgentPoolsResponse>
+ listAgentPoolsCallable;
+ private final UnaryCallable
+ listAgentPoolsPagedCallable;
+ private final UnaryCallable deleteAgentPoolCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonStorageTransferServiceStub create(
+ StorageTransferServiceStubSettings settings) throws IOException {
+ return new HttpJsonStorageTransferServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonStorageTransferServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonStorageTransferServiceStub(
+ StorageTransferServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonStorageTransferServiceStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonStorageTransferServiceStub(
+ StorageTransferServiceStubSettings.newHttpJsonBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonStorageTransferServiceStub, 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 HttpJsonStorageTransferServiceStub(
+ StorageTransferServiceStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new HttpJsonStorageTransferServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonStorageTransferServiceStub, 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 HttpJsonStorageTransferServiceStub(
+ StorageTransferServiceStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings<
+ TransferProto.GetGoogleServiceAccountRequest, TransferTypes.GoogleServiceAccount>
+ getGoogleServiceAccountTransportSettings =
+ HttpJsonCallSettings
+ .
+ newBuilder()
+ .setMethodDescriptor(getGoogleServiceAccountMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ createTransferJobTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(createTransferJobMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ updateTransferJobTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(updateTransferJobMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ getTransferJobTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(getTransferJobMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings<
+ TransferProto.ListTransferJobsRequest, TransferProto.ListTransferJobsResponse>
+ listTransferJobsTransportSettings =
+ HttpJsonCallSettings
+ .
+ newBuilder()
+ .setMethodDescriptor(listTransferJobsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ pauseTransferOperationTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(pauseTransferOperationMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ resumeTransferOperationTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(resumeTransferOperationMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ runTransferJobTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(runTransferJobMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ createAgentPoolTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(createAgentPoolMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ updateAgentPoolTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(updateAgentPoolMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ getAgentPoolTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(getAgentPoolMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listAgentPoolsTransportSettings =
+ HttpJsonCallSettings
+ .
+ newBuilder()
+ .setMethodDescriptor(listAgentPoolsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ deleteAgentPoolTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteAgentPoolMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.getGoogleServiceAccountCallable =
+ callableFactory.createUnaryCallable(
+ getGoogleServiceAccountTransportSettings,
+ settings.getGoogleServiceAccountSettings(),
+ clientContext);
+ this.createTransferJobCallable =
+ callableFactory.createUnaryCallable(
+ createTransferJobTransportSettings,
+ settings.createTransferJobSettings(),
+ clientContext);
+ this.updateTransferJobCallable =
+ callableFactory.createUnaryCallable(
+ updateTransferJobTransportSettings,
+ settings.updateTransferJobSettings(),
+ clientContext);
+ this.getTransferJobCallable =
+ callableFactory.createUnaryCallable(
+ getTransferJobTransportSettings, settings.getTransferJobSettings(), clientContext);
+ this.listTransferJobsCallable =
+ callableFactory.createUnaryCallable(
+ listTransferJobsTransportSettings, settings.listTransferJobsSettings(), clientContext);
+ this.listTransferJobsPagedCallable =
+ callableFactory.createPagedCallable(
+ listTransferJobsTransportSettings, settings.listTransferJobsSettings(), clientContext);
+ this.pauseTransferOperationCallable =
+ callableFactory.createUnaryCallable(
+ pauseTransferOperationTransportSettings,
+ settings.pauseTransferOperationSettings(),
+ clientContext);
+ this.resumeTransferOperationCallable =
+ callableFactory.createUnaryCallable(
+ resumeTransferOperationTransportSettings,
+ settings.resumeTransferOperationSettings(),
+ clientContext);
+ this.runTransferJobCallable =
+ callableFactory.createUnaryCallable(
+ runTransferJobTransportSettings, settings.runTransferJobSettings(), clientContext);
+ this.runTransferJobOperationCallable =
+ callableFactory.createOperationCallable(
+ runTransferJobTransportSettings,
+ settings.runTransferJobOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.createAgentPoolCallable =
+ callableFactory.createUnaryCallable(
+ createAgentPoolTransportSettings, settings.createAgentPoolSettings(), clientContext);
+ this.updateAgentPoolCallable =
+ callableFactory.createUnaryCallable(
+ updateAgentPoolTransportSettings, settings.updateAgentPoolSettings(), clientContext);
+ this.getAgentPoolCallable =
+ callableFactory.createUnaryCallable(
+ getAgentPoolTransportSettings, settings.getAgentPoolSettings(), clientContext);
+ this.listAgentPoolsCallable =
+ callableFactory.createUnaryCallable(
+ listAgentPoolsTransportSettings, settings.listAgentPoolsSettings(), clientContext);
+ this.listAgentPoolsPagedCallable =
+ callableFactory.createPagedCallable(
+ listAgentPoolsTransportSettings, settings.listAgentPoolsSettings(), clientContext);
+ this.deleteAgentPoolCallable =
+ callableFactory.createUnaryCallable(
+ deleteAgentPoolTransportSettings, settings.deleteAgentPoolSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(getGoogleServiceAccountMethodDescriptor);
+ methodDescriptors.add(createTransferJobMethodDescriptor);
+ methodDescriptors.add(updateTransferJobMethodDescriptor);
+ methodDescriptors.add(getTransferJobMethodDescriptor);
+ methodDescriptors.add(listTransferJobsMethodDescriptor);
+ methodDescriptors.add(pauseTransferOperationMethodDescriptor);
+ methodDescriptors.add(resumeTransferOperationMethodDescriptor);
+ methodDescriptors.add(runTransferJobMethodDescriptor);
+ methodDescriptors.add(createAgentPoolMethodDescriptor);
+ methodDescriptors.add(updateAgentPoolMethodDescriptor);
+ methodDescriptors.add(getAgentPoolMethodDescriptor);
+ methodDescriptors.add(listAgentPoolsMethodDescriptor);
+ methodDescriptors.add(deleteAgentPoolMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable<
+ TransferProto.GetGoogleServiceAccountRequest, TransferTypes.GoogleServiceAccount>
+ getGoogleServiceAccountCallable() {
+ return getGoogleServiceAccountCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ createTransferJobCallable() {
+ return createTransferJobCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ updateTransferJobCallable() {
+ return updateTransferJobCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ getTransferJobCallable() {
+ return getTransferJobCallable;
+ }
+
+ @Override
+ public UnaryCallable<
+ TransferProto.ListTransferJobsRequest, TransferProto.ListTransferJobsResponse>
+ listTransferJobsCallable() {
+ return listTransferJobsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listTransferJobsPagedCallable() {
+ return listTransferJobsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ pauseTransferOperationCallable() {
+ return pauseTransferOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ resumeTransferOperationCallable() {
+ return resumeTransferOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable runTransferJobCallable() {
+ return runTransferJobCallable;
+ }
+
+ @Override
+ public OperationCallable<
+ TransferProto.RunTransferJobRequest, Empty, TransferTypes.TransferOperation>
+ runTransferJobOperationCallable() {
+ return runTransferJobOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ createAgentPoolCallable() {
+ return createAgentPoolCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ updateAgentPoolCallable() {
+ return updateAgentPoolCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ getAgentPoolCallable() {
+ return getAgentPoolCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listAgentPoolsCallable() {
+ return listAgentPoolsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listAgentPoolsPagedCallable() {
+ return listAgentPoolsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteAgentPoolCallable() {
+ return deleteAgentPoolCallable;
+ }
+
+ @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-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStub.java b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStub.java
index 64657b717c24..40dfa9ef456d 100644
--- a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStub.java
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStub.java
@@ -39,7 +39,11 @@
public abstract class StorageTransferServiceStub 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<
diff --git a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStubSettings.java b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStubSettings.java
index c547f7615462..ad291313ba79 100644
--- a/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStubSettings.java
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/main/java/com/google/storagetransfer/v1/proto/stub/StorageTransferServiceStubSettings.java
@@ -29,6 +29,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;
@@ -390,6 +393,11 @@ public StorageTransferServiceStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcStorageTransferServiceStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonStorageTransferServiceStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -422,18 +430,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(StorageTransferServiceStubSettings.class))
@@ -441,11 +456,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(StorageTransferServiceStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return StorageTransferServiceStubSettings.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);
@@ -636,6 +670,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
.getGoogleServiceAccountSettings()
diff --git a/java-storage-transfer/google-cloud-storage-transfer/src/test/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClientHttpJsonTest.java b/java-storage-transfer/google-cloud-storage-transfer/src/test/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClientHttpJsonTest.java
new file mode 100644
index 000000000000..2a66f3d03188
--- /dev/null
+++ b/java-storage-transfer/google-cloud-storage-transfer/src/test/java/com/google/storagetransfer/v1/proto/StorageTransferServiceClientHttpJsonTest.java
@@ -0,0 +1,773 @@
+/*
+ * 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.storagetransfer.v1.proto;
+
+import static com.google.storagetransfer.v1.proto.StorageTransferServiceClient.ListAgentPoolsPagedResponse;
+import static com.google.storagetransfer.v1.proto.StorageTransferServiceClient.ListTransferJobsPagedResponse;
+
+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.common.collect.Lists;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Any;
+import com.google.protobuf.Empty;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.Timestamp;
+import com.google.storagetransfer.v1.proto.stub.HttpJsonStorageTransferServiceStub;
+import java.io.IOException;
+import java.util.Arrays;
+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 StorageTransferServiceClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static StorageTransferServiceClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonStorageTransferServiceStub.getMethodDescriptors(),
+ StorageTransferServiceSettings.getDefaultEndpoint());
+ StorageTransferServiceSettings settings =
+ StorageTransferServiceSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ StorageTransferServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = StorageTransferServiceClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void getGoogleServiceAccountTest() throws Exception {
+ TransferTypes.GoogleServiceAccount expectedResponse =
+ TransferTypes.GoogleServiceAccount.newBuilder()
+ .setAccountEmail("accountEmail1067197807")
+ .setSubjectId("subjectId258589543")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.GetGoogleServiceAccountRequest request =
+ TransferProto.GetGoogleServiceAccountRequest.newBuilder()
+ .setProjectId("projectId-1530")
+ .build();
+
+ TransferTypes.GoogleServiceAccount actualResponse = client.getGoogleServiceAccount(request);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void getGoogleServiceAccountExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.GetGoogleServiceAccountRequest request =
+ TransferProto.GetGoogleServiceAccountRequest.newBuilder()
+ .setProjectId("projectId-1530")
+ .build();
+ client.getGoogleServiceAccount(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createTransferJobTest() throws Exception {
+ TransferTypes.TransferJob expectedResponse =
+ TransferTypes.TransferJob.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setProjectId("projectId-894832108")
+ .setTransferSpec(TransferTypes.TransferSpec.newBuilder().build())
+ .setNotificationConfig(TransferTypes.NotificationConfig.newBuilder().build())
+ .setLoggingConfig(TransferTypes.LoggingConfig.newBuilder().build())
+ .setSchedule(TransferTypes.Schedule.newBuilder().build())
+ .setCreationTime(Timestamp.newBuilder().build())
+ .setLastModificationTime(Timestamp.newBuilder().build())
+ .setDeletionTime(Timestamp.newBuilder().build())
+ .setLatestOperationName("latestOperationName-1244328885")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.CreateTransferJobRequest request =
+ TransferProto.CreateTransferJobRequest.newBuilder()
+ .setTransferJob(TransferTypes.TransferJob.newBuilder().build())
+ .build();
+
+ TransferTypes.TransferJob actualResponse = client.createTransferJob(request);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void createTransferJobExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.CreateTransferJobRequest request =
+ TransferProto.CreateTransferJobRequest.newBuilder()
+ .setTransferJob(TransferTypes.TransferJob.newBuilder().build())
+ .build();
+ client.createTransferJob(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void updateTransferJobTest() throws Exception {
+ TransferTypes.TransferJob expectedResponse =
+ TransferTypes.TransferJob.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setProjectId("projectId-894832108")
+ .setTransferSpec(TransferTypes.TransferSpec.newBuilder().build())
+ .setNotificationConfig(TransferTypes.NotificationConfig.newBuilder().build())
+ .setLoggingConfig(TransferTypes.LoggingConfig.newBuilder().build())
+ .setSchedule(TransferTypes.Schedule.newBuilder().build())
+ .setCreationTime(Timestamp.newBuilder().build())
+ .setLastModificationTime(Timestamp.newBuilder().build())
+ .setDeletionTime(Timestamp.newBuilder().build())
+ .setLatestOperationName("latestOperationName-1244328885")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.UpdateTransferJobRequest request =
+ TransferProto.UpdateTransferJobRequest.newBuilder()
+ .setJobName("transferJobs/transferJob-1286")
+ .setProjectId("projectId-894832108")
+ .setTransferJob(TransferTypes.TransferJob.newBuilder().build())
+ .setUpdateTransferJobFieldMask(FieldMask.newBuilder().build())
+ .build();
+
+ TransferTypes.TransferJob actualResponse = client.updateTransferJob(request);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void updateTransferJobExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.UpdateTransferJobRequest request =
+ TransferProto.UpdateTransferJobRequest.newBuilder()
+ .setJobName("transferJobs/transferJob-1286")
+ .setProjectId("projectId-894832108")
+ .setTransferJob(TransferTypes.TransferJob.newBuilder().build())
+ .setUpdateTransferJobFieldMask(FieldMask.newBuilder().build())
+ .build();
+ client.updateTransferJob(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getTransferJobTest() throws Exception {
+ TransferTypes.TransferJob expectedResponse =
+ TransferTypes.TransferJob.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setProjectId("projectId-894832108")
+ .setTransferSpec(TransferTypes.TransferSpec.newBuilder().build())
+ .setNotificationConfig(TransferTypes.NotificationConfig.newBuilder().build())
+ .setLoggingConfig(TransferTypes.LoggingConfig.newBuilder().build())
+ .setSchedule(TransferTypes.Schedule.newBuilder().build())
+ .setCreationTime(Timestamp.newBuilder().build())
+ .setLastModificationTime(Timestamp.newBuilder().build())
+ .setDeletionTime(Timestamp.newBuilder().build())
+ .setLatestOperationName("latestOperationName-1244328885")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.GetTransferJobRequest request =
+ TransferProto.GetTransferJobRequest.newBuilder()
+ .setJobName("transferJobs/transferJob-1286")
+ .setProjectId("projectId-894832108")
+ .build();
+
+ TransferTypes.TransferJob actualResponse = client.getTransferJob(request);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void getTransferJobExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.GetTransferJobRequest request =
+ TransferProto.GetTransferJobRequest.newBuilder()
+ .setJobName("transferJobs/transferJob-1286")
+ .setProjectId("projectId-894832108")
+ .build();
+ client.getTransferJob(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listTransferJobsTest() throws Exception {
+ TransferTypes.TransferJob responsesElement = TransferTypes.TransferJob.newBuilder().build();
+ TransferProto.ListTransferJobsResponse expectedResponse =
+ TransferProto.ListTransferJobsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllTransferJobs(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.ListTransferJobsRequest request =
+ TransferProto.ListTransferJobsRequest.newBuilder()
+ .setFilter("filter-1274492040")
+ .setPageSize(883849137)
+ .setPageToken("pageToken873572522")
+ .build();
+
+ ListTransferJobsPagedResponse pagedListResponse = client.listTransferJobs(request);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getTransferJobsList().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 listTransferJobsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.ListTransferJobsRequest request =
+ TransferProto.ListTransferJobsRequest.newBuilder()
+ .setFilter("filter-1274492040")
+ .setPageSize(883849137)
+ .setPageToken("pageToken873572522")
+ .build();
+ client.listTransferJobs(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void pauseTransferOperationTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.PauseTransferOperationRequest request =
+ TransferProto.PauseTransferOperationRequest.newBuilder()
+ .setName("transferOperations/transferOperation-5763")
+ .build();
+
+ client.pauseTransferOperation(request);
+
+ 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 pauseTransferOperationExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.PauseTransferOperationRequest request =
+ TransferProto.PauseTransferOperationRequest.newBuilder()
+ .setName("transferOperations/transferOperation-5763")
+ .build();
+ client.pauseTransferOperation(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void resumeTransferOperationTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ TransferProto.ResumeTransferOperationRequest request =
+ TransferProto.ResumeTransferOperationRequest.newBuilder()
+ .setName("transferOperations/transferOperation-5763")
+ .build();
+
+ client.resumeTransferOperation(request);
+
+ 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 resumeTransferOperationExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.ResumeTransferOperationRequest request =
+ TransferProto.ResumeTransferOperationRequest.newBuilder()
+ .setName("transferOperations/transferOperation-5763")
+ .build();
+ client.resumeTransferOperation(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void runTransferJobTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("runTransferJobTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ TransferProto.RunTransferJobRequest request =
+ TransferProto.RunTransferJobRequest.newBuilder()
+ .setJobName("transferJobs/transferJob-1286")
+ .setProjectId("projectId-894832108")
+ .build();
+
+ client.runTransferJobAsync(request).get();
+
+ 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 runTransferJobExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferProto.RunTransferJobRequest request =
+ TransferProto.RunTransferJobRequest.newBuilder()
+ .setJobName("transferJobs/transferJob-1286")
+ .setProjectId("projectId-894832108")
+ .build();
+ client.runTransferJobAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void createAgentPoolTest() throws Exception {
+ TransferTypes.AgentPool expectedResponse =
+ TransferTypes.AgentPool.newBuilder()
+ .setName("name3373707")
+ .setDisplayName("displayName1714148973")
+ .setBandwidthLimit(TransferTypes.AgentPool.BandwidthLimit.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String projectId = "projectId-1530";
+ TransferTypes.AgentPool agentPool = TransferTypes.AgentPool.newBuilder().build();
+ String agentPoolId = "agentPoolId1562124732";
+
+ TransferTypes.AgentPool actualResponse =
+ client.createAgentPool(projectId, agentPool, agentPoolId);
+ 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 createAgentPoolExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String projectId = "projectId-1530";
+ TransferTypes.AgentPool agentPool = TransferTypes.AgentPool.newBuilder().build();
+ String agentPoolId = "agentPoolId1562124732";
+ client.createAgentPool(projectId, agentPool, agentPoolId);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void updateAgentPoolTest() throws Exception {
+ TransferTypes.AgentPool expectedResponse =
+ TransferTypes.AgentPool.newBuilder()
+ .setName("name3373707")
+ .setDisplayName("displayName1714148973")
+ .setBandwidthLimit(TransferTypes.AgentPool.BandwidthLimit.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ TransferTypes.AgentPool agentPool =
+ TransferTypes.AgentPool.newBuilder()
+ .setName("projects/project-9180/agentPools/agentPool-9180")
+ .setDisplayName("displayName1714148973")
+ .setBandwidthLimit(TransferTypes.AgentPool.BandwidthLimit.newBuilder().build())
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+
+ TransferTypes.AgentPool actualResponse = client.updateAgentPool(agentPool, updateMask);
+ 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 updateAgentPoolExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ TransferTypes.AgentPool agentPool =
+ TransferTypes.AgentPool.newBuilder()
+ .setName("projects/project-9180/agentPools/agentPool-9180")
+ .setDisplayName("displayName1714148973")
+ .setBandwidthLimit(TransferTypes.AgentPool.BandwidthLimit.newBuilder().build())
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ client.updateAgentPool(agentPool, updateMask);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getAgentPoolTest() throws Exception {
+ TransferTypes.AgentPool expectedResponse =
+ TransferTypes.AgentPool.newBuilder()
+ .setName("name3373707")
+ .setDisplayName("displayName1714148973")
+ .setBandwidthLimit(TransferTypes.AgentPool.BandwidthLimit.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "projects/project-9180/agentPools/agentPool-9180";
+
+ TransferTypes.AgentPool actualResponse = client.getAgentPool(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 getAgentPoolExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name = "projects/project-9180/agentPools/agentPool-9180";
+ client.getAgentPool(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listAgentPoolsTest() throws Exception {
+ TransferTypes.AgentPool responsesElement = TransferTypes.AgentPool.newBuilder().build();
+ TransferProto.ListAgentPoolsResponse expectedResponse =
+ TransferProto.ListAgentPoolsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllAgentPools(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String projectId = "projectId-1530";
+
+ ListAgentPoolsPagedResponse pagedListResponse = client.listAgentPools(projectId);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getAgentPoolsList().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 listAgentPoolsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String projectId = "projectId-1530";
+ client.listAgentPools(projectId);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteAgentPoolTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "projects/project-9180/agentPools/agentPool-9180";
+
+ client.deleteAgentPool(name);
+
+ 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 deleteAgentPoolExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name = "projects/project-9180/agentPools/agentPool-9180";
+ client.deleteAgentPool(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}