Skip to content

Commit 953c975

Browse files
feat: Adds support for configuring scaling settings (#232)
- [ ] Regenerate this pull request now. Clients can now specify machine type and min/max instances when creating a connector. PiperOrigin-RevId: 469463049 Source-Link: googleapis/googleapis@17b39f1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/88b74ac69e76791a020cb543747c090655ee7144 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODhiNzRhYzY5ZTc2NzkxYTAyMGNiNTQzNzQ3YzA5MDY1NWVlNzE0NCJ9
1 parent c232e61 commit 953c975

24 files changed

+1388
-84
lines changed

java-vpcaccess/google-cloud-vpcaccess/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
<artifactId>grpc-google-cloud-vpcaccess-v1</artifactId>
8181
<scope>test</scope>
8282
</dependency>
83+
<dependency>
84+
<groupId>com.google.api.grpc</groupId>
85+
<artifactId>grpc-google-common-protos</artifactId>
86+
<scope>test</scope>
87+
</dependency>
8388
<!-- Need testing utility classes for generated gRPC clients tests -->
8489
<dependency>
8590
<groupId>com.google.api</groupId>

java-vpcaccess/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceClient.java

+177
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import com.google.api.gax.rpc.OperationCallable;
2929
import com.google.api.gax.rpc.PageContext;
3030
import com.google.api.gax.rpc.UnaryCallable;
31+
import com.google.cloud.location.ListLocationsRequest;
32+
import com.google.cloud.location.ListLocationsResponse;
33+
import com.google.cloud.location.Location;
3134
import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStub;
3235
import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStubSettings;
3336
import com.google.common.util.concurrent.MoreExecutors;
@@ -722,6 +725,104 @@ public final UnaryCallable<DeleteConnectorRequest, Operation> deleteConnectorCal
722725
return stub.deleteConnectorCallable();
723726
}
724727

728+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
729+
/**
730+
* Lists information about the supported locations for this service.
731+
*
732+
* <p>Sample code:
733+
*
734+
* <pre>{@code
735+
* // This snippet has been automatically generated for illustrative purposes only.
736+
* // It may require modifications to work in your environment.
737+
* try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
738+
* ListLocationsRequest request =
739+
* ListLocationsRequest.newBuilder()
740+
* .setName("name3373707")
741+
* .setFilter("filter-1274492040")
742+
* .setPageSize(883849137)
743+
* .setPageToken("pageToken873572522")
744+
* .build();
745+
* for (Location element : vpcAccessServiceClient.listLocations(request).iterateAll()) {
746+
* // doThingsWith(element);
747+
* }
748+
* }
749+
* }</pre>
750+
*
751+
* @param request The request object containing all of the parameters for the API call.
752+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
753+
*/
754+
public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
755+
return listLocationsPagedCallable().call(request);
756+
}
757+
758+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
759+
/**
760+
* Lists information about the supported locations for this service.
761+
*
762+
* <p>Sample code:
763+
*
764+
* <pre>{@code
765+
* // This snippet has been automatically generated for illustrative purposes only.
766+
* // It may require modifications to work in your environment.
767+
* try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
768+
* ListLocationsRequest request =
769+
* ListLocationsRequest.newBuilder()
770+
* .setName("name3373707")
771+
* .setFilter("filter-1274492040")
772+
* .setPageSize(883849137)
773+
* .setPageToken("pageToken873572522")
774+
* .build();
775+
* ApiFuture<Location> future =
776+
* vpcAccessServiceClient.listLocationsPagedCallable().futureCall(request);
777+
* // Do something.
778+
* for (Location element : future.get().iterateAll()) {
779+
* // doThingsWith(element);
780+
* }
781+
* }
782+
* }</pre>
783+
*/
784+
public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
785+
listLocationsPagedCallable() {
786+
return stub.listLocationsPagedCallable();
787+
}
788+
789+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
790+
/**
791+
* Lists information about the supported locations for this service.
792+
*
793+
* <p>Sample code:
794+
*
795+
* <pre>{@code
796+
* // This snippet has been automatically generated for illustrative purposes only.
797+
* // It may require modifications to work in your environment.
798+
* try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
799+
* ListLocationsRequest request =
800+
* ListLocationsRequest.newBuilder()
801+
* .setName("name3373707")
802+
* .setFilter("filter-1274492040")
803+
* .setPageSize(883849137)
804+
* .setPageToken("pageToken873572522")
805+
* .build();
806+
* while (true) {
807+
* ListLocationsResponse response =
808+
* vpcAccessServiceClient.listLocationsCallable().call(request);
809+
* for (Location element : response.getLocationsList()) {
810+
* // doThingsWith(element);
811+
* }
812+
* String nextPageToken = response.getNextPageToken();
813+
* if (!Strings.isNullOrEmpty(nextPageToken)) {
814+
* request = request.toBuilder().setPageToken(nextPageToken).build();
815+
* } else {
816+
* break;
817+
* }
818+
* }
819+
* }
820+
* }</pre>
821+
*/
822+
public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
823+
return stub.listLocationsCallable();
824+
}
825+
725826
@Override
726827
public final void close() {
727828
stub.close();
@@ -827,4 +928,80 @@ protected ListConnectorsFixedSizeCollection createCollection(
827928
return new ListConnectorsFixedSizeCollection(pages, collectionSize);
828929
}
829930
}
931+
932+
public static class ListLocationsPagedResponse
933+
extends AbstractPagedListResponse<
934+
ListLocationsRequest,
935+
ListLocationsResponse,
936+
Location,
937+
ListLocationsPage,
938+
ListLocationsFixedSizeCollection> {
939+
940+
public static ApiFuture<ListLocationsPagedResponse> createAsync(
941+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
942+
ApiFuture<ListLocationsResponse> futureResponse) {
943+
ApiFuture<ListLocationsPage> futurePage =
944+
ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
945+
return ApiFutures.transform(
946+
futurePage,
947+
input -> new ListLocationsPagedResponse(input),
948+
MoreExecutors.directExecutor());
949+
}
950+
951+
private ListLocationsPagedResponse(ListLocationsPage page) {
952+
super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
953+
}
954+
}
955+
956+
public static class ListLocationsPage
957+
extends AbstractPage<
958+
ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
959+
960+
private ListLocationsPage(
961+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
962+
ListLocationsResponse response) {
963+
super(context, response);
964+
}
965+
966+
private static ListLocationsPage createEmptyPage() {
967+
return new ListLocationsPage(null, null);
968+
}
969+
970+
@Override
971+
protected ListLocationsPage createPage(
972+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
973+
ListLocationsResponse response) {
974+
return new ListLocationsPage(context, response);
975+
}
976+
977+
@Override
978+
public ApiFuture<ListLocationsPage> createPageAsync(
979+
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
980+
ApiFuture<ListLocationsResponse> futureResponse) {
981+
return super.createPageAsync(context, futureResponse);
982+
}
983+
}
984+
985+
public static class ListLocationsFixedSizeCollection
986+
extends AbstractFixedSizeCollection<
987+
ListLocationsRequest,
988+
ListLocationsResponse,
989+
Location,
990+
ListLocationsPage,
991+
ListLocationsFixedSizeCollection> {
992+
993+
private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
994+
super(pages, collectionSize);
995+
}
996+
997+
private static ListLocationsFixedSizeCollection createEmptyCollection() {
998+
return new ListLocationsFixedSizeCollection(null, 0);
999+
}
1000+
1001+
@Override
1002+
protected ListLocationsFixedSizeCollection createCollection(
1003+
List<ListLocationsPage> pages, int collectionSize) {
1004+
return new ListLocationsFixedSizeCollection(pages, collectionSize);
1005+
}
1006+
}
8301007
}

