diff --git a/owl-bot-staging/java-batch/v1/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java b/owl-bot-staging/java-batch/v1/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java new file mode 100644 index 000000000000..cc0b09937374 --- /dev/null +++ b/owl-bot-staging/java-batch/v1/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java @@ -0,0 +1,1447 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.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.httpjson.longrunning.OperationsClient; +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.batch.v1.stub.BatchServiceStub; +import com.google.cloud.batch.v1.stub.BatchServiceStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.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: Google Batch Service. The service manages user submitted batch jobs and + * allocates Google Compute Engine VM instances to run the jobs. + * + *
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: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * Job job = Job.newBuilder().build(); + * String jobId = "jobId101296568"; + * Job response = batchServiceClient.createJob(parent, job, jobId); + * } + * }+ * + *
Note: close() needs to be called on the BatchServiceClient 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: + * + *
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 BatchServiceSettings to + * create(). For example: + * + *
To customize credentials: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * BatchServiceSettings batchServiceSettings = + * BatchServiceSettings.newBuilder() + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + * .build(); + * BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings); + * }+ * + *
To customize the endpoint: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * BatchServiceSettings batchServiceSettings = + * BatchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + * BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings); + * }+ * + *
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. + * BatchServiceSettings batchServiceSettings = + * BatchServiceSettings.newBuilder() + * .setTransportChannelProvider( + * BatchServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + * .build(); + * BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings); + * }+ * + *
Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class BatchServiceClient implements BackgroundResource { + private final BatchServiceSettings settings; + private final BatchServiceStub stub; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; + + /** Constructs an instance of BatchServiceClient with default settings. */ + public static final BatchServiceClient create() throws IOException { + return create(BatchServiceSettings.newBuilder().build()); + } + + /** + * Constructs an instance of BatchServiceClient, 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 BatchServiceClient create(BatchServiceSettings settings) throws IOException { + return new BatchServiceClient(settings); + } + + /** + * Constructs an instance of BatchServiceClient, using the given stub for making calls. This is + * for advanced usage - prefer using create(BatchServiceSettings). + */ + public static final BatchServiceClient create(BatchServiceStub stub) { + return new BatchServiceClient(stub); + } + + /** + * Constructs an instance of BatchServiceClient, 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 BatchServiceClient(BatchServiceSettings settings) throws IOException { + this.settings = settings; + this.stub = ((BatchServiceStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + protected BatchServiceClient(BatchServiceStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + public final BatchServiceSettings getSettings() { + return settings; + } + + public BatchServiceStub 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 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. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a Job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * Job job = Job.newBuilder().build(); + * String jobId = "jobId101296568"; + * Job response = batchServiceClient.createJob(parent, job, jobId); + * } + * }+ * + * @param parent Required. The parent resource name where the Job will be created. Pattern: + * "projects/{project}/locations/{location}" + * @param job Required. The Job to create. + * @param jobId ID used to uniquely identify the Job within its parent scope. This field should + * contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-' + * character cannot be the first or the last one. A system generated ID will be used if the + * field is not set. + *
The job.name field in the request will be ignored and the created resource name of the + * Job will be "{parent}/jobs/{job_id}". + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job createJob(LocationName parent, Job job, String jobId) { + CreateJobRequest request = + CreateJobRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setJob(job) + .setJobId(jobId) + .build(); + return createJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a Job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + * Job job = Job.newBuilder().build(); + * String jobId = "jobId101296568"; + * Job response = batchServiceClient.createJob(parent, job, jobId); + * } + * }+ * + * @param parent Required. The parent resource name where the Job will be created. Pattern: + * "projects/{project}/locations/{location}" + * @param job Required. The Job to create. + * @param jobId ID used to uniquely identify the Job within its parent scope. This field should + * contain at most 63 characters. Only alphanumeric characters or '-' are accepted. The '-' + * character cannot be the first or the last one. A system generated ID will be used if the + * field is not set. + *
The job.name field in the request will be ignored and the created resource name of the + * Job will be "{parent}/jobs/{job_id}". + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job createJob(String parent, Job job, String jobId) { + CreateJobRequest request = + CreateJobRequest.newBuilder().setParent(parent).setJob(job).setJobId(jobId).build(); + return createJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a Job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * CreateJobRequest request = + * CreateJobRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setJobId("jobId101296568") + * .setJob(Job.newBuilder().build()) + * .setRequestId("requestId693933066") + * .build(); + * Job response = batchServiceClient.createJob(request); + * } + * }+ * + * @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 Job createJob(CreateJobRequest request) { + return createJobCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a Job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * CreateJobRequest request = + * CreateJobRequest.newBuilder() + * .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + * .setJobId("jobId101296568") + * .setJob(Job.newBuilder().build()) + * .setRequestId("requestId693933066") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.createJobCallable().futureCall(request); + * // Do something. + * Job response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + * Job response = batchServiceClient.getJob(name); + * } + * }+ * + * @param name Required. Job name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job getJob(JobName name) { + GetJobRequest request = + GetJobRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a Job specified by its resource name. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + * Job response = batchServiceClient.getJob(name); + * } + * }+ * + * @param name Required. Job name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Job getJob(String name) { + GetJobRequest request = GetJobRequest.newBuilder().setName(name).build(); + return getJob(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a Job specified by its resource name. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetJobRequest request = + * GetJobRequest.newBuilder() + * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .build(); + * Job response = batchServiceClient.getJob(request); + * } + * }+ * + * @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 Job getJob(GetJobRequest request) { + return getJobCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a Job specified by its resource name. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetJobRequest request = + * GetJobRequest.newBuilder() + * .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.getJobCallable().futureCall(request); + * // Do something. + * Job response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * String name = "name3373707"; + * batchServiceClient.deleteJobAsync(name).get(); + * } + * }+ * + * @param name Job name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * DeleteJobRequest request = + * DeleteJobRequest.newBuilder() + * .setName("name3373707") + * .setReason("reason-934964668") + * .setRequestId("requestId693933066") + * .build(); + * batchServiceClient.deleteJobAsync(request).get(); + * } + * }+ * + * @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
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * DeleteJobRequest request = + * DeleteJobRequest.newBuilder() + * .setName("name3373707") + * .setReason("reason-934964668") + * .setRequestId("requestId693933066") + * .build(); + * OperationFuture+ */ + public final OperationCallablefuture = + * batchServiceClient.deleteJobOperationCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * DeleteJobRequest request = + * DeleteJobRequest.newBuilder() + * .setName("name3373707") + * .setReason("reason-934964668") + * .setRequestId("requestId693933066") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.deleteJobCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * String parent = "parent-995424086"; + * for (Job element : batchServiceClient.listJobs(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Parent path. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListJobsPagedResponse listJobs(String parent) { + ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent).build(); + return listJobs(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all Jobs for a project within a region. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListJobsRequest request = + * ListJobsRequest.newBuilder() + * .setParent("parent-995424086") + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Job element : batchServiceClient.listJobs(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @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 ListJobsPagedResponse listJobs(ListJobsRequest request) { + return listJobsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all Jobs for a project within a region. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListJobsRequest request = + * ListJobsRequest.newBuilder() + * .setParent("parent-995424086") + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.listJobsPagedCallable().futureCall(request); + * // Do something. + * for (Job element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListJobsRequest request = + * ListJobsRequest.newBuilder() + * .setParent("parent-995424086") + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * while (true) { + * ListJobsResponse response = batchServiceClient.listJobsCallable().call(request); + * for (Job element : response.getJobsList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]"); + * Task response = batchServiceClient.getTask(name); + * } + * }+ * + * @param name Required. Task name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Task getTask(TaskName name) { + GetTaskRequest request = + GetTaskRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getTask(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Return a single Task. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * String name = + * TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]").toString(); + * Task response = batchServiceClient.getTask(name); + * } + * }+ * + * @param name Required. Task name. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Task getTask(String name) { + GetTaskRequest request = GetTaskRequest.newBuilder().setName(name).build(); + return getTask(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Return a single Task. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName( + * TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]") + * .toString()) + * .build(); + * Task response = batchServiceClient.getTask(request); + * } + * }+ * + * @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 Task getTask(GetTaskRequest request) { + return getTaskCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Return a single Task. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetTaskRequest request = + * GetTaskRequest.newBuilder() + * .setName( + * TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]") + * .toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.getTaskCallable().futureCall(request); + * // Do something. + * Task response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * TaskGroupName parent = TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]"); + * for (Task element : batchServiceClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. Name of a TaskGroup from which Tasks are being requested. Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListTasksPagedResponse listTasks(TaskGroupName parent) { + ListTasksRequest request = + ListTasksRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return listTasks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List Tasks associated with a job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * String parent = + * TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString(); + * for (Task element : batchServiceClient.listTasks(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. Name of a TaskGroup from which Tasks are being requested. Pattern: + * "projects/{project}/locations/{location}/jobs/{job}/taskGroups/{task_group}" + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListTasksPagedResponse listTasks(String parent) { + ListTasksRequest request = ListTasksRequest.newBuilder().setParent(parent).build(); + return listTasks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List Tasks associated with a job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent( + * TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Task element : batchServiceClient.listTasks(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @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 ListTasksPagedResponse listTasks(ListTasksRequest request) { + return listTasksPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List Tasks associated with a job. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent( + * TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.listTasksPagedCallable().futureCall(request); + * // Do something. + * for (Task element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListTasksRequest request = + * ListTasksRequest.newBuilder() + * .setParent( + * TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString()) + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * while (true) { + * ListTasksResponse response = batchServiceClient.listTasksCallable().call(request); + * for (Task element : response.getTasksList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListLocationsRequest request = + * ListLocationsRequest.newBuilder() + * .setName("name3373707") + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Location element : batchServiceClient.listLocations(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @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 ListLocationsPagedResponse listLocations(ListLocationsRequest request) { + return listLocationsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListLocationsRequest request = + * ListLocationsRequest.newBuilder() + * .setName("name3373707") + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * batchServiceClient.listLocationsPagedCallable().futureCall(request); + * // Do something. + * for (Location element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * ListLocationsRequest request = + * ListLocationsRequest.newBuilder() + * .setName("name3373707") + * .setFilter("filter-1274492040") + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * while (true) { + * ListLocationsResponse response = batchServiceClient.listLocationsCallable().call(request); + * for (Location element : response.getLocationsList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + * Location response = batchServiceClient.getLocation(request); + * } + * }+ * + * @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 Location getLocation(GetLocationRequest request) { + return getLocationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.getLocationCallable().futureCall(request); + * // Do something. + * Location response = future.get(); + * } + * }
Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * Policy response = batchServiceClient.setIamPolicy(request); + * } + * }+ * + * @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 Policy setIamPolicy(SetIamPolicyRequest request) { + return setIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sets the access control policy on the specified resource. Replacesany existing policy. + * + *
Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * SetIamPolicyRequest request = + * SetIamPolicyRequest.newBuilder() + * .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.setIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * Policy response = batchServiceClient.getIamPolicy(request); + * } + * }+ * + * @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 Policy getIamPolicy(GetIamPolicyRequest request) { + return getIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the access control policy for a resource. Returns an empty policyif the resource exists + * and does not have a policy set. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * GetIamPolicyRequest request = + * GetIamPolicyRequest.newBuilder() + * .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .setOptions(GetPolicyOptions.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = batchServiceClient.getIamPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Note: This operation is designed to be used for buildingpermission-aware UIs and + * command-line tools, not for authorizationchecking. This operation may "fail open" without + * warning. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .addAllPermissions(new ArrayList+ * + * @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 TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { + return testIamPermissionsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns permissions that a caller has on the specified resource. If theresource does not exist, + * this will return an empty set ofpermissions, not a `NOT_FOUND` error. + * + *()) + * .build(); + * TestIamPermissionsResponse response = batchServiceClient.testIamPermissions(request); + * } + * }
Note: This operation is designed to be used for buildingpermission-aware UIs and + * command-line tools, not for authorizationchecking. This operation may "fail open" without + * warning. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { + * TestIamPermissionsRequest request = + * TestIamPermissionsRequest.newBuilder() + * .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + * .addAllPermissions(new ArrayList+ */ + public final UnaryCallable()) + * .build(); + * ApiFuture future = + * batchServiceClient.testIamPermissionsCallable().futureCall(request); + * // Do something. + * TestIamPermissionsResponse response = future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
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 createJob to 30 seconds: + * + *
{@code + * // This snippet has been automatically generated for illustrative purposes only. + * // It may require modifications to work in your environment. + * BatchServiceSettings.Builder batchServiceSettingsBuilder = BatchServiceSettings.newBuilder(); + * batchServiceSettingsBuilder + * .createJobSettings() + * .setRetrySettings( + * batchServiceSettingsBuilder + * .createJobSettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * BatchServiceSettings batchServiceSettings = batchServiceSettingsBuilder.build(); + * }+ */ +@Generated("by gapic-generator-java") +public class BatchServiceSettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction The interfaces provided are listed below, along with usage samples.
+ *
+ * ======================= BatchServiceClient =======================
+ *
+ * Service Description: Google Batch Service. The service manages user submitted batch jobs and
+ * allocates Google Compute Engine VM instances to run the jobs.
+ *
+ * Sample for BatchServiceClient:
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class BatchServiceStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
+ }
+
+ public UnaryCallable The default instance has everything set to sensible defaults:
+ *
+ * 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 createJob to 30 seconds:
+ *
+ * Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcBatchServiceCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcBatchServiceStub extends BatchServiceStub {
+ private static final MethodDescriptor{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+ * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ * Job job = Job.newBuilder().build();
+ * String jobId = "jobId101296568";
+ * Job response = batchServiceClient.createJob(parent, job, jobId);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.batch.v1;
+
+import javax.annotation.Generated;
diff --git a/owl-bot-staging/java-batch/v1/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java b/owl-bot-staging/java-batch/v1/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java
new file mode 100644
index 000000000000..d895fe5c02e9
--- /dev/null
+++ b/owl-bot-staging/java-batch/v1/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.batch.v1.stub;
+
+import static com.google.cloud.batch.v1.BatchServiceClient.ListJobsPagedResponse;
+import static com.google.cloud.batch.v1.BatchServiceClient.ListLocationsPagedResponse;
+import static com.google.cloud.batch.v1.BatchServiceClient.ListTasksPagedResponse;
+
+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.batch.v1.CreateJobRequest;
+import com.google.cloud.batch.v1.DeleteJobRequest;
+import com.google.cloud.batch.v1.GetJobRequest;
+import com.google.cloud.batch.v1.GetTaskRequest;
+import com.google.cloud.batch.v1.Job;
+import com.google.cloud.batch.v1.ListJobsRequest;
+import com.google.cloud.batch.v1.ListJobsResponse;
+import com.google.cloud.batch.v1.ListTasksRequest;
+import com.google.cloud.batch.v1.ListTasksResponse;
+import com.google.cloud.batch.v1.OperationMetadata;
+import com.google.cloud.batch.v1.Task;
+import com.google.cloud.location.GetLocationRequest;
+import com.google.cloud.location.ListLocationsRequest;
+import com.google.cloud.location.ListLocationsResponse;
+import com.google.cloud.location.Location;
+import com.google.iam.v1.GetIamPolicyRequest;
+import com.google.iam.v1.Policy;
+import com.google.iam.v1.SetIamPolicyRequest;
+import com.google.iam.v1.TestIamPermissionsRequest;
+import com.google.iam.v1.TestIamPermissionsResponse;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import com.google.protobuf.Empty;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the BatchService service API.
+ *
+ *
+ *
+ *
+ * {@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * BatchServiceStubSettings.Builder batchServiceSettingsBuilder =
+ * BatchServiceStubSettings.newBuilder();
+ * batchServiceSettingsBuilder
+ * .createJobSettings()
+ * .setRetrySettings(
+ * batchServiceSettingsBuilder
+ * .createJobSettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * BatchServiceStubSettings batchServiceSettings = batchServiceSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class BatchServiceStubSettings extends StubSettings