Class VpcAccessServiceClient (2.6.0)

publicclass VpcAccessServiceClientimplementsBackgroundResource

Service Description: Serverless VPC Access API allows users to create and manage connectors for App Engine, Cloud Functions and Cloud Run to have internal connections to Virtual Private Cloud networks.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ConnectorNamename=ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]");
Connectorresponse=vpcAccessServiceClient.getConnector(name);
}

Note: close() needs to be called on the VpcAccessServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

The surface of this class includes several types of Java methods for each of the API's methods:

  1. A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
  2. A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
  3. A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of VpcAccessServiceSettings to create(). For example:

To customize credentials:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
VpcAccessServiceSettingsvpcAccessServiceSettings=
VpcAccessServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
VpcAccessServiceClientvpcAccessServiceClient=
VpcAccessServiceClient.create(vpcAccessServiceSettings);

To customize the endpoint:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
VpcAccessServiceSettingsvpcAccessServiceSettings=
VpcAccessServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
VpcAccessServiceClientvpcAccessServiceClient=
VpcAccessServiceClient.create(vpcAccessServiceSettings);

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


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
VpcAccessServiceSettingsvpcAccessServiceSettings=
VpcAccessServiceSettings.newBuilder()
.setTransportChannelProvider(
VpcAccessServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
VpcAccessServiceClientvpcAccessServiceClient=
VpcAccessServiceClient.create(vpcAccessServiceSettings);

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > VpcAccessServiceClient

Implements

BackgroundResource

Static Methods

create()

publicstaticfinalVpcAccessServiceClientcreate()

Constructs an instance of VpcAccessServiceClient with default settings.

Returns
Type Description
Exceptions
Type Description

create(VpcAccessServiceSettings settings)

publicstaticfinalVpcAccessServiceClientcreate(VpcAccessServiceSettingssettings)

Constructs an instance of VpcAccessServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
Returns
Type Description
Exceptions
Type Description

create(VpcAccessServiceStub stub)

publicstaticfinalVpcAccessServiceClientcreate(VpcAccessServiceStubstub)

Constructs an instance of VpcAccessServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(VpcAccessServiceSettings).

Parameter
Name Description
Returns
Type Description

Constructors

VpcAccessServiceClient(VpcAccessServiceSettings settings)

protectedVpcAccessServiceClient(VpcAccessServiceSettingssettings)

Constructs an instance of VpcAccessServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description

VpcAccessServiceClient(VpcAccessServiceStub stub)

protectedVpcAccessServiceClient(VpcAccessServiceStubstub)
Parameter
Name Description

Methods

awaitTermination(long duration, TimeUnit unit)

publicbooleanawaitTermination(longduration,TimeUnitunit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
Exceptions
Type Description

close()

publicfinalvoidclose()

createConnectorAsync(CreateConnectorRequest request)

publicfinalOperationFuture<Connector,OperationMetadata>createConnectorAsync(CreateConnectorRequestrequest)

Creates a Serverless VPC Access connector, returns an operation.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
CreateConnectorRequestrequest=
CreateConnectorRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setConnectorId("connectorId1724784200")
.setConnector(Connector.newBuilder().build())
.build();
Connectorresponse=vpcAccessServiceClient.createConnectorAsync(request).get();
}
Parameter
Name Description
request CreateConnectorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description

createConnectorAsync(LocationName parent, String connectorId, Connector connector)

publicfinalOperationFuture<Connector,OperationMetadata>createConnectorAsync(LocationNameparent,StringconnectorId,Connectorconnector)

Creates a Serverless VPC Access connector, returns an operation.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
StringconnectorId="connectorId1724784200";
Connectorconnector=Connector.newBuilder().build();
Connectorresponse=
vpcAccessServiceClient.createConnectorAsync(parent,connectorId,connector).get();
}
Parameters
Name Description
parent LocationName