java-vpcaccess/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/VpcAccessServiceSettings.java

+16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.cloud.vpcaccess.v1;
1818

1919
import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse;
20+
import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse;
2021

2122
import com.google.api.core.ApiFunction;
2223
import com.google.api.core.BetaApi;
@@ -31,6 +32,8 @@
3132
import com.google.api.gax.rpc.PagedCallSettings;
3233
import com.google.api.gax.rpc.TransportChannelProvider;
3334
import com.google.api.gax.rpc.UnaryCallSettings;
35+
import com.google.cloud.location.ListLocationsRequest;
36+
import com.google.cloud.location.ListLocationsResponse;
3437
import com.google.cloud.vpcaccess.v1.stub.VpcAccessServiceStubSettings;
3538
import com.google.longrunning.Operation;
3639
import com.google.protobuf.Empty;
@@ -109,6 +112,12 @@ public UnaryCallSettings<DeleteConnectorRequest, Operation> deleteConnectorSetti
109112
return ((VpcAccessServiceStubSettings) getStubSettings()).deleteConnectorOperationSettings();
110113
}
111114

115+
/** Returns the object with the settings used for calls to listLocations. */
116+
public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
117+
listLocationsSettings() {
118+
return ((VpcAccessServiceStubSettings) getStubSettings()).listLocationsSettings();
119+
}
120+
112121
public static final VpcAccessServiceSettings create(VpcAccessServiceStubSettings stub)
113122
throws IOException {
114123
return new VpcAccessServiceSettings.Builder(stub.toBuilder()).build();
@@ -258,6 +267,13 @@ public UnaryCallSettings.Builder<DeleteConnectorRequest, Operation> deleteConnec
258267
return getStubSettingsBuilder().deleteConnectorOperationSettings();
259268
}
260269

270+
/** Returns the builder for the settings used for calls to listLocations. */
271+
public PagedCallSettings.Builder<
272+
ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
273+
listLocationsSettings() {
274+
return getStubSettingsBuilder().listLocationsSettings();
275+
}
276+
261277
@Override
262278
public VpcAccessServiceSettings build() throws IOException {
263279
return new VpcAccessServiceSettings(this);

java-vpcaccess/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/gapic_metadata.json

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
},
2222
"ListConnectors": {
2323
"methods": ["listConnectors", "listConnectors", "listConnectors", "listConnectorsPagedCallable", "listConnectorsCallable"]
24+
},
25+
"ListLocations": {
26+
"methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"]
2427
}
2528
}
2629
}

