diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/BatchControllerClient.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/BatchControllerClient.java
new file mode 100644
index 00000000..c438bdd1
--- /dev/null
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/BatchControllerClient.java
@@ -0,0 +1,732 @@
+/*
+ * Copyright 2021 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.dataproc.v1;
+
+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.longrunning.OperationFuture;
+import com.google.api.gax.paging.AbstractFixedSizeCollection;
+import com.google.api.gax.paging.AbstractPage;
+import com.google.api.gax.paging.AbstractPagedListResponse;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.dataproc.v1.stub.BatchControllerStub;
+import com.google.cloud.dataproc.v1.stub.BatchControllerStubSettings;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.longrunning.Operation;
+import com.google.longrunning.OperationsClient;
+import com.google.protobuf.Empty;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Service Description: The BatchController provides methods to manage batch workloads.
+ *
+ *
This class provides the ability to make remote calls to the backing service through method
+ * calls that map to API methods. Sample code to get started:
+ *
+ *
Note: close() needs to be called on the BatchControllerClient object to clean up resources
+ * such as threads. In the example above, try-with-resources is used, which automatically calls
+ * close().
+ *
+ *
The surface of this class includes several types of Java methods for each of the API's
+ * methods:
+ *
+ *
+ *
A "flattened" method. With this type of method, the fields of the request type have been
+ * converted into function parameters. It may be the case that not all fields are available as
+ * parameters, and not every API method will have a flattened method entry point.
+ *
A "request object" method. This type of method only takes one parameter, a request object,
+ * which must be constructed before the call. Not every API method will have a request object
+ * method.
+ *
A "callable" method. This type of method takes no parameters and returns an immutable API
+ * callable object, which can be used to initiate calls to the service.
+ *
+ *
+ *
See the individual methods for example code.
+ *
+ *
Many parameters require resource names to be formatted in a particular way. To assist with
+ * these names, this class includes a format method for each type of name, and additionally a parse
+ * method to extract the individual identifiers contained within names that are returned.
+ *
+ *
This class can be customized by passing in a custom instance of BatchControllerSettings to
+ * create(). For example:
+ *
+ *
Please refer to the GitHub repository's samples for more quickstart code snippets.
+ */
+@Generated("by gapic-generator-java")
+public class BatchControllerClient implements BackgroundResource {
+ private final BatchControllerSettings settings;
+ private final BatchControllerStub stub;
+ private final OperationsClient operationsClient;
+
+ /** Constructs an instance of BatchControllerClient with default settings. */
+ public static final BatchControllerClient create() throws IOException {
+ return create(BatchControllerSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of BatchControllerClient, using the given settings. The channels are
+ * created based on the settings passed in, or defaults for any settings that are not set.
+ */
+ public static final BatchControllerClient create(BatchControllerSettings settings)
+ throws IOException {
+ return new BatchControllerClient(settings);
+ }
+
+ /**
+ * Constructs an instance of BatchControllerClient, using the given stub for making calls. This is
+ * for advanced usage - prefer using create(BatchControllerSettings).
+ */
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public static final BatchControllerClient create(BatchControllerStub stub) {
+ return new BatchControllerClient(stub);
+ }
+
+ /**
+ * Constructs an instance of BatchControllerClient, 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 BatchControllerClient(BatchControllerSettings settings) throws IOException {
+ this.settings = settings;
+ this.stub = ((BatchControllerStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ protected BatchControllerClient(BatchControllerStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ public final BatchControllerSettings getSettings() {
+ return settings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public BatchControllerStub getStub() {
+ return stub;
+ }
+
+ /**
+ * 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() {
+ return operationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a batch workload that executes asynchronously.
+ *
+ *
+ *
+ * @param parent Required. The parent resource where this batch will be created.
+ * @param batch Required. The batch to create.
+ * @param batchId Optional. The ID to use for the batch, which will become the final component of
+ * the batch's resource name.
+ *
This value must be 4-63 characters. Valid characters are `/[a-z][0-9]-/`.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture createBatchAsync(
+ LocationName parent, Batch batch, String batchId) {
+ CreateBatchRequest request =
+ CreateBatchRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .setBatch(batch)
+ .setBatchId(batchId)
+ .build();
+ return createBatchAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a batch workload that executes asynchronously.
+ *
+ *
+ *
+ * @param parent Required. The parent resource where this batch will be created.
+ * @param batch Required. The batch to create.
+ * @param batchId Optional. The ID to use for the batch, which will become the final component of
+ * the batch's resource name.
+ *
This value must be 4-63 characters. Valid characters are `/[a-z][0-9]-/`.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture createBatchAsync(
+ String parent, Batch batch, String batchId) {
+ CreateBatchRequest request =
+ CreateBatchRequest.newBuilder()
+ .setParent(parent)
+ .setBatch(batch)
+ .setBatchId(batchId)
+ .build();
+ return createBatchAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a batch workload that executes asynchronously.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture createBatchAsync(
+ CreateBatchRequest request) {
+ return createBatchOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a batch workload that executes asynchronously.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Batch getBatch(GetBatchRequest request) {
+ return getBatchCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets the batch workload resource representation.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListBatchesPagedResponse listBatches(ListBatchesRequest request) {
+ return listBatchesPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists batch workloads.
+ *
+ *
+ */
+ public final UnaryCallable listBatchesCallable() {
+ return stub.listBatchesCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
+ * and the response returns `FAILED_PRECONDITION`.
+ *
+ *
+ *
+ * @param name Required. The name of the batch resource to delete.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final void deleteBatch(BatchName name) {
+ DeleteBatchRequest request =
+ DeleteBatchRequest.newBuilder().setName(name == null ? null : name.toString()).build();
+ deleteBatch(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
+ * and the response returns `FAILED_PRECONDITION`.
+ *
+ *
+ *
+ * @param name Required. The name of the batch resource to delete.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final void deleteBatch(String name) {
+ DeleteBatchRequest request = DeleteBatchRequest.newBuilder().setName(name).build();
+ deleteBatch(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
+ * and the response returns `FAILED_PRECONDITION`.
+ *
+ *
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final void deleteBatch(DeleteBatchRequest request) {
+ deleteBatchCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes the batch workload resource. If the batch is not in terminal state, the delete fails
+ * and the response returns `FAILED_PRECONDITION`.
+ *
+ *
+ */
+ public final UnaryCallable deleteBatchCallable() {
+ return stub.deleteBatchCallable();
+ }
+
+ @Override
+ public final void close() {
+ stub.close();
+ }
+
+ @Override
+ public void shutdown() {
+ stub.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return stub.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return stub.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ stub.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return stub.awaitTermination(duration, unit);
+ }
+
+ public static class ListBatchesPagedResponse
+ extends AbstractPagedListResponse<
+ ListBatchesRequest,
+ ListBatchesResponse,
+ Batch,
+ ListBatchesPage,
+ ListBatchesFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListBatchesPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage, input -> new ListBatchesPagedResponse(input), MoreExecutors.directExecutor());
+ }
+
+ private ListBatchesPagedResponse(ListBatchesPage page) {
+ super(page, ListBatchesFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListBatchesPage
+ extends AbstractPage {
+
+ private ListBatchesPage(
+ PageContext context,
+ ListBatchesResponse response) {
+ super(context, response);
+ }
+
+ private static ListBatchesPage createEmptyPage() {
+ return new ListBatchesPage(null, null);
+ }
+
+ @Override
+ protected ListBatchesPage createPage(
+ PageContext context,
+ ListBatchesResponse response) {
+ return new ListBatchesPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListBatchesFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListBatchesRequest,
+ ListBatchesResponse,
+ Batch,
+ ListBatchesPage,
+ ListBatchesFixedSizeCollection> {
+
+ private ListBatchesFixedSizeCollection(List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListBatchesFixedSizeCollection createEmptyCollection() {
+ return new ListBatchesFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListBatchesFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListBatchesFixedSizeCollection(pages, collectionSize);
+ }
+ }
+}
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/BatchControllerSettings.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/BatchControllerSettings.java
new file mode 100644
index 00000000..0aceb61d
--- /dev/null
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/BatchControllerSettings.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2021 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.dataproc.v1;
+
+import static com.google.cloud.dataproc.v1.BatchControllerClient.ListBatchesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+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.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientSettings;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.cloud.dataproc.v1.stub.BatchControllerStubSettings;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Settings class to configure an instance of {@link BatchControllerClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (dataproc.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of getBatch to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator-java")
+public class BatchControllerSettings extends ClientSettings {
+
+ /** Returns the object with the settings used for calls to createBatch. */
+ public UnaryCallSettings createBatchSettings() {
+ return ((BatchControllerStubSettings) getStubSettings()).createBatchSettings();
+ }
+
+ /** Returns the object with the settings used for calls to createBatch. */
+ public OperationCallSettings
+ createBatchOperationSettings() {
+ return ((BatchControllerStubSettings) getStubSettings()).createBatchOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to getBatch. */
+ public UnaryCallSettings getBatchSettings() {
+ return ((BatchControllerStubSettings) getStubSettings()).getBatchSettings();
+ }
+
+ /** Returns the object with the settings used for calls to listBatches. */
+ public PagedCallSettings
+ listBatchesSettings() {
+ return ((BatchControllerStubSettings) getStubSettings()).listBatchesSettings();
+ }
+
+ /** Returns the object with the settings used for calls to deleteBatch. */
+ public UnaryCallSettings deleteBatchSettings() {
+ return ((BatchControllerStubSettings) getStubSettings()).deleteBatchSettings();
+ }
+
+ public static final BatchControllerSettings create(BatchControllerStubSettings stub)
+ throws IOException {
+ return new BatchControllerSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return BatchControllerStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return BatchControllerStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return BatchControllerStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return BatchControllerStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return BatchControllerStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return BatchControllerStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return BatchControllerStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected BatchControllerSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for BatchControllerSettings. */
+ public static class Builder extends ClientSettings.Builder {
+
+ protected Builder() throws IOException {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(BatchControllerStubSettings.newBuilder(clientContext));
+ }
+
+ protected Builder(BatchControllerSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(BatchControllerStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ private static Builder createDefault() {
+ return new Builder(BatchControllerStubSettings.newBuilder());
+ }
+
+ public BatchControllerStubSettings.Builder getStubSettingsBuilder() {
+ return ((BatchControllerStubSettings.Builder) getStubSettings());
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) {
+ super.applyToAllUnaryMethods(
+ getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
+ return this;
+ }
+
+ /** Returns the builder for the settings used for calls to createBatch. */
+ public UnaryCallSettings.Builder createBatchSettings() {
+ return getStubSettingsBuilder().createBatchSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createBatch. */
+ public OperationCallSettings.Builder
+ createBatchOperationSettings() {
+ return getStubSettingsBuilder().createBatchOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to getBatch. */
+ public UnaryCallSettings.Builder getBatchSettings() {
+ return getStubSettingsBuilder().getBatchSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to listBatches. */
+ public PagedCallSettings.Builder<
+ ListBatchesRequest, ListBatchesResponse, ListBatchesPagedResponse>
+ listBatchesSettings() {
+ return getStubSettingsBuilder().listBatchesSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deleteBatch. */
+ public UnaryCallSettings.Builder deleteBatchSettings() {
+ return getStubSettingsBuilder().deleteBatchSettings();
+ }
+
+ @Override
+ public BatchControllerSettings build() throws IOException {
+ return new BatchControllerSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/gapic_metadata.json b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/gapic_metadata.json
index 1b98e6d0..26e0eeb5 100644
--- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/gapic_metadata.json
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/gapic_metadata.json
@@ -29,6 +29,27 @@
}
}
},
+ "BatchController": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "BatchControllerClient",
+ "rpcs": {
+ "CreateBatch": {
+ "methods": ["createBatchAsync", "createBatchAsync", "createBatchAsync", "createBatchOperationCallable", "createBatchCallable"]
+ },
+ "DeleteBatch": {
+ "methods": ["deleteBatch", "deleteBatch", "deleteBatch", "deleteBatchCallable"]
+ },
+ "GetBatch": {
+ "methods": ["getBatch", "getBatch", "getBatch", "getBatchCallable"]
+ },
+ "ListBatches": {
+ "methods": ["listBatches", "listBatches", "listBatches", "listBatchesPagedCallable", "listBatchesCallable"]
+ }
+ }
+ }
+ }
+ },
"ClusterController": {
"clients": {
"grpc": {
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/package-info.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/package-info.java
index 246d9b5f..ff77c4df 100644
--- a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/package-info.java
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/package-info.java
@@ -33,6 +33,19 @@
* }
* }
*
+ *
Service Description: The ClusterControllerService provides methods to manage clusters of
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/BatchControllerStub.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/BatchControllerStub.java
new file mode 100644
index 00000000..3c8721b8
--- /dev/null
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/BatchControllerStub.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2021 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.dataproc.v1.stub;
+
+import static com.google.cloud.dataproc.v1.BatchControllerClient.ListBatchesPagedResponse;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.dataproc.v1.Batch;
+import com.google.cloud.dataproc.v1.BatchOperationMetadata;
+import com.google.cloud.dataproc.v1.CreateBatchRequest;
+import com.google.cloud.dataproc.v1.DeleteBatchRequest;
+import com.google.cloud.dataproc.v1.GetBatchRequest;
+import com.google.cloud.dataproc.v1.ListBatchesRequest;
+import com.google.cloud.dataproc.v1.ListBatchesResponse;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import com.google.protobuf.Empty;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the BatchController service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class BatchControllerStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ public OperationCallable
+ createBatchOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: createBatchOperationCallable()");
+ }
+
+ public UnaryCallable createBatchCallable() {
+ throw new UnsupportedOperationException("Not implemented: createBatchCallable()");
+ }
+
+ public UnaryCallable getBatchCallable() {
+ throw new UnsupportedOperationException("Not implemented: getBatchCallable()");
+ }
+
+ public UnaryCallable listBatchesPagedCallable() {
+ throw new UnsupportedOperationException("Not implemented: listBatchesPagedCallable()");
+ }
+
+ public UnaryCallable listBatchesCallable() {
+ throw new UnsupportedOperationException("Not implemented: listBatchesCallable()");
+ }
+
+ public UnaryCallable deleteBatchCallable() {
+ throw new UnsupportedOperationException("Not implemented: deleteBatchCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/BatchControllerStubSettings.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/BatchControllerStubSettings.java
new file mode 100644
index 00000000..793163de
--- /dev/null
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/BatchControllerStubSettings.java
@@ -0,0 +1,448 @@
+/*
+ * Copyright 2021 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.dataproc.v1.stub;
+
+import static com.google.cloud.dataproc.v1.BatchControllerClient.ListBatchesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.ApiFuture;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GaxProperties;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+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.grpc.ProtoOperationTransformers;
+import com.google.api.gax.longrunning.OperationSnapshot;
+import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiCallContext;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.PagedListDescriptor;
+import com.google.api.gax.rpc.PagedListResponseFactory;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.StubSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.dataproc.v1.Batch;
+import com.google.cloud.dataproc.v1.BatchOperationMetadata;
+import com.google.cloud.dataproc.v1.CreateBatchRequest;
+import com.google.cloud.dataproc.v1.DeleteBatchRequest;
+import com.google.cloud.dataproc.v1.GetBatchRequest;
+import com.google.cloud.dataproc.v1.ListBatchesRequest;
+import com.google.cloud.dataproc.v1.ListBatchesResponse;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+import org.threeten.bp.Duration;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Settings class to configure an instance of {@link BatchControllerStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (dataproc.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of getBatch to 30 seconds:
+ *
+ *
+ */
+@Generated("by gapic-generator-java")
+public class BatchControllerStubSettings extends StubSettings {
+ /** The default scopes of the service. */
+ private static final ImmutableList DEFAULT_SERVICE_SCOPES =
+ ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build();
+
+ private final UnaryCallSettings createBatchSettings;
+ private final OperationCallSettings
+ createBatchOperationSettings;
+ private final UnaryCallSettings getBatchSettings;
+ private final PagedCallSettings
+ listBatchesSettings;
+ private final UnaryCallSettings deleteBatchSettings;
+
+ private static final PagedListDescriptor
+ LIST_BATCHES_PAGE_STR_DESC =
+ new PagedListDescriptor() {
+ @Override
+ public String emptyToken() {
+ return "";
+ }
+
+ @Override
+ public ListBatchesRequest injectToken(ListBatchesRequest payload, String token) {
+ return ListBatchesRequest.newBuilder(payload).setPageToken(token).build();
+ }
+
+ @Override
+ public ListBatchesRequest injectPageSize(ListBatchesRequest payload, int pageSize) {
+ return ListBatchesRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListBatchesRequest payload) {
+ return payload.getPageSize();
+ }
+
+ @Override
+ public String extractNextToken(ListBatchesResponse payload) {
+ return payload.getNextPageToken();
+ }
+
+ @Override
+ public Iterable extractResources(ListBatchesResponse payload) {
+ return payload.getBatchesList() == null
+ ? ImmutableList.of()
+ : payload.getBatchesList();
+ }
+ };
+
+ private static final PagedListResponseFactory<
+ ListBatchesRequest, ListBatchesResponse, ListBatchesPagedResponse>
+ LIST_BATCHES_PAGE_STR_FACT =
+ new PagedListResponseFactory<
+ ListBatchesRequest, ListBatchesResponse, ListBatchesPagedResponse>() {
+ @Override
+ public ApiFuture getFuturePagedResponse(
+ UnaryCallable callable,
+ ListBatchesRequest request,
+ ApiCallContext context,
+ ApiFuture futureResponse) {
+ PageContext pageContext =
+ PageContext.create(callable, LIST_BATCHES_PAGE_STR_DESC, request, context);
+ return ListBatchesPagedResponse.createAsync(pageContext, futureResponse);
+ }
+ };
+
+ /** Returns the object with the settings used for calls to createBatch. */
+ public UnaryCallSettings createBatchSettings() {
+ return createBatchSettings;
+ }
+
+ /** Returns the object with the settings used for calls to createBatch. */
+ public OperationCallSettings
+ createBatchOperationSettings() {
+ return createBatchOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to getBatch. */
+ public UnaryCallSettings getBatchSettings() {
+ return getBatchSettings;
+ }
+
+ /** Returns the object with the settings used for calls to listBatches. */
+ public PagedCallSettings
+ listBatchesSettings() {
+ return listBatchesSettings;
+ }
+
+ /** Returns the object with the settings used for calls to deleteBatch. */
+ public UnaryCallSettings deleteBatchSettings() {
+ return deleteBatchSettings;
+ }
+
+ @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
+ public BatchControllerStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcBatchControllerStub.create(this);
+ }
+ throw new UnsupportedOperationException(
+ String.format(
+ "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return InstantiatingExecutorProvider.newBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return "dataproc.googleapis.com:443";
+ }
+
+ /** Returns the default mTLS service endpoint. */
+ public static String getDefaultMtlsEndpoint() {
+ return "dataproc.mtls.googleapis.com:443";
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DEFAULT_SERVICE_SCOPES;
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return GoogleCredentialsProvider.newBuilder()
+ .setScopesToApply(DEFAULT_SERVICE_SCOPES)
+ .setUseJwtAccessWithScope(true);
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ 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() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken(
+ "gapic", GaxProperties.getLibraryVersion(BatchControllerStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected BatchControllerStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ createBatchSettings = settingsBuilder.createBatchSettings().build();
+ createBatchOperationSettings = settingsBuilder.createBatchOperationSettings().build();
+ getBatchSettings = settingsBuilder.getBatchSettings().build();
+ listBatchesSettings = settingsBuilder.listBatchesSettings().build();
+ deleteBatchSettings = settingsBuilder.deleteBatchSettings().build();
+ }
+
+ /** Builder for BatchControllerStubSettings. */
+ public static class Builder extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+ private final UnaryCallSettings.Builder createBatchSettings;
+ private final OperationCallSettings.Builder
+ createBatchOperationSettings;
+ private final UnaryCallSettings.Builder getBatchSettings;
+ private final PagedCallSettings.Builder<
+ ListBatchesRequest, ListBatchesResponse, ListBatchesPagedResponse>
+ listBatchesSettings;
+ private final UnaryCallSettings.Builder deleteBatchSettings;
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList()));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
+ definitions.put("no_retry_params", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ createBatchSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createBatchOperationSettings = OperationCallSettings.newBuilder();
+ getBatchSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ listBatchesSettings = PagedCallSettings.newBuilder(LIST_BATCHES_PAGE_STR_FACT);
+ deleteBatchSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ createBatchSettings, getBatchSettings, listBatchesSettings, deleteBatchSettings);
+ initDefaults(this);
+ }
+
+ protected Builder(BatchControllerStubSettings settings) {
+ super(settings);
+
+ createBatchSettings = settings.createBatchSettings.toBuilder();
+ createBatchOperationSettings = settings.createBatchOperationSettings.toBuilder();
+ getBatchSettings = settings.getBatchSettings.toBuilder();
+ listBatchesSettings = settings.listBatchesSettings.toBuilder();
+ deleteBatchSettings = settings.deleteBatchSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ createBatchSettings, getBatchSettings, listBatchesSettings, deleteBatchSettings);
+ }
+
+ private static Builder createDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultTransportChannelProvider());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+ builder
+ .createBatchSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+
+ builder
+ .getBatchSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+
+ builder
+ .listBatchesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+
+ builder
+ .deleteBatchSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"));
+
+ builder
+ .createBatchOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings.newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Batch.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(BatchOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ return builder;
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) {
+ super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
+ return this;
+ }
+
+ public ImmutableList> unaryMethodSettingsBuilders() {
+ return unaryMethodSettingsBuilders;
+ }
+
+ /** Returns the builder for the settings used for calls to createBatch. */
+ public UnaryCallSettings.Builder createBatchSettings() {
+ return createBatchSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createBatch. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ createBatchOperationSettings() {
+ return createBatchOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to getBatch. */
+ public UnaryCallSettings.Builder getBatchSettings() {
+ return getBatchSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to listBatches. */
+ public PagedCallSettings.Builder<
+ ListBatchesRequest, ListBatchesResponse, ListBatchesPagedResponse>
+ listBatchesSettings() {
+ return listBatchesSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deleteBatch. */
+ public UnaryCallSettings.Builder deleteBatchSettings() {
+ return deleteBatchSettings;
+ }
+
+ @Override
+ public BatchControllerStubSettings build() throws IOException {
+ return new BatchControllerStubSettings(this);
+ }
+ }
+}
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcBatchControllerCallableFactory.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcBatchControllerCallableFactory.java
new file mode 100644
index 00000000..0a5ca6af
--- /dev/null
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcBatchControllerCallableFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2021 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.dataproc.v1.stub;
+
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+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.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC callable factory implementation for the BatchController service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcBatchControllerCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, callSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcBatchControllerStub.java b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcBatchControllerStub.java
new file mode 100644
index 00000000..c7b481b6
--- /dev/null
+++ b/google-cloud-dataproc/src/main/java/com/google/cloud/dataproc/v1/stub/GrpcBatchControllerStub.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2021 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.dataproc.v1.stub;
+
+import static com.google.cloud.dataproc.v1.BatchControllerClient.ListBatchesPagedResponse;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.dataproc.v1.Batch;
+import com.google.cloud.dataproc.v1.BatchOperationMetadata;
+import com.google.cloud.dataproc.v1.CreateBatchRequest;
+import com.google.cloud.dataproc.v1.DeleteBatchRequest;
+import com.google.cloud.dataproc.v1.GetBatchRequest;
+import com.google.cloud.dataproc.v1.ListBatchesRequest;
+import com.google.cloud.dataproc.v1.ListBatchesResponse;
+import com.google.common.collect.ImmutableMap;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.GrpcOperationsStub;
+import com.google.protobuf.Empty;
+import io.grpc.MethodDescriptor;
+import io.grpc.protobuf.ProtoUtils;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC stub implementation for the BatchController service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcBatchControllerStub extends BatchControllerStub {
+ private static final MethodDescriptor createBatchMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.dataproc.v1.BatchController/CreateBatch")
+ .setRequestMarshaller(ProtoUtils.marshaller(CreateBatchRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor getBatchMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.dataproc.v1.BatchController/GetBatch")
+ .setRequestMarshaller(ProtoUtils.marshaller(GetBatchRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Batch.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ listBatchesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.dataproc.v1.BatchController/ListBatches")
+ .setRequestMarshaller(ProtoUtils.marshaller(ListBatchesRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListBatchesResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor deleteBatchMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.dataproc.v1.BatchController/DeleteBatch")
+ .setRequestMarshaller(ProtoUtils.marshaller(DeleteBatchRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
+ .build();
+
+ private final UnaryCallable createBatchCallable;
+ private final OperationCallable
+ createBatchOperationCallable;
+ private final UnaryCallable getBatchCallable;
+ private final UnaryCallable listBatchesCallable;
+ private final UnaryCallable
+ listBatchesPagedCallable;
+ private final UnaryCallable deleteBatchCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcBatchControllerStub create(BatchControllerStubSettings settings)
+ throws IOException {
+ return new GrpcBatchControllerStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcBatchControllerStub create(ClientContext clientContext)
+ throws IOException {
+ return new GrpcBatchControllerStub(
+ BatchControllerStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcBatchControllerStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcBatchControllerStub(
+ BatchControllerStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcBatchControllerStub, 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 GrpcBatchControllerStub(
+ BatchControllerStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new GrpcBatchControllerCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcBatchControllerStub, 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 GrpcBatchControllerStub(
+ BatchControllerStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings createBatchTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(createBatchMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings getBatchTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getBatchMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings listBatchesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(listBatchesMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings deleteBatchTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(deleteBatchMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ })
+ .build();
+
+ this.createBatchCallable =
+ callableFactory.createUnaryCallable(
+ createBatchTransportSettings, settings.createBatchSettings(), clientContext);
+ this.createBatchOperationCallable =
+ callableFactory.createOperationCallable(
+ createBatchTransportSettings,
+ settings.createBatchOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.getBatchCallable =
+ callableFactory.createUnaryCallable(
+ getBatchTransportSettings, settings.getBatchSettings(), clientContext);
+ this.listBatchesCallable =
+ callableFactory.createUnaryCallable(
+ listBatchesTransportSettings, settings.listBatchesSettings(), clientContext);
+ this.listBatchesPagedCallable =
+ callableFactory.createPagedCallable(
+ listBatchesTransportSettings, settings.listBatchesSettings(), clientContext);
+ this.deleteBatchCallable =
+ callableFactory.createUnaryCallable(
+ deleteBatchTransportSettings, settings.deleteBatchSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @Override
+ public UnaryCallable createBatchCallable() {
+ return createBatchCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createBatchOperationCallable() {
+ return createBatchOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable getBatchCallable() {
+ return getBatchCallable;
+ }
+
+ @Override
+ public UnaryCallable listBatchesCallable() {
+ return listBatchesCallable;
+ }
+
+ @Override
+ public UnaryCallable listBatchesPagedCallable() {
+ return listBatchesPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteBatchCallable() {
+ return deleteBatchCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/BatchControllerClientTest.java b/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/BatchControllerClientTest.java
new file mode 100644
index 00000000..e8825b6f
--- /dev/null
+++ b/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/BatchControllerClientTest.java
@@ -0,0 +1,468 @@
+/*
+ * Copyright 2021 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.dataproc.v1;
+
+import static com.google.cloud.dataproc.v1.BatchControllerClient.ListBatchesPagedResponse;
+
+import com.google.api.gax.core.NoCredentialsProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+import com.google.api.gax.grpc.testing.LocalChannelProvider;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.api.gax.grpc.testing.MockServiceHelper;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.InvalidArgumentException;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import com.google.protobuf.Any;
+import com.google.protobuf.Empty;
+import com.google.protobuf.Timestamp;
+import io.grpc.StatusRuntimeException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+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 BatchControllerClientTest {
+ private static MockBatchController mockBatchController;
+ private static MockServiceHelper mockServiceHelper;
+ private LocalChannelProvider channelProvider;
+ private BatchControllerClient client;
+
+ @BeforeClass
+ public static void startStaticServer() {
+ mockBatchController = new MockBatchController();
+ mockServiceHelper =
+ new MockServiceHelper(
+ UUID.randomUUID().toString(), Arrays.asList(mockBatchController));
+ mockServiceHelper.start();
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ mockServiceHelper.stop();
+ }
+
+ @Before
+ public void setUp() throws IOException {
+ mockServiceHelper.reset();
+ channelProvider = mockServiceHelper.createChannelProvider();
+ BatchControllerSettings settings =
+ BatchControllerSettings.newBuilder()
+ .setTransportChannelProvider(channelProvider)
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = BatchControllerClient.create(settings);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ client.close();
+ }
+
+ @Test
+ public void createBatchTest() throws Exception {
+ Batch expectedResponse =
+ Batch.newBuilder()
+ .setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
+ .setUuid("uuid3601339")
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setRuntimeInfo(RuntimeInfo.newBuilder().build())
+ .setStateMessage("stateMessage1128185398")
+ .setStateTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .putAllLabels(new HashMap())
+ .setRuntimeConfig(RuntimeConfig.newBuilder().build())
+ .setEnvironmentConfig(EnvironmentConfig.newBuilder().build())
+ .setOperation("operation1662702951")
+ .addAllStateHistory(new ArrayList())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createBatchTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockBatchController.addResponse(resultOperation);
+
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ Batch batch = Batch.newBuilder().build();
+ String batchId = "batchId-331744779";
+
+ Batch actualResponse = client.createBatchAsync(parent, batch, batchId).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateBatchRequest actualRequest = ((CreateBatchRequest) actualRequests.get(0));
+
+ Assert.assertEquals(parent.toString(), actualRequest.getParent());
+ Assert.assertEquals(batch, actualRequest.getBatch());
+ Assert.assertEquals(batchId, actualRequest.getBatchId());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void createBatchExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ Batch batch = Batch.newBuilder().build();
+ String batchId = "batchId-331744779";
+ client.createBatchAsync(parent, batch, batchId).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void createBatchTest2() throws Exception {
+ Batch expectedResponse =
+ Batch.newBuilder()
+ .setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
+ .setUuid("uuid3601339")
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setRuntimeInfo(RuntimeInfo.newBuilder().build())
+ .setStateMessage("stateMessage1128185398")
+ .setStateTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .putAllLabels(new HashMap())
+ .setRuntimeConfig(RuntimeConfig.newBuilder().build())
+ .setEnvironmentConfig(EnvironmentConfig.newBuilder().build())
+ .setOperation("operation1662702951")
+ .addAllStateHistory(new ArrayList())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createBatchTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockBatchController.addResponse(resultOperation);
+
+ String parent = "parent-995424086";
+ Batch batch = Batch.newBuilder().build();
+ String batchId = "batchId-331744779";
+
+ Batch actualResponse = client.createBatchAsync(parent, batch, batchId).get();
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateBatchRequest actualRequest = ((CreateBatchRequest) actualRequests.get(0));
+
+ Assert.assertEquals(parent, actualRequest.getParent());
+ Assert.assertEquals(batch, actualRequest.getBatch());
+ Assert.assertEquals(batchId, actualRequest.getBatchId());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void createBatchExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ String parent = "parent-995424086";
+ Batch batch = Batch.newBuilder().build();
+ String batchId = "batchId-331744779";
+ client.createBatchAsync(parent, batch, batchId).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
+ InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
+ Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
+ }
+ }
+
+ @Test
+ public void getBatchTest() throws Exception {
+ Batch expectedResponse =
+ Batch.newBuilder()
+ .setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
+ .setUuid("uuid3601339")
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setRuntimeInfo(RuntimeInfo.newBuilder().build())
+ .setStateMessage("stateMessage1128185398")
+ .setStateTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .putAllLabels(new HashMap())
+ .setRuntimeConfig(RuntimeConfig.newBuilder().build())
+ .setEnvironmentConfig(EnvironmentConfig.newBuilder().build())
+ .setOperation("operation1662702951")
+ .addAllStateHistory(new ArrayList())
+ .build();
+ mockBatchController.addResponse(expectedResponse);
+
+ BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
+
+ Batch actualResponse = client.getBatch(name);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ GetBatchRequest actualRequest = ((GetBatchRequest) actualRequests.get(0));
+
+ Assert.assertEquals(name.toString(), actualRequest.getName());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void getBatchExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
+ client.getBatch(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getBatchTest2() throws Exception {
+ Batch expectedResponse =
+ Batch.newBuilder()
+ .setName(BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]").toString())
+ .setUuid("uuid3601339")
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setRuntimeInfo(RuntimeInfo.newBuilder().build())
+ .setStateMessage("stateMessage1128185398")
+ .setStateTime(Timestamp.newBuilder().build())
+ .setCreator("creator1028554796")
+ .putAllLabels(new HashMap())
+ .setRuntimeConfig(RuntimeConfig.newBuilder().build())
+ .setEnvironmentConfig(EnvironmentConfig.newBuilder().build())
+ .setOperation("operation1662702951")
+ .addAllStateHistory(new ArrayList())
+ .build();
+ mockBatchController.addResponse(expectedResponse);
+
+ String name = "name3373707";
+
+ Batch actualResponse = client.getBatch(name);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ GetBatchRequest actualRequest = ((GetBatchRequest) actualRequests.get(0));
+
+ Assert.assertEquals(name, actualRequest.getName());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void getBatchExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ String name = "name3373707";
+ client.getBatch(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listBatchesTest() throws Exception {
+ Batch responsesElement = Batch.newBuilder().build();
+ ListBatchesResponse expectedResponse =
+ ListBatchesResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllBatches(Arrays.asList(responsesElement))
+ .build();
+ mockBatchController.addResponse(expectedResponse);
+
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+
+ ListBatchesPagedResponse pagedListResponse = client.listBatches(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getBatchesList().get(0), resources.get(0));
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ListBatchesRequest actualRequest = ((ListBatchesRequest) actualRequests.get(0));
+
+ Assert.assertEquals(parent.toString(), actualRequest.getParent());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void listBatchesExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ client.listBatches(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listBatchesTest2() throws Exception {
+ Batch responsesElement = Batch.newBuilder().build();
+ ListBatchesResponse expectedResponse =
+ ListBatchesResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllBatches(Arrays.asList(responsesElement))
+ .build();
+ mockBatchController.addResponse(expectedResponse);
+
+ String parent = "parent-995424086";
+
+ ListBatchesPagedResponse pagedListResponse = client.listBatches(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getBatchesList().get(0), resources.get(0));
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ ListBatchesRequest actualRequest = ((ListBatchesRequest) actualRequests.get(0));
+
+ Assert.assertEquals(parent, actualRequest.getParent());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void listBatchesExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ String parent = "parent-995424086";
+ client.listBatches(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteBatchTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockBatchController.addResponse(expectedResponse);
+
+ BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
+
+ client.deleteBatch(name);
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ DeleteBatchRequest actualRequest = ((DeleteBatchRequest) actualRequests.get(0));
+
+ Assert.assertEquals(name.toString(), actualRequest.getName());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void deleteBatchExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ BatchName name = BatchName.of("[PROJECT]", "[LOCATION]", "[BATCH]");
+ client.deleteBatch(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteBatchTest2() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockBatchController.addResponse(expectedResponse);
+
+ String name = "name3373707";
+
+ client.deleteBatch(name);
+
+ List actualRequests = mockBatchController.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ DeleteBatchRequest actualRequest = ((DeleteBatchRequest) actualRequests.get(0));
+
+ Assert.assertEquals(name, actualRequest.getName());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void deleteBatchExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockBatchController.addException(exception);
+
+ try {
+ String name = "name3373707";
+ client.deleteBatch(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}
diff --git a/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/MockBatchController.java b/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/MockBatchController.java
new file mode 100644
index 00000000..0d35efbd
--- /dev/null
+++ b/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/MockBatchController.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2021 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.dataproc.v1;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+import javax.annotation.Generated;
+
+@BetaApi
+@Generated("by gapic-generator-java")
+public class MockBatchController implements MockGrpcService {
+ private final MockBatchControllerImpl serviceImpl;
+
+ public MockBatchController() {
+ serviceImpl = new MockBatchControllerImpl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void addResponse(AbstractMessage response) {
+ serviceImpl.addResponse(response);
+ }
+
+ @Override
+ public void addException(Exception exception) {
+ serviceImpl.addException(exception);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/MockBatchControllerImpl.java b/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/MockBatchControllerImpl.java
new file mode 100644
index 00000000..ae3b2c9d
--- /dev/null
+++ b/google-cloud-dataproc/src/test/java/com/google/cloud/dataproc/v1/MockBatchControllerImpl.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2021 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.dataproc.v1;
+
+import com.google.api.core.BetaApi;
+import com.google.cloud.dataproc.v1.BatchControllerGrpc.BatchControllerImplBase;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import com.google.protobuf.Empty;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import javax.annotation.Generated;
+
+@BetaApi
+@Generated("by gapic-generator-java")
+public class MockBatchControllerImpl extends BatchControllerImplBase {
+ private List requests;
+ private Queue