Class SubnetworksClient (1.8.1)

public class SubnetworksClient implements BackgroundResource

Service Description: The Subnetworks API.

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 (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String subnetwork = "subnetwork-1302785042";
   Subnetwork response = subnetworksClient.get(project, region, subnetwork);
 }
 

Note: close() needs to be called on the SubnetworksClient 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 SubnetworksSettings to create(). For example:

To customize credentials:


 SubnetworksSettings subnetworksSettings =
     SubnetworksSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 SubnetworksClient subnetworksClient = SubnetworksClient.create(subnetworksSettings);
 

To customize the endpoint:


 SubnetworksSettings subnetworksSettings =
     SubnetworksSettings.newBuilder().setEndpoint(myEndpoint).build();
 SubnetworksClient subnetworksClient = SubnetworksClient.create(subnetworksSettings);
 

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

Inheritance

java.lang.Object > SubnetworksClient

Implements

BackgroundResource

Static Methods

create()

public static final SubnetworksClient create()

Constructs an instance of SubnetworksClient with default settings.

Returns
TypeDescription
SubnetworksClient
Exceptions
TypeDescription
IOException

create(SubnetworksSettings settings)

public static final SubnetworksClient create(SubnetworksSettings settings)

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

Parameter
NameDescription
settingsSubnetworksSettings
Returns
TypeDescription
SubnetworksClient
Exceptions
TypeDescription
IOException

create(SubnetworksStub stub)

public static final SubnetworksClient create(SubnetworksStub stub)

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

Parameter
NameDescription
stubSubnetworksStub
Returns
TypeDescription
SubnetworksClient

Constructors

SubnetworksClient(SubnetworksSettings settings)

protected SubnetworksClient(SubnetworksSettings settings)

Constructs an instance of SubnetworksClient, 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
NameDescription
settingsSubnetworksSettings

SubnetworksClient(SubnetworksStub stub)

protected SubnetworksClient(SubnetworksStub stub)
Parameter
NameDescription
stubSubnetworksStub

Methods

aggregatedList(AggregatedListSubnetworksRequest request)

public final SubnetworksClient.AggregatedListPagedResponse aggregatedList(AggregatedListSubnetworksRequest request)