Required. The project and location in which the configuration should be created, specified in the format projects/*/locations/*.

connectorId String

Required. The ID to use for this connector.

connector Connector

Required. Resource to create.

Returns
Type Description

createConnectorAsync(String parent, String connectorId, Connector connector)

publicfinalOperationFuture<Connector,OperationMetadata>createConnectorAsync(Stringparent,StringconnectorId,Connectorconnector)

Creates a Serverless VPC Access connector, returns an operation.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
StringconnectorId="connectorId1724784200";
Connectorconnector=Connector.newBuilder().build();
Connectorresponse=
vpcAccessServiceClient.createConnectorAsync(parent,connectorId,connector).get();
}
Parameters
Name Description
parent String

Required. The project and location in which the configuration should be created, specified in the format projects/*/locations/*.

connectorId String

Required. The ID to use for this connector.

connector Connector

Required. Resource to create.

Returns
Type Description

createConnectorCallable()

publicfinalUnaryCallable<CreateConnectorRequest,Operation>createConnectorCallable()

Creates a Serverless VPC Access connector, returns an operation.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
CreateConnectorRequestrequest=
CreateConnectorRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setConnectorId("connectorId1724784200")
.setConnector(Connector.newBuilder().build())
.build();
ApiFuture<Operation>future=
vpcAccessServiceClient.createConnectorCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
Returns
Type Description

createConnectorOperationCallable()

publicfinalOperationCallable<CreateConnectorRequest,Connector,OperationMetadata>createConnectorOperationCallable()

Creates a Serverless VPC Access connector, returns an operation.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
CreateConnectorRequestrequest=
CreateConnectorRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setConnectorId("connectorId1724784200")
.setConnector(Connector.newBuilder().build())
.build();
OperationFuture<Connector,OperationMetadata>future=
vpcAccessServiceClient.createConnectorOperationCallable().futureCall(request);
// Do something.
Connectorresponse=future.get();
}
Returns
Type Description

deleteConnectorAsync(ConnectorName name)

publicfinalOperationFuture<Empty,OperationMetadata>deleteConnectorAsync(ConnectorNamename)

Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ConnectorNamename=ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]");
vpcAccessServiceClient.deleteConnectorAsync(name).get();
}
Parameter
Name Description
name ConnectorName

Required. Name of a Serverless VPC Access connector to delete.

Returns
Type Description

deleteConnectorAsync(DeleteConnectorRequest request)

publicfinalOperationFuture<Empty,OperationMetadata>deleteConnectorAsync(DeleteConnectorRequestrequest)

Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
DeleteConnectorRequestrequest=
DeleteConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString())
.build();
vpcAccessServiceClient.deleteConnectorAsync(request).get();
}
Parameter
Name Description
request DeleteConnectorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description

deleteConnectorAsync(String name)

publicfinalOperationFuture<Empty,OperationMetadata>deleteConnectorAsync(Stringname)

Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
Stringname=ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString();
vpcAccessServiceClient.deleteConnectorAsync(name).get();
}
Parameter
Name Description
name String

Required. Name of a Serverless VPC Access connector to delete.

Returns
Type Description

deleteConnectorCallable()

publicfinalUnaryCallable<DeleteConnectorRequest,Operation>deleteConnectorCallable()

Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
DeleteConnectorRequestrequest=
DeleteConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString())
.build();
ApiFuture<Operation>future=
vpcAccessServiceClient.deleteConnectorCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

deleteConnectorOperationCallable()

publicfinalOperationCallable<DeleteConnectorRequest,Empty,OperationMetadata>deleteConnectorOperationCallable()

Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
DeleteConnectorRequestrequest=
DeleteConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString())
.build();
OperationFuture<Empty,OperationMetadata>future=
vpcAccessServiceClient.deleteConnectorOperationCallable().futureCall(request);
// Do something.
future.get();
}
Returns
Type Description

getConnector(ConnectorName name)

publicfinalConnectorgetConnector(ConnectorNamename)

Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ConnectorNamename=ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]");
Connectorresponse=vpcAccessServiceClient.getConnector(name);
}
Parameter
Name Description
name ConnectorName

Required. Name of a Serverless VPC Access connector to get.

Returns
Type Description

getConnector(GetConnectorRequest request)

publicfinalConnectorgetConnector(GetConnectorRequestrequest)

Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
GetConnectorRequestrequest=
GetConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString())
.build();
Connectorresponse=vpcAccessServiceClient.getConnector(request);
}
Parameter
Name Description
request GetConnectorRequest

The request object containing all of the parameters for the API call.

Returns
Type Description

getConnector(String name)

publicfinalConnectorgetConnector(Stringname)

Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
Stringname=ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString();
Connectorresponse=vpcAccessServiceClient.getConnector(name);
}
Parameter
Name Description
name String

Required. Name of a Serverless VPC Access connector to get.

Returns
Type Description

getConnectorCallable()

publicfinalUnaryCallable<GetConnectorRequest,Connector>getConnectorCallable()

Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
GetConnectorRequestrequest=
GetConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]","[LOCATION]","[CONNECTOR]").toString())
.build();
ApiFuture<Connector>future=
vpcAccessServiceClient.getConnectorCallable().futureCall(request);
// Do something.
Connectorresponse=future.get();
}
Returns
Type Description

getHttpJsonOperationsClient()

publicfinalOperationsClientgetHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description

getOperationsClient()

publicfinalOperationsClientgetOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description

getSettings()

publicfinalVpcAccessServiceSettingsgetSettings()
Returns
Type Description

getStub()

publicVpcAccessServiceStubgetStub()
Returns
Type Description

isShutdown()

publicbooleanisShutdown()
Returns
Type Description

isTerminated()

publicbooleanisTerminated()
Returns
Type Description

listConnectors(ListConnectorsRequest request)

publicfinalVpcAccessServiceClient.ListConnectorsPagedResponselistConnectors(ListConnectorsRequestrequest)

Lists Serverless VPC Access connectors.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ListConnectorsRequestrequest=
ListConnectorsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Connectorelement:vpcAccessServiceClient.listConnectors(request).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
request ListConnectorsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description

listConnectors(LocationName parent)

publicfinalVpcAccessServiceClient.ListConnectorsPagedResponselistConnectors(LocationNameparent)

Lists Serverless VPC Access connectors.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");
for(Connectorelement:vpcAccessServiceClient.listConnectors(parent).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
parent LocationName

Required. The project and location from which the routes should be listed.

Returns
Type Description

listConnectors(String parent)

publicfinalVpcAccessServiceClient.ListConnectorsPagedResponselistConnectors(Stringparent)

Lists Serverless VPC Access connectors.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
Stringparent=LocationName.of("[PROJECT]","[LOCATION]").toString();
for(Connectorelement:vpcAccessServiceClient.listConnectors(parent).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
parent String

Required. The project and location from which the routes should be listed.

Returns
Type Description

listConnectorsCallable()

publicfinalUnaryCallable<ListConnectorsRequest,ListConnectorsResponse>listConnectorsCallable()

Lists Serverless VPC Access connectors.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ListConnectorsRequestrequest=
ListConnectorsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListConnectorsResponseresponse=
vpcAccessServiceClient.listConnectorsCallable().call(request);
for(Connectorelement:response.getConnectorsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
Returns
Type Description

listConnectorsPagedCallable()

publicfinalUnaryCallable<ListConnectorsRequest,VpcAccessServiceClient.ListConnectorsPagedResponse>listConnectorsPagedCallable()

Lists Serverless VPC Access connectors.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ListConnectorsRequestrequest=
ListConnectorsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Connector>future=
vpcAccessServiceClient.listConnectorsPagedCallable().futureCall(request);
// Do something.
for(Connectorelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
Returns
Type Description

listLocations(ListLocationsRequest request)

publicfinalVpcAccessServiceClient.ListLocationsPagedResponselistLocations(ListLocationsRequestrequest)

Lists information about the supported locations for this service.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(Locationelement:vpcAccessServiceClient.listLocations(request).iterateAll()){
// doThingsWith(element);
}
}
Parameter
Name Description
request com.google.cloud.location.ListLocationsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description

listLocationsCallable()

publicfinalUnaryCallable<ListLocationsRequest,ListLocationsResponse>listLocationsCallable()

Lists information about the supported locations for this service.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListLocationsResponseresponse=
vpcAccessServiceClient.listLocationsCallable().call(request);
for(Locationelement:response.getLocationsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse>

listLocationsPagedCallable()

publicfinalUnaryCallable<ListLocationsRequest,VpcAccessServiceClient.ListLocationsPagedResponse>listLocationsPagedCallable()

Lists information about the supported locations for this service.

Sample code:


// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try(VpcAccessServiceClientvpcAccessServiceClient=VpcAccessServiceClient.create()){
ListLocationsRequestrequest=
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location>future=
vpcAccessServiceClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for(Locationelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
Returns
Type Description
UnaryCallable<com.google.cloud.location.ListLocationsRequest,ListLocationsPagedResponse>

shutdown()

publicvoidshutdown()

shutdownNow()

publicvoidshutdownNow()

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月19日 UTC.