diff --git a/google-cloud-batch/pom.xml b/google-cloud-batch/pom.xml index 794b20c..9b0e6ad 100644 --- a/google-cloud-batch/pom.xml +++ b/google-cloud-batch/pom.xml @@ -58,6 +58,10 @@ com.google.api.grpc grpc-google-iam-v1 + + com.google.api.grpc + proto-google-iam-v1 + com.google.api.grpc proto-google-cloud-batch-v1 diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java index b0232ea..de718d1 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/BatchServiceClient.java @@ -30,7 +30,16 @@ import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.batch.v1.stub.BatchServiceStub; import com.google.cloud.batch.v1.stub.BatchServiceStubSettings; +import com.google.cloud.location.GetLocationRequest; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.common.util.concurrent.MoreExecutors; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; import com.google.longrunning.Operation; import com.google.protobuf.Empty; import java.io.IOException; @@ -895,6 +904,319 @@ public final UnaryCallable listTasksCallabl 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Location element : batchServiceClient.listLocations(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { + return listLocationsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       batchServiceClient.listLocationsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Location element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListLocationsResponse response = batchServiceClient.listLocationsCallable().call(request);
+   *     for (Location element : response.getLocationsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listLocationsCallable() { + return stub.listLocationsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   Location response = batchServiceClient.getLocation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Location getLocation(GetLocationRequest request) { + return getLocationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future = batchServiceClient.getLocationCallable().futureCall(request);
+   *   // Do something.
+   *   Location response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   SetIamPolicyRequest request =
+   *       SetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Policy response = batchServiceClient.setIamPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy setIamPolicy(SetIamPolicyRequest request) { + return setIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sets the access control policy on the specified resource. Replacesany existing policy. + * + *

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   SetIamPolicyRequest request =
+   *       SetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = batchServiceClient.setIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetIamPolicyRequest request =
+   *       GetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setOptions(GetPolicyOptions.newBuilder().build())
+   *           .build();
+   *   Policy response = batchServiceClient.getIamPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getIamPolicy(GetIamPolicyRequest request) { + return getIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the access control policy for a resource. Returns an empty policyif the resource exists + * and does not have a policy set. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetIamPolicyRequest request =
+   *       GetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setOptions(GetPolicyOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = batchServiceClient.getIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   TestIamPermissionsRequest request =
+   *       TestIamPermissionsRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .addAllPermissions(new ArrayList())
+   *           .build();
+   *   TestIamPermissionsResponse response = batchServiceClient.testIamPermissions(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 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. + * + *

Note: This operation is designed to be used for buildingpermission-aware UIs and + * command-line tools, not for authorizationchecking. This operation may "fail open" without + * warning. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   TestIamPermissionsRequest request =
+   *       TestIamPermissionsRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .addAllPermissions(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       batchServiceClient.testIamPermissionsCallable().futureCall(request);
+   *   // Do something.
+   *   TestIamPermissionsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + testIamPermissionsCallable() { + return stub.testIamPermissionsCallable(); + } + @Override public final void close() { stub.close(); @@ -1052,4 +1374,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..596d09a 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; @@ -113,6 +123,33 @@ public UnaryCallSettings getTaskSettings() { 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/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 UnaryCallable listTasksCallable() { 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..d05a7a3 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; @@ -120,6 +130,14 @@ public class BatchServiceStubSettings extends StubSettings getTaskSettings; 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.BuildernewArrayList(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..76e9229 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; @@ -279,6 +289,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())) + .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())) + .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 +479,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 +563,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 +621,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 +655,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 +713,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..76b44ba 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; @@ -105,6 +114,20 @@ * BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * BatchServiceSettings batchServiceSettings =
+ *     BatchServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             BatchServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * BatchServiceClient batchServiceClient = BatchServiceClient.create(batchServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -112,7 +135,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 +167,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 +192,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. @@ -868,6 +905,319 @@ public final UnaryCallable listTasksCallabl 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Location element : batchServiceClient.listLocations(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) { + return listLocationsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists information about the supported locations for this service. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       batchServiceClient.listLocationsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Location element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListLocationsResponse response = batchServiceClient.listLocationsCallable().call(request);
+   *     for (Location element : response.getLocationsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listLocationsCallable() { + return stub.listLocationsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   Location response = batchServiceClient.getLocation(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Location getLocation(GetLocationRequest request) { + return getLocationCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a location. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future = batchServiceClient.getLocationCallable().futureCall(request);
+   *   // Do something.
+   *   Location response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   SetIamPolicyRequest request =
+   *       SetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Policy response = batchServiceClient.setIamPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy setIamPolicy(SetIamPolicyRequest request) { + return setIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Sets the access control policy on the specified resource. Replacesany existing policy. + * + *

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`errors. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   SetIamPolicyRequest request =
+   *       SetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = batchServiceClient.setIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetIamPolicyRequest request =
+   *       GetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setOptions(GetPolicyOptions.newBuilder().build())
+   *           .build();
+   *   Policy response = batchServiceClient.getIamPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getIamPolicy(GetIamPolicyRequest request) { + return getIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the access control policy for a resource. Returns an empty policyif the resource exists + * and does not have a policy set. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   GetIamPolicyRequest request =
+   *       GetIamPolicyRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .setOptions(GetPolicyOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = batchServiceClient.getIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable 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 for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   TestIamPermissionsRequest request =
+   *       TestIamPermissionsRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .addAllPermissions(new ArrayList())
+   *           .build();
+   *   TestIamPermissionsResponse response = batchServiceClient.testIamPermissions(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 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. + * + *

Note: This operation is designed to be used for buildingpermission-aware UIs and + * command-line tools, not for authorizationchecking. This operation may "fail open" without + * warning. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated for illustrative purposes only.
+   * // It may require modifications to work in your environment.
+   * try (BatchServiceClient batchServiceClient = BatchServiceClient.create()) {
+   *   TestIamPermissionsRequest request =
+   *       TestIamPermissionsRequest.newBuilder()
+   *           .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString())
+   *           .addAllPermissions(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       batchServiceClient.testIamPermissionsCallable().futureCall(request);
+   *   // Do something.
+   *   TestIamPermissionsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + testIamPermissionsCallable() { + return stub.testIamPermissionsCallable(); + } + @Override public final void close() { stub.close(); @@ -1025,4 +1375,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/v1alpha/BatchServiceSettings.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceSettings.java index 349888a..9e23db9 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceSettings.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/BatchServiceSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.batch.v1alpha; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; import com.google.api.core.ApiFunction; @@ -24,6 +25,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -32,6 +34,15 @@ import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; 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.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; @@ -113,6 +124,33 @@ public UnaryCallSettings getTaskSettings() { 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(); @@ -138,11 +176,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return BatchServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return BatchServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return BatchServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return BatchServiceStubSettings.defaultTransportChannelProvider(); } @@ -152,11 +197,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return BatchServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -194,6 +245,11 @@ private static Builder createDefault() { return new Builder(BatchServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(BatchServiceStubSettings.newHttpJsonBuilder()); + } + public BatchServiceStubSettings.Builder getStubSettingsBuilder() { return ((BatchServiceStubSettings.Builder) getStubSettings()); } @@ -248,6 +304,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/v1alpha/gapic_metadata.json b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/gapic_metadata.json index 154c03f..fb91478 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/gapic_metadata.json +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/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/v1alpha/package-info.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/package-info.java index afb0037..0989c13 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/package-info.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/package-info.java @@ -15,7 +15,9 @@ */ /** - * The interfaces provided are listed below, along with usage samples. + * A client to Batch API + * + *

The interfaces provided are listed below, along with usage samples. * *

======================= BatchServiceClient ======================= * diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStub.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStub.java index 44de4c2..0b3397b 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStub.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStub.java @@ -17,6 +17,7 @@ package com.google.cloud.batch.v1alpha.stub; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; import com.google.api.core.BetaApi; @@ -34,6 +35,15 @@ import com.google.cloud.batch.v1alpha.ListTasksResponse; import com.google.cloud.batch.v1alpha.OperationMetadata; import com.google.cloud.batch.v1alpha.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; @@ -50,7 +60,11 @@ public abstract class BatchServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable createJobCallable() { @@ -90,6 +104,32 @@ public UnaryCallable listTasksCallable() { 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/v1alpha/stub/BatchServiceStubSettings.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStubSettings.java index e21896b..378c83c 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStubSettings.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/BatchServiceStubSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.batch.v1alpha.stub; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; import com.google.api.core.ApiFunction; @@ -29,6 +30,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -56,10 +60,19 @@ import com.google.cloud.batch.v1alpha.ListTasksResponse; import com.google.cloud.batch.v1alpha.OperationMetadata; import com.google.cloud.batch.v1alpha.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; @@ -118,6 +131,14 @@ public class BatchServiceStubSettings extends StubSettings getTaskSettings; 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 = @@ -191,6 +212,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 = @@ -224,6 +281,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; @@ -262,12 +336,44 @@ 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() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcBatchServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonBatchServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -300,18 +406,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(BatchServiceStubSettings.class)) @@ -319,11 +432,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(BatchServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return BatchServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -344,6 +476,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. */ @@ -361,6 +498,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; @@ -372,6 +517,7 @@ public static class Builder extends StubSettings.BuildernewArrayList(StatusCode.Code.UNAVAILABLE))); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -399,6 +545,8 @@ public static class Builder extends StubSettings.Builder>of( @@ -424,7 +577,12 @@ protected Builder(ClientContext clientContext) { deleteJobSettings, listJobsSettings, getTaskSettings, - listTasksSettings); + listTasksSettings, + listLocationsSettings, + getLocationSettings, + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings); initDefaults(this); } @@ -438,6 +596,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( @@ -446,7 +609,12 @@ protected Builder(BatchServiceStubSettings settings) { deleteJobSettings, listJobsSettings, getTaskSettings, - listTasksSettings); + listTasksSettings, + listLocationsSettings, + getLocationSettings, + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings); } private static Builder createDefault() { @@ -462,6 +630,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createJobSettings() @@ -493,6 +674,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( @@ -574,6 +780,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/v1alpha/stub/GrpcBatchServiceStub.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/GrpcBatchServiceStub.java index 17dcc58..553e28d 100644 --- a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/GrpcBatchServiceStub.java +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/GrpcBatchServiceStub.java @@ -17,6 +17,7 @@ package com.google.cloud.batch.v1alpha.stub; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; import com.google.api.core.BetaApi; @@ -38,7 +39,16 @@ import com.google.cloud.batch.v1alpha.ListTasksResponse; import com.google.cloud.batch.v1alpha.OperationMetadata; import com.google.cloud.batch.v1alpha.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; @@ -107,6 +117,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; @@ -117,6 +173,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; @@ -220,6 +284,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( @@ -251,6 +366,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()); @@ -306,6 +441,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/stub/HttpJsonBatchServiceCallableFactory.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/HttpJsonBatchServiceCallableFactory.java new file mode 100644 index 0000000..f061656 --- /dev/null +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/HttpJsonBatchServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the BatchService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonBatchServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/HttpJsonBatchServiceStub.java b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/HttpJsonBatchServiceStub.java new file mode 100644 index 0000000..83e1f59 --- /dev/null +++ b/google-cloud-batch/src/main/java/com/google/cloud/batch/v1alpha/stub/HttpJsonBatchServiceStub.java @@ -0,0 +1,783 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha.stub; + +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.batch.v1alpha.CreateJobRequest; +import com.google.cloud.batch.v1alpha.DeleteJobRequest; +import com.google.cloud.batch.v1alpha.GetJobRequest; +import com.google.cloud.batch.v1alpha.GetTaskRequest; +import com.google.cloud.batch.v1alpha.Job; +import com.google.cloud.batch.v1alpha.ListJobsRequest; +import com.google.cloud.batch.v1alpha.ListJobsResponse; +import com.google.cloud.batch.v1alpha.ListTasksRequest; +import com.google.cloud.batch.v1alpha.ListTasksResponse; +import com.google.cloud.batch.v1alpha.OperationMetadata; +import com.google.cloud.batch.v1alpha.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; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the BatchService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonBatchServiceStub extends BatchServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor createJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.batch.v1alpha.BatchService/CreateJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/jobs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "jobId", request.getJobId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("job", request.getJob())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.batch.v1alpha.BatchService/GetJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/jobs/*}", + 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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.batch.v1alpha.BatchService/DeleteJob") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/jobs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "reason", request.getReason()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteJobRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listJobsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.batch.v1alpha.BatchService/ListJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/jobs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getTaskMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.batch.v1alpha.BatchService/GetTask") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/jobs/*/taskGroups/*/tasks/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Task.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listTasksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.batch.v1alpha.BatchService/ListTasks") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/jobs/*/taskGroups/*}/tasks", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTasksResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .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( + "/v1alpha/{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( + "/v1alpha/{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( + "/v1alpha/{resource=projects/*/locations/*/jobs/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1alpha/{resource=projects/*/locations/*/tasks/*}:setIamPolicy", + "/v1alpha/{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())) + .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( + "/v1alpha/{resource=projects/*/locations/*/jobs/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1alpha/{resource=projects/*/locations/*/tasks/*}:getIamPolicy", + "/v1alpha/{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( + "/v1alpha/{resource=projects/*/locations/*/jobs/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1alpha/{resource=projects/*/locations/*/tasks/*}:testIamPermissions", + "/v1alpha/{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())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createJobCallable; + private final UnaryCallable getJobCallable; + private final UnaryCallable deleteJobCallable; + private final OperationCallable + deleteJobOperationCallable; + private final UnaryCallable listJobsCallable; + private final UnaryCallable listJobsPagedCallable; + 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; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonBatchServiceStub create(BatchServiceStubSettings settings) + throws IOException { + return new HttpJsonBatchServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonBatchServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonBatchServiceStub( + BatchServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonBatchServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonBatchServiceStub( + BatchServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonBatchServiceStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonBatchServiceStub(BatchServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonBatchServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonBatchServiceStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonBatchServiceStub( + BatchServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listJobsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getTaskTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getTaskMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listTasksTransportSettings = + HttpJsonCallSettings.newBuilder() + .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( + createJobTransportSettings, settings.createJobSettings(), clientContext); + this.getJobCallable = + callableFactory.createUnaryCallable( + getJobTransportSettings, settings.getJobSettings(), clientContext); + this.deleteJobCallable = + callableFactory.createUnaryCallable( + deleteJobTransportSettings, settings.deleteJobSettings(), clientContext); + this.deleteJobOperationCallable = + callableFactory.createOperationCallable( + deleteJobTransportSettings, + settings.deleteJobOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listJobsCallable = + callableFactory.createUnaryCallable( + listJobsTransportSettings, settings.listJobsSettings(), clientContext); + this.listJobsPagedCallable = + callableFactory.createPagedCallable( + listJobsTransportSettings, settings.listJobsSettings(), clientContext); + this.getTaskCallable = + callableFactory.createUnaryCallable( + getTaskTransportSettings, settings.getTaskSettings(), clientContext); + this.listTasksCallable = + callableFactory.createUnaryCallable( + listTasksTransportSettings, settings.listTasksSettings(), clientContext); + 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()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createJobMethodDescriptor); + methodDescriptors.add(getJobMethodDescriptor); + methodDescriptors.add(deleteJobMethodDescriptor); + 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; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createJobCallable() { + return createJobCallable; + } + + @Override + public UnaryCallable getJobCallable() { + return getJobCallable; + } + + @Override + public UnaryCallable deleteJobCallable() { + return deleteJobCallable; + } + + @Override + public OperationCallable + deleteJobOperationCallable() { + return deleteJobOperationCallable; + } + + @Override + public UnaryCallable listJobsCallable() { + return listJobsCallable; + } + + @Override + public UnaryCallable listJobsPagedCallable() { + return listJobsPagedCallable; + } + + @Override + public UnaryCallable getTaskCallable() { + return getTaskCallable; + } + + @Override + public UnaryCallable listTasksCallable() { + return listTasksCallable; + } + + @Override + public UnaryCallable listTasksPagedCallable() { + 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 { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientHttpJsonTest.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientHttpJsonTest.java index df13797..1c3885e 100644 --- a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientHttpJsonTest.java +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientHttpJsonTest.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.gax.core.NoCredentialsProvider; @@ -29,10 +30,24 @@ import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.rpc.testing.FakeStatusCode; import com.google.cloud.batch.v1.stub.HttpJsonBatchServiceStub; +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.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +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.Any; +import com.google.protobuf.ByteString; import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; import java.io.IOException; import java.util.ArrayList; @@ -599,4 +614,282 @@ public void listTasksExceptionTest2() throws Exception { // Expected exception. } } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getLocationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientTest.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientTest.java index 931d122..f096e59 100644 --- a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientTest.java +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/BatchServiceClientTest.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.gax.core.NoCredentialsProvider; @@ -27,11 +28,25 @@ import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.gax.rpc.StatusCode; +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.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +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.AbstractMessage; import com.google.protobuf.Any; +import com.google.protobuf.ByteString; import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; import io.grpc.StatusRuntimeException; import java.io.IOException; @@ -551,4 +566,253 @@ public void listTasksExceptionTest2() throws Exception { // Expected exception. } } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockLocations.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getFilter(), actualRequest.getFilter()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockLocations.addResponse(expectedResponse); + + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getLocationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockIAMPolicy.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIAMPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy()); + Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockIAMPolicy.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockIAMPolicy.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIAMPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getOptions(), actualRequest.getOptions()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockIAMPolicy.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockIAMPolicy.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIAMPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getPermissionsList(), actualRequest.getPermissionsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockIAMPolicy.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockIAMPolicyImpl.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockIAMPolicyImpl.java index 530cf4e..d5980a6 100644 --- a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockIAMPolicyImpl.java +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockIAMPolicyImpl.java @@ -17,8 +17,14 @@ package com.google.cloud.batch.v1; import com.google.api.core.BetaApi; +import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.IAMPolicyGrpc.IAMPolicyImplBase; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -56,4 +62,66 @@ public void reset() { requests = new ArrayList<>(); responses = new LinkedList<>(); } + + @Override + public void testIamPermissions( + TestIamPermissionsRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof TestIamPermissionsResponse) { + requests.add(request); + responseObserver.onNext(((TestIamPermissionsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method TestIamPermissions, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + TestIamPermissionsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void setIamPolicy(SetIamPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method SetIamPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getIamPolicy(GetIamPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetIamPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } } diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockLocationsImpl.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockLocationsImpl.java index 859767b..720c3c0 100644 --- a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockLocationsImpl.java +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1/MockLocationsImpl.java @@ -17,8 +17,13 @@ package com.google.cloud.batch.v1; import com.google.api.core.BetaApi; +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.cloud.location.LocationsGrpc.LocationsImplBase; import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -56,4 +61,45 @@ public void reset() { requests = new ArrayList<>(); responses = new LinkedList<>(); } + + @Override + public void listLocations( + ListLocationsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListLocationsResponse) { + requests.add(request); + responseObserver.onNext(((ListLocationsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListLocations, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListLocationsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getLocation(GetLocationRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Location) { + requests.add(request); + responseObserver.onNext(((Location) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetLocation, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Location.class.getName(), + Exception.class.getName()))); + } + } } diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientHttpJsonTest.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientHttpJsonTest.java new file mode 100644 index 0000000..4a5a75c --- /dev/null +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientHttpJsonTest.java @@ -0,0 +1,903 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha; + +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.batch.v1alpha.stub.HttpJsonBatchServiceStub; +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.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +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.Any; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class BatchServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static BatchServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonBatchServiceStub.getMethodDescriptors(), + BatchServiceSettings.getDefaultEndpoint()); + BatchServiceSettings settings = + BatchServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + BatchServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = BatchServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setUid("uid115792") + .setPriority(-1165461084) + .addAllTaskGroups(new ArrayList()) + .addAllDependencies(new ArrayList()) + .setAllocationPolicy(AllocationPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStatus(JobStatus.newBuilder().build()) + .setNotification(JobNotification.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLogsPolicy(LogsPolicy.newBuilder().build()) + .addAllNotifications(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Job job = Job.newBuilder().build(); + String jobId = "jobId101296568"; + + Job actualResponse = client.createJob(parent, job, jobId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Job job = Job.newBuilder().build(); + String jobId = "jobId101296568"; + client.createJob(parent, job, jobId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setUid("uid115792") + .setPriority(-1165461084) + .addAllTaskGroups(new ArrayList()) + .addAllDependencies(new ArrayList()) + .setAllocationPolicy(AllocationPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStatus(JobStatus.newBuilder().build()) + .setNotification(JobNotification.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLogsPolicy(LogsPolicy.newBuilder().build()) + .addAllNotifications(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Job job = Job.newBuilder().build(); + String jobId = "jobId101296568"; + + Job actualResponse = client.createJob(parent, job, jobId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Job job = Job.newBuilder().build(); + String jobId = "jobId101296568"; + client.createJob(parent, job, jobId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setUid("uid115792") + .setPriority(-1165461084) + .addAllTaskGroups(new ArrayList()) + .addAllDependencies(new ArrayList()) + .setAllocationPolicy(AllocationPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStatus(JobStatus.newBuilder().build()) + .setNotification(JobNotification.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLogsPolicy(LogsPolicy.newBuilder().build()) + .addAllNotifications(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.getJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setUid("uid115792") + .setPriority(-1165461084) + .addAllTaskGroups(new ArrayList()) + .addAllDependencies(new ArrayList()) + .setAllocationPolicy(AllocationPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStatus(JobStatus.newBuilder().build()) + .setNotification(JobNotification.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLogsPolicy(LogsPolicy.newBuilder().build()) + .addAllNotifications(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.getJob(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteJobTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + client.deleteJobAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.deleteJobAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listJobsTest() throws Exception { + Job responsesElement = Job.newBuilder().build(); + ListJobsResponse expectedResponse = + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listJobsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTaskTest() throws Exception { + Task expectedResponse = + Task.newBuilder() + .setName( + TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]") + .toString()) + .setStatus(TaskStatus.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]"); + + Task actualResponse = client.getTask(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getTaskExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TaskName name = TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]"); + client.getTask(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTaskTest2() throws Exception { + Task expectedResponse = + Task.newBuilder() + .setName( + TaskName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]", "[TASK]") + .toString()) + .setStatus(TaskStatus.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5433/locations/location-5433/jobs/job-5433/taskGroups/taskGroup-5433/tasks/task-5433"; + + Task actualResponse = client.getTask(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getTaskExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5433/locations/location-5433/jobs/job-5433/taskGroups/taskGroup-5433/tasks/task-5433"; + client.getTask(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTasksTest() throws Exception { + Task responsesElement = Task.newBuilder().build(); + ListTasksResponse expectedResponse = + ListTasksResponse.newBuilder() + .setNextPageToken("") + .addAllTasks(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + TaskGroupName parent = TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]"); + + ListTasksPagedResponse pagedListResponse = client.listTasks(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTasksList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTasksExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TaskGroupName parent = TaskGroupName.of("[PROJECT]", "[LOCATION]", "[JOB]", "[TASK_GROUP]"); + client.listTasks(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTasksTest2() throws Exception { + Task responsesElement = Task.newBuilder().build(); + ListTasksResponse expectedResponse = + ListTasksResponse.newBuilder() + .setNextPageToken("") + .addAllTasks(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-6196/locations/location-6196/jobs/job-6196/taskGroups/taskGroup-6196"; + + ListTasksPagedResponse pagedListResponse = client.listTasks(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTasksList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTasksExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-6196/locations/location-6196/jobs/job-6196/taskGroups/taskGroup-6196"; + client.listTasks(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("projects/project-3664") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getLocationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetLocationRequest request = + GetLocationRequest.newBuilder() + .setName("projects/project-9062/locations/location-9062") + .build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientTest.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientTest.java index e83ee93..e42a3b9 100644 --- a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientTest.java +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/BatchServiceClientTest.java @@ -17,6 +17,7 @@ package com.google.cloud.batch.v1alpha; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListJobsPagedResponse; +import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListLocationsPagedResponse; import static com.google.cloud.batch.v1alpha.BatchServiceClient.ListTasksPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; @@ -27,11 +28,25 @@ import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.gax.rpc.StatusCode; +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.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +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.AbstractMessage; import com.google.protobuf.Any; +import com.google.protobuf.ByteString; import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; import io.grpc.StatusRuntimeException; import java.io.IOException; @@ -52,6 +67,8 @@ @Generated("by gapic-generator-java") public class BatchServiceClientTest { private static MockBatchService mockBatchService; + private static MockIAMPolicy mockIAMPolicy; + private static MockLocations mockLocations; private static MockServiceHelper mockServiceHelper; private LocalChannelProvider channelProvider; private BatchServiceClient client; @@ -59,9 +76,12 @@ public class BatchServiceClientTest { @BeforeClass public static void startStaticServer() { mockBatchService = new MockBatchService(); + mockLocations = new MockLocations(); + mockIAMPolicy = new MockIAMPolicy(); mockServiceHelper = new MockServiceHelper( - UUID.randomUUID().toString(), Arrays.asList(mockBatchService)); + UUID.randomUUID().toString(), + Arrays.asList(mockBatchService, mockLocations, mockIAMPolicy)); mockServiceHelper.start(); } @@ -554,4 +574,253 @@ public void listTasksExceptionTest2() throws Exception { // Expected exception. } } + + @Test + public void listLocationsTest() throws Exception { + Location responsesElement = Location.newBuilder().build(); + ListLocationsResponse expectedResponse = + ListLocationsResponse.newBuilder() + .setNextPageToken("") + .addAllLocations(Arrays.asList(responsesElement)) + .build(); + mockLocations.addResponse(expectedResponse); + + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListLocationsPagedResponse pagedListResponse = client.listLocations(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getLocationsList().get(0), resources.get(0)); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getFilter(), actualRequest.getFilter()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listLocationsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listLocations(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getLocationTest() throws Exception { + Location expectedResponse = + Location.newBuilder() + .setName("name3373707") + .setLocationId("locationId1541836720") + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setMetadata(Any.newBuilder().build()) + .build(); + mockLocations.addResponse(expectedResponse); + + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + + Location actualResponse = client.getLocation(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockLocations.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getLocationExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockLocations.addException(exception); + + try { + GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build(); + client.getLocation(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockIAMPolicy.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIAMPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy()); + Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockIAMPolicy.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockIAMPolicy.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIAMPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getOptions(), actualRequest.getOptions()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockIAMPolicy.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockIAMPolicy.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockIAMPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getPermissionsList(), actualRequest.getPermissionsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockIAMPolicy.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockIAMPolicy.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockIAMPolicy.java new file mode 100644 index 0000000..a26aff3 --- /dev/null +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockIAMPolicy.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockIAMPolicy implements MockGrpcService { + private final MockIAMPolicyImpl serviceImpl; + + public MockIAMPolicy() { + serviceImpl = new MockIAMPolicyImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockIAMPolicyImpl.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockIAMPolicyImpl.java new file mode 100644 index 0000000..604cd3a --- /dev/null +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockIAMPolicyImpl.java @@ -0,0 +1,127 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha; + +import com.google.api.core.BetaApi; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.IAMPolicyGrpc.IAMPolicyImplBase; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockIAMPolicyImpl extends IAMPolicyImplBase { + private List requests; + private Queue responses; + + public MockIAMPolicyImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void testIamPermissions( + TestIamPermissionsRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof TestIamPermissionsResponse) { + requests.add(request); + responseObserver.onNext(((TestIamPermissionsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method TestIamPermissions, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + TestIamPermissionsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void setIamPolicy(SetIamPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method SetIamPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getIamPolicy(GetIamPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetIamPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockLocations.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockLocations.java new file mode 100644 index 0000000..06ca438 --- /dev/null +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocations implements MockGrpcService { + private final MockLocationsImpl serviceImpl; + + public MockLocations() { + serviceImpl = new MockLocationsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockLocationsImpl.java b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockLocationsImpl.java new file mode 100644 index 0000000..e9dc09b --- /dev/null +++ b/google-cloud-batch/src/test/java/com/google/cloud/batch/v1alpha/MockLocationsImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.batch.v1alpha; + +import com.google.api.core.BetaApi; +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.cloud.location.LocationsGrpc.LocationsImplBase; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocationsImpl extends LocationsImplBase { + private List requests; + private Queue responses; + + public MockLocationsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listLocations( + ListLocationsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListLocationsResponse) { + requests.add(request); + responseObserver.onNext(((ListLocationsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListLocations, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListLocationsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getLocation(GetLocationRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Location) { + requests.add(request); + responseObserver.onNext(((Location) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetLocation, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Location.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/AllocationPolicy.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/AllocationPolicy.java index 31c0d7a..7d5cfc7 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/AllocationPolicy.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/AllocationPolicy.java @@ -382,12 +382,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -399,12 +405,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -416,12 +428,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -434,12 +452,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -549,12 +573,18 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -568,12 +598,18 @@ public com.google.protobuf.ProtocolStringList getAllowedLocationsList() { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -587,12 +623,18 @@ public int getAllowedLocationsCount() { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -607,12 +649,18 @@ public java.lang.String getAllowedLocations(int index) { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -972,12 +1020,18 @@ private void ensureAllowedLocationsIsMutable() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -991,12 +1045,18 @@ public com.google.protobuf.ProtocolStringList getAllowedLocationsList() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1010,12 +1070,18 @@ public int getAllowedLocationsCount() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1030,12 +1096,18 @@ public java.lang.String getAllowedLocations(int index) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1050,12 +1122,18 @@ public com.google.protobuf.ByteString getAllowedLocationsBytes(int index) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1077,12 +1155,18 @@ public Builder setAllowedLocations(int index, java.lang.String value) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1103,12 +1187,18 @@ public Builder addAllowedLocations(java.lang.String value) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1126,12 +1216,18 @@ public Builder addAllAllowedLocations(java.lang.Iterable value * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1148,12 +1244,18 @@ public Builder clearAllowedLocations() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1308,7 +1410,7 @@ public interface DiskOrBuilder * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -1321,7 +1423,7 @@ public interface DiskOrBuilder * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -1336,6 +1438,8 @@ public interface DiskOrBuilder *
      * Disk size in GB.
      * This field is ignored if `data_source` is `disk` or `image`.
+     * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+     * otherwise, the final size will be the next greater multiple of 375 GB.
      * 
* * int64 size_gb = 2; @@ -1344,13 +1448,45 @@ public interface DiskOrBuilder */ long getSizeGb(); + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The diskInterface. + */ + java.lang.String getDiskInterface(); + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The bytes for diskInterface. + */ + com.google.protobuf.ByteString getDiskInterfaceBytes(); + public com.google.cloud.batch.v1.AllocationPolicy.Disk.DataSourceCase getDataSourceCase(); } /** * * *
-   * A new persistent disk.
+   * A new persistent disk or a local ssd.
+   * A VM can only have one local SSD setting but multiple local SSD partitions.
+   * https://cloud.google.com/compute/docs/disks#pdspecs.
+   * https://cloud.google.com/compute/docs/disks#localssds.
    * 
* * Protobuf type {@code google.cloud.batch.v1.AllocationPolicy.Disk} @@ -1367,6 +1503,7 @@ private Disk(com.google.protobuf.GeneratedMessageV3.Builder builder) { private Disk() { type_ = ""; + diskInterface_ = ""; } @java.lang.Override @@ -1424,6 +1561,13 @@ private Disk( dataSource_ = s; break; } + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + + diskInterface_ = s; + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -1654,7 +1798,7 @@ public com.google.protobuf.ByteString getSnapshotBytes() { * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -1678,7 +1822,7 @@ public java.lang.String getType() { * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -1706,6 +1850,8 @@ public com.google.protobuf.ByteString getTypeBytes() { *
      * Disk size in GB.
      * This field is ignored if `data_source` is `disk` or `image`.
+     * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+     * otherwise, the final size will be the next greater multiple of 375 GB.
      * 
* * int64 size_gb = 2; @@ -1717,6 +1863,59 @@ public long getSizeGb() { return sizeGb_; } + public static final int DISK_INTERFACE_FIELD_NUMBER = 6; + private volatile java.lang.Object diskInterface_; + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The diskInterface. + */ + @java.lang.Override + public java.lang.String getDiskInterface() { + java.lang.Object ref = diskInterface_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + diskInterface_ = s; + return s; + } + } + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The bytes for diskInterface. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDiskInterfaceBytes() { + java.lang.Object ref = diskInterface_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + diskInterface_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1743,6 +1942,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (dataSourceCase_ == 5) { com.google.protobuf.GeneratedMessageV3.writeString(output, 5, dataSource_); } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(diskInterface_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, diskInterface_); + } unknownFields.writeTo(output); } @@ -1764,6 +1966,9 @@ public int getSerializedSize() { if (dataSourceCase_ == 5) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, dataSource_); } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(diskInterface_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, diskInterface_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1782,6 +1987,7 @@ public boolean equals(final java.lang.Object obj) { if (!getType().equals(other.getType())) return false; if (getSizeGb() != other.getSizeGb()) return false; + if (!getDiskInterface().equals(other.getDiskInterface())) return false; if (!getDataSourceCase().equals(other.getDataSourceCase())) return false; switch (dataSourceCase_) { case 4: @@ -1808,6 +2014,8 @@ public int hashCode() { hash = (53 * hash) + getType().hashCode(); hash = (37 * hash) + SIZE_GB_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSizeGb()); + hash = (37 * hash) + DISK_INTERFACE_FIELD_NUMBER; + hash = (53 * hash) + getDiskInterface().hashCode(); switch (dataSourceCase_) { case 4: hash = (37 * hash) + IMAGE_FIELD_NUMBER; @@ -1925,7 +2133,10 @@ protected Builder newBuilderForType( * * *
-     * A new persistent disk.
+     * A new persistent disk or a local ssd.
+     * A VM can only have one local SSD setting but multiple local SSD partitions.
+     * https://cloud.google.com/compute/docs/disks#pdspecs.
+     * https://cloud.google.com/compute/docs/disks#localssds.
      * 
* * Protobuf type {@code google.cloud.batch.v1.AllocationPolicy.Disk} @@ -1971,6 +2182,8 @@ public Builder clear() { sizeGb_ = 0L; + diskInterface_ = ""; + dataSourceCase_ = 0; dataSource_ = null; return this; @@ -2008,6 +2221,7 @@ public com.google.cloud.batch.v1.AllocationPolicy.Disk buildPartial() { } result.type_ = type_; result.sizeGb_ = sizeGb_; + result.diskInterface_ = diskInterface_; result.dataSourceCase_ = dataSourceCase_; onBuilt(); return result; @@ -2068,6 +2282,10 @@ public Builder mergeFrom(com.google.cloud.batch.v1.AllocationPolicy.Disk other) if (other.getSizeGb() != 0L) { setSizeGb(other.getSizeGb()); } + if (!other.getDiskInterface().isEmpty()) { + diskInterface_ = other.diskInterface_; + onChanged(); + } switch (other.getDataSourceCase()) { case IMAGE: { @@ -2406,7 +2624,7 @@ public Builder setSnapshotBytes(com.google.protobuf.ByteString value) { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2429,7 +2647,7 @@ public java.lang.String getType() { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2452,7 +2670,7 @@ public com.google.protobuf.ByteString getTypeBytes() { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2474,7 +2692,7 @@ public Builder setType(java.lang.String value) { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2492,7 +2710,7 @@ public Builder clearType() { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2518,6 +2736,8 @@ public Builder setTypeBytes(com.google.protobuf.ByteString value) { *
        * Disk size in GB.
        * This field is ignored if `data_source` is `disk` or `image`.
+       * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+       * otherwise, the final size will be the next greater multiple of 375 GB.
        * 
* * int64 size_gb = 2; @@ -2534,6 +2754,8 @@ public long getSizeGb() { *
        * Disk size in GB.
        * This field is ignored if `data_source` is `disk` or `image`.
+       * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+       * otherwise, the final size will be the next greater multiple of 375 GB.
        * 
* * int64 size_gb = 2; @@ -2553,6 +2775,8 @@ public Builder setSizeGb(long value) { *
        * Disk size in GB.
        * This field is ignored if `data_source` is `disk` or `image`.
+       * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+       * otherwise, the final size will be the next greater multiple of 375 GB.
        * 
* * int64 size_gb = 2; @@ -2566,6 +2790,122 @@ public Builder clearSizeGb() { return this; } + private java.lang.Object diskInterface_ = ""; + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @return The diskInterface. + */ + public java.lang.String getDiskInterface() { + java.lang.Object ref = diskInterface_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + diskInterface_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @return The bytes for diskInterface. + */ + public com.google.protobuf.ByteString getDiskInterfaceBytes() { + java.lang.Object ref = diskInterface_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + diskInterface_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @param value The diskInterface to set. + * @return This builder for chaining. + */ + public Builder setDiskInterface(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + diskInterface_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @return This builder for chaining. + */ + public Builder clearDiskInterface() { + + diskInterface_ = getDefaultInstance().getDiskInterface(); + onChanged(); + return this; + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @param value The bytes for diskInterface to set. + * @return This builder for chaining. + */ + public Builder setDiskInterfaceBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + diskInterface_ = value; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -2708,7 +3048,8 @@ public interface AttachedDiskOrBuilder * * *
-   * A new or an existing persistent disk attached to a VM instance.
+   * A new or an existing persistent disk or a local ssd attached to a VM
+   * instance.
    * 
* * Protobuf type {@code google.cloud.batch.v1.AllocationPolicy.AttachedDisk} @@ -3225,7 +3566,8 @@ protected Builder newBuilderForType( * * *
-     * A new or an existing persistent disk attached to a VM instance.
+     * A new or an existing persistent disk or a local ssd attached to a VM
+     * instance.
      * 
* * Protobuf type {@code google.cloud.batch.v1.AllocationPolicy.AttachedDisk} @@ -3912,6 +4254,23 @@ public interface AcceleratorOrBuilder * @return The count. */ long getCount(); + + /** + * + * + *
+     * When true, Batch will install the GPU drivers.
+     * This field will be ignored if specified.
+     * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1/job.proto;l=291 + * @return The installGpuDrivers. + */ + @java.lang.Deprecated + boolean getInstallGpuDrivers(); } /** * @@ -3977,6 +4336,11 @@ private Accelerator( count_ = input.readInt64(); break; } + case 24: + { + installGpuDrivers_ = input.readBool(); + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -4082,6 +4446,28 @@ public long getCount() { return count_; } + public static final int INSTALL_GPU_DRIVERS_FIELD_NUMBER = 3; + private boolean installGpuDrivers_; + /** + * + * + *
+     * When true, Batch will install the GPU drivers.
+     * This field will be ignored if specified.
+     * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1/job.proto;l=291 + * @return The installGpuDrivers. + */ + @java.lang.Override + @java.lang.Deprecated + public boolean getInstallGpuDrivers() { + return installGpuDrivers_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -4102,6 +4488,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (count_ != 0L) { output.writeInt64(2, count_); } + if (installGpuDrivers_ != false) { + output.writeBool(3, installGpuDrivers_); + } unknownFields.writeTo(output); } @@ -4117,6 +4506,9 @@ public int getSerializedSize() { if (count_ != 0L) { size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, count_); } + if (installGpuDrivers_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, installGpuDrivers_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -4135,6 +4527,7 @@ public boolean equals(final java.lang.Object obj) { if (!getType().equals(other.getType())) return false; if (getCount() != other.getCount()) return false; + if (getInstallGpuDrivers() != other.getInstallGpuDrivers()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -4150,6 +4543,8 @@ public int hashCode() { hash = (53 * hash) + getType().hashCode(); hash = (37 * hash) + COUNT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getCount()); + hash = (37 * hash) + INSTALL_GPU_DRIVERS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getInstallGpuDrivers()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -4302,6 +4697,8 @@ public Builder clear() { count_ = 0L; + installGpuDrivers_ = false; + return this; } @@ -4331,6 +4728,7 @@ public com.google.cloud.batch.v1.AllocationPolicy.Accelerator buildPartial() { new com.google.cloud.batch.v1.AllocationPolicy.Accelerator(this); result.type_ = type_; result.count_ = count_; + result.installGpuDrivers_ = installGpuDrivers_; onBuilt(); return result; } @@ -4390,6 +4788,9 @@ public Builder mergeFrom(com.google.cloud.batch.v1.AllocationPolicy.Accelerator if (other.getCount() != 0L) { setCount(other.getCount()); } + if (other.getInstallGpuDrivers() != false) { + setInstallGpuDrivers(other.getInstallGpuDrivers()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -4583,6 +4984,70 @@ public Builder clearCount() { return this; } + private boolean installGpuDrivers_; + /** + * + * + *
+       * When true, Batch will install the GPU drivers.
+       * This field will be ignored if specified.
+       * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1/job.proto;l=291 + * @return The installGpuDrivers. + */ + @java.lang.Override + @java.lang.Deprecated + public boolean getInstallGpuDrivers() { + return installGpuDrivers_; + } + /** + * + * + *
+       * When true, Batch will install the GPU drivers.
+       * This field will be ignored if specified.
+       * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1/job.proto;l=291 + * @param value The installGpuDrivers to set. + * @return This builder for chaining. + */ + @java.lang.Deprecated + public Builder setInstallGpuDrivers(boolean value) { + + installGpuDrivers_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * When true, Batch will install the GPU drivers.
+       * This field will be ignored if specified.
+       * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1/job.proto;l=291 + * @return This builder for chaining. + */ + @java.lang.Deprecated + public Builder clearInstallGpuDrivers() { + + installGpuDrivers_ = false; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/JobProto.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/JobProto.java index ae4cc63..3135f0b 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/JobProto.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/JobProto.java @@ -176,7 +176,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "tate\022?\n\016new_task_state\030\003 \001(\0162\'.google.cl" + "oud.batch.v1.TaskStatus.State\"K\n\004Type\022\024\n" + "\020TYPE_UNSPECIFIED\020\000\022\025\n\021JOB_STATE_CHANGED" - + "\020\001\022\026\n\022TASK_STATE_CHANGED\020\002\"\221\013\n\020Allocatio" + + "\020\001\022\026\n\022TASK_STATE_CHANGED\020\002\"\312\013\n\020Allocatio" + "nPolicy\022H\n\010location\030\001 \001(\01326.google.cloud" + ".batch.v1.AllocationPolicy.LocationPolic" + "y\022S\n\tinstances\030\010 \003(\0132@.google.cloud.batc" @@ -185,48 +185,50 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "tch.v1.AllocationPolicy.LabelsEntry\022F\n\007n" + "etwork\030\007 \001(\01325.google.cloud.batch.v1.All" + "ocationPolicy.NetworkPolicy\032+\n\016LocationP" - + "olicy\022\031\n\021allowed_locations\030\001 \003(\t\032Y\n\004Disk" + + "olicy\022\031\n\021allowed_locations\030\001 \003(\t\032q\n\004Disk" + "\022\017\n\005image\030\004 \001(\tH\000\022\022\n\010snapshot\030\005 \001(\tH\000\022\014\n" - + "\004type\030\001 \001(\t\022\017\n\007size_gb\030\002 \001(\003B\r\n\013data_sou" - + "rce\032\212\001\n\014AttachedDisk\022@\n\010new_disk\030\001 \001(\0132," - + ".google.cloud.batch.v1.AllocationPolicy." - + "DiskH\000\022\027\n\rexisting_disk\030\002 \001(\tH\000\022\023\n\013devic" - + "e_name\030\003 \001(\tB\n\n\010attached\032*\n\013Accelerator\022" - + "\014\n\004type\030\001 \001(\t\022\r\n\005count\030\002 \001(\003\032\247\002\n\016Instanc" - + "ePolicy\022\024\n\014machine_type\030\002 \001(\t\022\030\n\020min_cpu" - + "_platform\030\003 \001(\t\022U\n\022provisioning_model\030\004 " - + "\001(\01629.google.cloud.batch.v1.AllocationPo" - + "licy.ProvisioningModel\022I\n\014accelerators\030\005" - + " \003(\01323.google.cloud.batch.v1.AllocationP" - + "olicy.Accelerator\022C\n\005disks\030\006 \003(\01324.googl" - + "e.cloud.batch.v1.AllocationPolicy.Attach" - + "edDisk\032\224\001\n\030InstancePolicyOrTemplate\022H\n\006p" - + "olicy\030\001 \001(\01326.google.cloud.batch.v1.Allo" - + "cationPolicy.InstancePolicyH\000\022\033\n\021instanc" - + "e_template\030\002 \001(\tH\000B\021\n\017policy_template\032W\n" - + "\020NetworkInterface\022\017\n\007network\030\001 \001(\t\022\022\n\nsu" - + "bnetwork\030\002 \001(\t\022\036\n\026no_external_ip_address" - + "\030\003 \001(\010\032e\n\rNetworkPolicy\022T\n\022network_inter" - + "faces\030\001 \003(\01328.google.cloud.batch.v1.Allo" - + "cationPolicy.NetworkInterface\032-\n\013LabelsE" - + "ntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"`\n\021" - + "ProvisioningModel\022\"\n\036PROVISIONING_MODEL_" - + "UNSPECIFIED\020\000\022\014\n\010STANDARD\020\001\022\010\n\004SPOT\020\002\022\017\n" - + "\013PREEMPTIBLE\020\003\"\201\003\n\tTaskGroup\022\021\n\004name\030\001 \001" - + "(\tB\003\340A\003\0227\n\ttask_spec\030\003 \001(\0132\037.google.clou" - + "d.batch.v1.TaskSpecB\003\340A\002\022\022\n\ntask_count\030\004" - + " \001(\003\022\023\n\013parallelism\030\005 \001(\003\022=\n\021task_enviro" - + "nments\030\t \003(\0132\".google.cloud.batch.v1.Env" - + "ironment\022\033\n\023task_count_per_node\030\n \001(\003\022\032\n" - + "\022require_hosts_file\030\013 \001(\010\022\026\n\016permissive_" - + "ssh\030\014 \001(\010:o\352Al\n\036batch.googleapis.com/Tas" - + "kGroup\022Jprojects/{project}/locations/{lo" - + "cation}/jobs/{job}/taskGroups/{task_grou" - + "p}B\264\001\n\031com.google.cloud.batch.v1B\010JobPro" - + "toP\001Z:google.golang.org/genproto/googlea" - + "pis/cloud/batch/v1;batch\242\002\003GCB\252\002\025Google." - + "Cloud.Batch.V1\312\002\025Google\\Cloud\\Batch\\V1\352\002" - + "\030Google::Cloud::Batch::V1b\006proto3" + + "\004type\030\001 \001(\t\022\017\n\007size_gb\030\002 \001(\003\022\026\n\016disk_int" + + "erface\030\006 \001(\tB\r\n\013data_source\032\212\001\n\014Attached" + + "Disk\022@\n\010new_disk\030\001 \001(\0132,.google.cloud.ba" + + "tch.v1.AllocationPolicy.DiskH\000\022\027\n\rexisti" + + "ng_disk\030\002 \001(\tH\000\022\023\n\013device_name\030\003 \001(\tB\n\n\010" + + "attached\032K\n\013Accelerator\022\014\n\004type\030\001 \001(\t\022\r\n" + + "\005count\030\002 \001(\003\022\037\n\023install_gpu_drivers\030\003 \001(" + + "\010B\002\030\001\032\247\002\n\016InstancePolicy\022\024\n\014machine_type" + + "\030\002 \001(\t\022\030\n\020min_cpu_platform\030\003 \001(\t\022U\n\022prov" + + "isioning_model\030\004 \001(\01629.google.cloud.batc" + + "h.v1.AllocationPolicy.ProvisioningModel\022" + + "I\n\014accelerators\030\005 \003(\01323.google.cloud.bat" + + "ch.v1.AllocationPolicy.Accelerator\022C\n\005di" + + "sks\030\006 \003(\01324.google.cloud.batch.v1.Alloca" + + "tionPolicy.AttachedDisk\032\224\001\n\030InstancePoli" + + "cyOrTemplate\022H\n\006policy\030\001 \001(\01326.google.cl" + + "oud.batch.v1.AllocationPolicy.InstancePo" + + "licyH\000\022\033\n\021instance_template\030\002 \001(\tH\000B\021\n\017p" + + "olicy_template\032W\n\020NetworkInterface\022\017\n\007ne" + + "twork\030\001 \001(\t\022\022\n\nsubnetwork\030\002 \001(\t\022\036\n\026no_ex" + + "ternal_ip_address\030\003 \001(\010\032e\n\rNetworkPolicy" + + "\022T\n\022network_interfaces\030\001 \003(\01328.google.cl" + + "oud.batch.v1.AllocationPolicy.NetworkInt" + + "erface\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005va" + + "lue\030\002 \001(\t:\0028\001\"`\n\021ProvisioningModel\022\"\n\036PR" + + "OVISIONING_MODEL_UNSPECIFIED\020\000\022\014\n\010STANDA" + + "RD\020\001\022\010\n\004SPOT\020\002\022\017\n\013PREEMPTIBLE\020\003\"\201\003\n\tTask" + + "Group\022\021\n\004name\030\001 \001(\tB\003\340A\003\0227\n\ttask_spec\030\003 " + + "\001(\0132\037.google.cloud.batch.v1.TaskSpecB\003\340A" + + "\002\022\022\n\ntask_count\030\004 \001(\003\022\023\n\013parallelism\030\005 \001" + + "(\003\022=\n\021task_environments\030\t \003(\0132\".google.c" + + "loud.batch.v1.Environment\022\033\n\023task_count_" + + "per_node\030\n \001(\003\022\032\n\022require_hosts_file\030\013 \001" + + "(\010\022\026\n\016permissive_ssh\030\014 \001(\010:o\352Al\n\036batch.g" + + "oogleapis.com/TaskGroup\022Jprojects/{proje" + + "ct}/locations/{location}/jobs/{job}/task" + + "Groups/{task_group}B\264\001\n\031com.google.cloud" + + ".batch.v1B\010JobProtoP\001Z:google.golang.org" + + "/genproto/googleapis/cloud/batch/v1;batc" + + "h\242\002\003GCB\252\002\025Google.Cloud.Batch.V1\312\002\025Google" + + "\\Cloud\\Batch\\V1\352\002\030Google::Cloud::Batch::" + + "V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -351,7 +353,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_batch_v1_AllocationPolicy_Disk_descriptor, new java.lang.String[] { - "Image", "Snapshot", "Type", "SizeGb", "DataSource", + "Image", "Snapshot", "Type", "SizeGb", "DiskInterface", "DataSource", }); internal_static_google_cloud_batch_v1_AllocationPolicy_AttachedDisk_descriptor = internal_static_google_cloud_batch_v1_AllocationPolicy_descriptor.getNestedTypes().get(2); @@ -367,7 +369,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_batch_v1_AllocationPolicy_Accelerator_descriptor, new java.lang.String[] { - "Type", "Count", + "Type", "Count", "InstallGpuDrivers", }); internal_static_google_cloud_batch_v1_AllocationPolicy_InstancePolicy_descriptor = internal_static_google_cloud_batch_v1_AllocationPolicy_descriptor.getNestedTypes().get(4); diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/Runnable.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/Runnable.java index c42b894..a639ec3 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/Runnable.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/Runnable.java @@ -131,6 +131,37 @@ private Runnable( executable_ = subBuilder.buildPartial(); } executableCase_ = 6; + break; + } + case 58: + { + com.google.cloud.batch.v1.Environment.Builder subBuilder = null; + if (environment_ != null) { + subBuilder = environment_.toBuilder(); + } + environment_ = + input.readMessage( + com.google.cloud.batch.v1.Environment.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(environment_); + environment_ = subBuilder.buildPartial(); + } + + break; + } + case 66: + { + com.google.protobuf.Duration.Builder subBuilder = null; + if (timeout_ != null) { + subBuilder = timeout_.toBuilder(); + } + timeout_ = + input.readMessage(com.google.protobuf.Duration.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(timeout_); + timeout_ = subBuilder.buildPartial(); + } + break; } default: @@ -4518,6 +4549,103 @@ public boolean getAlwaysRun() { return alwaysRun_; } + public static final int ENVIRONMENT_FIELD_NUMBER = 7; + private com.google.cloud.batch.v1.Environment environment_; + /** + * + * + *
+   * Environment variables for this Runnable (overrides variables set for the
+   * whole Task or TaskGroup).
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + * + * @return Whether the environment field is set. + */ + @java.lang.Override + public boolean hasEnvironment() { + return environment_ != null; + } + /** + * + * + *
+   * Environment variables for this Runnable (overrides variables set for the
+   * whole Task or TaskGroup).
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + * + * @return The environment. + */ + @java.lang.Override + public com.google.cloud.batch.v1.Environment getEnvironment() { + return environment_ == null + ? com.google.cloud.batch.v1.Environment.getDefaultInstance() + : environment_; + } + /** + * + * + *
+   * Environment variables for this Runnable (overrides variables set for the
+   * whole Task or TaskGroup).
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + @java.lang.Override + public com.google.cloud.batch.v1.EnvironmentOrBuilder getEnvironmentOrBuilder() { + return getEnvironment(); + } + + public static final int TIMEOUT_FIELD_NUMBER = 8; + private com.google.protobuf.Duration timeout_; + /** + * + * + *
+   * Timeout for this Runnable.
+   * 
+ * + * .google.protobuf.Duration timeout = 8; + * + * @return Whether the timeout field is set. + */ + @java.lang.Override + public boolean hasTimeout() { + return timeout_ != null; + } + /** + * + * + *
+   * Timeout for this Runnable.
+   * 
+ * + * .google.protobuf.Duration timeout = 8; + * + * @return The timeout. + */ + @java.lang.Override + public com.google.protobuf.Duration getTimeout() { + return timeout_ == null ? com.google.protobuf.Duration.getDefaultInstance() : timeout_; + } + /** + * + * + *
+   * Timeout for this Runnable.
+   * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getTimeoutOrBuilder() { + return getTimeout(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -4550,6 +4678,12 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (executableCase_ == 6) { output.writeMessage(6, (com.google.cloud.batch.v1.Runnable.Barrier) executable_); } + if (environment_ != null) { + output.writeMessage(7, getEnvironment()); + } + if (timeout_ != null) { + output.writeMessage(8, getTimeout()); + } unknownFields.writeTo(output); } @@ -4583,6 +4717,12 @@ public int getSerializedSize() { com.google.protobuf.CodedOutputStream.computeMessageSize( 6, (com.google.cloud.batch.v1.Runnable.Barrier) executable_); } + if (environment_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getEnvironment()); + } + if (timeout_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getTimeout()); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -4601,6 +4741,14 @@ public boolean equals(final java.lang.Object obj) { if (getIgnoreExitStatus() != other.getIgnoreExitStatus()) return false; if (getBackground() != other.getBackground()) return false; if (getAlwaysRun() != other.getAlwaysRun()) return false; + if (hasEnvironment() != other.hasEnvironment()) return false; + if (hasEnvironment()) { + if (!getEnvironment().equals(other.getEnvironment())) return false; + } + if (hasTimeout() != other.hasTimeout()) return false; + if (hasTimeout()) { + if (!getTimeout().equals(other.getTimeout())) return false; + } if (!getExecutableCase().equals(other.getExecutableCase())) return false; switch (executableCase_) { case 1: @@ -4632,6 +4780,14 @@ public int hashCode() { hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getBackground()); hash = (37 * hash) + ALWAYS_RUN_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getAlwaysRun()); + if (hasEnvironment()) { + hash = (37 * hash) + ENVIRONMENT_FIELD_NUMBER; + hash = (53 * hash) + getEnvironment().hashCode(); + } + if (hasTimeout()) { + hash = (37 * hash) + TIMEOUT_FIELD_NUMBER; + hash = (53 * hash) + getTimeout().hashCode(); + } switch (executableCase_) { case 1: hash = (37 * hash) + CONTAINER_FIELD_NUMBER; @@ -4799,6 +4955,18 @@ public Builder clear() { alwaysRun_ = false; + if (environmentBuilder_ == null) { + environment_ = null; + } else { + environment_ = null; + environmentBuilder_ = null; + } + if (timeoutBuilder_ == null) { + timeout_ = null; + } else { + timeout_ = null; + timeoutBuilder_ = null; + } executableCase_ = 0; executable_ = null; return this; @@ -4851,6 +5019,16 @@ public com.google.cloud.batch.v1.Runnable buildPartial() { result.ignoreExitStatus_ = ignoreExitStatus_; result.background_ = background_; result.alwaysRun_ = alwaysRun_; + if (environmentBuilder_ == null) { + result.environment_ = environment_; + } else { + result.environment_ = environmentBuilder_.build(); + } + if (timeoutBuilder_ == null) { + result.timeout_ = timeout_; + } else { + result.timeout_ = timeoutBuilder_.build(); + } result.executableCase_ = executableCase_; onBuilt(); return result; @@ -4910,6 +5088,12 @@ public Builder mergeFrom(com.google.cloud.batch.v1.Runnable other) { if (other.getAlwaysRun() != false) { setAlwaysRun(other.getAlwaysRun()); } + if (other.hasEnvironment()) { + mergeEnvironment(other.getEnvironment()); + } + if (other.hasTimeout()) { + mergeTimeout(other.getTimeout()); + } switch (other.getExecutableCase()) { case CONTAINER: { @@ -5785,6 +5969,379 @@ public Builder clearAlwaysRun() { return this; } + private com.google.cloud.batch.v1.Environment environment_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.batch.v1.Environment, + com.google.cloud.batch.v1.Environment.Builder, + com.google.cloud.batch.v1.EnvironmentOrBuilder> + environmentBuilder_; + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + * + * @return Whether the environment field is set. + */ + public boolean hasEnvironment() { + return environmentBuilder_ != null || environment_ != null; + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + * + * @return The environment. + */ + public com.google.cloud.batch.v1.Environment getEnvironment() { + if (environmentBuilder_ == null) { + return environment_ == null + ? com.google.cloud.batch.v1.Environment.getDefaultInstance() + : environment_; + } else { + return environmentBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + public Builder setEnvironment(com.google.cloud.batch.v1.Environment value) { + if (environmentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + environment_ = value; + onChanged(); + } else { + environmentBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + public Builder setEnvironment(com.google.cloud.batch.v1.Environment.Builder builderForValue) { + if (environmentBuilder_ == null) { + environment_ = builderForValue.build(); + onChanged(); + } else { + environmentBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + public Builder mergeEnvironment(com.google.cloud.batch.v1.Environment value) { + if (environmentBuilder_ == null) { + if (environment_ != null) { + environment_ = + com.google.cloud.batch.v1.Environment.newBuilder(environment_) + .mergeFrom(value) + .buildPartial(); + } else { + environment_ = value; + } + onChanged(); + } else { + environmentBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + public Builder clearEnvironment() { + if (environmentBuilder_ == null) { + environment_ = null; + onChanged(); + } else { + environment_ = null; + environmentBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + public com.google.cloud.batch.v1.Environment.Builder getEnvironmentBuilder() { + + onChanged(); + return getEnvironmentFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + public com.google.cloud.batch.v1.EnvironmentOrBuilder getEnvironmentOrBuilder() { + if (environmentBuilder_ != null) { + return environmentBuilder_.getMessageOrBuilder(); + } else { + return environment_ == null + ? com.google.cloud.batch.v1.Environment.getDefaultInstance() + : environment_; + } + } + /** + * + * + *
+     * Environment variables for this Runnable (overrides variables set for the
+     * whole Task or TaskGroup).
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.batch.v1.Environment, + com.google.cloud.batch.v1.Environment.Builder, + com.google.cloud.batch.v1.EnvironmentOrBuilder> + getEnvironmentFieldBuilder() { + if (environmentBuilder_ == null) { + environmentBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.batch.v1.Environment, + com.google.cloud.batch.v1.Environment.Builder, + com.google.cloud.batch.v1.EnvironmentOrBuilder>( + getEnvironment(), getParentForChildren(), isClean()); + environment_ = null; + } + return environmentBuilder_; + } + + private com.google.protobuf.Duration timeout_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + timeoutBuilder_; + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + * + * @return Whether the timeout field is set. + */ + public boolean hasTimeout() { + return timeoutBuilder_ != null || timeout_ != null; + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + * + * @return The timeout. + */ + public com.google.protobuf.Duration getTimeout() { + if (timeoutBuilder_ == null) { + return timeout_ == null ? com.google.protobuf.Duration.getDefaultInstance() : timeout_; + } else { + return timeoutBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + public Builder setTimeout(com.google.protobuf.Duration value) { + if (timeoutBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + timeout_ = value; + onChanged(); + } else { + timeoutBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + public Builder setTimeout(com.google.protobuf.Duration.Builder builderForValue) { + if (timeoutBuilder_ == null) { + timeout_ = builderForValue.build(); + onChanged(); + } else { + timeoutBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + public Builder mergeTimeout(com.google.protobuf.Duration value) { + if (timeoutBuilder_ == null) { + if (timeout_ != null) { + timeout_ = + com.google.protobuf.Duration.newBuilder(timeout_).mergeFrom(value).buildPartial(); + } else { + timeout_ = value; + } + onChanged(); + } else { + timeoutBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + public Builder clearTimeout() { + if (timeoutBuilder_ == null) { + timeout_ = null; + onChanged(); + } else { + timeout_ = null; + timeoutBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + public com.google.protobuf.Duration.Builder getTimeoutBuilder() { + + onChanged(); + return getTimeoutFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + public com.google.protobuf.DurationOrBuilder getTimeoutOrBuilder() { + if (timeoutBuilder_ != null) { + return timeoutBuilder_.getMessageOrBuilder(); + } else { + return timeout_ == null ? com.google.protobuf.Duration.getDefaultInstance() : timeout_; + } + } + /** + * + * + *
+     * Timeout for this Runnable.
+     * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + getTimeoutFieldBuilder() { + if (timeoutBuilder_ == null) { + timeoutBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getTimeout(), getParentForChildren(), isClean()); + timeout_ = null; + } + return timeoutBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/RunnableOrBuilder.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/RunnableOrBuilder.java index 46bcb99..3cd7c53 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/RunnableOrBuilder.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/RunnableOrBuilder.java @@ -176,5 +176,78 @@ public interface RunnableOrBuilder */ boolean getAlwaysRun(); + /** + * + * + *
+   * Environment variables for this Runnable (overrides variables set for the
+   * whole Task or TaskGroup).
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + * + * @return Whether the environment field is set. + */ + boolean hasEnvironment(); + /** + * + * + *
+   * Environment variables for this Runnable (overrides variables set for the
+   * whole Task or TaskGroup).
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + * + * @return The environment. + */ + com.google.cloud.batch.v1.Environment getEnvironment(); + /** + * + * + *
+   * Environment variables for this Runnable (overrides variables set for the
+   * whole Task or TaskGroup).
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 7; + */ + com.google.cloud.batch.v1.EnvironmentOrBuilder getEnvironmentOrBuilder(); + + /** + * + * + *
+   * Timeout for this Runnable.
+   * 
+ * + * .google.protobuf.Duration timeout = 8; + * + * @return Whether the timeout field is set. + */ + boolean hasTimeout(); + /** + * + * + *
+   * Timeout for this Runnable.
+   * 
+ * + * .google.protobuf.Duration timeout = 8; + * + * @return The timeout. + */ + com.google.protobuf.Duration getTimeout(); + /** + * + * + *
+   * Timeout for this Runnable.
+   * 
+ * + * .google.protobuf.Duration timeout = 8; + */ + com.google.protobuf.DurationOrBuilder getTimeoutOrBuilder(); + public com.google.cloud.batch.v1.Runnable.ExecutableCase getExecutableCase(); } diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskProto.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskProto.java index 226ef1e..4484e19 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskProto.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskProto.java @@ -113,51 +113,55 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "google.cloud.batch.v1.StatusEvent\"a\n\005Sta" + "te\022\025\n\021STATE_UNSPECIFIED\020\000\022\013\n\007PENDING\020\001\022\014" + "\n\010ASSIGNED\020\002\022\013\n\007RUNNING\020\003\022\n\n\006FAILED\020\004\022\r\n" - + "\tSUCCEEDED\020\005\"\215\004\n\010Runnable\022>\n\tcontainer\030\001" + + "\tSUCCEEDED\020\005\"\362\004\n\010Runnable\022>\n\tcontainer\030\001" + " \001(\0132).google.cloud.batch.v1.Runnable.Co" + "ntainerH\000\0228\n\006script\030\002 \001(\0132&.google.cloud" + ".batch.v1.Runnable.ScriptH\000\022:\n\007barrier\030\006" + " \001(\0132\'.google.cloud.batch.v1.Runnable.Ba" + "rrierH\000\022\032\n\022ignore_exit_status\030\003 \001(\010\022\022\n\nb" - + "ackground\030\004 \001(\010\022\022\n\nalways_run\030\005 \001(\010\032\252\001\n\t" - + "Container\022\021\n\timage_uri\030\001 \001(\t\022\020\n\010commands" - + "\030\002 \003(\t\022\022\n\nentrypoint\030\003 \001(\t\022\017\n\007volumes\030\007 " - + "\003(\t\022\017\n\007options\030\010 \001(\t\022\036\n\026block_external_n" - + "etwork\030\t \001(\010\022\020\n\010username\030\n \001(\t\022\020\n\010passwo" - + "rd\030\013 \001(\t\0323\n\006Script\022\016\n\004path\030\001 \001(\tH\000\022\016\n\004te" - + "xt\030\002 \001(\tH\000B\t\n\007command\032\027\n\007Barrier\022\014\n\004name" - + "\030\001 \001(\tB\014\n\nexecutable\"\300\003\n\010TaskSpec\0222\n\trun" - + "nables\030\010 \003(\0132\037.google.cloud.batch.v1.Run" - + "nable\022@\n\020compute_resource\030\003 \001(\0132&.google" - + ".cloud.batch.v1.ComputeResource\0223\n\020max_r" - + "un_duration\030\004 \001(\0132\031.google.protobuf.Dura" - + "tion\022\027\n\017max_retry_count\030\005 \001(\005\022B\n\022lifecyc" - + "le_policies\030\t \003(\0132&.google.cloud.batch.v" - + "1.LifecyclePolicy\022G\n\014environments\030\006 \003(\0132" - + "1.google.cloud.batch.v1.TaskSpec.Environ" - + "mentsEntry\022.\n\007volumes\030\007 \003(\0132\035.google.clo" - + "ud.batch.v1.Volume\0323\n\021EnvironmentsEntry\022" - + "\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\212\002\n\017Life" - + "cyclePolicy\022=\n\006action\030\001 \001(\0162-.google.clo" - + "ud.batch.v1.LifecyclePolicy.Action\022P\n\020ac" - + "tion_condition\030\002 \001(\01326.google.cloud.batc" - + "h.v1.LifecyclePolicy.ActionCondition\032%\n\017" - + "ActionCondition\022\022\n\nexit_codes\030\001 \003(\005\"?\n\006A" - + "ction\022\026\n\022ACTION_UNSPECIFIED\020\000\022\016\n\nRETRY_T" - + "ASK\020\001\022\r\n\tFAIL_TASK\020\002\"\300\001\n\004Task\022\014\n\004name\030\001 " - + "\001(\t\0221\n\006status\030\002 \001(\0132!.google.cloud.batch" - + ".v1.TaskStatus:w\352At\n\031batch.googleapis.co" - + "m/Task\022Wprojects/{project}/locations/{lo" - + "cation}/jobs/{job}/taskGroups/{task_grou" - + "p}/tasks/{task}\"\205\001\n\013Environment\022D\n\tvaria" - + "bles\030\001 \003(\01321.google.cloud.batch.v1.Envir" - + "onment.VariablesEntry\0320\n\016VariablesEntry\022" - + "\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001B\265\001\n\031com." - + "google.cloud.batch.v1B\tTaskProtoP\001Z:goog" - + "le.golang.org/genproto/googleapis/cloud/" - + "batch/v1;batch\242\002\003GCB\252\002\025Google.Cloud.Batc" - + "h.V1\312\002\025Google\\Cloud\\Batch\\V1\352\002\030Google::C" - + "loud::Batch::V1b\006proto3" + + "ackground\030\004 \001(\010\022\022\n\nalways_run\030\005 \001(\010\0227\n\013e" + + "nvironment\030\007 \001(\0132\".google.cloud.batch.v1" + + ".Environment\022*\n\007timeout\030\010 \001(\0132\031.google.p" + + "rotobuf.Duration\032\252\001\n\tContainer\022\021\n\timage_" + + "uri\030\001 \001(\t\022\020\n\010commands\030\002 \003(\t\022\022\n\nentrypoin" + + "t\030\003 \001(\t\022\017\n\007volumes\030\007 \003(\t\022\017\n\007options\030\010 \001(" + + "\t\022\036\n\026block_external_network\030\t \001(\010\022\020\n\010use" + + "rname\030\n \001(\t\022\020\n\010password\030\013 \001(\t\0323\n\006Script\022" + + "\016\n\004path\030\001 \001(\tH\000\022\016\n\004text\030\002 \001(\tH\000B\t\n\007comma" + + "nd\032\027\n\007Barrier\022\014\n\004name\030\001 \001(\tB\014\n\nexecutabl" + + "e\"\375\003\n\010TaskSpec\0222\n\trunnables\030\010 \003(\0132\037.goog" + + "le.cloud.batch.v1.Runnable\022@\n\020compute_re" + + "source\030\003 \001(\0132&.google.cloud.batch.v1.Com" + + "puteResource\0223\n\020max_run_duration\030\004 \001(\0132\031" + + ".google.protobuf.Duration\022\027\n\017max_retry_c" + + "ount\030\005 \001(\005\022B\n\022lifecycle_policies\030\t \003(\0132&" + + ".google.cloud.batch.v1.LifecyclePolicy\022K" + + "\n\014environments\030\006 \003(\01321.google.cloud.batc" + + "h.v1.TaskSpec.EnvironmentsEntryB\002\030\001\022.\n\007v" + + "olumes\030\007 \003(\0132\035.google.cloud.batch.v1.Vol" + + "ume\0227\n\013environment\030\n \001(\0132\".google.cloud." + + "batch.v1.Environment\0323\n\021EnvironmentsEntr" + + "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\212\002\n\017Li" + + "fecyclePolicy\022=\n\006action\030\001 \001(\0162-.google.c" + + "loud.batch.v1.LifecyclePolicy.Action\022P\n\020" + + "action_condition\030\002 \001(\01326.google.cloud.ba" + + "tch.v1.LifecyclePolicy.ActionCondition\032%" + + "\n\017ActionCondition\022\022\n\nexit_codes\030\001 \003(\005\"?\n" + + "\006Action\022\026\n\022ACTION_UNSPECIFIED\020\000\022\016\n\nRETRY" + + "_TASK\020\001\022\r\n\tFAIL_TASK\020\002\"\300\001\n\004Task\022\014\n\004name\030" + + "\001 \001(\t\0221\n\006status\030\002 \001(\0132!.google.cloud.bat" + + "ch.v1.TaskStatus:w\352At\n\031batch.googleapis." + + "com/Task\022Wprojects/{project}/locations/{" + + "location}/jobs/{job}/taskGroups/{task_gr" + + "oup}/tasks/{task}\"\205\001\n\013Environment\022D\n\tvar" + + "iables\030\001 \003(\01321.google.cloud.batch.v1.Env" + + "ironment.VariablesEntry\0320\n\016VariablesEntr" + + "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001B\265\001\n\031co" + + "m.google.cloud.batch.v1B\tTaskProtoP\001Z:go" + + "ogle.golang.org/genproto/googleapis/clou" + + "d/batch/v1;batch\242\002\003GCB\252\002\025Google.Cloud.Ba" + + "tch.V1\312\002\025Google\\Cloud\\Batch\\V1\352\002\030Google:" + + ":Cloud::Batch::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -212,6 +216,8 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "IgnoreExitStatus", "Background", "AlwaysRun", + "Environment", + "Timeout", "Executable", }); internal_static_google_cloud_batch_v1_Runnable_Container_descriptor = @@ -258,6 +264,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "LifecyclePolicies", "Environments", "Volumes", + "Environment", }); internal_static_google_cloud_batch_v1_TaskSpec_EnvironmentsEntry_descriptor = internal_static_google_cloud_batch_v1_TaskSpec_descriptor.getNestedTypes().get(0); diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpec.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpec.java index 7d43cf4..01c7cc7 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpec.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpec.java @@ -157,6 +157,22 @@ private TaskSpec( com.google.cloud.batch.v1.LifecyclePolicy.parser(), extensionRegistry)); break; } + case 82: + { + com.google.cloud.batch.v1.Environment.Builder subBuilder = null; + if (environment_ != null) { + subBuilder = environment_.toBuilder(); + } + environment_ = + input.readMessage( + com.google.cloud.batch.v1.Environment.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(environment_); + environment_ = subBuilder.buildPartial(); + } + + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -575,6 +591,7 @@ private static final class EnvironmentsDefaultEntryHolder { return environments_; } + @java.lang.Deprecated public int getEnvironmentsCount() { return internalGetEnvironments().getMap().size(); } @@ -586,8 +603,9 @@ public int getEnvironmentsCount() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated @java.lang.Override public boolean containsEnvironments(java.lang.String key) { if (key == null) { @@ -609,9 +627,10 @@ public java.util.Map getEnvironments() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ @java.lang.Override + @java.lang.Deprecated public java.util.Map getEnvironmentsMap() { return internalGetEnvironments().getMap(); } @@ -623,9 +642,10 @@ public java.util.Map getEnvironmentsMap() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ @java.lang.Override + @java.lang.Deprecated public java.lang.String getEnvironmentsOrDefault( java.lang.String key, java.lang.String defaultValue) { if (key == null) { @@ -642,9 +662,10 @@ public java.lang.String getEnvironmentsOrDefault( * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ @java.lang.Override + @java.lang.Deprecated public java.lang.String getEnvironmentsOrThrow(java.lang.String key) { if (key == null) { throw new NullPointerException("map key"); @@ -725,6 +746,54 @@ public com.google.cloud.batch.v1.VolumeOrBuilder getVolumesOrBuilder(int index) return volumes_.get(index); } + public static final int ENVIRONMENT_FIELD_NUMBER = 10; + private com.google.cloud.batch.v1.Environment environment_; + /** + * + * + *
+   * Environment variables to set before running the Task.
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + * + * @return Whether the environment field is set. + */ + @java.lang.Override + public boolean hasEnvironment() { + return environment_ != null; + } + /** + * + * + *
+   * Environment variables to set before running the Task.
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + * + * @return The environment. + */ + @java.lang.Override + public com.google.cloud.batch.v1.Environment getEnvironment() { + return environment_ == null + ? com.google.cloud.batch.v1.Environment.getDefaultInstance() + : environment_; + } + /** + * + * + *
+   * Environment variables to set before running the Task.
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + @java.lang.Override + public com.google.cloud.batch.v1.EnvironmentOrBuilder getEnvironmentOrBuilder() { + return getEnvironment(); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -759,6 +828,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io for (int i = 0; i < lifecyclePolicies_.size(); i++) { output.writeMessage(9, lifecyclePolicies_.get(i)); } + if (environment_ != null) { + output.writeMessage(10, getEnvironment()); + } unknownFields.writeTo(output); } @@ -797,6 +869,9 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, lifecyclePolicies_.get(i)); } + if (environment_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getEnvironment()); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -825,6 +900,10 @@ public boolean equals(final java.lang.Object obj) { if (!getLifecyclePoliciesList().equals(other.getLifecyclePoliciesList())) return false; if (!internalGetEnvironments().equals(other.internalGetEnvironments())) return false; if (!getVolumesList().equals(other.getVolumesList())) return false; + if (hasEnvironment() != other.hasEnvironment()) return false; + if (hasEnvironment()) { + if (!getEnvironment().equals(other.getEnvironment())) return false; + } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -862,6 +941,10 @@ public int hashCode() { hash = (37 * hash) + VOLUMES_FIELD_NUMBER; hash = (53 * hash) + getVolumesList().hashCode(); } + if (hasEnvironment()) { + hash = (37 * hash) + ENVIRONMENT_FIELD_NUMBER; + hash = (53 * hash) + getEnvironment().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1063,6 +1146,12 @@ public Builder clear() { } else { volumesBuilder_.clear(); } + if (environmentBuilder_ == null) { + environment_ = null; + } else { + environment_ = null; + environmentBuilder_ = null; + } return this; } @@ -1130,6 +1219,11 @@ public com.google.cloud.batch.v1.TaskSpec buildPartial() { } else { result.volumes_ = volumesBuilder_.build(); } + if (environmentBuilder_ == null) { + result.environment_ = environment_; + } else { + result.environment_ = environmentBuilder_.build(); + } onBuilt(); return result; } @@ -1270,6 +1364,9 @@ public Builder mergeFrom(com.google.cloud.batch.v1.TaskSpec other) { } } } + if (other.hasEnvironment()) { + mergeEnvironment(other.getEnvironment()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -2759,6 +2856,7 @@ public com.google.cloud.batch.v1.LifecyclePolicy.Builder addLifecyclePoliciesBui return environments_; } + @java.lang.Deprecated public int getEnvironmentsCount() { return internalGetEnvironments().getMap().size(); } @@ -2770,8 +2868,9 @@ public int getEnvironmentsCount() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated @java.lang.Override public boolean containsEnvironments(java.lang.String key) { if (key == null) { @@ -2793,9 +2892,10 @@ public java.util.Map getEnvironments() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ @java.lang.Override + @java.lang.Deprecated public java.util.Map getEnvironmentsMap() { return internalGetEnvironments().getMap(); } @@ -2807,9 +2907,10 @@ public java.util.Map getEnvironmentsMap() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ @java.lang.Override + @java.lang.Deprecated public java.lang.String getEnvironmentsOrDefault( java.lang.String key, java.lang.String defaultValue) { if (key == null) { @@ -2826,9 +2927,10 @@ public java.lang.String getEnvironmentsOrDefault( * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ @java.lang.Override + @java.lang.Deprecated public java.lang.String getEnvironmentsOrThrow(java.lang.String key) { if (key == null) { throw new NullPointerException("map key"); @@ -2840,6 +2942,7 @@ public java.lang.String getEnvironmentsOrThrow(java.lang.String key) { return map.get(key); } + @java.lang.Deprecated public Builder clearEnvironments() { internalGetMutableEnvironments().getMutableMap().clear(); return this; @@ -2852,8 +2955,9 @@ public Builder clearEnvironments() { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated public Builder removeEnvironments(java.lang.String key) { if (key == null) { throw new NullPointerException("map key"); @@ -2874,8 +2978,9 @@ public java.util.Map getMutableEnvironments( * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated public Builder putEnvironments(java.lang.String key, java.lang.String value) { if (key == null) { throw new NullPointerException("map key"); @@ -2895,8 +3000,9 @@ public Builder putEnvironments(java.lang.String key, java.lang.String value) { * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated public Builder putAllEnvironments(java.util.Map values) { internalGetMutableEnvironments().getMutableMap().putAll(values); return this; @@ -3248,6 +3354,191 @@ public java.util.List getVolumesBuilde return volumesBuilder_; } + private com.google.cloud.batch.v1.Environment environment_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.batch.v1.Environment, + com.google.cloud.batch.v1.Environment.Builder, + com.google.cloud.batch.v1.EnvironmentOrBuilder> + environmentBuilder_; + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + * + * @return Whether the environment field is set. + */ + public boolean hasEnvironment() { + return environmentBuilder_ != null || environment_ != null; + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + * + * @return The environment. + */ + public com.google.cloud.batch.v1.Environment getEnvironment() { + if (environmentBuilder_ == null) { + return environment_ == null + ? com.google.cloud.batch.v1.Environment.getDefaultInstance() + : environment_; + } else { + return environmentBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + public Builder setEnvironment(com.google.cloud.batch.v1.Environment value) { + if (environmentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + environment_ = value; + onChanged(); + } else { + environmentBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + public Builder setEnvironment(com.google.cloud.batch.v1.Environment.Builder builderForValue) { + if (environmentBuilder_ == null) { + environment_ = builderForValue.build(); + onChanged(); + } else { + environmentBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + public Builder mergeEnvironment(com.google.cloud.batch.v1.Environment value) { + if (environmentBuilder_ == null) { + if (environment_ != null) { + environment_ = + com.google.cloud.batch.v1.Environment.newBuilder(environment_) + .mergeFrom(value) + .buildPartial(); + } else { + environment_ = value; + } + onChanged(); + } else { + environmentBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + public Builder clearEnvironment() { + if (environmentBuilder_ == null) { + environment_ = null; + onChanged(); + } else { + environment_ = null; + environmentBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + public com.google.cloud.batch.v1.Environment.Builder getEnvironmentBuilder() { + + onChanged(); + return getEnvironmentFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + public com.google.cloud.batch.v1.EnvironmentOrBuilder getEnvironmentOrBuilder() { + if (environmentBuilder_ != null) { + return environmentBuilder_.getMessageOrBuilder(); + } else { + return environment_ == null + ? com.google.cloud.batch.v1.Environment.getDefaultInstance() + : environment_; + } + } + /** + * + * + *
+     * Environment variables to set before running the Task.
+     * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.batch.v1.Environment, + com.google.cloud.batch.v1.Environment.Builder, + com.google.cloud.batch.v1.EnvironmentOrBuilder> + getEnvironmentFieldBuilder() { + if (environmentBuilder_ == null) { + environmentBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.batch.v1.Environment, + com.google.cloud.batch.v1.Environment.Builder, + com.google.cloud.batch.v1.EnvironmentOrBuilder>( + getEnvironment(), getParentForChildren(), isClean()); + environment_ = null; + } + return environmentBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpecOrBuilder.java b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpecOrBuilder.java index bd20399..448ebf4 100644 --- a/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpecOrBuilder.java +++ b/proto-google-cloud-batch-v1/src/main/java/com/google/cloud/batch/v1/TaskSpecOrBuilder.java @@ -302,8 +302,9 @@ public interface TaskSpecOrBuilder * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated int getEnvironmentsCount(); /** * @@ -313,8 +314,9 @@ public interface TaskSpecOrBuilder * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated boolean containsEnvironments(java.lang.String key); /** Use {@link #getEnvironmentsMap()} instead. */ @java.lang.Deprecated @@ -327,8 +329,9 @@ public interface TaskSpecOrBuilder * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated java.util.Map getEnvironmentsMap(); /** * @@ -338,9 +341,9 @@ public interface TaskSpecOrBuilder * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ - + @java.lang.Deprecated /* nullable */ java.lang.String getEnvironmentsOrDefault( java.lang.String key, @@ -354,8 +357,9 @@ java.lang.String getEnvironmentsOrDefault( * You can set up to 100 environments. * * - * map<string, string> environments = 6; + * map<string, string> environments = 6 [deprecated = true]; */ + @java.lang.Deprecated java.lang.String getEnvironmentsOrThrow(java.lang.String key); /** @@ -408,4 +412,39 @@ java.lang.String getEnvironmentsOrDefault( * repeated .google.cloud.batch.v1.Volume volumes = 7; */ com.google.cloud.batch.v1.VolumeOrBuilder getVolumesOrBuilder(int index); + + /** + * + * + *
+   * Environment variables to set before running the Task.
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + * + * @return Whether the environment field is set. + */ + boolean hasEnvironment(); + /** + * + * + *
+   * Environment variables to set before running the Task.
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + * + * @return The environment. + */ + com.google.cloud.batch.v1.Environment getEnvironment(); + /** + * + * + *
+   * Environment variables to set before running the Task.
+   * 
+ * + * .google.cloud.batch.v1.Environment environment = 10; + */ + com.google.cloud.batch.v1.EnvironmentOrBuilder getEnvironmentOrBuilder(); } diff --git a/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/job.proto b/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/job.proto index a24c017..2b62254 100644 --- a/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/job.proto +++ b/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/job.proto @@ -218,16 +218,25 @@ message JobNotification { // resources should be allocated for the Job. message AllocationPolicy { message LocationPolicy { - // A list of allowed location names represented by internal URLs, - // First location in the list must be a region. - // for example, - // ["regions/us-central1"] allow VMs in region us-central1, - // ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone - // us-central1-a. + // A list of allowed location names represented by internal URLs. + // Each location can be a region or a zone. + // Only one region or multiple zones in one region is supported now. + // For example, + // ["regions/us-central1"] allow VMs in any zones in region us-central1. + // ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs + // in zones us-central1-a and us-central1-c. + // All locations end up in different regions would cause errors. + // For example, + // ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", + // "zones/us-west1-a"] contains 2 regions "us-central1" and + // "us-west1". An error is expected in this case. repeated string allowed_locations = 1; } - // A new persistent disk. + // A new persistent disk or a local ssd. + // A VM can only have one local SSD setting but multiple local SSD partitions. + // https://cloud.google.com/compute/docs/disks#pdspecs. + // https://cloud.google.com/compute/docs/disks#localssds. message Disk { // A data source from which a PD will be created. oneof data_source { @@ -239,15 +248,23 @@ message AllocationPolicy { } // Disk type as shown in `gcloud compute disk-types list` - // For example, "pd-ssd", "pd-standard", "pd-balanced". + // For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd". string type = 1; // Disk size in GB. // This field is ignored if `data_source` is `disk` or `image`. + // If `type` is `local-ssd`, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. int64 size_gb = 2; + + // Local SSDs are available through both "SCSI" and "NVMe" interfaces. + // If not indicated, "NVMe" will be the default one for local ssds. + // We only support "SCSI" for persistent disks now. + string disk_interface = 6; } - // A new or an existing persistent disk attached to a VM instance. + // A new or an existing persistent disk or a local ssd attached to a VM + // instance. message AttachedDisk { oneof attached { Disk new_disk = 1; @@ -269,6 +286,10 @@ message AllocationPolicy { // The number of accelerators of this type. int64 count = 2; + + // When true, Batch will install the GPU drivers. + // This field will be ignored if specified. + bool install_gpu_drivers = 3 [deprecated = true]; } // InstancePolicy describes an instance type and resources attached to each VM diff --git a/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/task.proto b/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/task.proto index 5462ee7..bc4dbfe 100644 --- a/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/task.proto +++ b/proto-google-cloud-batch-v1/src/main/proto/google/cloud/batch/v1/task.proto @@ -184,6 +184,13 @@ message Runnable { // If the max_run_duration has expired then no further Runnables will execute, // not even always_run Runnables. bool always_run = 5; + + // Environment variables for this Runnable (overrides variables set for the + // whole Task or TaskGroup). + Environment environment = 7; + + // Timeout for this Runnable. + google.protobuf.Duration timeout = 8; } // Spec of a task @@ -225,10 +232,13 @@ message TaskSpec { // Environment variables to set before running the Task. // You can set up to 100 environments. - map environments = 6; + map environments = 6 [deprecated = true]; // Volumes to mount before running Tasks using this TaskSpec. repeated Volume volumes = 7; + + // Environment variables to set before running the Task. + Environment environment = 10; } // LifecyclePolicy describes how to deal with task failures diff --git a/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicy.java b/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicy.java index b3f1e6e..ed5408f 100644 --- a/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicy.java +++ b/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicy.java @@ -470,12 +470,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -487,12 +493,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -504,12 +516,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -522,12 +540,18 @@ public interface LocationPolicyOrBuilder * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -706,12 +730,18 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -725,12 +755,18 @@ public com.google.protobuf.ProtocolStringList getAllowedLocationsList() { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -744,12 +780,18 @@ public int getAllowedLocationsCount() { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -764,12 +806,18 @@ public java.lang.String getAllowedLocations(int index) { * * *
-     * A list of allowed location names represented by internal URLs,
-     * First location in the list must be a region.
-     * for example,
-     * ["regions/us-central1"] allow VMs in region us-central1,
-     * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-     * us-central1-a.
+     * A list of allowed location names represented by internal URLs.
+     * Each location can be a region or a zone.
+     * Only one region or multiple zones in one region is supported now.
+     * For example,
+     * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+     * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+     * in zones us-central1-a and us-central1-c.
+     * All locations end up in different regions would cause errors.
+     * For example,
+     * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+     * "zones/us-west1-a"] contains 2 regions "us-central1" and
+     * "us-west1". An error is expected in this case.
      * 
* * repeated string allowed_locations = 1; @@ -1231,12 +1279,18 @@ private void ensureAllowedLocationsIsMutable() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1250,12 +1304,18 @@ public com.google.protobuf.ProtocolStringList getAllowedLocationsList() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1269,12 +1329,18 @@ public int getAllowedLocationsCount() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1289,12 +1355,18 @@ public java.lang.String getAllowedLocations(int index) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1309,12 +1381,18 @@ public com.google.protobuf.ByteString getAllowedLocationsBytes(int index) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1336,12 +1414,18 @@ public Builder setAllowedLocations(int index, java.lang.String value) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1362,12 +1446,18 @@ public Builder addAllowedLocations(java.lang.String value) { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1385,12 +1475,18 @@ public Builder addAllAllowedLocations(java.lang.Iterable value * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1407,12 +1503,18 @@ public Builder clearAllowedLocations() { * * *
-       * A list of allowed location names represented by internal URLs,
-       * First location in the list must be a region.
-       * for example,
-       * ["regions/us-central1"] allow VMs in region us-central1,
-       * ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone
-       * us-central1-a.
+       * A list of allowed location names represented by internal URLs.
+       * Each location can be a region or a zone.
+       * Only one region or multiple zones in one region is supported now.
+       * For example,
+       * ["regions/us-central1"] allow VMs in any zones in region us-central1.
+       * ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs
+       * in zones us-central1-a and us-central1-c.
+       * All locations end up in different regions would cause errors.
+       * For example,
+       * ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b",
+       * "zones/us-west1-a"] contains 2 regions "us-central1" and
+       * "us-west1". An error is expected in this case.
        * 
* * repeated string allowed_locations = 1; @@ -1747,7 +1849,7 @@ public interface DiskOrBuilder * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -1760,7 +1862,7 @@ public interface DiskOrBuilder * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -1775,6 +1877,8 @@ public interface DiskOrBuilder *
      * Disk size in GB.
      * This field is ignored if `data_source` is `disk` or `image`.
+     * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+     * otherwise, the final size will be the next greater multiple of 375 GB.
      * 
* * int64 size_gb = 2; @@ -1783,13 +1887,45 @@ public interface DiskOrBuilder */ long getSizeGb(); + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The diskInterface. + */ + java.lang.String getDiskInterface(); + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The bytes for diskInterface. + */ + com.google.protobuf.ByteString getDiskInterfaceBytes(); + public com.google.cloud.batch.v1alpha.AllocationPolicy.Disk.DataSourceCase getDataSourceCase(); } /** * * *
-   * A new persistent disk.
+   * A new persistent disk or a local ssd.
+   * A VM can only have one local SSD setting but multiple local SSD partitions.
+   * https://cloud.google.com/compute/docs/disks#pdspecs.
+   * https://cloud.google.com/compute/docs/disks#localssds.
    * 
* * Protobuf type {@code google.cloud.batch.v1alpha.AllocationPolicy.Disk} @@ -1806,6 +1942,7 @@ private Disk(com.google.protobuf.GeneratedMessageV3.Builder builder) { private Disk() { type_ = ""; + diskInterface_ = ""; } @java.lang.Override @@ -1863,6 +2000,13 @@ private Disk( dataSource_ = s; break; } + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + + diskInterface_ = s; + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -2093,7 +2237,7 @@ public com.google.protobuf.ByteString getSnapshotBytes() { * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -2117,7 +2261,7 @@ public java.lang.String getType() { * *
      * Disk type as shown in `gcloud compute disk-types list`
-     * For example, "pd-ssd", "pd-standard", "pd-balanced".
+     * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
      * 
* * string type = 1; @@ -2145,6 +2289,8 @@ public com.google.protobuf.ByteString getTypeBytes() { *
      * Disk size in GB.
      * This field is ignored if `data_source` is `disk` or `image`.
+     * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+     * otherwise, the final size will be the next greater multiple of 375 GB.
      * 
* * int64 size_gb = 2; @@ -2156,6 +2302,59 @@ public long getSizeGb() { return sizeGb_; } + public static final int DISK_INTERFACE_FIELD_NUMBER = 6; + private volatile java.lang.Object diskInterface_; + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The diskInterface. + */ + @java.lang.Override + public java.lang.String getDiskInterface() { + java.lang.Object ref = diskInterface_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + diskInterface_ = s; + return s; + } + } + /** + * + * + *
+     * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+     * If not indicated, "NVMe" will be the default one for local ssds.
+     * We only support "SCSI" for persistent disks now.
+     * 
+ * + * string disk_interface = 6; + * + * @return The bytes for diskInterface. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDiskInterfaceBytes() { + java.lang.Object ref = diskInterface_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + diskInterface_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -2182,6 +2381,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (dataSourceCase_ == 5) { com.google.protobuf.GeneratedMessageV3.writeString(output, 5, dataSource_); } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(diskInterface_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, diskInterface_); + } unknownFields.writeTo(output); } @@ -2203,6 +2405,9 @@ public int getSerializedSize() { if (dataSourceCase_ == 5) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, dataSource_); } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(diskInterface_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, diskInterface_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -2221,6 +2426,7 @@ public boolean equals(final java.lang.Object obj) { if (!getType().equals(other.getType())) return false; if (getSizeGb() != other.getSizeGb()) return false; + if (!getDiskInterface().equals(other.getDiskInterface())) return false; if (!getDataSourceCase().equals(other.getDataSourceCase())) return false; switch (dataSourceCase_) { case 4: @@ -2247,6 +2453,8 @@ public int hashCode() { hash = (53 * hash) + getType().hashCode(); hash = (37 * hash) + SIZE_GB_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSizeGb()); + hash = (37 * hash) + DISK_INTERFACE_FIELD_NUMBER; + hash = (53 * hash) + getDiskInterface().hashCode(); switch (dataSourceCase_) { case 4: hash = (37 * hash) + IMAGE_FIELD_NUMBER; @@ -2365,7 +2573,10 @@ protected Builder newBuilderForType( * * *
-     * A new persistent disk.
+     * A new persistent disk or a local ssd.
+     * A VM can only have one local SSD setting but multiple local SSD partitions.
+     * https://cloud.google.com/compute/docs/disks#pdspecs.
+     * https://cloud.google.com/compute/docs/disks#localssds.
      * 
* * Protobuf type {@code google.cloud.batch.v1alpha.AllocationPolicy.Disk} @@ -2411,6 +2622,8 @@ public Builder clear() { sizeGb_ = 0L; + diskInterface_ = ""; + dataSourceCase_ = 0; dataSource_ = null; return this; @@ -2448,6 +2661,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.Disk buildPartial() { } result.type_ = type_; result.sizeGb_ = sizeGb_; + result.diskInterface_ = diskInterface_; result.dataSourceCase_ = dataSourceCase_; onBuilt(); return result; @@ -2508,6 +2722,10 @@ public Builder mergeFrom(com.google.cloud.batch.v1alpha.AllocationPolicy.Disk ot if (other.getSizeGb() != 0L) { setSizeGb(other.getSizeGb()); } + if (!other.getDiskInterface().isEmpty()) { + diskInterface_ = other.diskInterface_; + onChanged(); + } switch (other.getDataSourceCase()) { case IMAGE: { @@ -2846,7 +3064,7 @@ public Builder setSnapshotBytes(com.google.protobuf.ByteString value) { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2869,7 +3087,7 @@ public java.lang.String getType() { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2892,7 +3110,7 @@ public com.google.protobuf.ByteString getTypeBytes() { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2914,7 +3132,7 @@ public Builder setType(java.lang.String value) { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2932,7 +3150,7 @@ public Builder clearType() { * *
        * Disk type as shown in `gcloud compute disk-types list`
-       * For example, "pd-ssd", "pd-standard", "pd-balanced".
+       * For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd".
        * 
* * string type = 1; @@ -2958,6 +3176,8 @@ public Builder setTypeBytes(com.google.protobuf.ByteString value) { *
        * Disk size in GB.
        * This field is ignored if `data_source` is `disk` or `image`.
+       * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+       * otherwise, the final size will be the next greater multiple of 375 GB.
        * 
* * int64 size_gb = 2; @@ -2974,6 +3194,8 @@ public long getSizeGb() { *
        * Disk size in GB.
        * This field is ignored if `data_source` is `disk` or `image`.
+       * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+       * otherwise, the final size will be the next greater multiple of 375 GB.
        * 
* * int64 size_gb = 2; @@ -2993,6 +3215,8 @@ public Builder setSizeGb(long value) { *
        * Disk size in GB.
        * This field is ignored if `data_source` is `disk` or `image`.
+       * If `type` is `local-ssd`, size_gb should be a multiple of 375GB,
+       * otherwise, the final size will be the next greater multiple of 375 GB.
        * 
* * int64 size_gb = 2; @@ -3006,6 +3230,122 @@ public Builder clearSizeGb() { return this; } + private java.lang.Object diskInterface_ = ""; + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @return The diskInterface. + */ + public java.lang.String getDiskInterface() { + java.lang.Object ref = diskInterface_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + diskInterface_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @return The bytes for diskInterface. + */ + public com.google.protobuf.ByteString getDiskInterfaceBytes() { + java.lang.Object ref = diskInterface_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + diskInterface_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @param value The diskInterface to set. + * @return This builder for chaining. + */ + public Builder setDiskInterface(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + diskInterface_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @return This builder for chaining. + */ + public Builder clearDiskInterface() { + + diskInterface_ = getDefaultInstance().getDiskInterface(); + onChanged(); + return this; + } + /** + * + * + *
+       * Local SSDs are available through both "SCSI" and "NVMe" interfaces.
+       * If not indicated, "NVMe" will be the default one for local ssds.
+       * We only support "SCSI" for persistent disks now.
+       * 
+ * + * string disk_interface = 6; + * + * @param value The bytes for diskInterface to set. + * @return This builder for chaining. + */ + public Builder setDiskInterfaceBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + diskInterface_ = value; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -3149,7 +3489,8 @@ public interface AttachedDiskOrBuilder * * *
-   * A new or an existing persistent disk attached to a VM instance.
+   * A new or an existing persistent disk or a local ssd attached to a VM
+   * instance.
    * 
* * Protobuf type {@code google.cloud.batch.v1alpha.AllocationPolicy.AttachedDisk} @@ -3668,7 +4009,8 @@ protected Builder newBuilderForType( * * *
-     * A new or an existing persistent disk attached to a VM instance.
+     * A new or an existing persistent disk or a local ssd attached to a VM
+     * instance.
      * 
* * Protobuf type {@code google.cloud.batch.v1alpha.AllocationPolicy.AttachedDisk} @@ -4361,6 +4703,23 @@ public interface AcceleratorOrBuilder * @return The count. */ long getCount(); + + /** + * + * + *
+     * When true, Batch will install the GPU drivers.
+     * This field will be ignored if specified.
+     * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=346 + * @return The installGpuDrivers. + */ + @java.lang.Deprecated + boolean getInstallGpuDrivers(); } /** * @@ -4426,6 +4785,11 @@ private Accelerator( count_ = input.readInt64(); break; } + case 24: + { + installGpuDrivers_ = input.readBool(); + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -4531,6 +4895,28 @@ public long getCount() { return count_; } + public static final int INSTALL_GPU_DRIVERS_FIELD_NUMBER = 3; + private boolean installGpuDrivers_; + /** + * + * + *
+     * When true, Batch will install the GPU drivers.
+     * This field will be ignored if specified.
+     * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=346 + * @return The installGpuDrivers. + */ + @java.lang.Override + @java.lang.Deprecated + public boolean getInstallGpuDrivers() { + return installGpuDrivers_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -4551,6 +4937,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (count_ != 0L) { output.writeInt64(2, count_); } + if (installGpuDrivers_ != false) { + output.writeBool(3, installGpuDrivers_); + } unknownFields.writeTo(output); } @@ -4566,6 +4955,9 @@ public int getSerializedSize() { if (count_ != 0L) { size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, count_); } + if (installGpuDrivers_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, installGpuDrivers_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -4584,6 +4976,7 @@ public boolean equals(final java.lang.Object obj) { if (!getType().equals(other.getType())) return false; if (getCount() != other.getCount()) return false; + if (getInstallGpuDrivers() != other.getInstallGpuDrivers()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -4599,6 +4992,8 @@ public int hashCode() { hash = (53 * hash) + getType().hashCode(); hash = (37 * hash) + COUNT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getCount()); + hash = (37 * hash) + INSTALL_GPU_DRIVERS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getInstallGpuDrivers()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -4751,6 +5146,8 @@ public Builder clear() { count_ = 0L; + installGpuDrivers_ = false; + return this; } @@ -4781,6 +5178,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.Accelerator buildPartial( new com.google.cloud.batch.v1alpha.AllocationPolicy.Accelerator(this); result.type_ = type_; result.count_ = count_; + result.installGpuDrivers_ = installGpuDrivers_; onBuilt(); return result; } @@ -4841,6 +5239,9 @@ public Builder mergeFrom(com.google.cloud.batch.v1alpha.AllocationPolicy.Acceler if (other.getCount() != 0L) { setCount(other.getCount()); } + if (other.getInstallGpuDrivers() != false) { + setInstallGpuDrivers(other.getInstallGpuDrivers()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -5035,6 +5436,70 @@ public Builder clearCount() { return this; } + private boolean installGpuDrivers_; + /** + * + * + *
+       * When true, Batch will install the GPU drivers.
+       * This field will be ignored if specified.
+       * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=346 + * @return The installGpuDrivers. + */ + @java.lang.Override + @java.lang.Deprecated + public boolean getInstallGpuDrivers() { + return installGpuDrivers_; + } + /** + * + * + *
+       * When true, Batch will install the GPU drivers.
+       * This field will be ignored if specified.
+       * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=346 + * @param value The installGpuDrivers to set. + * @return This builder for chaining. + */ + @java.lang.Deprecated + public Builder setInstallGpuDrivers(boolean value) { + + installGpuDrivers_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * When true, Batch will install the GPU drivers.
+       * This field will be ignored if specified.
+       * 
+ * + * bool install_gpu_drivers = 3 [deprecated = true]; + * + * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.Accelerator.install_gpu_drivers is + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=346 + * @return This builder for chaining. + */ + @java.lang.Deprecated + public Builder clearInstallGpuDrivers() { + + installGpuDrivers_ = false; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -5097,7 +5562,7 @@ public interface InstancePolicyOrBuilder * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return A list containing the allowedMachineTypes. */ @java.lang.Deprecated @@ -5106,7 +5571,7 @@ public interface InstancePolicyOrBuilder * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return The count of allowedMachineTypes. */ @java.lang.Deprecated @@ -5115,7 +5580,7 @@ public interface InstancePolicyOrBuilder * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index of the element to return. * @return The allowedMachineTypes at the given index. */ @@ -5125,7 +5590,7 @@ public interface InstancePolicyOrBuilder * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index of the value to return. * @return The bytes of the allowedMachineTypes at the given index. */ @@ -5506,7 +5971,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return A list containing the allowedMachineTypes. */ @java.lang.Deprecated @@ -5517,7 +5982,7 @@ public com.google.protobuf.ProtocolStringList getAllowedMachineTypesList() { * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return The count of allowedMachineTypes. */ @java.lang.Deprecated @@ -5528,7 +5993,7 @@ public int getAllowedMachineTypesCount() { * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index of the element to return. * @return The allowedMachineTypes at the given index. */ @@ -5540,7 +6005,7 @@ public java.lang.String getAllowedMachineTypes(int index) { * repeated string allowed_machine_types = 1 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types - * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * is deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index of the value to return. * @return The bytes of the allowedMachineTypes at the given index. */ @@ -6380,7 +6845,7 @@ private void ensureAllowedMachineTypesIsMutable() { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return A list containing the allowedMachineTypes. */ @java.lang.Deprecated @@ -6392,7 +6857,7 @@ public com.google.protobuf.ProtocolStringList getAllowedMachineTypesList() { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return The count of allowedMachineTypes. */ @java.lang.Deprecated @@ -6404,7 +6869,7 @@ public int getAllowedMachineTypesCount() { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index of the element to return. * @return The allowedMachineTypes at the given index. */ @@ -6417,7 +6882,7 @@ public java.lang.String getAllowedMachineTypes(int index) { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index of the value to return. * @return The bytes of the allowedMachineTypes at the given index. */ @@ -6430,7 +6895,7 @@ public com.google.protobuf.ByteString getAllowedMachineTypesBytes(int index) { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param index The index to set the value at. * @param value The allowedMachineTypes to set. * @return This builder for chaining. @@ -6450,7 +6915,7 @@ public Builder setAllowedMachineTypes(int index, java.lang.String value) { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param value The allowedMachineTypes to add. * @return This builder for chaining. */ @@ -6469,7 +6934,7 @@ public Builder addAllowedMachineTypes(java.lang.String value) { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param values The allowedMachineTypes to add. * @return This builder for chaining. */ @@ -6485,7 +6950,7 @@ public Builder addAllAllowedMachineTypes(java.lang.Iterable va * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @return This builder for chaining. */ @java.lang.Deprecated @@ -6500,7 +6965,7 @@ public Builder clearAllowedMachineTypes() { * * @deprecated * google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicy.allowed_machine_types is - * deprecated. See google/cloud/batch/v1alpha/job.proto;l=331 + * deprecated. See google/cloud/batch/v1alpha/job.proto;l=352 * @param value The bytes of the allowedMachineTypes to add. * @return This builder for chaining. */ @@ -7778,6 +8243,13 @@ public interface InstancePolicyOrTemplateOrBuilder */ com.google.protobuf.ByteString getInstanceTemplateBytes(); + /** + * bool install_gpu_drivers = 3; + * + * @return The installGpuDrivers. + */ + boolean getInstallGpuDrivers(); + public com.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate .PolicyTemplateCase getPolicyTemplateCase(); @@ -7862,6 +8334,11 @@ private InstancePolicyOrTemplate( policyTemplate_ = s; break; } + case 24: + { + installGpuDrivers_ = input.readBool(); + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -8074,6 +8551,18 @@ public com.google.protobuf.ByteString getInstanceTemplateBytes() { } } + public static final int INSTALL_GPU_DRIVERS_FIELD_NUMBER = 3; + private boolean installGpuDrivers_; + /** + * bool install_gpu_drivers = 3; + * + * @return The installGpuDrivers. + */ + @java.lang.Override + public boolean getInstallGpuDrivers() { + return installGpuDrivers_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -8095,6 +8584,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (policyTemplateCase_ == 2) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, policyTemplate_); } + if (installGpuDrivers_ != false) { + output.writeBool(3, installGpuDrivers_); + } unknownFields.writeTo(output); } @@ -8113,6 +8605,9 @@ public int getSerializedSize() { if (policyTemplateCase_ == 2) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, policyTemplate_); } + if (installGpuDrivers_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, installGpuDrivers_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -8130,6 +8625,7 @@ public boolean equals(final java.lang.Object obj) { com.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate other = (com.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate) obj; + if (getInstallGpuDrivers() != other.getInstallGpuDrivers()) return false; if (!getPolicyTemplateCase().equals(other.getPolicyTemplateCase())) return false; switch (policyTemplateCase_) { case 1: @@ -8152,6 +8648,8 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + INSTALL_GPU_DRIVERS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getInstallGpuDrivers()); switch (policyTemplateCase_) { case 1: hash = (37 * hash) + POLICY_FIELD_NUMBER; @@ -8320,6 +8818,8 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); + installGpuDrivers_ = false; + policyTemplateCase_ = 0; policyTemplate_ = null; return this; @@ -8363,6 +8863,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate if (policyTemplateCase_ == 2) { result.policyTemplate_ = policyTemplate_; } + result.installGpuDrivers_ = installGpuDrivers_; result.policyTemplateCase_ = policyTemplateCase_; onBuilt(); return result; @@ -8420,6 +8921,9 @@ public Builder mergeFrom( if (other == com.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate .getDefaultInstance()) return this; + if (other.getInstallGpuDrivers() != false) { + setInstallGpuDrivers(other.getInstallGpuDrivers()); + } switch (other.getPolicyTemplateCase()) { case POLICY: { @@ -8851,6 +9355,40 @@ public Builder setInstanceTemplateBytes(com.google.protobuf.ByteString value) { return this; } + private boolean installGpuDrivers_; + /** + * bool install_gpu_drivers = 3; + * + * @return The installGpuDrivers. + */ + @java.lang.Override + public boolean getInstallGpuDrivers() { + return installGpuDrivers_; + } + /** + * bool install_gpu_drivers = 3; + * + * @param value The installGpuDrivers to set. + * @return This builder for chaining. + */ + public Builder setInstallGpuDrivers(boolean value) { + + installGpuDrivers_ = value; + onChanged(); + return this; + } + /** + * bool install_gpu_drivers = 3; + * + * @return This builder for chaining. + */ + public Builder clearInstallGpuDrivers() { + + installGpuDrivers_ = false; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { @@ -11074,7 +11612,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.LocationPolicy getLocatio * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=415 + * google/cloud/batch/v1alpha/job.proto;l=438 * @return Whether the instance field is set. */ @java.lang.Override @@ -11094,7 +11632,7 @@ public boolean hasInstance() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=415 + * google/cloud/batch/v1alpha/job.proto;l=438 * @return The instance. */ @java.lang.Override @@ -11225,7 +11763,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.InstancePolicyOrTemplate * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return A list containing the instanceTemplates. */ @java.lang.Deprecated @@ -11243,7 +11781,7 @@ public com.google.protobuf.ProtocolStringList getInstanceTemplatesList() { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return The count of instanceTemplates. */ @java.lang.Deprecated @@ -11261,7 +11799,7 @@ public int getInstanceTemplatesCount() { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index of the element to return. * @return The instanceTemplates at the given index. */ @@ -11280,7 +11818,7 @@ public java.lang.String getInstanceTemplates(int index) { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index of the value to return. * @return The bytes of the instanceTemplates at the given index. */ @@ -11322,7 +11860,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel convert * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @return A list containing the provisioningModels. */ @java.lang.Override @@ -11348,7 +11886,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel convert * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @return The count of provisioningModels. */ @java.lang.Override @@ -11371,7 +11909,7 @@ public int getProvisioningModelsCount() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index of the element to return. * @return The provisioningModels at the given index. */ @@ -11396,7 +11934,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel getProv * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @return A list containing the enum numeric values on the wire for provisioningModels. */ @java.lang.Override @@ -11419,7 +11957,7 @@ public java.util.List getProvisioningModelsValueList() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index of the value to return. * @return The enum numeric value on the wire of provisioningModels at the given index. */ @@ -12515,7 +13053,7 @@ public Builder clearLocation() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=415 + * google/cloud/batch/v1alpha/job.proto;l=438 * @return Whether the instance field is set. */ @java.lang.Deprecated @@ -12534,7 +13072,7 @@ public boolean hasInstance() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=415 + * google/cloud/batch/v1alpha/job.proto;l=438 * @return The instance. */ @java.lang.Deprecated @@ -13168,7 +13706,7 @@ private void ensureInstanceTemplatesIsMutable() { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return A list containing the instanceTemplates. */ @java.lang.Deprecated @@ -13186,7 +13724,7 @@ public com.google.protobuf.ProtocolStringList getInstanceTemplatesList() { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return The count of instanceTemplates. */ @java.lang.Deprecated @@ -13204,7 +13742,7 @@ public int getInstanceTemplatesCount() { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index of the element to return. * @return The instanceTemplates at the given index. */ @@ -13223,7 +13761,7 @@ public java.lang.String getInstanceTemplates(int index) { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index of the value to return. * @return The bytes of the instanceTemplates at the given index. */ @@ -13242,7 +13780,7 @@ public com.google.protobuf.ByteString getInstanceTemplatesBytes(int index) { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index to set the value at. * @param value The instanceTemplates to set. * @return This builder for chaining. @@ -13268,7 +13806,7 @@ public Builder setInstanceTemplates(int index, java.lang.String value) { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param value The instanceTemplates to add. * @return This builder for chaining. */ @@ -13293,7 +13831,7 @@ public Builder addInstanceTemplates(java.lang.String value) { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param values The instanceTemplates to add. * @return This builder for chaining. */ @@ -13315,7 +13853,7 @@ public Builder addAllInstanceTemplates(java.lang.Iterable valu * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return This builder for chaining. */ @java.lang.Deprecated @@ -13336,7 +13874,7 @@ public Builder clearInstanceTemplates() { * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param value The bytes of the instanceTemplates to add. * @return This builder for chaining. */ @@ -13376,7 +13914,7 @@ private void ensureProvisioningModelsIsMutable() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @return A list containing the provisioningModels. */ @java.lang.Deprecated @@ -13401,7 +13939,7 @@ private void ensureProvisioningModelsIsMutable() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @return The count of provisioningModels. */ @java.lang.Deprecated @@ -13423,7 +13961,7 @@ public int getProvisioningModelsCount() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index of the element to return. * @return The provisioningModels at the given index. */ @@ -13447,7 +13985,7 @@ public com.google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel getProv * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index to set the value at. * @param value The provisioningModels to set. * @return This builder for chaining. @@ -13478,7 +14016,7 @@ public Builder setProvisioningModels( * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param value The provisioningModels to add. * @return This builder for chaining. */ @@ -13508,7 +14046,7 @@ public Builder addProvisioningModels( * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param values The provisioningModels to add. * @return This builder for chaining. */ @@ -13539,7 +14077,7 @@ public Builder addAllProvisioningModels( * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @return This builder for chaining. */ @java.lang.Deprecated @@ -13564,7 +14102,7 @@ public Builder clearProvisioningModels() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @return A list containing the enum numeric values on the wire for provisioningModels. */ @java.lang.Deprecated @@ -13586,7 +14124,7 @@ public java.util.List getProvisioningModelsValueList() { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index of the value to return. * @return The enum numeric value on the wire of provisioningModels at the given index. */ @@ -13609,7 +14147,7 @@ public int getProvisioningModelsValue(int index) { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index to set the value at. * @param value The enum numeric value on the wire for provisioningModels to set. * @return This builder for chaining. @@ -13636,7 +14174,7 @@ public Builder setProvisioningModelsValue(int index, int value) { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param value The enum numeric value on the wire for provisioningModels to add. * @return This builder for chaining. */ @@ -13662,7 +14200,7 @@ public Builder addProvisioningModelsValue(int value) { * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. - * See google/cloud/batch/v1alpha/job.proto;l=430 + * See google/cloud/batch/v1alpha/job.proto;l=453 * @param values The enum numeric values on the wire for provisioningModels to add. * @return This builder for chaining. */ diff --git a/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicyOrBuilder.java b/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicyOrBuilder.java index 22071de..4efcc73 100644 --- a/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicyOrBuilder.java +++ b/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/AllocationPolicyOrBuilder.java @@ -70,7 +70,7 @@ public interface AllocationPolicyOrBuilder * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=415 + * google/cloud/batch/v1alpha/job.proto;l=438 * @return Whether the instance field is set. */ @java.lang.Deprecated @@ -87,7 +87,7 @@ public interface AllocationPolicyOrBuilder * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=415 + * google/cloud/batch/v1alpha/job.proto;l=438 * @return The instance. */ @java.lang.Deprecated @@ -188,7 +188,7 @@ public interface AllocationPolicyOrBuilder * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return A list containing the instanceTemplates. */ @java.lang.Deprecated @@ -204,7 +204,7 @@ public interface AllocationPolicyOrBuilder * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @return The count of instanceTemplates. */ @java.lang.Deprecated @@ -220,7 +220,7 @@ public interface AllocationPolicyOrBuilder * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index of the element to return. * @return The instanceTemplates at the given index. */ @@ -237,7 +237,7 @@ public interface AllocationPolicyOrBuilder * repeated string instance_templates = 3 [deprecated = true]; * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.instance_templates is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=423 + * google/cloud/batch/v1alpha/job.proto;l=446 * @param index The index of the value to return. * @return The bytes of the instanceTemplates at the given index. */ @@ -259,7 +259,7 @@ public interface AllocationPolicyOrBuilder * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @return A list containing the provisioningModels. */ @java.lang.Deprecated @@ -280,7 +280,7 @@ public interface AllocationPolicyOrBuilder * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @return The count of provisioningModels. */ @java.lang.Deprecated @@ -300,7 +300,7 @@ public interface AllocationPolicyOrBuilder * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index of the element to return. * @return The provisioningModels at the given index. */ @@ -322,7 +322,7 @@ com.google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel getProvisionin * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @return A list containing the enum numeric values on the wire for provisioningModels. */ @java.lang.Deprecated @@ -342,7 +342,7 @@ com.google.cloud.batch.v1alpha.AllocationPolicy.ProvisioningModel getProvisionin * * * @deprecated google.cloud.batch.v1alpha.AllocationPolicy.provisioning_models is deprecated. See - * google/cloud/batch/v1alpha/job.proto;l=430 + * google/cloud/batch/v1alpha/job.proto;l=453 * @param index The index of the value to return. * @return The enum numeric value on the wire of provisioningModels at the given index. */ diff --git a/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/JobProto.java b/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/JobProto.java index b95e4d5..42ac264 100644 --- a/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/JobProto.java +++ b/proto-google-cloud-batch-v1alpha/src/main/java/com/google/cloud/batch/v1alpha/JobProto.java @@ -208,7 +208,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "tus.State\022D\n\016new_task_state\030\003 \001(\0162,.goog" + "le.cloud.batch.v1alpha.TaskStatus.State\"" + "K\n\004Type\022\024\n\020TYPE_UNSPECIFIED\020\000\022\025\n\021JOB_STA" - + "TE_CHANGED\020\001\022\026\n\022TASK_STATE_CHANGED\020\002\"\270\016\n" + + "TE_CHANGED\020\001\022\026\n\022TASK_STATE_CHANGED\020\002\"\216\017\n" + "\020AllocationPolicy\022M\n\010location\030\001 \001(\0132;.go" + "ogle.cloud.batch.v1alpha.AllocationPolic" + "y.LocationPolicy\022Q\n\010instance\030\002 \001(\0132;.goo" @@ -227,60 +227,62 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "loud.batch.v1alpha.AllocationPolicy.Netw" + "orkPolicy\032E\n\016LocationPolicy\022\031\n\021allowed_l" + "ocations\030\001 \003(\t\022\030\n\020denied_locations\030\002 \003(\t" - + "\032Y\n\004Disk\022\017\n\005image\030\004 \001(\tH\000\022\022\n\010snapshot\030\005 " - + "\001(\tH\000\022\014\n\004type\030\001 \001(\t\022\017\n\007size_gb\030\002 \001(\003B\r\n\013" - + "data_source\032\217\001\n\014AttachedDisk\022E\n\010new_disk" - + "\030\001 \001(\01321.google.cloud.batch.v1alpha.Allo" - + "cationPolicy.DiskH\000\022\027\n\rexisting_disk\030\002 \001" - + "(\tH\000\022\023\n\013device_name\030\003 \001(\tB\n\n\010attached\032*\n" - + "\013Accelerator\022\014\n\004type\030\001 \001(\t\022\r\n\005count\030\002 \001(" - + "\003\032\331\002\n\016InstancePolicy\022!\n\025allowed_machine_" - + "types\030\001 \003(\tB\002\030\001\022\024\n\014machine_type\030\002 \001(\t\022\030\n" - + "\020min_cpu_platform\030\003 \001(\t\022Z\n\022provisioning_" - + "model\030\004 \001(\0162>.google.cloud.batch.v1alpha" - + ".AllocationPolicy.ProvisioningModel\022N\n\014a" - + "ccelerators\030\005 \003(\01328.google.cloud.batch.v" - + "1alpha.AllocationPolicy.Accelerator\022H\n\005d" - + "isks\030\006 \003(\01329.google.cloud.batch.v1alpha." - + "AllocationPolicy.AttachedDisk\032\231\001\n\030Instan" - + "cePolicyOrTemplate\022M\n\006policy\030\001 \001(\0132;.goo" + + "\032q\n\004Disk\022\017\n\005image\030\004 \001(\tH\000\022\022\n\010snapshot\030\005 " + + "\001(\tH\000\022\014\n\004type\030\001 \001(\t\022\017\n\007size_gb\030\002 \001(\003\022\026\n\016" + + "disk_interface\030\006 \001(\tB\r\n\013data_source\032\217\001\n\014" + + "AttachedDisk\022E\n\010new_disk\030\001 \001(\01321.google." + + "cloud.batch.v1alpha.AllocationPolicy.Dis" + + "kH\000\022\027\n\rexisting_disk\030\002 \001(\tH\000\022\023\n\013device_n" + + "ame\030\003 \001(\tB\n\n\010attached\032K\n\013Accelerator\022\014\n\004" + + "type\030\001 \001(\t\022\r\n\005count\030\002 \001(\003\022\037\n\023install_gpu" + + "_drivers\030\003 \001(\010B\002\030\001\032\331\002\n\016InstancePolicy\022!\n" + + "\025allowed_machine_types\030\001 \003(\tB\002\030\001\022\024\n\014mach" + + "ine_type\030\002 \001(\t\022\030\n\020min_cpu_platform\030\003 \001(\t" + + "\022Z\n\022provisioning_model\030\004 \001(\0162>.google.cl" + + "oud.batch.v1alpha.AllocationPolicy.Provi" + + "sioningModel\022N\n\014accelerators\030\005 \003(\01328.goo" + "gle.cloud.batch.v1alpha.AllocationPolicy" - + ".InstancePolicyH\000\022\033\n\021instance_template\030\002" - + " \001(\tH\000B\021\n\017policy_template\032W\n\020NetworkInte" - + "rface\022\017\n\007network\030\001 \001(\t\022\022\n\nsubnetwork\030\002 \001" - + "(\t\022\036\n\026no_external_ip_address\030\003 \001(\010\032j\n\rNe" - + "tworkPolicy\022Y\n\022network_interfaces\030\001 \003(\0132" - + "=.google.cloud.batch.v1alpha.AllocationP" - + "olicy.NetworkInterface\032-\n\013LabelsEntry\022\013\n" - + "\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"`\n\021Provisi" - + "oningModel\022\"\n\036PROVISIONING_MODEL_UNSPECI" - + "FIED\020\000\022\014\n\010STANDARD\020\001\022\010\n\004SPOT\020\002\022\017\n\013PREEMP" - + "TIBLE\020\003\"\351\005\n\tTaskGroup\022\021\n\004name\030\001 \001(\tB\003\340A\003" - + "\022<\n\ttask_spec\030\003 \001(\0132$.google.cloud.batch" - + ".v1alpha.TaskSpecB\003\340A\002\022\022\n\ntask_count\030\004 \001" - + "(\003\022\023\n\013parallelism\030\005 \001(\003\022Q\n\021scheduling_po" - + "licy\030\006 \001(\01626.google.cloud.batch.v1alpha." - + "TaskGroup.SchedulingPolicy\022G\n\021allocation" - + "_policy\030\007 \001(\0132,.google.cloud.batch.v1alp" - + "ha.AllocationPolicy\022A\n\006labels\030\010 \003(\01321.go" - + "ogle.cloud.batch.v1alpha.TaskGroup.Label" - + "sEntry\022B\n\021task_environments\030\t \003(\0132\'.goog" - + "le.cloud.batch.v1alpha.Environment\022\033\n\023ta" - + "sk_count_per_node\030\n \001(\003\022\032\n\022require_hosts" - + "_file\030\013 \001(\010\022\026\n\016permissive_ssh\030\014 \001(\010\032-\n\013L" - + "abelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\002" - + "8\001\"N\n\020SchedulingPolicy\022!\n\035SCHEDULING_POL" - + "ICY_UNSPECIFIED\020\000\022\027\n\023AS_SOON_AS_POSSIBLE" - + "\020\001:o\352Al\n\036batch.googleapis.com/TaskGroup\022" - + "Jprojects/{project}/locations/{location}" - + "/jobs/{job}/taskGroups/{task_group}\"/\n\016S" - + "erviceAccount\022\r\n\005email\030\001 \001(\t\022\016\n\006scopes\030\002" - + " \003(\tB\315\001\n\036com.google.cloud.batch.v1alphaB" - + "\010JobProtoP\001Z?google.golang.org/genproto/" - + "googleapis/cloud/batch/v1alpha;batch\242\002\003G" - + "CB\252\002\032Google.Cloud.Batch.V1Alpha\312\002\032Google" - + "\\Cloud\\Batch\\V1alpha\352\002\035Google::Cloud::Ba" - + "tch::V1alphab\006proto3" + + ".Accelerator\022H\n\005disks\030\006 \003(\01329.google.clo" + + "ud.batch.v1alpha.AllocationPolicy.Attach" + + "edDisk\032\266\001\n\030InstancePolicyOrTemplate\022M\n\006p" + + "olicy\030\001 \001(\0132;.google.cloud.batch.v1alpha" + + ".AllocationPolicy.InstancePolicyH\000\022\033\n\021in" + + "stance_template\030\002 \001(\tH\000\022\033\n\023install_gpu_d" + + "rivers\030\003 \001(\010B\021\n\017policy_template\032W\n\020Netwo" + + "rkInterface\022\017\n\007network\030\001 \001(\t\022\022\n\nsubnetwo" + + "rk\030\002 \001(\t\022\036\n\026no_external_ip_address\030\003 \001(\010" + + "\032j\n\rNetworkPolicy\022Y\n\022network_interfaces\030" + + "\001 \003(\0132=.google.cloud.batch.v1alpha.Alloc" + + "ationPolicy.NetworkInterface\032-\n\013LabelsEn" + + "try\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"`\n\021P" + + "rovisioningModel\022\"\n\036PROVISIONING_MODEL_U" + + "NSPECIFIED\020\000\022\014\n\010STANDARD\020\001\022\010\n\004SPOT\020\002\022\017\n\013" + + "PREEMPTIBLE\020\003\"\351\005\n\tTaskGroup\022\021\n\004name\030\001 \001(" + + "\tB\003\340A\003\022<\n\ttask_spec\030\003 \001(\0132$.google.cloud" + + ".batch.v1alpha.TaskSpecB\003\340A\002\022\022\n\ntask_cou" + + "nt\030\004 \001(\003\022\023\n\013parallelism\030\005 \001(\003\022Q\n\021schedul" + + "ing_policy\030\006 \001(\01626.google.cloud.batch.v1" + + "alpha.TaskGroup.SchedulingPolicy\022G\n\021allo" + + "cation_policy\030\007 \001(\0132,.google.cloud.batch" + + ".v1alpha.AllocationPolicy\022A\n\006labels\030\010 \003(" + + "\01321.google.cloud.batch.v1alpha.TaskGroup" + + ".LabelsEntry\022B\n\021task_environments\030\t \003(\0132" + + "\'.google.cloud.batch.v1alpha.Environment" + + "\022\033\n\023task_count_per_node\030\n \001(\003\022\032\n\022require" + + "_hosts_file\030\013 \001(\010\022\026\n\016permissive_ssh\030\014 \001(" + + "\010\032-\n\013LabelsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002" + + " \001(\t:\0028\001\"N\n\020SchedulingPolicy\022!\n\035SCHEDULI" + + "NG_POLICY_UNSPECIFIED\020\000\022\027\n\023AS_SOON_AS_PO" + + "SSIBLE\020\001:o\352Al\n\036batch.googleapis.com/Task" + + "Group\022Jprojects/{project}/locations/{loc" + + "ation}/jobs/{job}/taskGroups/{task_group" + + "}\"/\n\016ServiceAccount\022\r\n\005email\030\001 \001(\t\022\016\n\006sc" + + "opes\030\002 \003(\tB\315\001\n\036com.google.cloud.batch.v1" + + "alphaB\010JobProtoP\001Z?google.golang.org/gen" + + "proto/googleapis/cloud/batch/v1alpha;bat" + + "ch\242\002\003GCB\252\002\032Google.Cloud.Batch.V1Alpha\312\002\032" + + "Google\\Cloud\\Batch\\V1alpha\352\002\035Google::Clo" + + "ud::Batch::V1alphab\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -439,7 +441,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_batch_v1alpha_AllocationPolicy_Disk_descriptor, new java.lang.String[] { - "Image", "Snapshot", "Type", "SizeGb", "DataSource", + "Image", "Snapshot", "Type", "SizeGb", "DiskInterface", "DataSource", }); internal_static_google_cloud_batch_v1alpha_AllocationPolicy_AttachedDisk_descriptor = internal_static_google_cloud_batch_v1alpha_AllocationPolicy_descriptor @@ -459,7 +461,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_batch_v1alpha_AllocationPolicy_Accelerator_descriptor, new java.lang.String[] { - "Type", "Count", + "Type", "Count", "InstallGpuDrivers", }); internal_static_google_cloud_batch_v1alpha_AllocationPolicy_InstancePolicy_descriptor = internal_static_google_cloud_batch_v1alpha_AllocationPolicy_descriptor @@ -484,7 +486,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_batch_v1alpha_AllocationPolicy_InstancePolicyOrTemplate_descriptor, new java.lang.String[] { - "Policy", "InstanceTemplate", "PolicyTemplate", + "Policy", "InstanceTemplate", "InstallGpuDrivers", "PolicyTemplate", }); internal_static_google_cloud_batch_v1alpha_AllocationPolicy_NetworkInterface_descriptor = internal_static_google_cloud_batch_v1alpha_AllocationPolicy_descriptor diff --git a/proto-google-cloud-batch-v1alpha/src/main/proto/google/cloud/batch/v1alpha/job.proto b/proto-google-cloud-batch-v1alpha/src/main/proto/google/cloud/batch/v1alpha/job.proto index 1264ce2..1b5a1b2 100644 --- a/proto-google-cloud-batch-v1alpha/src/main/proto/google/cloud/batch/v1alpha/job.proto +++ b/proto-google-cloud-batch-v1alpha/src/main/proto/google/cloud/batch/v1alpha/job.proto @@ -268,12 +268,18 @@ message JobNotification { // resources should be allocated for the Job. message AllocationPolicy { message LocationPolicy { - // A list of allowed location names represented by internal URLs, - // First location in the list must be a region. - // for example, - // ["regions/us-central1"] allow VMs in region us-central1, - // ["regions/us-central1", "zones/us-central1-a"] only allow VMs in zone - // us-central1-a. + // A list of allowed location names represented by internal URLs. + // Each location can be a region or a zone. + // Only one region or multiple zones in one region is supported now. + // For example, + // ["regions/us-central1"] allow VMs in any zones in region us-central1. + // ["zones/us-central1-a", "zones/us-central1-c"] only allow VMs + // in zones us-central1-a and us-central1-c. + // All locations end up in different regions would cause errors. + // For example, + // ["regions/us-central1", "zones/us-central1-a", "zones/us-central1-b", + // "zones/us-west1-a"] contains 2 regions "us-central1" and + // "us-west1". An error is expected in this case. repeated string allowed_locations = 1; // A list of denied location names. @@ -282,7 +288,10 @@ message AllocationPolicy { repeated string denied_locations = 2; } - // A new persistent disk. + // A new persistent disk or a local ssd. + // A VM can only have one local SSD setting but multiple local SSD partitions. + // https://cloud.google.com/compute/docs/disks#pdspecs. + // https://cloud.google.com/compute/docs/disks#localssds. message Disk { // A data source from which a PD will be created. oneof data_source { @@ -294,15 +303,23 @@ message AllocationPolicy { } // Disk type as shown in `gcloud compute disk-types list` - // For example, "pd-ssd", "pd-standard", "pd-balanced". + // For example, "pd-ssd", "pd-standard", "pd-balanced", "local-ssd". string type = 1; // Disk size in GB. // This field is ignored if `data_source` is `disk` or `image`. + // If `type` is `local-ssd`, size_gb should be a multiple of 375GB, + // otherwise, the final size will be the next greater multiple of 375 GB. int64 size_gb = 2; + + // Local SSDs are available through both "SCSI" and "NVMe" interfaces. + // If not indicated, "NVMe" will be the default one for local ssds. + // We only support "SCSI" for persistent disks now. + string disk_interface = 6; } - // A new or an existing persistent disk attached to a VM instance. + // A new or an existing persistent disk or a local ssd attached to a VM + // instance. message AttachedDisk { oneof attached { Disk new_disk = 1; @@ -324,6 +341,10 @@ message AllocationPolicy { // The number of accelerators of this type. int64 count = 2; + + // When true, Batch will install the GPU drivers. + // This field will be ignored if specified. + bool install_gpu_drivers = 3 [deprecated = true]; } // InstancePolicy describes an instance type and resources attached to each VM @@ -363,6 +384,8 @@ message AllocationPolicy { // c++ keyword conflict. string instance_template = 2; } + + bool install_gpu_drivers = 3; } // A network interface.