Retrieves an aggregated list of subnetworks.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   AggregatedListSubnetworksRequest request =
       AggregatedListSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setIncludeAllScopes(true)
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   for (Map.Entry
Parameter
NameDescription
requestAggregatedListSubnetworksRequest

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

Returns
TypeDescription
SubnetworksClient.AggregatedListPagedResponse

aggregatedList(String project)

public final SubnetworksClient.AggregatedListPagedResponse aggregatedList(String project)

Retrieves an aggregated list of subnetworks.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   for (Map.Entry
Parameter
NameDescription
projectString

Project ID for this request.

Returns
TypeDescription
SubnetworksClient.AggregatedListPagedResponse

aggregatedListCallable()

public final UnaryCallable<AggregatedListSubnetworksRequest,SubnetworkAggregatedList> aggregatedListCallable()

Retrieves an aggregated list of subnetworks.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   AggregatedListSubnetworksRequest request =
       AggregatedListSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setIncludeAllScopes(true)
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   while (true) {
     SubnetworkAggregatedList response =
         subnetworksClient.aggregatedListCallable().call(request);
     for (Map.Entry
Returns
TypeDescription
UnaryCallable<AggregatedListSubnetworksRequest,SubnetworkAggregatedList>

aggregatedListPagedCallable()

public final UnaryCallable<AggregatedListSubnetworksRequest,SubnetworksClient.AggregatedListPagedResponse> aggregatedListPagedCallable()

Retrieves an aggregated list of subnetworks.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   AggregatedListSubnetworksRequest request =
       AggregatedListSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setIncludeAllScopes(true)
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   ApiFuture<>
Returns
TypeDescription
UnaryCallable<AggregatedListSubnetworksRequest,AggregatedListPagedResponse>

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

deleteAsync(DeleteSubnetworkRequest request)

public final OperationFuture<Operation,Operation> deleteAsync(DeleteSubnetworkRequest request)

Deletes the specified subnetwork.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   DeleteSubnetworkRequest request =
       DeleteSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .build();
   Operation response = subnetworksClient.deleteAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteSubnetworkRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

deleteAsync(String project, String region, String subnetwork)

public final OperationFuture<Operation,Operation> deleteAsync(String project, String region, String subnetwork)

Deletes the specified subnetwork.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String subnetwork = "subnetwork-1302785042";
   Operation response = subnetworksClient.deleteAsync(project, region, subnetwork).get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

subnetworkString

Name of the Subnetwork resource to delete.

Returns
TypeDescription
OperationFuture<Operation,Operation>

deleteCallable()

public final UnaryCallable<DeleteSubnetworkRequest,Operation> deleteCallable()

Deletes the specified subnetwork.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   DeleteSubnetworkRequest request =
       DeleteSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .build();
   ApiFuture<Operation> future = subnetworksClient.deleteCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteSubnetworkRequest,Operation>

deleteOperationCallable()

public final OperationCallable<DeleteSubnetworkRequest,Operation,Operation> deleteOperationCallable()

Deletes the specified subnetwork.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   DeleteSubnetworkRequest request =
       DeleteSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .build();
   OperationFuture
Returns
TypeDescription
OperationCallable<DeleteSubnetworkRequest,Operation,Operation>

expandIpCidrRangeAsync(ExpandIpCidrRangeSubnetworkRequest request)

public final OperationFuture<Operation,Operation> expandIpCidrRangeAsync(ExpandIpCidrRangeSubnetworkRequest request)

Expands the IP CIDR range of the subnetwork to a specified value.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ExpandIpCidrRangeSubnetworkRequest request =
       ExpandIpCidrRangeSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworksExpandIpCidrRangeRequestResource(
               SubnetworksExpandIpCidrRangeRequest.newBuilder().build())
           .build();
   Operation response = subnetworksClient.expandIpCidrRangeAsync(request).get();
 }
 
Parameter
NameDescription
requestExpandIpCidrRangeSubnetworkRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

expandIpCidrRangeAsync(String project, String region, String subnetwork, SubnetworksExpandIpCidrRangeRequest subnetworksExpandIpCidrRangeRequestResource)

public final OperationFuture<Operation,Operation> expandIpCidrRangeAsync(String project, String region, String subnetwork, SubnetworksExpandIpCidrRangeRequest subnetworksExpandIpCidrRangeRequestResource)

Expands the IP CIDR range of the subnetwork to a specified value.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String subnetwork = "subnetwork-1302785042";
   SubnetworksExpandIpCidrRangeRequest subnetworksExpandIpCidrRangeRequestResource =
       SubnetworksExpandIpCidrRangeRequest.newBuilder().build();
   Operation response =
       subnetworksClient
           .expandIpCidrRangeAsync(
               project, region, subnetwork, subnetworksExpandIpCidrRangeRequestResource)
           .get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

subnetworkString

Name of the Subnetwork resource to update.

subnetworksExpandIpCidrRangeRequestResourceSubnetworksExpandIpCidrRangeRequest

The body resource for this request

Returns
TypeDescription
OperationFuture<Operation,Operation>

expandIpCidrRangeCallable()

public final UnaryCallable<ExpandIpCidrRangeSubnetworkRequest,Operation> expandIpCidrRangeCallable()

Expands the IP CIDR range of the subnetwork to a specified value.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ExpandIpCidrRangeSubnetworkRequest request =
       ExpandIpCidrRangeSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworksExpandIpCidrRangeRequestResource(
               SubnetworksExpandIpCidrRangeRequest.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       subnetworksClient.expandIpCidrRangeCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<ExpandIpCidrRangeSubnetworkRequest,Operation>

expandIpCidrRangeOperationCallable()

public final OperationCallable<ExpandIpCidrRangeSubnetworkRequest,Operation,Operation> expandIpCidrRangeOperationCallable()

Expands the IP CIDR range of the subnetwork to a specified value.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ExpandIpCidrRangeSubnetworkRequest request =
       ExpandIpCidrRangeSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworksExpandIpCidrRangeRequestResource(
               SubnetworksExpandIpCidrRangeRequest.newBuilder().build())
           .build();
   OperationFuture
Returns
TypeDescription
OperationCallable<ExpandIpCidrRangeSubnetworkRequest,Operation,Operation>

get(GetSubnetworkRequest request)

public final Subnetwork get(GetSubnetworkRequest request)

Returns the specified subnetwork. Gets a list of available subnetworks list() request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   GetSubnetworkRequest request =
       GetSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setSubnetwork("subnetwork-1302785042")
           .build();
   Subnetwork response = subnetworksClient.get(request);
 }
 
Parameter
NameDescription
requestGetSubnetworkRequest

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

Returns
TypeDescription
Subnetwork

get(String project, String region, String subnetwork)

public final Subnetwork get(String project, String region, String subnetwork)

Returns the specified subnetwork. Gets a list of available subnetworks list() request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String subnetwork = "subnetwork-1302785042";
   Subnetwork response = subnetworksClient.get(project, region, subnetwork);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

subnetworkString

Name of the Subnetwork resource to return.

Returns
TypeDescription
Subnetwork

getCallable()

public final UnaryCallable<GetSubnetworkRequest,Subnetwork> getCallable()

Returns the specified subnetwork. Gets a list of available subnetworks list() request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   GetSubnetworkRequest request =
       GetSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setSubnetwork("subnetwork-1302785042")
           .build();
   ApiFuture<Subnetwork> future = subnetworksClient.getCallable().futureCall(request);
   // Do something.
   Subnetwork response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetSubnetworkRequest,Subnetwork>

getIamPolicy(GetIamPolicySubnetworkRequest request)

public final Policy getIamPolicy(GetIamPolicySubnetworkRequest request)

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   GetIamPolicySubnetworkRequest request =
       GetIamPolicySubnetworkRequest.newBuilder()
           .setOptionsRequestedPolicyVersion(-574521795)
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setResource("resource-341064690")
           .build();
   Policy response = subnetworksClient.getIamPolicy(request);
 }
 
Parameter
NameDescription
requestGetIamPolicySubnetworkRequest

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

Returns
TypeDescription
Policy

getIamPolicy(String project, String region, String resource)

public final Policy getIamPolicy(String project, String region, String resource)

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String resource = "resource-341064690";
   Policy response = subnetworksClient.getIamPolicy(project, region, resource);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

The name of the region for this request.

resourceString

Name or id of the resource for this request.

Returns
TypeDescription
Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicySubnetworkRequest,Policy> getIamPolicyCallable()

Gets the access control policy for a resource. May be empty if no such policy or resource exists.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   GetIamPolicySubnetworkRequest request =
       GetIamPolicySubnetworkRequest.newBuilder()
           .setOptionsRequestedPolicyVersion(-574521795)
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setResource("resource-341064690")
           .build();
   ApiFuture<Policy> future = subnetworksClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetIamPolicySubnetworkRequest,Policy>

getSettings()

public final SubnetworksSettings getSettings()
Returns
TypeDescription
SubnetworksSettings

getStub()

public SubnetworksStub getStub()
Returns
TypeDescription
SubnetworksStub

insertAsync(InsertSubnetworkRequest request)

public final OperationFuture<Operation,Operation> insertAsync(InsertSubnetworkRequest request)

Creates a subnetwork in the specified project using the data included in the request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   InsertSubnetworkRequest request =
       InsertSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetworkResource(Subnetwork.newBuilder().build())
           .build();
   Operation response = subnetworksClient.insertAsync(request).get();
 }
 
Parameter
NameDescription
requestInsertSubnetworkRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

insertAsync(String project, String region, Subnetwork subnetworkResource)

public final OperationFuture<Operation,Operation> insertAsync(String project, String region, Subnetwork subnetworkResource)

Creates a subnetwork in the specified project using the data included in the request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   Subnetwork subnetworkResource = Subnetwork.newBuilder().build();
   Operation response = subnetworksClient.insertAsync(project, region, subnetworkResource).get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

subnetworkResourceSubnetwork

The body resource for this request

Returns
TypeDescription
OperationFuture<Operation,Operation>

insertCallable()

public final UnaryCallable<InsertSubnetworkRequest,Operation> insertCallable()

Creates a subnetwork in the specified project using the data included in the request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   InsertSubnetworkRequest request =
       InsertSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetworkResource(Subnetwork.newBuilder().build())
           .build();
   ApiFuture<Operation> future = subnetworksClient.insertCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<InsertSubnetworkRequest,Operation>

insertOperationCallable()

public final OperationCallable<InsertSubnetworkRequest,Operation,Operation> insertOperationCallable()

Creates a subnetwork in the specified project using the data included in the request.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   InsertSubnetworkRequest request =
       InsertSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetworkResource(Subnetwork.newBuilder().build())
           .build();
   OperationFuture
Returns
TypeDescription
OperationCallable<InsertSubnetworkRequest,Operation,Operation>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

list(ListSubnetworksRequest request)

public final SubnetworksClient.ListPagedResponse list(ListSubnetworksRequest request)

Retrieves a list of subnetworks available to the specified project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ListSubnetworksRequest request =
       ListSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setReturnPartialSuccess(true)
           .build();
   for (Subnetwork element : subnetworksClient.list(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListSubnetworksRequest

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

Returns
TypeDescription
SubnetworksClient.ListPagedResponse

list(String project, String region)

public final SubnetworksClient.ListPagedResponse list(String project, String region)

Retrieves a list of subnetworks available to the specified project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   for (Subnetwork element : subnetworksClient.list(project, region).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

Returns
TypeDescription
SubnetworksClient.ListPagedResponse

listCallable()

public final UnaryCallable<ListSubnetworksRequest,SubnetworkList> listCallable()

Retrieves a list of subnetworks available to the specified project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ListSubnetworksRequest request =
       ListSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setReturnPartialSuccess(true)
           .build();
   while (true) {
     SubnetworkList response = subnetworksClient.listCallable().call(request);
     for (Subnetwork element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListSubnetworksRequest,SubnetworkList>

listPagedCallable()

public final UnaryCallable<ListSubnetworksRequest,SubnetworksClient.ListPagedResponse> listPagedCallable()

Retrieves a list of subnetworks available to the specified project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ListSubnetworksRequest request =
       ListSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setReturnPartialSuccess(true)
           .build();
   ApiFuture<Subnetwork> future = subnetworksClient.listPagedCallable().futureCall(request);
   // Do something.
   for (Subnetwork element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListSubnetworksRequest,ListPagedResponse>

listUsable(ListUsableSubnetworksRequest request)

public final SubnetworksClient.ListUsablePagedResponse listUsable(ListUsableSubnetworksRequest request)

Retrieves an aggregated list of all usable subnetworks in the project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ListUsableSubnetworksRequest request =
       ListUsableSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   for (UsableSubnetwork element : subnetworksClient.listUsable(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListUsableSubnetworksRequest

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

Returns
TypeDescription
SubnetworksClient.ListUsablePagedResponse

listUsable(String project)

public final SubnetworksClient.ListUsablePagedResponse listUsable(String project)

Retrieves an aggregated list of all usable subnetworks in the project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   for (UsableSubnetwork element : subnetworksClient.listUsable(project).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
projectString

Project ID for this request.

Returns
TypeDescription
SubnetworksClient.ListUsablePagedResponse

listUsableCallable()

public final UnaryCallable<ListUsableSubnetworksRequest,UsableSubnetworksAggregatedList> listUsableCallable()

Retrieves an aggregated list of all usable subnetworks in the project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ListUsableSubnetworksRequest request =
       ListUsableSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   while (true) {
     UsableSubnetworksAggregatedList response =
         subnetworksClient.listUsableCallable().call(request);
     for (UsableSubnetwork element : response.getResponsesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListUsableSubnetworksRequest,UsableSubnetworksAggregatedList>

listUsablePagedCallable()

public final UnaryCallable<ListUsableSubnetworksRequest,SubnetworksClient.ListUsablePagedResponse> listUsablePagedCallable()

Retrieves an aggregated list of all usable subnetworks in the project.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   ListUsableSubnetworksRequest request =
       ListUsableSubnetworksRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   ApiFuture
Returns
TypeDescription
UnaryCallable<ListUsableSubnetworksRequest,ListUsablePagedResponse>

patchAsync(PatchSubnetworkRequest request)

public final OperationFuture<Operation,Operation> patchAsync(PatchSubnetworkRequest request)

Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   PatchSubnetworkRequest request =
       PatchSubnetworkRequest.newBuilder()
           .setDrainTimeoutSeconds(1431448922)
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworkResource(Subnetwork.newBuilder().build())
           .build();
   Operation response = subnetworksClient.patchAsync(request).get();
 }
 
Parameter
NameDescription
requestPatchSubnetworkRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

patchAsync(String project, String region, String subnetwork, Subnetwork subnetworkResource)

public final OperationFuture<Operation,Operation> patchAsync(String project, String region, String subnetwork, Subnetwork subnetworkResource)

Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String subnetwork = "subnetwork-1302785042";
   Subnetwork subnetworkResource = Subnetwork.newBuilder().build();
   Operation response =
       subnetworksClient.patchAsync(project, region, subnetwork, subnetworkResource).get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

subnetworkString

Name of the Subnetwork resource to patch.

subnetworkResourceSubnetwork

The body resource for this request

Returns
TypeDescription
OperationFuture<Operation,Operation>

patchCallable()

public final UnaryCallable<PatchSubnetworkRequest,Operation> patchCallable()

Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   PatchSubnetworkRequest request =
       PatchSubnetworkRequest.newBuilder()
           .setDrainTimeoutSeconds(1431448922)
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworkResource(Subnetwork.newBuilder().build())
           .build();
   ApiFuture<Operation> future = subnetworksClient.patchCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<PatchSubnetworkRequest,Operation>

patchOperationCallable()

public final OperationCallable<PatchSubnetworkRequest,Operation,Operation> patchOperationCallable()

Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   PatchSubnetworkRequest request =
       PatchSubnetworkRequest.newBuilder()
           .setDrainTimeoutSeconds(1431448922)
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworkResource(Subnetwork.newBuilder().build())
           .build();
   OperationFuture
Returns
TypeDescription
OperationCallable<PatchSubnetworkRequest,Operation,Operation>

setIamPolicy(SetIamPolicySubnetworkRequest request)

public final Policy setIamPolicy(SetIamPolicySubnetworkRequest request)

Sets the access control policy on the specified resource. Replaces any existing policy.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   SetIamPolicySubnetworkRequest request =
       SetIamPolicySubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
           .setResource("resource-341064690")
           .build();
   Policy response = subnetworksClient.setIamPolicy(request);
 }
 
Parameter
NameDescription
requestSetIamPolicySubnetworkRequest

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

Returns
TypeDescription
Policy

setIamPolicy(String project, String region, String resource, RegionSetPolicyRequest regionSetPolicyRequestResource)

public final Policy setIamPolicy(String project, String region, String resource, RegionSetPolicyRequest regionSetPolicyRequestResource)

Sets the access control policy on the specified resource. Replaces any existing policy.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String resource = "resource-341064690";
   RegionSetPolicyRequest regionSetPolicyRequestResource =
       RegionSetPolicyRequest.newBuilder().build();
   Policy response =
       subnetworksClient.setIamPolicy(project, region, resource, regionSetPolicyRequestResource);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

The name of the region for this request.

resourceString

Name or id of the resource for this request.

regionSetPolicyRequestResourceRegionSetPolicyRequest

The body resource for this request

Returns
TypeDescription
Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicySubnetworkRequest,Policy> setIamPolicyCallable()

Sets the access control policy on the specified resource. Replaces any existing policy.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   SetIamPolicySubnetworkRequest request =
       SetIamPolicySubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
           .setResource("resource-341064690")
           .build();
   ApiFuture<Policy> future = subnetworksClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<SetIamPolicySubnetworkRequest,Policy>

setPrivateIpGoogleAccessAsync(SetPrivateIpGoogleAccessSubnetworkRequest request)

public final OperationFuture<Operation,Operation> setPrivateIpGoogleAccessAsync(SetPrivateIpGoogleAccessSubnetworkRequest request)

Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   SetPrivateIpGoogleAccessSubnetworkRequest request =
       SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
               SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build())
           .build();
   Operation response = subnetworksClient.setPrivateIpGoogleAccessAsync(request).get();
 }
 
Parameter
NameDescription
requestSetPrivateIpGoogleAccessSubnetworkRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

setPrivateIpGoogleAccessAsync(String project, String region, String subnetwork, SubnetworksSetPrivateIpGoogleAccessRequest subnetworksSetPrivateIpGoogleAccessRequestResource)

public final OperationFuture<Operation,Operation> setPrivateIpGoogleAccessAsync(String project, String region, String subnetwork, SubnetworksSetPrivateIpGoogleAccessRequest subnetworksSetPrivateIpGoogleAccessRequestResource)

Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String subnetwork = "subnetwork-1302785042";
   SubnetworksSetPrivateIpGoogleAccessRequest
       subnetworksSetPrivateIpGoogleAccessRequestResource =
           SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build();
   Operation response =
       subnetworksClient
           .setPrivateIpGoogleAccessAsync(
               project, region, subnetwork, subnetworksSetPrivateIpGoogleAccessRequestResource)
           .get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

Name of the region scoping this request.

subnetworkString

Name of the Subnetwork resource.

subnetworksSetPrivateIpGoogleAccessRequestResourceSubnetworksSetPrivateIpGoogleAccessRequest

The body resource for this request

Returns
TypeDescription
OperationFuture<Operation,Operation>

setPrivateIpGoogleAccessCallable()

public final UnaryCallable<SetPrivateIpGoogleAccessSubnetworkRequest,Operation> setPrivateIpGoogleAccessCallable()

Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   SetPrivateIpGoogleAccessSubnetworkRequest request =
       SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
               SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build())
           .build();
   ApiFuture<Operation> future =
       subnetworksClient.setPrivateIpGoogleAccessCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<SetPrivateIpGoogleAccessSubnetworkRequest,Operation>

setPrivateIpGoogleAccessOperationCallable()

public final OperationCallable<SetPrivateIpGoogleAccessSubnetworkRequest,Operation,Operation> setPrivateIpGoogleAccessOperationCallable()

Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   SetPrivateIpGoogleAccessSubnetworkRequest request =
       SetPrivateIpGoogleAccessSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setRequestId("requestId693933066")
           .setSubnetwork("subnetwork-1302785042")
           .setSubnetworksSetPrivateIpGoogleAccessRequestResource(
               SubnetworksSetPrivateIpGoogleAccessRequest.newBuilder().build())
           .build();
   OperationFuture
Returns
TypeDescription
OperationCallable<SetPrivateIpGoogleAccessSubnetworkRequest,Operation,Operation>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testIamPermissions(TestIamPermissionsSubnetworkRequest request)

public final TestPermissionsResponse testIamPermissions(TestIamPermissionsSubnetworkRequest request)

Returns permissions that a caller has on the specified resource.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   TestIamPermissionsSubnetworkRequest request =
       TestIamPermissionsSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setResource("resource-341064690")
           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
           .build();
   TestPermissionsResponse response = subnetworksClient.testIamPermissions(request);
 }
 
Parameter
NameDescription
requestTestIamPermissionsSubnetworkRequest

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

Returns
TypeDescription
TestPermissionsResponse

testIamPermissions(String project, String region, String resource, TestPermissionsRequest testPermissionsRequestResource)

public final TestPermissionsResponse testIamPermissions(String project, String region, String resource, TestPermissionsRequest testPermissionsRequestResource)

Returns permissions that a caller has on the specified resource.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   String project = "project-309310695";
   String region = "region-934795532";
   String resource = "resource-341064690";
   TestPermissionsRequest testPermissionsRequestResource =
       TestPermissionsRequest.newBuilder().build();
   TestPermissionsResponse response =
       subnetworksClient.testIamPermissions(
           project, region, resource, testPermissionsRequestResource);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

regionString

The name of the region for this request.

resourceString

Name or id of the resource for this request.

testPermissionsRequestResourceTestPermissionsRequest

The body resource for this request

Returns
TypeDescription
TestPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsSubnetworkRequest,TestPermissionsResponse> testIamPermissionsCallable()

Returns permissions that a caller has on the specified resource.

Sample code:


 try (SubnetworksClient subnetworksClient = SubnetworksClient.create()) {
   TestIamPermissionsSubnetworkRequest request =
       TestIamPermissionsSubnetworkRequest.newBuilder()
           .setProject("project-309310695")
           .setRegion("region-934795532")
           .setResource("resource-341064690")
           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
           .build();
   ApiFuture
Returns
TypeDescription
UnaryCallable<TestIamPermissionsSubnetworkRequest,TestPermissionsResponse>