diff --git a/google-cloud-vpcaccess/pom.xml b/google-cloud-vpcaccess/pom.xml index b6c4475a..e9910e70 100644 --- a/google-cloud-vpcaccess/pom.xml +++ b/google-cloud-vpcaccess/pom.xml @@ -80,6 +80,11 @@ grpc-google-cloud-vpcaccess-v1 test + + com.google.api.grpc + grpc-google-common-protos + test + com.google.api diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClient.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClient.java index e2057d60..4fd00891 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClient.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClient.java @@ -28,6 +28,9 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStub; import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; @@ -722,6 +725,104 @@ public final UnaryCallable deleteConnectorCal return stub.deleteConnectorCallable(); } + // 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 (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Location element : vpcAccessServiceClient.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 (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       vpcAccessServiceClient.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 (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
+   *   ListLocationsRequest request =
+   *       ListLocationsRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListLocationsResponse response =
+   *         vpcAccessServiceClient.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(); + } + @Override public final void close() { stub.close(); @@ -827,4 +928,80 @@ protected ListConnectorsFixedSizeCollection createCollection( return new ListConnectorsFixedSizeCollection(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-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceSettings.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceSettings.java index b0207fa7..241e6e1d 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceSettings.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.vpcaccess.v1; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; @@ -31,6 +32,8 @@ import com.google.api.gax.rpc.PagedCallSettings; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStubSettings; import com.google.longrunning.Operation; import com.google.protobuf.Empty; @@ -109,6 +112,12 @@ public UnaryCallSettings deleteConnectorSetti return ((VpcAccessServiceStubSettings) getStubSettings()).deleteConnectorOperationSettings(); } + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return ((VpcAccessServiceStubSettings) getStubSettings()).listLocationsSettings(); + } + public static final VpcAccessServiceSettings create(VpcAccessServiceStubSettings stub) throws IOException { return new VpcAccessServiceSettings.Builder(stub.toBuilder()).build(); @@ -258,6 +267,13 @@ public UnaryCallSettings.Builder deleteConnec return getStubSettingsBuilder().deleteConnectorOperationSettings(); } + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return getStubSettingsBuilder().listLocationsSettings(); + } + @Override public VpcAccessServiceSettings build() throws IOException { return new VpcAccessServiceSettings(this); diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/gapic_metadata.json b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/gapic_metadata.json index 706c30f2..105f48a5 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/gapic_metadata.json +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/gapic_metadata.json @@ -21,6 +21,9 @@ }, "ListConnectors": { "methods": ["listConnectors", "listConnectors", "listConnectors", "listConnectorsPagedCallable", "listConnectorsCallable"] + }, + "ListLocations": { + "methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"] } } } diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/package-info.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/package-info.java index ad55ba29..221caac9 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/package-info.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/package-info.java @@ -15,7 +15,9 @@ */ /** - * The interfaces provided are listed below, along with usage samples. + * A client to Serverless VPC Access API + * + *

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

======================= VpcAccessServiceClient ======================= * diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/GrpcVpcAccessServiceStub.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/GrpcVpcAccessServiceStub.java index eb7b7474..e7f52bec 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/GrpcVpcAccessServiceStub.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/GrpcVpcAccessServiceStub.java @@ -17,6 +17,7 @@ package com.google.cloud.vpcaccess.v1.stub; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; @@ -25,6 +26,8 @@ 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.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; import com.google.cloud.vpcaccess.v1.Connector; import com.google.cloud.vpcaccess.v1.CreateConnectorRequest; import com.google.cloud.vpcaccess.v1.DeleteConnectorRequest; @@ -90,6 +93,17 @@ public class GrpcVpcAccessServiceStub extends VpcAccessServiceStub { .setResponseMarshaller(ProtoUtils.marshaller(Operation.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 final UnaryCallable createConnectorCallable; private final OperationCallable createConnectorOperationCallable; @@ -100,6 +114,9 @@ public class GrpcVpcAccessServiceStub extends VpcAccessServiceStub { private final UnaryCallable deleteConnectorCallable; private final OperationCallable deleteConnectorOperationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -186,6 +203,16 @@ protected GrpcVpcAccessServiceStub( 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(); this.createConnectorCallable = callableFactory.createUnaryCallable( @@ -214,6 +241,12 @@ protected GrpcVpcAccessServiceStub( settings.deleteConnectorOperationSettings(), clientContext, operationsStub); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -261,6 +294,17 @@ public UnaryCallable deleteConnectorCallable( return deleteConnectorOperationCallable; } + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/HttpJsonVpcAccessServiceStub.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/HttpJsonVpcAccessServiceStub.java index f610e4c6..160e3b46 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/HttpJsonVpcAccessServiceStub.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/HttpJsonVpcAccessServiceStub.java @@ -17,6 +17,7 @@ package com.google.cloud.vpcaccess.v1.stub; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; @@ -33,6 +34,8 @@ 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.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; import com.google.cloud.vpcaccess.v1.Connector; import com.google.cloud.vpcaccess.v1.CreateConnectorRequest; import com.google.cloud.vpcaccess.v1.DeleteConnectorRequest; @@ -212,6 +215,39 @@ public class HttpJsonVpcAccessServiceStub extends VpcAccessServiceStub { HttpJsonOperationSnapshot.create(response)) .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 final UnaryCallable createConnectorCallable; private final OperationCallable createConnectorOperationCallable; @@ -222,6 +258,9 @@ public class HttpJsonVpcAccessServiceStub extends VpcAccessServiceStub { private final UnaryCallable deleteConnectorCallable; private final OperationCallable deleteConnectorOperationCallable; + private final UnaryCallable listLocationsCallable; + private final UnaryCallable + listLocationsPagedCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; @@ -289,6 +328,12 @@ protected HttpJsonVpcAccessServiceStub( .setMethodDescriptor(deleteConnectorMethodDescriptor) .setTypeRegistry(typeRegistry) .build(); + HttpJsonCallSettings + listLocationsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listLocationsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); this.createConnectorCallable = callableFactory.createUnaryCallable( @@ -317,6 +362,12 @@ protected HttpJsonVpcAccessServiceStub( settings.deleteConnectorOperationSettings(), clientContext, httpJsonOperationsStub); + this.listLocationsCallable = + callableFactory.createUnaryCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); + this.listLocationsPagedCallable = + callableFactory.createPagedCallable( + listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -329,6 +380,7 @@ public static List getMethodDescriptors() { methodDescriptors.add(getConnectorMethodDescriptor); methodDescriptors.add(listConnectorsMethodDescriptor); methodDescriptors.add(deleteConnectorMethodDescriptor); + methodDescriptors.add(listLocationsMethodDescriptor); return methodDescriptors; } @@ -374,6 +426,17 @@ public UnaryCallable deleteConnectorCallable( return deleteConnectorOperationCallable; } + @Override + public UnaryCallable listLocationsCallable() { + return listLocationsCallable; + } + + @Override + public UnaryCallable + listLocationsPagedCallable() { + return listLocationsPagedCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStub.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStub.java index 18d84e28..d92d7f2f 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStub.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStub.java @@ -17,10 +17,13 @@ package com.google.cloud.vpcaccess.v1.stub; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; import com.google.cloud.vpcaccess.v1.Connector; import com.google.cloud.vpcaccess.v1.CreateConnectorRequest; import com.google.cloud.vpcaccess.v1.DeleteConnectorRequest; @@ -81,6 +84,15 @@ public UnaryCallable deleteConnectorCallable( throw new UnsupportedOperationException("Not implemented: deleteConnectorCallable()"); } + public UnaryCallable + listLocationsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsPagedCallable()"); + } + + public UnaryCallable listLocationsCallable() { + throw new UnsupportedOperationException("Not implemented: listLocationsCallable()"); + } + @Override public abstract void close(); } diff --git a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStubSettings.java b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStubSettings.java index 01827378..eb6adeb2 100644 --- a/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStubSettings.java +++ b/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/VpcAccessServiceStubSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.vpcaccess.v1.stub; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; @@ -47,6 +48,9 @@ import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.cloud.vpcaccess.v1.Connector; import com.google.cloud.vpcaccess.v1.CreateConnectorRequest; import com.google.cloud.vpcaccess.v1.DeleteConnectorRequest; @@ -115,6 +119,9 @@ public class VpcAccessServiceStubSettings extends StubSettings deleteConnectorSettings; private final OperationCallSettings deleteConnectorOperationSettings; + private final PagedCallSettings< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; private static final PagedListDescriptor LIST_CONNECTORS_PAGE_STR_DESC = @@ -153,6 +160,42 @@ public Iterable extractResources(ListConnectorsResponse 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< ListConnectorsRequest, ListConnectorsResponse, ListConnectorsPagedResponse> LIST_CONNECTORS_PAGE_STR_FACT = @@ -170,6 +213,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 createConnector. */ public UnaryCallSettings createConnectorSettings() { return createConnectorSettings; @@ -204,6 +264,12 @@ public UnaryCallSettings deleteConnectorSetti return deleteConnectorOperationSettings; } + /** Returns the object with the settings used for calls to listLocations. */ + public PagedCallSettings + listLocationsSettings() { + return listLocationsSettings; + } + public VpcAccessServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() @@ -316,6 +382,7 @@ protected VpcAccessServiceStubSettings(Builder settingsBuilder) throws IOExcepti listConnectorsSettings = settingsBuilder.listConnectorsSettings().build(); deleteConnectorSettings = settingsBuilder.deleteConnectorSettings().build(); deleteConnectorOperationSettings = settingsBuilder.deleteConnectorOperationSettings().build(); + listLocationsSettings = settingsBuilder.listLocationsSettings().build(); } /** Builder for VpcAccessServiceStubSettings. */ @@ -334,6 +401,9 @@ public static class Builder extends StubSettings.Builder deleteConnectorOperationSettings; + private final PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -342,6 +412,11 @@ public static class Builder extends StubSettings.BuildernewArrayList())); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNKNOWN))); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -358,6 +433,17 @@ public static class Builder extends StubSettings.Builder>of( createConnectorSettings, getConnectorSettings, listConnectorsSettings, - deleteConnectorSettings); + deleteConnectorSettings, + listLocationsSettings); initDefaults(this); } @@ -393,13 +481,15 @@ protected Builder(VpcAccessServiceStubSettings settings) { listConnectorsSettings = settings.listConnectorsSettings.toBuilder(); deleteConnectorSettings = settings.deleteConnectorSettings.toBuilder(); deleteConnectorOperationSettings = settings.deleteConnectorOperationSettings.toBuilder(); + listLocationsSettings = settings.listLocationsSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( createConnectorSettings, getConnectorSettings, listConnectorsSettings, - deleteConnectorSettings); + deleteConnectorSettings, + listLocationsSettings); } private static Builder createDefault() { @@ -449,6 +539,11 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + builder + .listLocationsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder .createConnectorOperationSettings() .setInitialCallSettings( @@ -553,6 +648,13 @@ public UnaryCallSettings.Builder deleteConnec return deleteConnectorOperationSettings; } + /** Returns the builder for the settings used for calls to listLocations. */ + public PagedCallSettings.Builder< + ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> + listLocationsSettings() { + return listLocationsSettings; + } + @Override public VpcAccessServiceStubSettings build() throws IOException { return new VpcAccessServiceStubSettings(this); diff --git a/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/MockLocations.java b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/MockLocations.java new file mode 100644 index 00000000..2ea202d4 --- /dev/null +++ b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/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.vpcaccess.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class 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-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/MockLocationsImpl.java b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/MockLocationsImpl.java new file mode 100644 index 00000000..3df7f0f7 --- /dev/null +++ b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/MockLocationsImpl.java @@ -0,0 +1,83 @@ +/* + * 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.vpcaccess.v1; + +import com.google.api.core.BetaApi; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +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()))); + } + } +} diff --git a/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientHttpJsonTest.java b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientHttpJsonTest.java index e2487409..a13348e3 100644 --- a/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientHttpJsonTest.java +++ b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientHttpJsonTest.java @@ -17,6 +17,7 @@ package com.google.cloud.vpcaccess.v1; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.httpjson.GaxHttpJsonProperties; @@ -27,6 +28,9 @@ 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.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.cloud.vpcaccess.v1.stub.HttpJsonVpcAccessServiceStub; import com.google.common.collect.Lists; import com.google.longrunning.Operation; @@ -91,6 +95,9 @@ public void createConnectorTest() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); Operation resultOperation = Operation.newBuilder() @@ -150,6 +157,9 @@ public void createConnectorTest2() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); Operation resultOperation = Operation.newBuilder() @@ -209,6 +219,9 @@ public void getConnectorTest() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); mockService.addResponse(expectedResponse); @@ -259,6 +272,9 @@ public void getConnectorTest2() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); mockService.addResponse(expectedResponse); @@ -487,4 +503,66 @@ public void deleteConnectorExceptionTest2() throws Exception { } catch (ExecutionException e) { } } + + @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. + } + } } diff --git a/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientTest.java b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientTest.java index 6fbcbdcd..4a5f4098 100644 --- a/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientTest.java +++ b/google-cloud-vpcaccess/src/test/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClientTest.java @@ -17,6 +17,7 @@ package com.google.cloud.vpcaccess.v1; import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse; +import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; @@ -26,6 +27,9 @@ 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.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; import com.google.common.collect.Lists; import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; @@ -48,6 +52,7 @@ @Generated("by gapic-generator-java") public class VpcAccessServiceClientTest { + private static MockLocations mockLocations; private static MockServiceHelper mockServiceHelper; private static MockVpcAccessService mockVpcAccessService; private LocalChannelProvider channelProvider; @@ -56,9 +61,11 @@ public class VpcAccessServiceClientTest { @BeforeClass public static void startStaticServer() { mockVpcAccessService = new MockVpcAccessService(); + mockLocations = new MockLocations(); mockServiceHelper = new MockServiceHelper( - UUID.randomUUID().toString(), Arrays.asList(mockVpcAccessService)); + UUID.randomUUID().toString(), + Arrays.asList(mockVpcAccessService, mockLocations)); mockServiceHelper.start(); } @@ -95,6 +102,9 @@ public void createConnectorTest() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); Operation resultOperation = Operation.newBuilder() @@ -153,6 +163,9 @@ public void createConnectorTest2() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); Operation resultOperation = Operation.newBuilder() @@ -211,6 +224,9 @@ public void getConnectorTest() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); mockVpcAccessService.addResponse(expectedResponse); @@ -255,6 +271,9 @@ public void getConnectorTest2() throws Exception { .setMaxThroughput(1407819749) .addAllConnectedProjects(new ArrayList()) .setSubnet(Connector.Subnet.newBuilder().build()) + .setMachineType("machineType-218117087") + .setMinInstances(1491624145) + .setMaxInstances(-330682013) .build(); mockVpcAccessService.addResponse(expectedResponse); @@ -459,4 +478,63 @@ public void deleteConnectorExceptionTest2() throws Exception { Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } + + @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. + } + } } diff --git a/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/Connector.java b/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/Connector.java index f647dd8a..895112a2 100644 --- a/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/Connector.java +++ b/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/Connector.java @@ -43,6 +43,7 @@ private Connector() { ipCidrRange_ = ""; state_ = 0; connectedProjects_ = com.google.protobuf.LazyStringArrayList.EMPTY; + machineType_ = ""; } @java.lang.Override @@ -137,6 +138,23 @@ private Connector( subnet_ = subBuilder.buildPartial(); } + break; + } + case 82: + { + java.lang.String s = input.readStringRequireUtf8(); + + machineType_ = s; + break; + } + case 88: + { + minInstances_ = input.readInt32(); + break; + } + case 96: + { + maxInstances_ = input.readInt32(); break; } default: @@ -1516,7 +1534,7 @@ public int getMinThroughput() { * * *
-   * Maximum throughput of the connector in Mbps. Default is 200, max is 1000.
+   * Maximum throughput of the connector in Mbps. Default is 300, max is 1000.
    * 
* * int32 max_throughput = 6; @@ -1641,6 +1659,91 @@ public com.google.cloud.vpcaccess.v1.Connector.SubnetOrBuilder getSubnetOrBuilde return getSubnet(); } + public static final int MACHINE_TYPE_FIELD_NUMBER = 10; + private volatile java.lang.Object machineType_; + /** + * + * + *
+   * Machine type of VM Instance underlying connector. Default is e2-micro
+   * 
+ * + * string machine_type = 10; + * + * @return The machineType. + */ + @java.lang.Override + public java.lang.String getMachineType() { + java.lang.Object ref = machineType_; + 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(); + machineType_ = s; + return s; + } + } + /** + * + * + *
+   * Machine type of VM Instance underlying connector. Default is e2-micro
+   * 
+ * + * string machine_type = 10; + * + * @return The bytes for machineType. + */ + @java.lang.Override + public com.google.protobuf.ByteString getMachineTypeBytes() { + java.lang.Object ref = machineType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + machineType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MIN_INSTANCES_FIELD_NUMBER = 11; + private int minInstances_; + /** + * + * + *
+   * Minimum value of instances in autoscaling group underlying the connector.
+   * 
+ * + * int32 min_instances = 11; + * + * @return The minInstances. + */ + @java.lang.Override + public int getMinInstances() { + return minInstances_; + } + + public static final int MAX_INSTANCES_FIELD_NUMBER = 12; + private int maxInstances_; + /** + * + * + *
+   * Maximum value of instances in autoscaling group underlying the connector.
+   * 
+ * + * int32 max_instances = 12; + * + * @return The maxInstances. + */ + @java.lang.Override + public int getMaxInstances() { + return maxInstances_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1679,6 +1782,15 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (subnet_ != null) { output.writeMessage(8, getSubnet()); } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(machineType_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 10, machineType_); + } + if (minInstances_ != 0) { + output.writeInt32(11, minInstances_); + } + if (maxInstances_ != 0) { + output.writeInt32(12, maxInstances_); + } unknownFields.writeTo(output); } @@ -1717,6 +1829,15 @@ public int getSerializedSize() { if (subnet_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getSubnet()); } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(machineType_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, machineType_); + } + if (minInstances_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(11, minInstances_); + } + if (maxInstances_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(12, maxInstances_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -1743,6 +1864,9 @@ public boolean equals(final java.lang.Object obj) { if (hasSubnet()) { if (!getSubnet().equals(other.getSubnet())) return false; } + if (!getMachineType().equals(other.getMachineType())) return false; + if (getMinInstances() != other.getMinInstances()) return false; + if (getMaxInstances() != other.getMaxInstances()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -1774,6 +1898,12 @@ public int hashCode() { hash = (37 * hash) + SUBNET_FIELD_NUMBER; hash = (53 * hash) + getSubnet().hashCode(); } + hash = (37 * hash) + MACHINE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getMachineType().hashCode(); + hash = (37 * hash) + MIN_INSTANCES_FIELD_NUMBER; + hash = (53 * hash) + getMinInstances(); + hash = (37 * hash) + MAX_INSTANCES_FIELD_NUMBER; + hash = (53 * hash) + getMaxInstances(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -1939,6 +2069,12 @@ public Builder clear() { subnet_ = null; subnetBuilder_ = null; } + machineType_ = ""; + + minInstances_ = 0; + + maxInstances_ = 0; + return this; } @@ -1983,6 +2119,9 @@ public com.google.cloud.vpcaccess.v1.Connector buildPartial() { } else { result.subnet_ = subnetBuilder_.build(); } + result.machineType_ = machineType_; + result.minInstances_ = minInstances_; + result.maxInstances_ = maxInstances_; onBuilt(); return result; } @@ -2066,6 +2205,16 @@ public Builder mergeFrom(com.google.cloud.vpcaccess.v1.Connector other) { if (other.hasSubnet()) { mergeSubnet(other.getSubnet()); } + if (!other.getMachineType().isEmpty()) { + machineType_ = other.machineType_; + onChanged(); + } + if (other.getMinInstances() != 0) { + setMinInstances(other.getMinInstances()); + } + if (other.getMaxInstances() != 0) { + setMaxInstances(other.getMaxInstances()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -2578,7 +2727,7 @@ public Builder clearMinThroughput() { * * *
-     * Maximum throughput of the connector in Mbps. Default is 200, max is 1000.
+     * Maximum throughput of the connector in Mbps. Default is 300, max is 1000.
      * 
* * int32 max_throughput = 6; @@ -2593,7 +2742,7 @@ public int getMaxThroughput() { * * *
-     * Maximum throughput of the connector in Mbps. Default is 200, max is 1000.
+     * Maximum throughput of the connector in Mbps. Default is 300, max is 1000.
      * 
* * int32 max_throughput = 6; @@ -2611,7 +2760,7 @@ public Builder setMaxThroughput(int value) { * * *
-     * Maximum throughput of the connector in Mbps. Default is 200, max is 1000.
+     * Maximum throughput of the connector in Mbps. Default is 300, max is 1000.
      * 
* * int32 max_throughput = 6; @@ -2988,6 +3137,216 @@ public com.google.cloud.vpcaccess.v1.Connector.SubnetOrBuilder getSubnetOrBuilde return subnetBuilder_; } + private java.lang.Object machineType_ = ""; + /** + * + * + *
+     * Machine type of VM Instance underlying connector. Default is e2-micro
+     * 
+ * + * string machine_type = 10; + * + * @return The machineType. + */ + public java.lang.String getMachineType() { + java.lang.Object ref = machineType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + machineType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Machine type of VM Instance underlying connector. Default is e2-micro
+     * 
+ * + * string machine_type = 10; + * + * @return The bytes for machineType. + */ + public com.google.protobuf.ByteString getMachineTypeBytes() { + java.lang.Object ref = machineType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + machineType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Machine type of VM Instance underlying connector. Default is e2-micro
+     * 
+ * + * string machine_type = 10; + * + * @param value The machineType to set. + * @return This builder for chaining. + */ + public Builder setMachineType(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + machineType_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Machine type of VM Instance underlying connector. Default is e2-micro
+     * 
+ * + * string machine_type = 10; + * + * @return This builder for chaining. + */ + public Builder clearMachineType() { + + machineType_ = getDefaultInstance().getMachineType(); + onChanged(); + return this; + } + /** + * + * + *
+     * Machine type of VM Instance underlying connector. Default is e2-micro
+     * 
+ * + * string machine_type = 10; + * + * @param value The bytes for machineType to set. + * @return This builder for chaining. + */ + public Builder setMachineTypeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + machineType_ = value; + onChanged(); + return this; + } + + private int minInstances_; + /** + * + * + *
+     * Minimum value of instances in autoscaling group underlying the connector.
+     * 
+ * + * int32 min_instances = 11; + * + * @return The minInstances. + */ + @java.lang.Override + public int getMinInstances() { + return minInstances_; + } + /** + * + * + *
+     * Minimum value of instances in autoscaling group underlying the connector.
+     * 
+ * + * int32 min_instances = 11; + * + * @param value The minInstances to set. + * @return This builder for chaining. + */ + public Builder setMinInstances(int value) { + + minInstances_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Minimum value of instances in autoscaling group underlying the connector.
+     * 
+ * + * int32 min_instances = 11; + * + * @return This builder for chaining. + */ + public Builder clearMinInstances() { + + minInstances_ = 0; + onChanged(); + return this; + } + + private int maxInstances_; + /** + * + * + *
+     * Maximum value of instances in autoscaling group underlying the connector.
+     * 
+ * + * int32 max_instances = 12; + * + * @return The maxInstances. + */ + @java.lang.Override + public int getMaxInstances() { + return maxInstances_; + } + /** + * + * + *
+     * Maximum value of instances in autoscaling group underlying the connector.
+     * 
+ * + * int32 max_instances = 12; + * + * @param value The maxInstances to set. + * @return This builder for chaining. + */ + public Builder setMaxInstances(int value) { + + maxInstances_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Maximum value of instances in autoscaling group underlying the connector.
+     * 
+ * + * int32 max_instances = 12; + * + * @return This builder for chaining. + */ + public Builder clearMaxInstances() { + + maxInstances_ = 0; + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/ConnectorOrBuilder.java b/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/ConnectorOrBuilder.java index 5ee83598..c5e4697a 100644 --- a/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/ConnectorOrBuilder.java +++ b/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/ConnectorOrBuilder.java @@ -146,7 +146,7 @@ public interface ConnectorOrBuilder * * *
-   * Maximum throughput of the connector in Mbps. Default is 200, max is 1000.
+   * Maximum throughput of the connector in Mbps. Default is 300, max is 1000.
    * 
* * int32 max_throughput = 6; @@ -244,4 +244,55 @@ public interface ConnectorOrBuilder * .google.cloud.vpcaccess.v1.Connector.Subnet subnet = 8; */ com.google.cloud.vpcaccess.v1.Connector.SubnetOrBuilder getSubnetOrBuilder(); + + /** + * + * + *
+   * Machine type of VM Instance underlying connector. Default is e2-micro
+   * 
+ * + * string machine_type = 10; + * + * @return The machineType. + */ + java.lang.String getMachineType(); + /** + * + * + *
+   * Machine type of VM Instance underlying connector. Default is e2-micro
+   * 
+ * + * string machine_type = 10; + * + * @return The bytes for machineType. + */ + com.google.protobuf.ByteString getMachineTypeBytes(); + + /** + * + * + *
+   * Minimum value of instances in autoscaling group underlying the connector.
+   * 
+ * + * int32 min_instances = 11; + * + * @return The minInstances. + */ + int getMinInstances(); + + /** + * + * + *
+   * Maximum value of instances in autoscaling group underlying the connector.
+   * 
+ * + * int32 max_instances = 12; + * + * @return The maxInstances. + */ + int getMaxInstances(); } diff --git a/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessProto.java b/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessProto.java index 39ee2b17..acc6a599 100644 --- a/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessProto.java +++ b/proto-google-cloud-vpcaccess-v1/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessProto.java @@ -74,67 +74,69 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + ".proto\032\037google/api/field_behavior.proto\032" + "\031google/api/resource.proto\032#google/longr" + "unning/operations.proto\032\037google/protobuf" - + "/timestamp.proto\"\204\004\n\tConnector\022\014\n\004name\030\001" + + "/timestamp.proto\"\310\004\n\tConnector\022\014\n\004name\030\001" + " \001(\t\022\017\n\007network\030\002 \001(\t\022\025\n\rip_cidr_range\030\003" + " \001(\t\022>\n\005state\030\004 \001(\0162*.google.cloud.vpcac" + "cess.v1.Connector.StateB\003\340A\003\022\026\n\016min_thro" + "ughput\030\005 \001(\005\022\026\n\016max_throughput\030\006 \001(\005\022\037\n\022" + "connected_projects\030\007 \003(\tB\003\340A\003\022;\n\006subnet\030" + "\010 \001(\0132+.google.cloud.vpcaccess.v1.Connec" - + "tor.Subnet\032*\n\006Subnet\022\014\n\004name\030\001 \001(\t\022\022\n\npr" - + "oject_id\030\002 \001(\t\"^\n\005State\022\025\n\021STATE_UNSPECI" - + "FIED\020\000\022\t\n\005READY\020\001\022\014\n\010CREATING\020\002\022\014\n\010DELET" - + "ING\020\003\022\t\n\005ERROR\020\004\022\014\n\010UPDATING\020\005:g\352Ad\n\"vpc" - + "access.googleapis.com/Connector\022>project" - + "s/{project}/locations/{location}/connect" - + "ors/{connector}\"\254\001\n\026CreateConnectorReque" - + "st\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!locations.go" - + "ogleapis.com/Location\022\031\n\014connector_id\030\002 " - + "\001(\tB\003\340A\002\022<\n\tconnector\030\003 \001(\0132$.google.clo" - + "ud.vpcaccess.v1.ConnectorB\003\340A\002\"O\n\023GetCon" - + "nectorRequest\0228\n\004name\030\001 \001(\tB*\340A\002\372A$\n\"vpc" - + "access.googleapis.com/Connector\"y\n\025ListC" - + "onnectorsRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#" - + "\n!locations.googleapis.com/Location\022\021\n\tp" - + "age_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"k\n\026Li" - + "stConnectorsResponse\0228\n\nconnectors\030\001 \003(\013" - + "2$.google.cloud.vpcaccess.v1.Connector\022\027" - + "\n\017next_page_token\030\002 \001(\t\"R\n\026DeleteConnect" - + "orRequest\0228\n\004name\030\001 \001(\tB*\340A\002\372A$\n\"vpcacce" - + "ss.googleapis.com/Connector\"\315\001\n\021Operatio" - + "nMetadata\022\023\n\006method\030\001 \001(\tB\003\340A\003\0224\n\013create" - + "_time\030\002 \001(\0132\032.google.protobuf.TimestampB" - + "\003\340A\003\0221\n\010end_time\030\003 \001(\0132\032.google.protobuf" - + ".TimestampB\003\340A\003\022:\n\006target\030\005 \001(\tB*\340A\003\372A$\n" - + "\"vpcaccess.googleapis.com/Connector2\374\006\n\020" - + "VpcAccessService\022\350\001\n\017CreateConnector\0221.g" - + "oogle.cloud.vpcaccess.v1.CreateConnector" - + "Request\032\035.google.longrunning.Operation\"\202" - + "\001\202\323\344\223\002;\"./v1/{parent=projects/*/location" - + "s/*}/connectors:\tconnector\332A\035parent,conn" - + "ector_id,connector\312A\036\n\tConnector\022\021Operat" - + "ionMetadata\022\243\001\n\014GetConnector\022..google.cl" - + "oud.vpcaccess.v1.GetConnectorRequest\032$.g" - + "oogle.cloud.vpcaccess.v1.Connector\"=\202\323\344\223" - + "\0020\022./v1/{name=projects/*/locations/*/con" - + "nectors/*}\332A\004name\022\266\001\n\016ListConnectors\0220.g" - + "oogle.cloud.vpcaccess.v1.ListConnectorsR" - + "equest\0321.google.cloud.vpcaccess.v1.ListC" - + "onnectorsResponse\"?\202\323\344\223\0020\022./v1/{parent=p" - + "rojects/*/locations/*}/connectors\332A\006pare" - + "nt\022\317\001\n\017DeleteConnector\0221.google.cloud.vp" - + "caccess.v1.DeleteConnectorRequest\032\035.goog" - + "le.longrunning.Operation\"j\202\323\344\223\0020*./v1/{n" - + "ame=projects/*/locations/*/connectors/*}" - + "\332A\004name\312A*\n\025google.protobuf.Empty\022\021Opera" - + "tionMetadata\032L\312A\030vpcaccess.googleapis.co" - + "m\322A.https://www.googleapis.com/auth/clou" - + "d-platformB\314\001\n\035com.google.cloud.vpcacces" - + "s.v1B\016VpcAccessProtoP\001ZBgoogle.golang.or" - + "g/genproto/googleapis/cloud/vpcaccess/v1" - + ";vpcaccess\252\002\031Google.Cloud.VpcAccess.V1\312\002" - + "\031Google\\Cloud\\VpcAccess\\V1\352\002\034Google::Clo" - + "ud::VpcAccess::V1b\006proto3" + + "tor.Subnet\022\024\n\014machine_type\030\n \001(\t\022\025\n\rmin_" + + "instances\030\013 \001(\005\022\025\n\rmax_instances\030\014 \001(\005\032*" + + "\n\006Subnet\022\014\n\004name\030\001 \001(\t\022\022\n\nproject_id\030\002 \001" + + "(\t\"^\n\005State\022\025\n\021STATE_UNSPECIFIED\020\000\022\t\n\005RE" + + "ADY\020\001\022\014\n\010CREATING\020\002\022\014\n\010DELETING\020\003\022\t\n\005ERR" + + "OR\020\004\022\014\n\010UPDATING\020\005:g\352Ad\n\"vpcaccess.googl" + + "eapis.com/Connector\022>projects/{project}/" + + "locations/{location}/connectors/{connect" + + "or}\"\254\001\n\026CreateConnectorRequest\0229\n\006parent" + + "\030\001 \001(\tB)\340A\002\372A#\n!locations.googleapis.com" + + "/Location\022\031\n\014connector_id\030\002 \001(\tB\003\340A\002\022<\n\t" + + "connector\030\003 \001(\0132$.google.cloud.vpcaccess" + + ".v1.ConnectorB\003\340A\002\"O\n\023GetConnectorReques" + + "t\0228\n\004name\030\001 \001(\tB*\340A\002\372A$\n\"vpcaccess.googl" + + "eapis.com/Connector\"y\n\025ListConnectorsReq" + + "uest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!locations." + + "googleapis.com/Location\022\021\n\tpage_size\030\002 \001" + + "(\005\022\022\n\npage_token\030\003 \001(\t\"k\n\026ListConnectors" + + "Response\0228\n\nconnectors\030\001 \003(\0132$.google.cl" + + "oud.vpcaccess.v1.Connector\022\027\n\017next_page_" + + "token\030\002 \001(\t\"R\n\026DeleteConnectorRequest\0228\n" + + "\004name\030\001 \001(\tB*\340A\002\372A$\n\"vpcaccess.googleapi" + + "s.com/Connector\"\315\001\n\021OperationMetadata\022\023\n" + + "\006method\030\001 \001(\tB\003\340A\003\0224\n\013create_time\030\002 \001(\0132" + + "\032.google.protobuf.TimestampB\003\340A\003\0221\n\010end_" + + "time\030\003 \001(\0132\032.google.protobuf.TimestampB\003" + + "\340A\003\022:\n\006target\030\005 \001(\tB*\340A\003\372A$\n\"vpcaccess.g" + + "oogleapis.com/Connector2\374\006\n\020VpcAccessSer" + + "vice\022\350\001\n\017CreateConnector\0221.google.cloud." + + "vpcaccess.v1.CreateConnectorRequest\032\035.go" + + "ogle.longrunning.Operation\"\202\001\202\323\344\223\002;\"./v1" + + "/{parent=projects/*/locations/*}/connect" + + "ors:\tconnector\332A\035parent,connector_id,con" + + "nector\312A\036\n\tConnector\022\021OperationMetadata\022" + + "\243\001\n\014GetConnector\022..google.cloud.vpcacces" + + "s.v1.GetConnectorRequest\032$.google.cloud." + + "vpcaccess.v1.Connector\"=\202\323\344\223\0020\022./v1/{nam" + + "e=projects/*/locations/*/connectors/*}\332A" + + "\004name\022\266\001\n\016ListConnectors\0220.google.cloud." + + "vpcaccess.v1.ListConnectorsRequest\0321.goo" + + "gle.cloud.vpcaccess.v1.ListConnectorsRes" + + "ponse\"?\202\323\344\223\0020\022./v1/{parent=projects/*/lo" + + "cations/*}/connectors\332A\006parent\022\317\001\n\017Delet" + + "eConnector\0221.google.cloud.vpcaccess.v1.D" + + "eleteConnectorRequest\032\035.google.longrunni" + + "ng.Operation\"j\202\323\344\223\0020*./v1/{name=projects" + + "/*/locations/*/connectors/*}\332A\004name\312A*\n\025" + + "google.protobuf.Empty\022\021OperationMetadata" + + "\032L\312A\030vpcaccess.googleapis.com\322A.https://" + + "www.googleapis.com/auth/cloud-platformB\314" + + "\001\n\035com.google.cloud.vpcaccess.v1B\016VpcAcc" + + "essProtoP\001ZBgoogle.golang.org/genproto/g" + + "oogleapis/cloud/vpcaccess/v1;vpcaccess\252\002" + + "\031Google.Cloud.VpcAccess.V1\312\002\031Google\\Clou" + + "d\\VpcAccess\\V1\352\002\034Google::Cloud::VpcAcces" + + "s::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -161,6 +163,9 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "MaxThroughput", "ConnectedProjects", "Subnet", + "MachineType", + "MinInstances", + "MaxInstances", }); internal_static_google_cloud_vpcaccess_v1_Connector_Subnet_descriptor = internal_static_google_cloud_vpcaccess_v1_Connector_descriptor.getNestedTypes().get(0); diff --git a/proto-google-cloud-vpcaccess-v1/src/main/proto/google/cloud/vpcaccess/v1/vpc_access.proto b/proto-google-cloud-vpcaccess-v1/src/main/proto/google/cloud/vpcaccess/v1/vpc_access.proto index 24ac40dd..bf2b2fc8 100644 --- a/proto-google-cloud-vpcaccess-v1/src/main/proto/google/cloud/vpcaccess/v1/vpc_access.proto +++ b/proto-google-cloud-vpcaccess-v1/src/main/proto/google/cloud/vpcaccess/v1/vpc_access.proto @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// 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. @@ -89,20 +89,6 @@ message Connector { pattern: "projects/{project}/locations/{location}/connectors/{connector}" }; - // The subnet in which to house the connector - message Subnet { - // Subnet name (relative, not fully qualified). - // E.g. if the full subnet selfLink is - // https://compute.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetName} - // the correct input for this field would be {subnetName} - string name = 1; - - // Project in which the subnet exists. - // If not set, this project is assumed to be the project for which - // the connector create request was issued. - string project_id = 2; - } - // State of a connector. enum State { // Invalid state. @@ -124,6 +110,20 @@ message Connector { UPDATING = 5; } + // The subnet in which to house the connector + message Subnet { + // Subnet name (relative, not fully qualified). + // E.g. if the full subnet selfLink is + // https://compute.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetName} + // the correct input for this field would be {subnetName} + string name = 1; + + // Project in which the subnet exists. + // If not set, this project is assumed to be the project for which + // the connector create request was issued. + string project_id = 2; + } + // The resource name in the format `projects/*/locations/*/connectors/*`. string name = 1; @@ -140,7 +140,7 @@ message Connector { // Minimum throughput of the connector in Mbps. Default and min is 200. int32 min_throughput = 5; - // Maximum throughput of the connector in Mbps. Default is 200, max is 1000. + // Maximum throughput of the connector in Mbps. Default is 300, max is 1000. int32 max_throughput = 6; // Output only. List of projects using the connector. @@ -148,6 +148,15 @@ message Connector { // The subnet in which to house the VPC Access Connector. Subnet subnet = 8; + + // Machine type of VM Instance underlying connector. Default is e2-micro + string machine_type = 10; + + // Minimum value of instances in autoscaling group underlying the connector. + int32 min_instances = 11; + + // Maximum value of instances in autoscaling group underlying the connector. + int32 max_instances = 12; } // Request for creating a Serverless VPC Access connector. diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/createconnector/SyncCreateConnectorLocationnameStringConnector.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/createconnector/SyncCreateConnectorLocationnameStringConnector.java index d559f65e..d2f0f1b5 100644 --- a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/createconnector/SyncCreateConnectorLocationnameStringConnector.java +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/createconnector/SyncCreateConnectorLocationnameStringConnector.java @@ -16,8 +16,7 @@ package com.google.cloud.vpcaccess.v1.samples; -// [START -// vpcaccess_v1_generated_vpcaccessserviceclient_createconnector_locationnamestringconnector_sync] +// [START vpcaccess_v1_generated_vpcaccessserviceclient_createconnector_locationnamestringconnector_sync] import com.google.cloud.vpcaccess.v1.Connector; import com.google.cloud.vpcaccess.v1.LocationName; import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; @@ -40,5 +39,4 @@ public static void syncCreateConnectorLocationnameStringConnector() throws Excep } } } -// [END -// vpcaccess_v1_generated_vpcaccessserviceclient_createconnector_locationnamestringconnector_sync] +// [END vpcaccess_v1_generated_vpcaccessserviceclient_createconnector_locationnamestringconnector_sync] diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnector.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnector.java index b13ba891..12ff233f 100644 --- a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnector.java +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnector.java @@ -20,6 +20,7 @@ import com.google.cloud.vpcaccess.v1.ConnectorName; import com.google.cloud.vpcaccess.v1.DeleteConnectorRequest; import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; +import com.google.protobuf.Empty; public class SyncDeleteConnector { diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorConnectorname.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorConnectorname.java index aaf23ca9..a04fe677 100644 --- a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorConnectorname.java +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorConnectorname.java @@ -19,6 +19,7 @@ // [START vpcaccess_v1_generated_vpcaccessserviceclient_deleteconnector_connectorname_sync] import com.google.cloud.vpcaccess.v1.ConnectorName; import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; +import com.google.protobuf.Empty; public class SyncDeleteConnectorConnectorname { diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorString.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorString.java index a3832c58..eb10e2db 100644 --- a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorString.java +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/deleteconnector/SyncDeleteConnectorString.java @@ -19,6 +19,7 @@ // [START vpcaccess_v1_generated_vpcaccessserviceclient_deleteconnector_string_sync] import com.google.cloud.vpcaccess.v1.ConnectorName; import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; +import com.google.protobuf.Empty; public class SyncDeleteConnectorString { diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/AsyncListLocations.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/AsyncListLocations.java new file mode 100644 index 00000000..302e5f6f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/AsyncListLocations.java @@ -0,0 +1,51 @@ +/* + * 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.vpcaccess.v1.samples; + +// [START vpcaccess_v1_generated_vpcaccessserviceclient_listlocations_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; +import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; + +public class AsyncListLocations { + + public static void main(String[] args) throws Exception { + asyncListLocations(); + } + + public static void asyncListLocations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + vpcAccessServiceClient.listLocationsPagedCallable().futureCall(request); + // Do something. + for (Location element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vpcaccess_v1_generated_vpcaccessserviceclient_listlocations_async] diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/AsyncListLocationsPaged.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/AsyncListLocationsPaged.java new file mode 100644 index 00000000..e3b1dc1d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/AsyncListLocationsPaged.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.vpcaccess.v1.samples; + +// [START vpcaccess_v1_generated_vpcaccessserviceclient_listlocations_paged_async] +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.ListLocationsResponse; +import com.google.cloud.location.Location; +import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; +import com.google.common.base.Strings; + +public class AsyncListLocationsPaged { + + public static void main(String[] args) throws Exception { + asyncListLocationsPaged(); + } + + public static void asyncListLocationsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListLocationsResponse response = + vpcAccessServiceClient.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; + } + } + } + } +} +// [END vpcaccess_v1_generated_vpcaccessserviceclient_listlocations_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/SyncListLocations.java b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/SyncListLocations.java new file mode 100644 index 00000000..13be8957 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/vpcaccess/v1/vpcaccessserviceclient/listlocations/SyncListLocations.java @@ -0,0 +1,47 @@ +/* + * 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.vpcaccess.v1.samples; + +// [START vpcaccess_v1_generated_vpcaccessserviceclient_listlocations_sync] +import com.google.cloud.location.ListLocationsRequest; +import com.google.cloud.location.Location; +import com.google.cloud.vpcaccess.v1.VpcAccessServiceClient; + +public class SyncListLocations { + + public static void main(String[] args) throws Exception { + syncListLocations(); + } + + public static void syncListLocations() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) { + ListLocationsRequest request = + ListLocationsRequest.newBuilder() + .setName("name3373707") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Location element : vpcAccessServiceClient.listLocations(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END vpcaccess_v1_generated_vpcaccessserviceclient_listlocations_sync]