Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
feat: Adds support for configuring scaling settings (#232)
Browse files Browse the repository at this point in the history
- [ ] 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: googleapis/googleapis-gen@88b74ac
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODhiNzRhYzY5ZTc2NzkxYTAyMGNiNTQzNzQ3YzA5MDY1NWVlNzE0NCJ9
  • Loading branch information
gcf-owl-bot[bot] committed Aug 25, 2022
1 parent 3b62081 commit 90f3253
Show file tree
Hide file tree
Showing 24 changed files with 1,388 additions and 84 deletions.
5 changes: 5 additions & 0 deletions google-cloud-vpcaccess/pom.xml
Expand Up @@ -80,6 +80,11 @@
<artifactId>grpc-google-cloud-vpcaccess-v1</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
<scope>test</scope>
</dependency>
<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -722,6 +725,104 @@ public final UnaryCallable<DeleteConnectorRequest, Operation> deleteConnectorCal
return stub.deleteConnectorCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* <p>Sample code:
*
* <pre>{@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);
* }
* }
* }</pre>
*
* @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.
*
* <p>Sample code:
*
* <pre>{@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<Location> future =
* vpcAccessServiceClient.listLocationsPagedCallable().futureCall(request);
* // Do something.
* for (Location element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }</pre>
*/
public final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable() {
return stub.listLocationsPagedCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* <p>Sample code:
*
* <pre>{@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;
* }
* }
* }
* }</pre>
*/
public final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
return stub.listLocationsCallable();
}

@Override
public final void close() {
stub.close();
Expand Down Expand Up @@ -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<ListLocationsPagedResponse> createAsync(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ApiFuture<ListLocationsResponse> futureResponse) {
ApiFuture<ListLocationsPage> 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<ListLocationsRequest, ListLocationsResponse, Location> context,
ListLocationsResponse response) {
super(context, response);
}

private static ListLocationsPage createEmptyPage() {
return new ListLocationsPage(null, null);
}

@Override
protected ListLocationsPage createPage(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ListLocationsResponse response) {
return new ListLocationsPage(context, response);
}

@Override
public ApiFuture<ListLocationsPage> createPageAsync(
PageContext<ListLocationsRequest, ListLocationsResponse, Location> context,
ApiFuture<ListLocationsResponse> futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}

public static class ListLocationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {

private ListLocationsFixedSizeCollection(List<ListLocationsPage> pages, int collectionSize) {
super(pages, collectionSize);
}

private static ListLocationsFixedSizeCollection createEmptyCollection() {
return new ListLocationsFixedSizeCollection(null, 0);
}

@Override
protected ListLocationsFixedSizeCollection createCollection(
List<ListLocationsPage> pages, int collectionSize) {
return new ListLocationsFixedSizeCollection(pages, collectionSize);
}
}
}
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -109,6 +112,12 @@ public UnaryCallSettings<DeleteConnectorRequest, Operation> deleteConnectorSetti
return ((VpcAccessServiceStubSettings) getStubSettings()).deleteConnectorOperationSettings();
}

/** Returns the object with the settings used for calls to listLocations. */
public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse>
listLocationsSettings() {
return ((VpcAccessServiceStubSettings) getStubSettings()).listLocationsSettings();
}

public static final VpcAccessServiceSettings create(VpcAccessServiceStubSettings stub)
throws IOException {
return new VpcAccessServiceSettings.Builder(stub.toBuilder()).build();
Expand Down Expand Up @@ -258,6 +267,13 @@ public UnaryCallSettings.Builder<DeleteConnectorRequest, Operation> 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);
Expand Down
Expand Up @@ -21,6 +21,9 @@
},
"ListConnectors": {
"methods": ["listConnectors", "listConnectors", "listConnectors", "listConnectorsPagedCallable", "listConnectorsCallable"]
},
"ListLocations": {
"methods": ["listLocations", "listLocationsPagedCallable", "listLocationsCallable"]
}
}
}
Expand Down
Expand Up @@ -15,7 +15,9 @@
*/

/**
* The interfaces provided are listed below, along with usage samples.
* A client to Serverless VPC Access API
*
* <p>The interfaces provided are listed below, along with usage samples.
*
* <p>======================= VpcAccessServiceClient =======================
*
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -90,6 +93,17 @@ public class GrpcVpcAccessServiceStub extends VpcAccessServiceStub {
.setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
.build();

private static final MethodDescriptor<ListLocationsRequest, ListLocationsResponse>
listLocationsMethodDescriptor =
MethodDescriptor.<ListLocationsRequest, ListLocationsResponse>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<CreateConnectorRequest, Operation> createConnectorCallable;
private final OperationCallable<CreateConnectorRequest, Connector, OperationMetadata>
createConnectorOperationCallable;
Expand All @@ -100,6 +114,9 @@ public class GrpcVpcAccessServiceStub extends VpcAccessServiceStub {
private final UnaryCallable<DeleteConnectorRequest, Operation> deleteConnectorCallable;
private final OperationCallable<DeleteConnectorRequest, Empty, OperationMetadata>
deleteConnectorOperationCallable;
private final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable;
private final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable;

private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
Expand Down Expand Up @@ -186,6 +203,16 @@ protected GrpcVpcAccessServiceStub(
return params.build();
})
.build();
GrpcCallSettings<ListLocationsRequest, ListLocationsResponse> listLocationsTransportSettings =
GrpcCallSettings.<ListLocationsRequest, ListLocationsResponse>newBuilder()
.setMethodDescriptor(listLocationsMethodDescriptor)
.setParamsExtractor(
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
})
.build();

this.createConnectorCallable =
callableFactory.createUnaryCallable(
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -261,6 +294,17 @@ public UnaryCallable<DeleteConnectorRequest, Operation> deleteConnectorCallable(
return deleteConnectorOperationCallable;
}

@Override
public UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
return listLocationsCallable;
}

@Override
public UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable() {
return listLocationsPagedCallable;
}

@Override
public final void close() {
try {
Expand Down

0 comments on commit 90f3253

Please sign in to comment.