{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); * Job job = Job.newBuilder().build(); @@ -86,8 +98,11 @@ *To customize credentials: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * BatchServiceSettings batchServiceSettings = * BatchServiceSettings.newBuilder() * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) @@ -98,8 +113,11 @@ *To customize the endpoint: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * BatchServiceSettings batchServiceSettings = * BatchServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); * BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings); @@ -109,8 +127,11 @@ * the wire: * *{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * BatchServiceSettings batchServiceSettings = * BatchServiceSettings.newBuilder() * .setTransportChannelProvider( @@ -202,8 +223,11 @@ public final OperationsClient getHttpJsonOperationsClient() { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); * Job job = Job.newBuilder().build(); @@ -240,8 +264,11 @@ public final Job createJob(LocationName parent, Job job, String jobId) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); * Job job = Job.newBuilder().build(); @@ -274,8 +301,11 @@ public final Job createJob(String parent, Job job, String jobId) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * CreateJobRequest request = * CreateJobRequest.newBuilder() @@ -302,8 +332,11 @@ public final Job createJob(CreateJobRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * CreateJobRequest request = * CreateJobRequest.newBuilder() @@ -329,8 +362,11 @@ public final UnaryCallablecreateJobCallable() { * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); * Job response = batchServiceClient.getJob(name); @@ -353,8 +389,11 @@ public final Job getJob(JobName name) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); * Job response = batchServiceClient.getJob(name); @@ -376,8 +415,11 @@ public final Job getJob(String name) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * GetJobRequest request = * GetJobRequest.newBuilder() @@ -401,8 +443,11 @@ public final Job getJob(GetJobRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * GetJobRequest request = * GetJobRequest.newBuilder() @@ -425,8 +470,11 @@ public final UnaryCallablegetJobCallable() { * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String name = "name3373707"; * batchServiceClient.deleteJobAsync(name).get(); @@ -448,8 +496,11 @@ public final OperationFuturedeleteJobAsync(String nam * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * DeleteJobRequest request = * DeleteJobRequest.newBuilder() @@ -475,8 +526,11 @@ public final OperationFuturedeleteJobAsync(DeleteJobR * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * DeleteJobRequest request = * DeleteJobRequest.newBuilder() @@ -503,8 +557,11 @@ public final OperationFuturedeleteJobAsync(DeleteJobR * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * DeleteJobRequest request = * DeleteJobRequest.newBuilder() @@ -529,8 +586,11 @@ public final UnaryCallabledeleteJobCallable() { * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String parent = "parent-995424086"; * for (Job element : batchServiceClient.listJobs(parent).iterateAll()) { @@ -554,8 +614,11 @@ public final ListJobsPagedResponse listJobs(String parent) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * ListJobsRequest request = * ListJobsRequest.newBuilder() @@ -584,8 +647,11 @@ public final ListJobsPagedResponse listJobs(ListJobsRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * ListJobsRequest request = * ListJobsRequest.newBuilder() @@ -613,8 +679,11 @@ public final UnaryCallablelistJobsPaged * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * ListJobsRequest request = * ListJobsRequest.newBuilder() @@ -649,8 +718,11 @@ public final UnaryCallablelistJobsCallable() * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]"); * Task response = batchServiceClient.getTask(name); @@ -673,8 +745,11 @@ public final Task getTask(TaskName name) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String name = * TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]").toString(); @@ -697,8 +772,11 @@ public final Task getTask(String name) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * GetTaskRequest request = * GetTaskRequest.newBuilder() @@ -724,8 +802,11 @@ public final Task getTask(GetTaskRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * GetTaskRequest request = * GetTaskRequest.newBuilder() @@ -750,8 +831,11 @@ public final UnaryCallablegetTaskCallable() { * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * TaskGroupName parent = TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]"); * for (Task element : batchServiceClient.listTasks(parent).iterateAll()) { @@ -777,8 +861,11 @@ public final ListTasksPagedResponse listTasks(TaskGroupName parent) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String parent = * TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]").toString(); @@ -804,8 +891,11 @@ public final ListTasksPagedResponse listTasks(String parent) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * ListTasksRequest request = * ListTasksRequest.newBuilder() @@ -835,8 +925,11 @@ public final ListTasksPagedResponse listTasks(ListTasksRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * ListTasksRequest request = * ListTasksRequest.newBuilder() @@ -865,8 +958,11 @@ public final UnaryCallablelistTasksPa * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * ListTasksRequest request = * ListTasksRequest.newBuilder() @@ -895,6 +991,352 @@ public final UnaryCallablelistTasksCallabl return stub.listTasksCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + * Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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); + * } + * } + * } + listLocationsPagedCallable() { + return stub.listLocationsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + * Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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 UnaryCallablelistLocationsCallable() { + return stub.listLocationsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + * Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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(); + * } + * } getLocationCallable() { + return stub.getLocationCallable(); + } + + // 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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(); + * } + * } setIamPolicyCallable() { + return stub.setIamPolicyCallable(); + } + + // 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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(); + * } + * } getIamPolicyCallable() { + return stub.getIamPolicyCallable(); + } + + // 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. + * + * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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(); + * } + * } + testIamPermissionsCallable() { + return stub.testIamPermissionsCallable(); + } + @Override public final void close() { stub.close(); @@ -1052,4 +1494,80 @@ protected ListTasksFixedSizeCollection createCollection( return new ListTasksFixedSizeCollection(pages, collectionSize); } } + + public static class ListLocationsPagedResponse + extends AbstractPagedListResponse< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListLocationsPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListLocationsPagedResponse(ListLocationsPage page) { + super(page, ListLocationsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListLocationsPage + extends AbstractPage< + ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> { + + private ListLocationsPage( + PageContext context, + ListLocationsResponse response) { + super(context, response); + } + + private static ListLocationsPage createEmptyPage() { + return new ListLocationsPage(null, null); + } + + @Override + protected ListLocationsPage createPage( + PageContext context, + ListLocationsResponse response) { + return new ListLocationsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListLocationsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListLocationsRequest, + ListLocationsResponse, + Location, + ListLocationsPage, + ListLocationsFixedSizeCollection> { + + private ListLocationsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListLocationsFixedSizeCollection createEmptyCollection() { + return new ListLocationsFixedSizeCollection(null, 0); + } + + @Override + protected ListLocationsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListLocationsFixedSizeCollection(pages, collectionSize); + } + } } diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceSettings.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceSettings.java index eec86fe..8db69ee 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceSettings.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.batch.v1; 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.core.ApiFunction; @@ -33,6 +34,15 @@ import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; 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.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; @@ -57,16 +67,16 @@ * 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. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * BatchServiceSettings.Builder batchServiceSettingsBuilder = BatchServiceSettings.newBuilder(); * batchServiceSettingsBuilder * .createJobSettings() * .setRetrySettings( - * batchServiceSettingsBuilder - * .createJobSettings() - * .getRetrySettings() - * .toBuilder() + * batchServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder() * .setTotalTimeout(Duration.ofSeconds(30)) * .build()); * BatchServiceSettings batchServiceSettings = batchServiceSettingsBuilder.build(); @@ -113,6 +123,33 @@ public UnaryCallSettingsgetTaskSettings() { return ((BatchServiceStubSettings) getStubSettings()).listTasksSettings(); } + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return ((BatchServiceStubSettings) getStubSettings()).listLocationsSettings(); + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return ((BatchServiceStubSettings) getStubSettings()).getLocationSettings(); + } + + /** Returns the object with the settings used for calls to setIamPolicy. */ + public UnaryCallSettings setIamPolicySettings() { + return ((BatchServiceStubSettings) getStubSettings()).setIamPolicySettings(); + } + + /** Returns the object with the settings used for calls to getIamPolicy. */ + public UnaryCallSettings getIamPolicySettings() { + return ((BatchServiceStubSettings) getStubSettings()).getIamPolicySettings(); + } + + /** Returns the object with the settings used for calls to testIamPermissions. */ + public UnaryCallSettings + testIamPermissionsSettings() { + return ((BatchServiceStubSettings) getStubSettings()).testIamPermissionsSettings(); + } + public static final BatchServiceSettings create(BatchServiceStubSettings stub) throws IOException { return new BatchServiceSettings.Builder(stub.toBuilder()).build(); @@ -266,6 +303,34 @@ public UnaryCallSettings.Builder getTaskSettings() { return getStubSettingsBuilder().listTasksSettings(); } + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return getStubSettingsBuilder().listLocationsSettings(); + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getStubSettingsBuilder().getLocationSettings(); + } + + /** Returns the builder for the settings used for calls to setIamPolicy. */ + public UnaryCallSettings.Builder setIamPolicySettings() { + return getStubSettingsBuilder().setIamPolicySettings(); + } + + /** Returns the builder for the settings used for calls to getIamPolicy. */ + public UnaryCallSettings.Builder getIamPolicySettings() { + return getStubSettingsBuilder().getIamPolicySettings(); + } + + /** Returns the builder for the settings used for calls to testIamPermissions. */ + public UnaryCallSettings.Builder + testIamPermissionsSettings() { + return getStubSettingsBuilder().testIamPermissionsSettings(); + } + @Override public BatchServiceSettings build() throws IOException { return new BatchServiceSettings(this); diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/gapic_metadata.json b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/gapic_metadata.json index e1b5f3e..b66edee 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/gapic_metadata.json +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/gapic_metadata.json @@ -16,17 +16,32 @@ "DeleteJob": { "methods": ["deleteJobAsync", "deleteJobAsync", "deleteJobOperationCallable", "deleteJobCallable"] }, + "GetIamPolicy": { + "methods": ["getIamPolicy", "getIamPolicyCallable"] + }, "GetJob": { "methods": ["getJob", "getJob", "getJob", "getJobCallable"] }, + "GetLocation": { + "methods": ["getLocation", "getLocationCallable"] + }, "GetTask": { "methods": ["getTask", "getTask", "getTask", "getTaskCallable"] }, "ListJobs": { "methods": ["listJobs", "listJobs", "listJobsPagedCallable", "listJobsCallable"] }, + "ListLocations": { + "methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"] + }, "ListTasks": { "methods": ["listTasks", "listTasks", "listTasks", "listTasksPagedCallable", "listTasksCallable"] + }, + "SetIamPolicy": { + "methods": ["setIamPolicy", "setIamPolicyCallable"] + }, + "TestIamPermissions": { + "methods": ["testIamPermissions", "testIamPermissionsCallable"] } } } diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/package-info.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/package-info.java index e675510..4662f0d 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/package-info.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/package-info.java @@ -27,8 +27,11 @@ * Sample for BatchServiceClient: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); * Job job = Job.newBuilder().build(); diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java index f10d790..d895fe5 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStub.java @@ -17,6 +17,7 @@ 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; @@ -33,6 +34,15 @@ 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; @@ -92,6 +102,32 @@ public UnaryCallablelistTasksCallable() { throw new UnsupportedOperationException("Not implemented: listTasksCallable()"); } + public UnaryCallable + listLocationsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsPagedCallable()"); + } + + public UnaryCallable listLocationsCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsCallable()"); + } + + public UnaryCallable getLocationCallable() { + throw new UnsupportedOperationException("Not implemented: getLocationCallable()"); + } + + public UnaryCallable setIamPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: setIamPolicyCallable()"); + } + + public UnaryCallable getIamPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getIamPolicyCallable()"); + } + + public UnaryCallable + testIamPermissionsCallable() { + throw new UnsupportedOperationException("Not implemented: testIamPermissionsCallable()"); + } + @Override public abstract void close(); } diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStubSettings.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStubSettings.java index c729398..cf7136c 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStubSettings.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStubSettings.java @@ -17,6 +17,7 @@ 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.core.ApiFunction; @@ -59,10 +60,19 @@ 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.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +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; @@ -88,17 +98,17 @@ * 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. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * BatchServiceStubSettings.Builder batchServiceSettingsBuilder = * BatchServiceStubSettings.newBuilder(); * batchServiceSettingsBuilder * .createJobSettings() * .setRetrySettings( - * batchServiceSettingsBuilder - * .createJobSettings() - * .getRetrySettings() - * .toBuilder() + * batchServiceSettingsBuilder.createJobSettings().getRetrySettings().toBuilder() * .setTotalTimeout(Duration.ofSeconds(30)) * .build()); * BatchServiceStubSettings batchServiceSettings = batchServiceSettingsBuilder.build(); @@ -120,6 +130,14 @@ public class BatchServiceStubSettings extends StubSettingsgetTaskSettings; private final PagedCallSettings listTasksSettings; + private final PagedCallSettings< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings getLocationSettings; + private final UnaryCallSettings setIamPolicySettings; + private final UnaryCallSettings getIamPolicySettings; + private final UnaryCallSettings + testIamPermissionsSettings; private static final PagedListDescriptor LIST_JOBS_PAGE_STR_DESC = @@ -193,6 +211,42 @@ public Iterable extractResources(ListTasksResponse payload) { } }; + private static final PagedListDescriptor + LIST_LOCATIONS_PAGE_STR_DESC = + new PagedListDescriptor () { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListLocationsRequest injectToken(ListLocationsRequest payload, String token) { + return ListLocationsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListLocationsRequest injectPageSize(ListLocationsRequest payload, int pageSize) { + return ListLocationsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListLocationsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListLocationsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListLocationsResponse payload) { + return payload.getLocationsList() == null + ? ImmutableList. of() + : payload.getLocationsList(); + } + }; + private static final PagedListResponseFactory< ListJobsRequest, ListJobsResponse, ListJobsPagedResponse> LIST_JOBS_PAGE_STR_FACT = @@ -226,6 +280,23 @@ public ApiFuture getFuturePagedResponse( } }; + private static final PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + LIST_LOCATIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListLocationsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_LOCATIONS_PAGE_STR_DESC, request, context); + return ListLocationsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to createJob. */ public UnaryCallSettings createJobSettings() { return createJobSettings; @@ -264,6 +335,33 @@ public UnaryCallSettings getTaskSettings() { return listTasksSettings; } + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the object with the settings used for calls to getLocation. */ + public UnaryCallSettings getLocationSettings() { + return getLocationSettings; + } + + /** Returns the object with the settings used for calls to setIamPolicy. */ + public UnaryCallSettings setIamPolicySettings() { + return setIamPolicySettings; + } + + /** Returns the object with the settings used for calls to getIamPolicy. */ + public UnaryCallSettings getIamPolicySettings() { + return getIamPolicySettings; + } + + /** Returns the object with the settings used for calls to testIamPermissions. */ + public UnaryCallSettings + testIamPermissionsSettings() { + return testIamPermissionsSettings; + } + public BatchServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() @@ -377,6 +475,11 @@ protected BatchServiceStubSettings(Builder settingsBuilder) throws IOException { listJobsSettings = settingsBuilder.listJobsSettings().build(); getTaskSettings = settingsBuilder.getTaskSettings().build(); listTasksSettings = settingsBuilder.listTasksSettings().build(); + listLocationsSettings = settingsBuilder.listLocationsSettings().build(); + getLocationSettings = settingsBuilder.getLocationSettings().build(); + setIamPolicySettings = settingsBuilder.setIamPolicySettings().build(); + getIamPolicySettings = settingsBuilder.getIamPolicySettings().build(); + testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); } /** Builder for BatchServiceStubSettings. */ @@ -394,6 +497,14 @@ public static class Builder extends StubSettings.Builder listTasksSettings; + private final PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; + private final UnaryCallSettings.Builder getLocationSettings; + private final UnaryCallSettings.Builder setIamPolicySettings; + private final UnaryCallSettings.Builder getIamPolicySettings; + private final UnaryCallSettings.Builder + testIamPermissionsSettings; private static final ImmutableMap > RETRYABLE_CODE_DEFINITIONS; @@ -405,6 +516,7 @@ public static class Builder extends StubSettings.Builder newArrayList(StatusCode.Code.UNAVAILABLE))); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists. newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -432,6 +544,8 @@ public static class Builder extends StubSettings.Builder >of( @@ -457,7 +576,12 @@ protected Builder(ClientContext clientContext) { deleteJobSettings, listJobsSettings, getTaskSettings, - listTasksSettings); + listTasksSettings, + listLocationsSettings, + getLocationSettings, + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings); initDefaults(this); } @@ -471,6 +595,11 @@ protected Builder(BatchServiceStubSettings settings) { listJobsSettings = settings.listJobsSettings.toBuilder(); getTaskSettings = settings.getTaskSettings.toBuilder(); listTasksSettings = settings.listTasksSettings.toBuilder(); + listLocationsSettings = settings.listLocationsSettings.toBuilder(); + getLocationSettings = settings.getLocationSettings.toBuilder(); + setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); + getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); + testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList. >of( @@ -479,7 +608,12 @@ protected Builder(BatchServiceStubSettings settings) { deleteJobSettings, listJobsSettings, getTaskSettings, - listTasksSettings); + listTasksSettings, + listLocationsSettings, + getLocationSettings, + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings); } private static Builder createDefault() { @@ -539,6 +673,31 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder + .listLocationsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getLocationSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .setIamPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getIamPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .testIamPermissionsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + builder .deleteJobOperationSettings() .setInitialCallSettings( @@ -620,6 +779,34 @@ public UnaryCallSettings.Builder getTaskSettings() { return listTasksSettings; } + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return listLocationsSettings; + } + + /** Returns the builder for the settings used for calls to getLocation. */ + public UnaryCallSettings.Builder getLocationSettings() { + return getLocationSettings; + } + + /** Returns the builder for the settings used for calls to setIamPolicy. */ + public UnaryCallSettings.Builder setIamPolicySettings() { + return setIamPolicySettings; + } + + /** Returns the builder for the settings used for calls to getIamPolicy. */ + public UnaryCallSettings.Builder getIamPolicySettings() { + return getIamPolicySettings; + } + + /** Returns the builder for the settings used for calls to testIamPermissions. */ + public UnaryCallSettings.Builder + testIamPermissionsSettings() { + return testIamPermissionsSettings; + } + @Override public BatchServiceStubSettings build() throws IOException { return new BatchServiceStubSettings(this); diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/GrpcBatchServiceStub.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/GrpcBatchServiceStub.java index 0ac056a..e463b04 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/GrpcBatchServiceStub.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/GrpcBatchServiceStub.java @@ -17,6 +17,7 @@ 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; @@ -37,7 +38,16 @@ 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.common.collect.ImmutableMap; +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.GrpcOperationsStub; import com.google.protobuf.Empty; @@ -105,6 +115,52 @@ public class GrpcBatchServiceStub extends BatchServiceStub { .setResponseMarshaller(ProtoUtils.marshaller(ListTasksResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor + listLocationsMethodDescriptor = + MethodDescriptor. newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setRequestMarshaller( + ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getLocationMethodDescriptor = + MethodDescriptor. newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setRequestMarshaller(ProtoUtils.marshaller(GetLocationRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Location.getDefaultInstance())) + .build(); + + private static final MethodDescriptor setIamPolicyMethodDescriptor = + MethodDescriptor. newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy") + .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getIamPolicyMethodDescriptor = + MethodDescriptor. newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy") + .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + testIamPermissionsMethodDescriptor = + MethodDescriptor. newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions") + .setRequestMarshaller( + ProtoUtils.marshaller(TestIamPermissionsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) + .build(); + private final UnaryCallable createJobCallable; private final UnaryCallable getJobCallable; private final UnaryCallable deleteJobCallable; @@ -115,6 +171,14 @@ public class GrpcBatchServiceStub extends BatchServiceStub { private final UnaryCallable getTaskCallable; private final UnaryCallable listTasksCallable; private final UnaryCallable listTasksPagedCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -218,6 +282,57 @@ protected GrpcBatchServiceStub( return params.build(); }) .build(); + GrpcCallSettings listLocationsTransportSettings = + GrpcCallSettings. newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + GrpcCallSettings getLocationTransportSettings = + GrpcCallSettings. newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + GrpcCallSettings setIamPolicyTransportSettings = + GrpcCallSettings. newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); + }) + .build(); + GrpcCallSettings getIamPolicyTransportSettings = + GrpcCallSettings. newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); + }) + .build(); + GrpcCallSettings + testIamPermissionsTransportSettings = + GrpcCallSettings. newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("resource", String.valueOf(request.getResource())); + return params.build(); + }) + .build(); this.createJobCallable = callableFactory.createUnaryCallable( @@ -249,6 +364,26 @@ protected GrpcBatchServiceStub( this.listTasksPagedCallable = callableFactory.createPagedCallable( listTasksTransportSettings, settings.listTasksSettings(), clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -304,6 +439,38 @@ public UnaryCallable listTasksPagedCal return listTasksPagedCallable; } + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/HttpJsonBatchServiceStub.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/HttpJsonBatchServiceStub.java index 2543029..33de228 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/HttpJsonBatchServiceStub.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/HttpJsonBatchServiceStub.java @@ -17,6 +17,7 @@ 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.core.BetaApi; @@ -45,6 +46,15 @@ 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.protobuf.Empty; import com.google.protobuf.TypeRegistry; @@ -97,7 +107,8 @@ public class HttpJsonBatchServiceStub extends BatchServiceStub { return fields; }) .setRequestBodyExtractor( - request -> ProtoRestSerializer.create().toBody("job", request.getJob())) + request -> + ProtoRestSerializer.create().toBody("job", request.getJob(), false)) .build()) .setResponseParser( ProtoMessageResponseParser. newBuilder() @@ -279,6 +290,186 @@ public class HttpJsonBatchServiceStub extends BatchServiceStub { .build()) .build(); + private static final ApiMethodDescriptor + listLocationsMethodDescriptor = + ApiMethodDescriptor. newBuilder() + .setFullMethodName("google.cloud.location.Locations/ListLocations") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter. newBuilder() + .setPath( + "/v1/{name=projects/*}/locations", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map > fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser. newBuilder() + .setDefaultInstance(ListLocationsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getLocationMethodDescriptor = + ApiMethodDescriptor. newBuilder() + .setFullMethodName("google.cloud.location.Locations/GetLocation") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter. newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map > fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser. newBuilder() + .setDefaultInstance(Location.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor. newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter. newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/jobs/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/tasks/*}:setIamPolicy", + "/v1/{resource=projects/*/locations/*/nodes/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map > fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build(), false)) + .build()) + .setResponseParser( + ProtoMessageResponseParser. newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor. newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter. newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/jobs/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/tasks/*}:getIamPolicy", + "/v1/{resource=projects/*/locations/*/nodes/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map > fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser. newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor. newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter. newBuilder() + .setPath( + "/v1/{resource=projects/*/locations/*/jobs/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/locations/*/tasks/*}:testIamPermissions", + "/v1/{resource=projects/*/locations/*/nodes/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map > fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build(), false)) + .build()) + .setResponseParser( + ProtoMessageResponseParser. newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + private final UnaryCallable createJobCallable; private final UnaryCallable getJobCallable; private final UnaryCallable deleteJobCallable; @@ -289,6 +480,14 @@ public class HttpJsonBatchServiceStub extends BatchServiceStub { private final UnaryCallable getTaskCallable; private final UnaryCallable listTasksCallable; private final UnaryCallable listTasksPagedCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; + private final UnaryCallable getLocationCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; @@ -365,6 +564,33 @@ protected HttpJsonBatchServiceStub( .setMethodDescriptor(listTasksMethodDescriptor) .setTypeRegistry(typeRegistry) .build(); + HttpJsonCallSettings + listLocationsTransportSettings = + HttpJsonCallSettings. newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getLocationTransportSettings = + HttpJsonCallSettings. newBuilder() + .setMethodDescriptor(getLocationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings. newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings. newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings. newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); this.createJobCallable = callableFactory.createUnaryCallable( @@ -396,6 +622,26 @@ protected HttpJsonBatchServiceStub( this.listTasksPagedCallable = callableFactory.createPagedCallable( listTasksTransportSettings, settings.listTasksSettings(), clientContext); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.getLocationCallable = + callableFactory.createUnaryCallable( + getLocationTransportSettings, settings.getLocationSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -410,6 +656,11 @@ public static List getMethodDescriptors() { methodDescriptors.add(listJobsMethodDescriptor); methodDescriptors.add(getTaskMethodDescriptor); methodDescriptors.add(listTasksMethodDescriptor); + methodDescriptors.add(listLocationsMethodDescriptor); + methodDescriptors.add(getLocationMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); return methodDescriptors; } @@ -463,6 +714,38 @@ public UnaryCallable listTasksPagedCal return listTasksPagedCallable; } + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + + @Override + public UnaryCallable getLocationCallable() { + return getLocationCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceClient.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceClient.java index 02e9478..6c036c1 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceClient.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceClient.java @@ -20,6 +20,7 @@ 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; @@ -29,9 +30,17 @@ import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.batch.v1alpha.stub.BatchServiceStub; import com.google.cloud.batch.v1alpha.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.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -47,8 +56,11 @@ * 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. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); * Job job = Job.newBuilder().build(); @@ -86,8 +98,11 @@ *To customize credentials: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * BatchServiceSettings batchServiceSettings = * BatchServiceSettings.newBuilder() * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) @@ -98,13 +113,33 @@ *To customize the endpoint: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * 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 and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * 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. */ @BetaApi @@ -112,7 +147,8 @@ public class BatchServiceClient implements BackgroundResource { private final BatchServiceSettings settings; private final BatchServiceStub stub; - private final OperationsClient operationsClient; + 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 { @@ -143,13 +179,17 @@ public static final BatchServiceClient create(BatchServiceStub stub) { protected BatchServiceClient(BatchServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((BatchServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected BatchServiceClient(BatchServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final BatchServiceSettings getSettings() { @@ -164,10 +204,19 @@ public BatchServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create a Job. @@ -175,8 +224,11 @@ public final OperationsClient getOperationsClient() { *
Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); * Job job = Job.newBuilder().build(); @@ -213,8 +265,11 @@ public final Job createJob(LocationName parent, Job job, String jobId) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); * Job job = Job.newBuilder().build(); @@ -247,8 +302,11 @@ public final Job createJob(String parent, Job job, String jobId) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * CreateJobRequest request = * CreateJobRequest.newBuilder() @@ -275,8 +333,11 @@ public final Job createJob(CreateJobRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * CreateJobRequest request = * CreateJobRequest.newBuilder() @@ -302,8 +363,11 @@ public final UnaryCallablecreateJobCallable() { * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); * Job response = batchServiceClient.getJob(name); @@ -326,8 +390,11 @@ public final Job getJob(JobName name) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); * Job response = batchServiceClient.getJob(name); @@ -349,8 +416,11 @@ public final Job getJob(String name) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * GetJobRequest request = * GetJobRequest.newBuilder() @@ -374,8 +444,11 @@ public final Job getJob(GetJobRequest request) { *Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * GetJobRequest request = * GetJobRequest.newBuilder() @@ -398,8 +471,11 @@ public final UnaryCallablegetJobCallable() { * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * String name = "name3373707"; * batchServiceClient.deleteJobAsync(name).get(); @@ -421,8 +497,11 @@ public final OperationFuturedeleteJobAsync(String nam * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * DeleteJobRequest request = * DeleteJobRequest.newBuilder() @@ -448,8 +527,11 @@ public final OperationFuturedeleteJobAsync(DeleteJobR * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * DeleteJobRequest request = * DeleteJobRequest.newBuilder() @@ -476,8 +558,11 @@ public final OperationFuturedeleteJobAsync(DeleteJobR * Sample code: * *
{@code - * // This snippet has been automatically generated for illustrative purposes only. - * // It may require modifications to work in your environment. + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) { * DeleteJobRequest request = * DeleteJobRequest.newBuilder() @@ -502,8 +587,11 @@ public final UnaryCallable