@Generated(value="by gapic-generator") @BetaApi public class RouterClient extends Object implements BackgroundResource
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 (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Operation response = routerClient.deleteRouter(router);
}
Note: close() needs to be called on the routerClient 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:
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 RouterSettings to create(). For example:
To customize credentials:
RouterSettings routerSettings =
RouterSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RouterClient routerClient =
RouterClient.create(routerSettings);
To customize the endpoint:
RouterSettings routerSettings =
RouterSettings.newBuilder().setEndpoint(myEndpoint).build();
RouterClient routerClient =
RouterClient.create(routerSettings);
Modifier and Type | Class and Description |
---|---|
static class |
RouterClient.AggregatedListRoutersFixedSizeCollection |
static class |
RouterClient.AggregatedListRoutersPage |
static class |
RouterClient.AggregatedListRoutersPagedResponse |
static class |
RouterClient.GetNatMappingInfoRoutersFixedSizeCollection |
static class |
RouterClient.GetNatMappingInfoRoutersPage |
static class |
RouterClient.GetNatMappingInfoRoutersPagedResponse |
static class |
RouterClient.ListRoutersFixedSizeCollection |
static class |
RouterClient.ListRoutersPage |
static class |
RouterClient.ListRoutersPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
RouterClient(RouterSettings settings)
Constructs an instance of RouterClient, using the given settings.
|
protected |
RouterClient(RouterStub stub) |
Modifier and Type | Method and Description |
---|---|
RouterClient.AggregatedListRoutersPagedResponse |
aggregatedListRouters(AggregatedListRoutersHttpRequest request)
Retrieves an aggregated list of routers.
|
RouterClient.AggregatedListRoutersPagedResponse |
aggregatedListRouters(ProjectName project)
Retrieves an aggregated list of routers.
|
RouterClient.AggregatedListRoutersPagedResponse |
aggregatedListRouters(String project)
Retrieves an aggregated list of routers.
|
UnaryCallable<AggregatedListRoutersHttpRequest,RouterAggregatedList> |
aggregatedListRoutersCallable()
Retrieves an aggregated list of routers.
|
UnaryCallable<AggregatedListRoutersHttpRequest,RouterClient.AggregatedListRoutersPagedResponse> |
aggregatedListRoutersPagedCallable()
Retrieves an aggregated list of routers.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static RouterClient |
create()
Constructs an instance of RouterClient with default settings.
|
static RouterClient |
create(RouterSettings settings)
Constructs an instance of RouterClient, using the given settings.
|
static RouterClient |
create(RouterStub stub)
Constructs an instance of RouterClient, using the given stub for making calls.
|
Operation |
deleteRouter(DeleteRouterHttpRequest request)
Deletes the specified Router resource.
|
Operation |
deleteRouter(ProjectRegionRouterName router)
Deletes the specified Router resource.
|
Operation |
deleteRouter(String router)
Deletes the specified Router resource.
|
UnaryCallable<DeleteRouterHttpRequest,Operation> |
deleteRouterCallable()
Deletes the specified Router resource.
|
RouterClient.GetNatMappingInfoRoutersPagedResponse |
getNatMappingInfoRouters(GetNatMappingInfoRoutersHttpRequest request)
Retrieves runtime Nat mapping information of VM endpoints.
|
RouterClient.GetNatMappingInfoRoutersPagedResponse |
getNatMappingInfoRouters(ProjectRegionRouterName router)
Retrieves runtime Nat mapping information of VM endpoints.
|
RouterClient.GetNatMappingInfoRoutersPagedResponse |
getNatMappingInfoRouters(String router)
Retrieves runtime Nat mapping information of VM endpoints.
|
UnaryCallable<GetNatMappingInfoRoutersHttpRequest,VmEndpointNatMappingsList> |
getNatMappingInfoRoutersCallable()
Retrieves runtime Nat mapping information of VM endpoints.
|
UnaryCallable<GetNatMappingInfoRoutersHttpRequest,RouterClient.GetNatMappingInfoRoutersPagedResponse> |
getNatMappingInfoRoutersPagedCallable()
Retrieves runtime Nat mapping information of VM endpoints.
|
Router |
getRouter(GetRouterHttpRequest request)
Returns the specified Router resource.
|
Router |
getRouter(ProjectRegionRouterName router)
Returns the specified Router resource.
|
Router |
getRouter(String router)
Returns the specified Router resource.
|
UnaryCallable<GetRouterHttpRequest,Router> |
getRouterCallable()
Returns the specified Router resource.
|
RouterStatusResponse |
getRouterStatusRouter(GetRouterStatusRouterHttpRequest request)
Retrieves runtime information of the specified router.
|
RouterStatusResponse |
getRouterStatusRouter(ProjectRegionRouterName router)
Retrieves runtime information of the specified router.
|
RouterStatusResponse |
getRouterStatusRouter(String router)
Retrieves runtime information of the specified router.
|
UnaryCallable<GetRouterStatusRouterHttpRequest,RouterStatusResponse> |
getRouterStatusRouterCallable()
Retrieves runtime information of the specified router.
|
RouterSettings |
getSettings() |
RouterStub |
getStub() |
Operation |
insertRouter(InsertRouterHttpRequest request)
Creates a Router resource in the specified project and region using the data included in the
request.
|
Operation |
insertRouter(ProjectRegionName region,
Router routerResource)
Creates a Router resource in the specified project and region using the data included in the
request.
|
Operation |
insertRouter(String region,
Router routerResource)
Creates a Router resource in the specified project and region using the data included in the
request.
|
UnaryCallable<InsertRouterHttpRequest,Operation> |
insertRouterCallable()
Creates a Router resource in the specified project and region using the data included in the
request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
RouterClient.ListRoutersPagedResponse |
listRouters(ListRoutersHttpRequest request)
Retrieves a list of Router resources available to the specified project.
|
RouterClient.ListRoutersPagedResponse |
listRouters(ProjectRegionName region)
Retrieves a list of Router resources available to the specified project.
|
RouterClient.ListRoutersPagedResponse |
listRouters(String region)
Retrieves a list of Router resources available to the specified project.
|
UnaryCallable<ListRoutersHttpRequest,RouterList> |
listRoutersCallable()
Retrieves a list of Router resources available to the specified project.
|
UnaryCallable<ListRoutersHttpRequest,RouterClient.ListRoutersPagedResponse> |
listRoutersPagedCallable()
Retrieves a list of Router resources available to the specified project.
|
Operation |
patchRouter(PatchRouterHttpRequest request)
Patches the specified Router resource with the data included in the request.
|
Operation |
patchRouter(ProjectRegionRouterName router,
Router routerResource,
List<String> fieldMask)
Patches the specified Router resource with the data included in the request.
|
Operation |
patchRouter(String router,
Router routerResource,
List<String> fieldMask)
Patches the specified Router resource with the data included in the request.
|
UnaryCallable<PatchRouterHttpRequest,Operation> |
patchRouterCallable()
Patches the specified Router resource with the data included in the request.
|
RoutersPreviewResponse |
previewRouter(PreviewRouterHttpRequest request)
Preview fields auto-generated during router create and update operations.
|
RoutersPreviewResponse |
previewRouter(ProjectRegionRouterName router,
Router routerResource)
Preview fields auto-generated during router create and update operations.
|
RoutersPreviewResponse |
previewRouter(String router,
Router routerResource)
Preview fields auto-generated during router create and update operations.
|
UnaryCallable<PreviewRouterHttpRequest,RoutersPreviewResponse> |
previewRouterCallable()
Preview fields auto-generated during router create and update operations.
|
void |
shutdown() |
void |
shutdownNow() |
Operation |
updateRouter(ProjectRegionRouterName router,
Router routerResource,
List<String> fieldMask)
Updates the specified Router resource with the data included in the request.
|
Operation |
updateRouter(String router,
Router routerResource,
List<String> fieldMask)
Updates the specified Router resource with the data included in the request.
|
Operation |
updateRouter(UpdateRouterHttpRequest request)
Updates the specified Router resource with the data included in the request.
|
UnaryCallable<UpdateRouterHttpRequest,Operation> |
updateRouterCallable()
Updates the specified Router resource with the data included in the request.
|
protected RouterClient(RouterSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected RouterClient(RouterStub stub)
public static final RouterClient create() throws IOException
IOException
public static final RouterClient create(RouterSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final RouterClient create(RouterStub stub)
public final RouterSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public RouterStub getStub()
@BetaApi public final RouterClient.AggregatedListRoutersPagedResponse aggregatedListRouters(ProjectName project)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (RoutersScopedList element : routerClient.aggregatedListRouters(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final RouterClient.AggregatedListRoutersPagedResponse aggregatedListRouters(String project)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (RoutersScopedList element : routerClient.aggregatedListRouters(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final RouterClient.AggregatedListRoutersPagedResponse aggregatedListRouters(AggregatedListRoutersHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListRoutersHttpRequest request = AggregatedListRoutersHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (RoutersScopedList element : routerClient.aggregatedListRouters(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<AggregatedListRoutersHttpRequest,RouterClient.AggregatedListRoutersPagedResponse> aggregatedListRoutersPagedCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListRoutersHttpRequest request = AggregatedListRoutersHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListRoutersPagedResponse> future = routerClient.aggregatedListRoutersPagedCallable().futureCall(request);
// Do something
for (RoutersScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<AggregatedListRoutersHttpRequest,RouterAggregatedList> aggregatedListRoutersCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListRoutersHttpRequest request = AggregatedListRoutersHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
RouterAggregatedList response = routerClient.aggregatedListRoutersCallable().call(request);
for (RoutersScopedList element : response.getItemsMap()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation deleteRouter(ProjectRegionRouterName router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Operation response = routerClient.deleteRouter(router);
}
router
- Name of the Router resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteRouter(String router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Operation response = routerClient.deleteRouter(router.toString());
}
router
- Name of the Router resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteRouter(DeleteRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
DeleteRouterHttpRequest request = DeleteRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
Operation response = routerClient.deleteRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteRouterHttpRequest,Operation> deleteRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
DeleteRouterHttpRequest request = DeleteRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
ApiFuture<Operation> future = routerClient.deleteRouterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Router getRouter(ProjectRegionRouterName router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router response = routerClient.getRouter(router);
}
router
- Name of the Router resource to return.ApiException
- if the remote call fails@BetaApi public final Router getRouter(String router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router response = routerClient.getRouter(router.toString());
}
router
- Name of the Router resource to return.ApiException
- if the remote call fails@BetaApi public final Router getRouter(GetRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetRouterHttpRequest request = GetRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
Router response = routerClient.getRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetRouterHttpRequest,Router> getRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetRouterHttpRequest request = GetRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
ApiFuture<Router> future = routerClient.getRouterCallable().futureCall(request);
// Do something
Router response = future.get();
}
@BetaApi public final RouterClient.GetNatMappingInfoRoutersPagedResponse getNatMappingInfoRouters(ProjectRegionRouterName router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
for (VmEndpointNatMappings element : routerClient.getNatMappingInfoRouters(router).iterateAll()) {
// doThingsWith(element);
}
}
router
- Name of the Router resource to query for Nat Mapping information of VM endpoints.ApiException
- if the remote call fails@BetaApi public final RouterClient.GetNatMappingInfoRoutersPagedResponse getNatMappingInfoRouters(String router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
for (VmEndpointNatMappings element : routerClient.getNatMappingInfoRouters(router.toString()).iterateAll()) {
// doThingsWith(element);
}
}
router
- Name of the Router resource to query for Nat Mapping information of VM endpoints.ApiException
- if the remote call fails@BetaApi public final RouterClient.GetNatMappingInfoRoutersPagedResponse getNatMappingInfoRouters(GetNatMappingInfoRoutersHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetNatMappingInfoRoutersHttpRequest request = GetNatMappingInfoRoutersHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
for (VmEndpointNatMappings element : routerClient.getNatMappingInfoRouters(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetNatMappingInfoRoutersHttpRequest,RouterClient.GetNatMappingInfoRoutersPagedResponse> getNatMappingInfoRoutersPagedCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetNatMappingInfoRoutersHttpRequest request = GetNatMappingInfoRoutersHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
ApiFuture<GetNatMappingInfoRoutersPagedResponse> future = routerClient.getNatMappingInfoRoutersPagedCallable().futureCall(request);
// Do something
for (VmEndpointNatMappings element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<GetNatMappingInfoRoutersHttpRequest,VmEndpointNatMappingsList> getNatMappingInfoRoutersCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetNatMappingInfoRoutersHttpRequest request = GetNatMappingInfoRoutersHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
while (true) {
VmEndpointNatMappingsList response = routerClient.getNatMappingInfoRoutersCallable().call(request);
for (VmEndpointNatMappings element : response.getResultList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final RouterStatusResponse getRouterStatusRouter(ProjectRegionRouterName router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
RouterStatusResponse response = routerClient.getRouterStatusRouter(router);
}
router
- Name of the Router resource to query.ApiException
- if the remote call fails@BetaApi public final RouterStatusResponse getRouterStatusRouter(String router)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
RouterStatusResponse response = routerClient.getRouterStatusRouter(router.toString());
}
router
- Name of the Router resource to query.ApiException
- if the remote call fails@BetaApi public final RouterStatusResponse getRouterStatusRouter(GetRouterStatusRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetRouterStatusRouterHttpRequest request = GetRouterStatusRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
RouterStatusResponse response = routerClient.getRouterStatusRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetRouterStatusRouterHttpRequest,RouterStatusResponse> getRouterStatusRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
GetRouterStatusRouterHttpRequest request = GetRouterStatusRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.build();
ApiFuture<RouterStatusResponse> future = routerClient.getRouterStatusRouterCallable().futureCall(request);
// Do something
RouterStatusResponse response = future.get();
}
@BetaApi public final Operation insertRouter(ProjectRegionName region, Router routerResource)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
Router routerResource = Router.newBuilder().build();
Operation response = routerClient.insertRouter(region, routerResource);
}
region
- Name of the region for this request.routerResource
- Router resource.ApiException
- if the remote call fails@BetaApi public final Operation insertRouter(String region, Router routerResource)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
Router routerResource = Router.newBuilder().build();
Operation response = routerClient.insertRouter(region.toString(), routerResource);
}
region
- Name of the region for this request.routerResource
- Router resource.ApiException
- if the remote call fails@BetaApi public final Operation insertRouter(InsertRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
Router routerResource = Router.newBuilder().build();
InsertRouterHttpRequest request = InsertRouterHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setRouterResource(routerResource)
.build();
Operation response = routerClient.insertRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertRouterHttpRequest,Operation> insertRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
Router routerResource = Router.newBuilder().build();
InsertRouterHttpRequest request = InsertRouterHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setRouterResource(routerResource)
.build();
ApiFuture<Operation> future = routerClient.insertRouterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final RouterClient.ListRoutersPagedResponse listRouters(ProjectRegionName region)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (Router element : routerClient.listRouters(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final RouterClient.ListRoutersPagedResponse listRouters(String region)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (Router element : routerClient.listRouters(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region for this request.ApiException
- if the remote call fails@BetaApi public final RouterClient.ListRoutersPagedResponse listRouters(ListRoutersHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRoutersHttpRequest request = ListRoutersHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (Router element : routerClient.listRouters(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<ListRoutersHttpRequest,RouterClient.ListRoutersPagedResponse> listRoutersPagedCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRoutersHttpRequest request = ListRoutersHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListRoutersPagedResponse> future = routerClient.listRoutersPagedCallable().futureCall(request);
// Do something
for (Router element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListRoutersHttpRequest,RouterList> listRoutersCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListRoutersHttpRequest request = ListRoutersHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
RouterList response = routerClient.listRoutersCallable().call(request);
for (Router element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
@BetaApi public final Operation patchRouter(ProjectRegionRouterName router, Router routerResource, List<String> fieldMask)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = routerClient.patchRouter(router, routerResource, fieldMask);
}
router
- Name of the Router resource to patch.routerResource
- Router resource.fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation patchRouter(String router, Router routerResource, List<String> fieldMask)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = routerClient.patchRouter(router.toString(), routerResource, fieldMask);
}
router
- Name of the Router resource to patch.routerResource
- Router resource.fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation patchRouter(PatchRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchRouterHttpRequest request = PatchRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.setRouterResource(routerResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = routerClient.patchRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<PatchRouterHttpRequest,Operation> patchRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchRouterHttpRequest request = PatchRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.setRouterResource(routerResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = routerClient.patchRouterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final RoutersPreviewResponse previewRouter(ProjectRegionRouterName router, Router routerResource)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
RoutersPreviewResponse response = routerClient.previewRouter(router, routerResource);
}
router
- Name of the Router resource to query.routerResource
- Router resource.ApiException
- if the remote call fails@BetaApi public final RoutersPreviewResponse previewRouter(String router, Router routerResource)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
RoutersPreviewResponse response = routerClient.previewRouter(router.toString(), routerResource);
}
router
- Name of the Router resource to query.routerResource
- Router resource.ApiException
- if the remote call fails@BetaApi public final RoutersPreviewResponse previewRouter(PreviewRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
PreviewRouterHttpRequest request = PreviewRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.setRouterResource(routerResource)
.build();
RoutersPreviewResponse response = routerClient.previewRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<PreviewRouterHttpRequest,RoutersPreviewResponse> previewRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
PreviewRouterHttpRequest request = PreviewRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.setRouterResource(routerResource)
.build();
ApiFuture<RoutersPreviewResponse> future = routerClient.previewRouterCallable().futureCall(request);
// Do something
RoutersPreviewResponse response = future.get();
}
@BetaApi public final Operation updateRouter(ProjectRegionRouterName router, Router routerResource, List<String> fieldMask)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = routerClient.updateRouter(router, routerResource, fieldMask);
}
router
- Name of the Router resource to update.routerResource
- Router resource.fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation updateRouter(String router, Router routerResource, List<String> fieldMask)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
ProjectRegionRouterName router = ProjectRegionRouterName.of("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = routerClient.updateRouter(router.toString(), routerResource, fieldMask);
}
router
- Name of the Router resource to update.routerResource
- Router resource.fieldMask
- The fields that should be serialized (even if they have empty values). If the
containing message object has a non-null fieldmask, then all the fields in the field mask
(and only those fields in the field mask) will be serialized. If the containing object does
not have a fieldmask, then only non-empty fields will be serialized.ApiException
- if the remote call fails@BetaApi public final Operation updateRouter(UpdateRouterHttpRequest request)
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
UpdateRouterHttpRequest request = UpdateRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.setRouterResource(routerResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = routerClient.updateRouter(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<UpdateRouterHttpRequest,Operation> updateRouterCallable()
Sample code:
try (RouterClient routerClient = RouterClient.create()) {
String formattedRouter = ProjectRegionRouterName.format("[PROJECT]", "[REGION]", "[ROUTER]");
Router routerResource = Router.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
UpdateRouterHttpRequest request = UpdateRouterHttpRequest.newBuilder()
.setRouter(formattedRouter)
.setRouterResource(routerResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = routerClient.updateRouterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.