java-vpcaccess/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/package-info.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
/**
18-
* The interfaces provided are listed below, along with usage samples.
18+
* A client to Serverless VPC Access API
19+
*
20+
* <p>The interfaces provided are listed below, along with usage samples.
1921
*
2022
* <p>======================= VpcAccessServiceClient =======================
2123
*

java-vpcaccess/google-cloud-vpcaccess/src/main/java/com/google/cloud/vpcaccess/v1/stub/GrpcVpcAccessServiceStub.java

+44
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.google.cloud.vpcaccess.v1.stub;
1818

1919
import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListConnectorsPagedResponse;
20+
import static com.google.cloud.vpcaccess.v1.VpcAccessServiceClient.ListLocationsPagedResponse;
2021

2122
import com.google.api.gax.core.BackgroundResource;
2223
import com.google.api.gax.core.BackgroundResourceAggregation;
@@ -25,6 +26,8 @@
2526
import com.google.api.gax.rpc.ClientContext;
2627
import com.google.api.gax.rpc.OperationCallable;
2728
import com.google.api.gax.rpc.UnaryCallable;
29+
import com.google.cloud.location.ListLocationsRequest;
30+
import com.google.cloud.location.ListLocationsResponse;
2831
import com.google.cloud.vpcaccess.v1.Connector;
2932
import com.google.cloud.vpcaccess.v1.CreateConnectorRequest;
3033
import com.google.cloud.vpcaccess.v1.DeleteConnectorRequest;
@@ -90,6 +93,17 @@ public class GrpcVpcAccessServiceStub extends VpcAccessServiceStub {
9093
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
9194
.build();
9295

96+
private static final MethodDescriptor<ListLocationsRequest, ListLocationsResponse>
97+
listLocationsMethodDescriptor =
98+
MethodDescriptor.<ListLocationsRequest, ListLocationsResponse>newBuilder()
99+
.setType(MethodDescriptor.MethodType.UNARY)
100+
.setFullMethodName("google.cloud.location.Locations/ListLocations")
101+
.setRequestMarshaller(
102+
ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance()))
103+
.setResponseMarshaller(
104+
ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance()))
105+
.build();
106+
93107
private final UnaryCallable<CreateConnectorRequest, Operation> createConnectorCallable;
94108
private final OperationCallable<CreateConnectorRequest, Connector, OperationMetadata>
95109
createConnectorOperationCallable;
@@ -100,6 +114,9 @@ public class GrpcVpcAccessServiceStub extends VpcAccessServiceStub {
100114
private final UnaryCallable<DeleteConnectorRequest, Operation> deleteConnectorCallable;
101115
private final OperationCallable<DeleteConnectorRequest, Empty, OperationMetadata>
102116
deleteConnectorOperationCallable;
117+
private final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable;
118+
private final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
119+
listLocationsPagedCallable;
103120

104121
private final BackgroundResource backgroundResources;
105122
private final GrpcOperationsStub operationsStub;
@@ -186,6 +203,16 @@ protected GrpcVpcAccessServiceStub(
186203
return params.build();
187204
})
188205
.build();
206+
GrpcCallSettings<ListLocationsRequest, ListLocationsResponse> listLocationsTransportSettings =
207+
GrpcCallSettings.<ListLocationsRequest, ListLocationsResponse>newBuilder()
208+
.setMethodDescriptor(listLocationsMethodDescriptor)
209+
.setParamsExtractor(
210+
request -> {
211+
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
212+
params.put("name", String.valueOf(request.getName()));
213+
return params.build();
214+
})
215+
.build();
189216

190217
this.createConnectorCallable =
191218
callableFactory.createUnaryCallable(
@@ -214,6 +241,12 @@ protected GrpcVpcAccessServiceStub(
214241
settings.deleteConnectorOperationSettings(),
215242
clientContext,
216243
operationsStub);
244+
this.listLocationsCallable =
245+
callableFactory.createUnaryCallable(
246+
listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
247+
this.listLocationsPagedCallable =
248+
callableFactory.createPagedCallable(
249+
listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
217250

218251
this.backgroundResources =
219252
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
@@ -261,6 +294,17 @@ public UnaryCallable<DeleteConnectorRequest, Operation> deleteConnectorCallable(
261294
return deleteConnectorOperationCallable;
262295
}
263296

297+
@Override
298+
public UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
299+
return listLocationsCallable;
300+
}
301+
302+
@Override
303+
public UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
304+
listLocationsPagedCallable() {
305+
return listLocationsPagedCallable;
306+
}
307+
264308
@Override
265309
public final void close() {
266310
try {

0 commit comments

Comments
 (0)