- 2.54.0 (latest)
- 2.53.0
- 2.52.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.1.10
public class VpcAccessServiceClient implements BackgroundResource
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:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
ConnectorName name = ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
Connector response = 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:
- 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.
- 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.
- 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:
VpcAccessServiceSettings vpcAccessServiceSettings =
VpcAccessServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
VpcAccessServiceClient vpcAccessServiceClient =
VpcAccessServiceClient.create(vpcAccessServiceSettings);
To customize the endpoint:
VpcAccessServiceSettings vpcAccessServiceSettings =
VpcAccessServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
VpcAccessServiceClient vpcAccessServiceClient =
VpcAccessServiceClient.create(vpcAccessServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final VpcAccessServiceClient create()
Constructs an instance of VpcAccessServiceClient with default settings.
Type | Description |
VpcAccessServiceClient |
Type | Description |
IOException |
create(VpcAccessServiceSettings settings)
public static final VpcAccessServiceClient create(VpcAccessServiceSettings settings)
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.
Name | Description |
settings | VpcAccessServiceSettings |
Type | Description |
VpcAccessServiceClient |
Type | Description |
IOException |
create(VpcAccessServiceStub stub)
public static final VpcAccessServiceClient create(VpcAccessServiceStub stub)
Constructs an instance of VpcAccessServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(VpcAccessServiceSettings).
Name | Description |
stub | VpcAccessServiceStub |
Type | Description |
VpcAccessServiceClient |
Constructors
VpcAccessServiceClient(VpcAccessServiceSettings settings)
protected VpcAccessServiceClient(VpcAccessServiceSettings settings)
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.
Name | Description |
settings | VpcAccessServiceSettings |
VpcAccessServiceClient(VpcAccessServiceStub stub)
protected VpcAccessServiceClient(VpcAccessServiceStub stub)
Name | Description |
stub | VpcAccessServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createConnectorAsync(CreateConnectorRequest request)
public final OperationFuture<Connector,OperationMetadata> createConnectorAsync(CreateConnectorRequest request)
Creates a Serverless VPC Access connector, returns an operation.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
CreateConnectorRequest request =
CreateConnectorRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setConnectorId("connectorId1724784200")
.setConnector(Connector.newBuilder().build())
.build();
Connector response = vpcAccessServiceClient.createConnectorAsync(request).get();
}
Name | Description |
request | CreateConnectorRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Connector,OperationMetadata> |
createConnectorAsync(LocationName parent, String connectorId, Connector connector)
public final OperationFuture<Connector,OperationMetadata> createConnectorAsync(LocationName parent, String connectorId, Connector connector)
Creates a Serverless VPC Access connector, returns an operation.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String connectorId = "connectorId1724784200";
Connector connector = Connector.newBuilder().build();
Connector response =
vpcAccessServiceClient.createConnectorAsync(parent, connectorId, connector).get();
}
Name | Description |
parent | LocationName Required. The project and location in which the configuration should be created,
specified in the format |
connectorId | String Required. The ID to use for this connector. |
connector | Connector Required. Resource to create. |
Type | Description |
OperationFuture<Connector,OperationMetadata> |
createConnectorAsync(String parent, String connectorId, Connector connector)
public final OperationFuture<Connector,OperationMetadata> createConnectorAsync(String parent, String connectorId, Connector connector)
Creates a Serverless VPC Access connector, returns an operation.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
String connectorId = "connectorId1724784200";
Connector connector = Connector.newBuilder().build();
Connector response =
vpcAccessServiceClient.createConnectorAsync(parent, connectorId, connector).get();
}
Name | Description |
parent | String Required. The project and location in which the configuration should be created,
specified in the format |
connectorId | String Required. The ID to use for this connector. |
connector | Connector Required. Resource to create. |
Type | Description |
OperationFuture<Connector,OperationMetadata> |
createConnectorCallable()
public final UnaryCallable<CreateConnectorRequest,Operation> createConnectorCallable()
Creates a Serverless VPC Access connector, returns an operation.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
CreateConnectorRequest request =
CreateConnectorRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setConnectorId("connectorId1724784200")
.setConnector(Connector.newBuilder().build())
.build();
ApiFuture<Operation> future =
vpcAccessServiceClient.createConnectorCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<CreateConnectorRequest,Operation> |
createConnectorOperationCallable()
public final OperationCallable<CreateConnectorRequest,Connector,OperationMetadata> createConnectorOperationCallable()
Creates a Serverless VPC Access connector, returns an operation.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
CreateConnectorRequest request =
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.
Connector response = future.get();
}
Type | Description |
OperationCallable<CreateConnectorRequest,Connector,OperationMetadata> |
deleteConnectorAsync(ConnectorName name)
public final OperationFuture<Empty,OperationMetadata> deleteConnectorAsync(ConnectorName name)
Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
ConnectorName name = ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
vpcAccessServiceClient.deleteConnectorAsync(name).get();
}
Name | Description |
name | ConnectorName Required. Name of a Serverless VPC Access connector to delete. |
Type | Description |
OperationFuture<Empty,OperationMetadata> |
deleteConnectorAsync(DeleteConnectorRequest request)
public final OperationFuture<Empty,OperationMetadata> deleteConnectorAsync(DeleteConnectorRequest request)
Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
DeleteConnectorRequest request =
DeleteConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString())
.build();
vpcAccessServiceClient.deleteConnectorAsync(request).get();
}
Name | Description |
request | DeleteConnectorRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Empty,OperationMetadata> |
deleteConnectorAsync(String name)
public final OperationFuture<Empty,OperationMetadata> deleteConnectorAsync(String name)
Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
String name = ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString();
vpcAccessServiceClient.deleteConnectorAsync(name).get();
}
Name | Description |
name | String Required. Name of a Serverless VPC Access connector to delete. |
Type | Description |
OperationFuture<Empty,OperationMetadata> |
deleteConnectorCallable()
public final UnaryCallable<DeleteConnectorRequest,Operation> deleteConnectorCallable()
Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
DeleteConnectorRequest request =
DeleteConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString())
.build();
ApiFuture<Operation> future =
vpcAccessServiceClient.deleteConnectorCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteConnectorRequest,Operation> |
deleteConnectorOperationCallable()
public final OperationCallable<DeleteConnectorRequest,Empty,OperationMetadata> deleteConnectorOperationCallable()
Deletes a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
DeleteConnectorRequest request =
DeleteConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString())
.build();
OperationFuture<Empty, OperationMetadata> future =
vpcAccessServiceClient.deleteConnectorOperationCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
OperationCallable<DeleteConnectorRequest,Empty,OperationMetadata> |
getConnector(ConnectorName name)
public final Connector getConnector(ConnectorName name)
Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
ConnectorName name = ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
Connector response = vpcAccessServiceClient.getConnector(name);
}
Name | Description |
name | ConnectorName Required. Name of a Serverless VPC Access connector to get. |
Type | Description |
Connector |
getConnector(GetConnectorRequest request)
public final Connector getConnector(GetConnectorRequest request)
Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
GetConnectorRequest request =
GetConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString())
.build();
Connector response = vpcAccessServiceClient.getConnector(request);
}
Name | Description |
request | GetConnectorRequest The request object containing all of the parameters for the API call. |
Type | Description |
Connector |
getConnector(String name)
public final Connector getConnector(String name)
Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
String name = ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString();
Connector response = vpcAccessServiceClient.getConnector(name);
}
Name | Description |
name | String Required. Name of a Serverless VPC Access connector to get. |
Type | Description |
Connector |
getConnectorCallable()
public final UnaryCallable<GetConnectorRequest,Connector> getConnectorCallable()
Gets a Serverless VPC Access connector. Returns NOT_FOUND if the resource does not exist.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
GetConnectorRequest request =
GetConnectorRequest.newBuilder()
.setName(ConnectorName.of("[PROJECT]", "[LOCATION]", "[CONNECTOR]").toString())
.build();
ApiFuture<Connector> future =
vpcAccessServiceClient.getConnectorCallable().futureCall(request);
// Do something.
Connector response = future.get();
}
Type | Description |
UnaryCallable<GetConnectorRequest,Connector> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final VpcAccessServiceSettings getSettings()
Type | Description |
VpcAccessServiceSettings |
getStub()
public VpcAccessServiceStub getStub()
Type | Description |
VpcAccessServiceStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listConnectors(ListConnectorsRequest request)
public final VpcAccessServiceClient.ListConnectorsPagedResponse listConnectors(ListConnectorsRequest request)
Lists Serverless VPC Access connectors.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
ListConnectorsRequest request =
ListConnectorsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Connector element : vpcAccessServiceClient.listConnectors(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListConnectorsRequest The request object containing all of the parameters for the API call. |
Type | Description |
VpcAccessServiceClient.ListConnectorsPagedResponse |
listConnectors(LocationName parent)
public final VpcAccessServiceClient.ListConnectorsPagedResponse listConnectors(LocationName parent)
Lists Serverless VPC Access connectors.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Connector element : vpcAccessServiceClient.listConnectors(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The project and location from which the routes should be listed. |
Type | Description |
VpcAccessServiceClient.ListConnectorsPagedResponse |
listConnectors(String parent)
public final VpcAccessServiceClient.ListConnectorsPagedResponse listConnectors(String parent)
Lists Serverless VPC Access connectors.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
for (Connector element : vpcAccessServiceClient.listConnectors(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The project and location from which the routes should be listed. |
Type | Description |
VpcAccessServiceClient.ListConnectorsPagedResponse |
listConnectorsCallable()
public final UnaryCallable<ListConnectorsRequest,ListConnectorsResponse> listConnectorsCallable()
Lists Serverless VPC Access connectors.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
ListConnectorsRequest request =
ListConnectorsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListConnectorsResponse response =
vpcAccessServiceClient.listConnectorsCallable().call(request);
for (Connector element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListConnectorsRequest,ListConnectorsResponse> |
listConnectorsPagedCallable()
public final UnaryCallable<ListConnectorsRequest,VpcAccessServiceClient.ListConnectorsPagedResponse> listConnectorsPagedCallable()
Lists Serverless VPC Access connectors.
Sample code:
try (VpcAccessServiceClient vpcAccessServiceClient = VpcAccessServiceClient.create()) {
ListConnectorsRequest request =
ListConnectorsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Connector> future =
vpcAccessServiceClient.listConnectorsPagedCallable().futureCall(request);
// Do something.
for (Connector element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListConnectorsRequest,ListConnectorsPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()