@Generated(value="by gapic-generator") @BetaApi public class ForwardingRuleClient extends Object implements com.google.api.gax.core.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 (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
Operation response = forwardingRuleClient.deleteForwardingRule(forwardingRule);
}
Note: close() needs to be called on the forwardingRuleClient 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 ForwardingRuleSettings to create(). For example:
To customize credentials:
ForwardingRuleSettings forwardingRuleSettings =
ForwardingRuleSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
ForwardingRuleClient forwardingRuleClient =
ForwardingRuleClient.create(forwardingRuleSettings);
To customize the endpoint:
ForwardingRuleSettings forwardingRuleSettings =
ForwardingRuleSettings.newBuilder().setEndpoint(myEndpoint).build();
ForwardingRuleClient forwardingRuleClient =
ForwardingRuleClient.create(forwardingRuleSettings);
Modifier and Type | Class and Description |
---|---|
static class |
ForwardingRuleClient.AggregatedListForwardingRulesFixedSizeCollection |
static class |
ForwardingRuleClient.AggregatedListForwardingRulesPage |
static class |
ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse |
static class |
ForwardingRuleClient.ListForwardingRulesFixedSizeCollection |
static class |
ForwardingRuleClient.ListForwardingRulesPage |
static class |
ForwardingRuleClient.ListForwardingRulesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
ForwardingRuleClient(ForwardingRuleSettings settings)
Constructs an instance of ForwardingRuleClient, using the given settings.
|
protected |
ForwardingRuleClient(ForwardingRuleStub stub) |
Modifier and Type | Method and Description |
---|---|
ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse |
aggregatedListForwardingRules(AggregatedListForwardingRulesHttpRequest request)
Retrieves an aggregated list of forwarding rules.
|
ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse |
aggregatedListForwardingRules(ProjectName project)
Retrieves an aggregated list of forwarding rules.
|
ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse |
aggregatedListForwardingRules(String project)
Retrieves an aggregated list of forwarding rules.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListForwardingRulesHttpRequest,ForwardingRuleAggregatedList> |
aggregatedListForwardingRulesCallable()
Retrieves an aggregated list of forwarding rules.
|
com.google.api.gax.rpc.UnaryCallable<AggregatedListForwardingRulesHttpRequest,ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse> |
aggregatedListForwardingRulesPagedCallable()
Retrieves an aggregated list of forwarding rules.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static ForwardingRuleClient |
create()
Constructs an instance of ForwardingRuleClient with default settings.
|
static ForwardingRuleClient |
create(ForwardingRuleSettings settings)
Constructs an instance of ForwardingRuleClient, using the given settings.
|
static ForwardingRuleClient |
create(ForwardingRuleStub stub)
Constructs an instance of ForwardingRuleClient, using the given stub for making calls.
|
Operation |
deleteForwardingRule(DeleteForwardingRuleHttpRequest request)
Deletes the specified ForwardingRule resource.
|
Operation |
deleteForwardingRule(ProjectRegionForwardingRuleName forwardingRule)
Deletes the specified ForwardingRule resource.
|
Operation |
deleteForwardingRule(String forwardingRule)
Deletes the specified ForwardingRule resource.
|
com.google.api.gax.rpc.UnaryCallable<DeleteForwardingRuleHttpRequest,Operation> |
deleteForwardingRuleCallable()
Deletes the specified ForwardingRule resource.
|
ForwardingRule |
getForwardingRule(GetForwardingRuleHttpRequest request)
Returns the specified ForwardingRule resource.
|
ForwardingRule |
getForwardingRule(ProjectRegionForwardingRuleName forwardingRule)
Returns the specified ForwardingRule resource.
|
ForwardingRule |
getForwardingRule(String forwardingRule)
Returns the specified ForwardingRule resource.
|
com.google.api.gax.rpc.UnaryCallable<GetForwardingRuleHttpRequest,ForwardingRule> |
getForwardingRuleCallable()
Returns the specified ForwardingRule resource.
|
ForwardingRuleSettings |
getSettings() |
ForwardingRuleStub |
getStub() |
Operation |
insertForwardingRule(InsertForwardingRuleHttpRequest request)
Creates a ForwardingRule resource in the specified project and region using the data included
in the request.
|
Operation |
insertForwardingRule(ProjectRegionName region,
ForwardingRule forwardingRuleResource)
Creates a ForwardingRule resource in the specified project and region using the data included
in the request.
|
Operation |
insertForwardingRule(String region,
ForwardingRule forwardingRuleResource)
Creates a ForwardingRule resource in the specified project and region using the data included
in the request.
|
com.google.api.gax.rpc.UnaryCallable<InsertForwardingRuleHttpRequest,Operation> |
insertForwardingRuleCallable()
Creates a ForwardingRule resource in the specified project and region using the data included
in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
ForwardingRuleClient.ListForwardingRulesPagedResponse |
listForwardingRules(ListForwardingRulesHttpRequest request)
Retrieves a list of ForwardingRule resources available to the specified project and region.
|
ForwardingRuleClient.ListForwardingRulesPagedResponse |
listForwardingRules(ProjectRegionName region)
Retrieves a list of ForwardingRule resources available to the specified project and region.
|
ForwardingRuleClient.ListForwardingRulesPagedResponse |
listForwardingRules(String region)
Retrieves a list of ForwardingRule resources available to the specified project and region.
|
com.google.api.gax.rpc.UnaryCallable<ListForwardingRulesHttpRequest,ForwardingRuleList> |
listForwardingRulesCallable()
Retrieves a list of ForwardingRule resources available to the specified project and region.
|
com.google.api.gax.rpc.UnaryCallable<ListForwardingRulesHttpRequest,ForwardingRuleClient.ListForwardingRulesPagedResponse> |
listForwardingRulesPagedCallable()
Retrieves a list of ForwardingRule resources available to the specified project and region.
|
Operation |
setTargetForwardingRule(ProjectRegionForwardingRuleName forwardingRule,
TargetReference targetReferenceResource)
Changes target URL for forwarding rule.
|
Operation |
setTargetForwardingRule(SetTargetForwardingRuleHttpRequest request)
Changes target URL for forwarding rule.
|
Operation |
setTargetForwardingRule(String forwardingRule,
TargetReference targetReferenceResource)
Changes target URL for forwarding rule.
|
com.google.api.gax.rpc.UnaryCallable<SetTargetForwardingRuleHttpRequest,Operation> |
setTargetForwardingRuleCallable()
Changes target URL for forwarding rule.
|
void |
shutdown() |
void |
shutdownNow() |
protected ForwardingRuleClient(ForwardingRuleSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected ForwardingRuleClient(ForwardingRuleStub stub)
public static final ForwardingRuleClient create() throws IOException
IOException
public static final ForwardingRuleClient create(ForwardingRuleSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final ForwardingRuleClient create(ForwardingRuleStub stub)
public final ForwardingRuleSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public ForwardingRuleStub getStub()
@BetaApi public final ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse aggregatedListForwardingRules(ProjectName project)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (ForwardingRulesScopedList element : forwardingRuleClient.aggregatedListForwardingRules(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse aggregatedListForwardingRules(String project)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (ForwardingRulesScopedList element : forwardingRuleClient.aggregatedListForwardingRules(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse aggregatedListForwardingRules(AggregatedListForwardingRulesHttpRequest request)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListForwardingRulesHttpRequest request = AggregatedListForwardingRulesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (ForwardingRulesScopedList element : forwardingRuleClient.aggregatedListForwardingRules(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListForwardingRulesHttpRequest,ForwardingRuleClient.AggregatedListForwardingRulesPagedResponse> aggregatedListForwardingRulesPagedCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListForwardingRulesHttpRequest request = AggregatedListForwardingRulesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<AggregatedListForwardingRulesPagedResponse> future = forwardingRuleClient.aggregatedListForwardingRulesPagedCallable().futureCall(request);
// Do something
for (ForwardingRulesScopedList element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<AggregatedListForwardingRulesHttpRequest,ForwardingRuleAggregatedList> aggregatedListForwardingRulesCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
AggregatedListForwardingRulesHttpRequest request = AggregatedListForwardingRulesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
ForwardingRuleAggregatedList response = forwardingRuleClient.aggregatedListForwardingRulesCallable().call(request);
for (ForwardingRulesScopedList 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 deleteForwardingRule(ProjectRegionForwardingRuleName forwardingRule)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
Operation response = forwardingRuleClient.deleteForwardingRule(forwardingRule);
}
forwardingRule
- Name of the ForwardingRule resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteForwardingRule(String forwardingRule)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
Operation response = forwardingRuleClient.deleteForwardingRule(forwardingRule.toString());
}
forwardingRule
- Name of the ForwardingRule resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteForwardingRule(DeleteForwardingRuleHttpRequest request)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectRegionForwardingRuleName.format("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
DeleteForwardingRuleHttpRequest request = DeleteForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
Operation response = forwardingRuleClient.deleteForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<DeleteForwardingRuleHttpRequest,Operation> deleteForwardingRuleCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectRegionForwardingRuleName.format("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
DeleteForwardingRuleHttpRequest request = DeleteForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
ApiFuture<Operation> future = forwardingRuleClient.deleteForwardingRuleCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final ForwardingRule getForwardingRule(ProjectRegionForwardingRuleName forwardingRule)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
ForwardingRule response = forwardingRuleClient.getForwardingRule(forwardingRule);
}
forwardingRule
- Name of the ForwardingRule resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ForwardingRule getForwardingRule(String forwardingRule)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
ForwardingRule response = forwardingRuleClient.getForwardingRule(forwardingRule.toString());
}
forwardingRule
- Name of the ForwardingRule resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ForwardingRule getForwardingRule(GetForwardingRuleHttpRequest request)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectRegionForwardingRuleName.format("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
GetForwardingRuleHttpRequest request = GetForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
ForwardingRule response = forwardingRuleClient.getForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetForwardingRuleHttpRequest,ForwardingRule> getForwardingRuleCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectRegionForwardingRuleName.format("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
GetForwardingRuleHttpRequest request = GetForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
ApiFuture<ForwardingRule> future = forwardingRuleClient.getForwardingRuleCallable().futureCall(request);
// Do something
ForwardingRule response = future.get();
}
@BetaApi public final Operation insertForwardingRule(ProjectRegionName region, ForwardingRule forwardingRuleResource)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
Operation response = forwardingRuleClient.insertForwardingRule(region, forwardingRuleResource);
}
region
- Name of the region scoping this request.forwardingRuleResource
- Represents a Forwarding Rule resource.
A forwardingRules resource represents a regional forwarding rule.
Regional external forwarding rules can reference any of the following resources:
- A target instance - A Cloud VPN Classic gateway (targetVpnGateway), - A target pool for a Network Load Balancer - A global target HTTP(S) proxy for an HTTP(S) load balancer using Standard Tier - A target SSL proxy for a SSL Proxy load balancer using Standard Tier - A target TCP proxy for a TCP Proxy load balancer using Standard Tier.
Regional internal forwarding rules can reference the backend service of an internal TCP/UDP load balancer.
For regional internal forwarding rules, the following applies: - If the loadBalancingScheme for the load balancer is INTERNAL, then the forwarding rule references a regional internal backend service. - If the loadBalancingScheme for the load balancer is INTERNAL_MANAGED, then the forwarding rule must reference a regional target HTTP(S) proxy.
For more information, read Using Forwarding rules.
A globalForwardingRules resource represents a global forwarding rule.
Global forwarding rules are only used by load balancers that use Premium Tier. (== resource_for beta.forwardingRules ==) (== resource_for v1.forwardingRules ==) (== resource_for beta.globalForwardingRules ==) (== resource_for v1.globalForwardingRules ==) (== resource_for beta.regionForwardingRules ==) (== resource_for v1.regionForwardingRules ==)
com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertForwardingRule(String region, ForwardingRule forwardingRuleResource)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
Operation response = forwardingRuleClient.insertForwardingRule(region.toString(), forwardingRuleResource);
}
region
- Name of the region scoping this request.forwardingRuleResource
- Represents a Forwarding Rule resource.
A forwardingRules resource represents a regional forwarding rule.
Regional external forwarding rules can reference any of the following resources:
- A target instance - A Cloud VPN Classic gateway (targetVpnGateway), - A target pool for a Network Load Balancer - A global target HTTP(S) proxy for an HTTP(S) load balancer using Standard Tier - A target SSL proxy for a SSL Proxy load balancer using Standard Tier - A target TCP proxy for a TCP Proxy load balancer using Standard Tier.
Regional internal forwarding rules can reference the backend service of an internal TCP/UDP load balancer.
For regional internal forwarding rules, the following applies: - If the loadBalancingScheme for the load balancer is INTERNAL, then the forwarding rule references a regional internal backend service. - If the loadBalancingScheme for the load balancer is INTERNAL_MANAGED, then the forwarding rule must reference a regional target HTTP(S) proxy.
For more information, read Using Forwarding rules.
A globalForwardingRules resource represents a global forwarding rule.
Global forwarding rules are only used by load balancers that use Premium Tier. (== resource_for beta.forwardingRules ==) (== resource_for v1.forwardingRules ==) (== resource_for beta.globalForwardingRules ==) (== resource_for v1.globalForwardingRules ==) (== resource_for beta.regionForwardingRules ==) (== resource_for v1.regionForwardingRules ==)
com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertForwardingRule(InsertForwardingRuleHttpRequest request)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
InsertForwardingRuleHttpRequest request = InsertForwardingRuleHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setForwardingRuleResource(forwardingRuleResource)
.build();
Operation response = forwardingRuleClient.insertForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<InsertForwardingRuleHttpRequest,Operation> insertForwardingRuleCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
InsertForwardingRuleHttpRequest request = InsertForwardingRuleHttpRequest.newBuilder()
.setRegion(formattedRegion)
.setForwardingRuleResource(forwardingRuleResource)
.build();
ApiFuture<Operation> future = forwardingRuleClient.insertForwardingRuleCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final ForwardingRuleClient.ListForwardingRulesPagedResponse listForwardingRules(ProjectRegionName region)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (ForwardingRule element : forwardingRuleClient.listForwardingRules(region).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region scoping this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ForwardingRuleClient.ListForwardingRulesPagedResponse listForwardingRules(String region)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
for (ForwardingRule element : forwardingRuleClient.listForwardingRules(region.toString()).iterateAll()) {
// doThingsWith(element);
}
}
region
- Name of the region scoping this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final ForwardingRuleClient.ListForwardingRulesPagedResponse listForwardingRules(ListForwardingRulesHttpRequest request)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListForwardingRulesHttpRequest request = ListForwardingRulesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
for (ForwardingRule element : forwardingRuleClient.listForwardingRules(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListForwardingRulesHttpRequest,ForwardingRuleClient.ListForwardingRulesPagedResponse> listForwardingRulesPagedCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListForwardingRulesHttpRequest request = ListForwardingRulesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
ApiFuture<ListForwardingRulesPagedResponse> future = forwardingRuleClient.listForwardingRulesPagedCallable().futureCall(request);
// Do something
for (ForwardingRule element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListForwardingRulesHttpRequest,ForwardingRuleList> listForwardingRulesCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedRegion = ProjectRegionName.format("[PROJECT]", "[REGION]");
ListForwardingRulesHttpRequest request = ListForwardingRulesHttpRequest.newBuilder()
.setRegion(formattedRegion)
.build();
while (true) {
ForwardingRuleList response = forwardingRuleClient.listForwardingRulesCallable().call(request);
for (ForwardingRule 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 setTargetForwardingRule(ProjectRegionForwardingRuleName forwardingRule, TargetReference targetReferenceResource)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
Operation response = forwardingRuleClient.setTargetForwardingRule(forwardingRule, targetReferenceResource);
}
forwardingRule
- Name of the ForwardingRule resource in which target is to be set.targetReferenceResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation setTargetForwardingRule(String forwardingRule, TargetReference targetReferenceResource)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
ProjectRegionForwardingRuleName forwardingRule = ProjectRegionForwardingRuleName.of("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
Operation response = forwardingRuleClient.setTargetForwardingRule(forwardingRule.toString(), targetReferenceResource);
}
forwardingRule
- Name of the ForwardingRule resource in which target is to be set.targetReferenceResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation setTargetForwardingRule(SetTargetForwardingRuleHttpRequest request)
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectRegionForwardingRuleName.format("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
SetTargetForwardingRuleHttpRequest request = SetTargetForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.setTargetReferenceResource(targetReferenceResource)
.build();
Operation response = forwardingRuleClient.setTargetForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<SetTargetForwardingRuleHttpRequest,Operation> setTargetForwardingRuleCallable()
Sample code:
try (ForwardingRuleClient forwardingRuleClient = ForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectRegionForwardingRuleName.format("[PROJECT]", "[REGION]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
SetTargetForwardingRuleHttpRequest request = SetTargetForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.setTargetReferenceResource(targetReferenceResource)
.build();
ApiFuture<Operation> future = forwardingRuleClient.setTargetForwardingRuleCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.