@Generated(value="by gapic-generator") @BetaApi public class GlobalForwardingRuleClient 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 (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
Operation response = globalForwardingRuleClient.deleteGlobalForwardingRule(forwardingRule);
}
Note: close() needs to be called on the globalForwardingRuleClient 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 GlobalForwardingRuleSettings to create(). For example:
To customize credentials:
GlobalForwardingRuleSettings globalForwardingRuleSettings =
GlobalForwardingRuleSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GlobalForwardingRuleClient globalForwardingRuleClient =
GlobalForwardingRuleClient.create(globalForwardingRuleSettings);
To customize the endpoint:
GlobalForwardingRuleSettings globalForwardingRuleSettings =
GlobalForwardingRuleSettings.newBuilder().setEndpoint(myEndpoint).build();
GlobalForwardingRuleClient globalForwardingRuleClient =
GlobalForwardingRuleClient.create(globalForwardingRuleSettings);
Modifier and Type | Class and Description |
---|---|
static class |
GlobalForwardingRuleClient.ListGlobalForwardingRulesFixedSizeCollection |
static class |
GlobalForwardingRuleClient.ListGlobalForwardingRulesPage |
static class |
GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
GlobalForwardingRuleClient(GlobalForwardingRuleSettings settings)
Constructs an instance of GlobalForwardingRuleClient, using the given settings.
|
protected |
GlobalForwardingRuleClient(GlobalForwardingRuleStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static GlobalForwardingRuleClient |
create()
Constructs an instance of GlobalForwardingRuleClient with default settings.
|
static GlobalForwardingRuleClient |
create(GlobalForwardingRuleSettings settings)
Constructs an instance of GlobalForwardingRuleClient, using the given settings.
|
static GlobalForwardingRuleClient |
create(GlobalForwardingRuleStub stub)
Constructs an instance of GlobalForwardingRuleClient, using the given stub for making calls.
|
Operation |
deleteGlobalForwardingRule(DeleteGlobalForwardingRuleHttpRequest request)
Deletes the specified GlobalForwardingRule resource.
|
Operation |
deleteGlobalForwardingRule(ProjectGlobalForwardingRuleName forwardingRule)
Deletes the specified GlobalForwardingRule resource.
|
Operation |
deleteGlobalForwardingRule(String forwardingRule)
Deletes the specified GlobalForwardingRule resource.
|
UnaryCallable<DeleteGlobalForwardingRuleHttpRequest,Operation> |
deleteGlobalForwardingRuleCallable()
Deletes the specified GlobalForwardingRule resource.
|
ForwardingRule |
getGlobalForwardingRule(GetGlobalForwardingRuleHttpRequest request)
Returns the specified GlobalForwardingRule resource.
|
ForwardingRule |
getGlobalForwardingRule(ProjectGlobalForwardingRuleName forwardingRule)
Returns the specified GlobalForwardingRule resource.
|
ForwardingRule |
getGlobalForwardingRule(String forwardingRule)
Returns the specified GlobalForwardingRule resource.
|
UnaryCallable<GetGlobalForwardingRuleHttpRequest,ForwardingRule> |
getGlobalForwardingRuleCallable()
Returns the specified GlobalForwardingRule resource.
|
GlobalForwardingRuleSettings |
getSettings() |
GlobalForwardingRuleStub |
getStub() |
Operation |
insertGlobalForwardingRule(InsertGlobalForwardingRuleHttpRequest request)
Creates a GlobalForwardingRule resource in the specified project using the data included in the
request.
|
Operation |
insertGlobalForwardingRule(ProjectName project,
ForwardingRule forwardingRuleResource)
Creates a GlobalForwardingRule resource in the specified project using the data included in the
request.
|
Operation |
insertGlobalForwardingRule(String project,
ForwardingRule forwardingRuleResource)
Creates a GlobalForwardingRule resource in the specified project using the data included in the
request.
|
UnaryCallable<InsertGlobalForwardingRuleHttpRequest,Operation> |
insertGlobalForwardingRuleCallable()
Creates a GlobalForwardingRule resource in the specified project using the data included in the
request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse |
listGlobalForwardingRules(ListGlobalForwardingRulesHttpRequest request)
Retrieves a list of GlobalForwardingRule resources available to the specified project.
|
GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse |
listGlobalForwardingRules(ProjectName project)
Retrieves a list of GlobalForwardingRule resources available to the specified project.
|
GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse |
listGlobalForwardingRules(String project)
Retrieves a list of GlobalForwardingRule resources available to the specified project.
|
UnaryCallable<ListGlobalForwardingRulesHttpRequest,ForwardingRuleList> |
listGlobalForwardingRulesCallable()
Retrieves a list of GlobalForwardingRule resources available to the specified project.
|
UnaryCallable<ListGlobalForwardingRulesHttpRequest,GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse> |
listGlobalForwardingRulesPagedCallable()
Retrieves a list of GlobalForwardingRule resources available to the specified project.
|
Operation |
setTargetGlobalForwardingRule(ProjectGlobalForwardingRuleName forwardingRule,
TargetReference targetReferenceResource)
Changes target URL for the GlobalForwardingRule resource.
|
Operation |
setTargetGlobalForwardingRule(SetTargetGlobalForwardingRuleHttpRequest request)
Changes target URL for the GlobalForwardingRule resource.
|
Operation |
setTargetGlobalForwardingRule(String forwardingRule,
TargetReference targetReferenceResource)
Changes target URL for the GlobalForwardingRule resource.
|
UnaryCallable<SetTargetGlobalForwardingRuleHttpRequest,Operation> |
setTargetGlobalForwardingRuleCallable()
Changes target URL for the GlobalForwardingRule resource.
|
void |
shutdown() |
void |
shutdownNow() |
protected GlobalForwardingRuleClient(GlobalForwardingRuleSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected GlobalForwardingRuleClient(GlobalForwardingRuleStub stub)
public static final GlobalForwardingRuleClient create() throws IOException
IOException
public static final GlobalForwardingRuleClient create(GlobalForwardingRuleSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final GlobalForwardingRuleClient create(GlobalForwardingRuleStub stub)
public final GlobalForwardingRuleSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public GlobalForwardingRuleStub getStub()
@BetaApi public final Operation deleteGlobalForwardingRule(ProjectGlobalForwardingRuleName forwardingRule)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
Operation response = globalForwardingRuleClient.deleteGlobalForwardingRule(forwardingRule);
}
forwardingRule
- Name of the ForwardingRule resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteGlobalForwardingRule(String forwardingRule)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
Operation response = globalForwardingRuleClient.deleteGlobalForwardingRule(forwardingRule.toString());
}
forwardingRule
- Name of the ForwardingRule resource to delete.ApiException
- if the remote call fails@BetaApi public final Operation deleteGlobalForwardingRule(DeleteGlobalForwardingRuleHttpRequest request)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectGlobalForwardingRuleName.format("[PROJECT]", "[FORWARDING_RULE]");
DeleteGlobalForwardingRuleHttpRequest request = DeleteGlobalForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
Operation response = globalForwardingRuleClient.deleteGlobalForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<DeleteGlobalForwardingRuleHttpRequest,Operation> deleteGlobalForwardingRuleCallable()
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectGlobalForwardingRuleName.format("[PROJECT]", "[FORWARDING_RULE]");
DeleteGlobalForwardingRuleHttpRequest request = DeleteGlobalForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
ApiFuture<Operation> future = globalForwardingRuleClient.deleteGlobalForwardingRuleCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final ForwardingRule getGlobalForwardingRule(ProjectGlobalForwardingRuleName forwardingRule)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
ForwardingRule response = globalForwardingRuleClient.getGlobalForwardingRule(forwardingRule);
}
forwardingRule
- Name of the ForwardingRule resource to return.ApiException
- if the remote call fails@BetaApi public final ForwardingRule getGlobalForwardingRule(String forwardingRule)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
ForwardingRule response = globalForwardingRuleClient.getGlobalForwardingRule(forwardingRule.toString());
}
forwardingRule
- Name of the ForwardingRule resource to return.ApiException
- if the remote call fails@BetaApi public final ForwardingRule getGlobalForwardingRule(GetGlobalForwardingRuleHttpRequest request)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectGlobalForwardingRuleName.format("[PROJECT]", "[FORWARDING_RULE]");
GetGlobalForwardingRuleHttpRequest request = GetGlobalForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
ForwardingRule response = globalForwardingRuleClient.getGlobalForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<GetGlobalForwardingRuleHttpRequest,ForwardingRule> getGlobalForwardingRuleCallable()
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectGlobalForwardingRuleName.format("[PROJECT]", "[FORWARDING_RULE]");
GetGlobalForwardingRuleHttpRequest request = GetGlobalForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.build();
ApiFuture<ForwardingRule> future = globalForwardingRuleClient.getGlobalForwardingRuleCallable().futureCall(request);
// Do something
ForwardingRule response = future.get();
}
@BetaApi public final Operation insertGlobalForwardingRule(ProjectName project, ForwardingRule forwardingRuleResource)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
Operation response = globalForwardingRuleClient.insertGlobalForwardingRule(project, forwardingRuleResource);
}
project
- Project ID for this request.forwardingRuleResource
- A ForwardingRule resource. A ForwardingRule resource specifies
which pool of target virtual machines to forward a packet to if it matches the given
[IPAddress, IPProtocol, ports] tuple. (== resource_for beta.forwardingRules ==) (==
resource_for v1.forwardingRules ==) (== resource_for beta.globalForwardingRules ==) (==
resource_for v1.globalForwardingRules ==) (== resource_for beta.regionForwardingRules ==)
(== resource_for v1.regionForwardingRules ==)ApiException
- if the remote call fails@BetaApi public final Operation insertGlobalForwardingRule(String project, ForwardingRule forwardingRuleResource)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
Operation response = globalForwardingRuleClient.insertGlobalForwardingRule(project.toString(), forwardingRuleResource);
}
project
- Project ID for this request.forwardingRuleResource
- A ForwardingRule resource. A ForwardingRule resource specifies
which pool of target virtual machines to forward a packet to if it matches the given
[IPAddress, IPProtocol, ports] tuple. (== resource_for beta.forwardingRules ==) (==
resource_for v1.forwardingRules ==) (== resource_for beta.globalForwardingRules ==) (==
resource_for v1.globalForwardingRules ==) (== resource_for beta.regionForwardingRules ==)
(== resource_for v1.regionForwardingRules ==)ApiException
- if the remote call fails@BetaApi public final Operation insertGlobalForwardingRule(InsertGlobalForwardingRuleHttpRequest request)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
InsertGlobalForwardingRuleHttpRequest request = InsertGlobalForwardingRuleHttpRequest.newBuilder()
.setProject(formattedProject)
.setForwardingRuleResource(forwardingRuleResource)
.build();
Operation response = globalForwardingRuleClient.insertGlobalForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<InsertGlobalForwardingRuleHttpRequest,Operation> insertGlobalForwardingRuleCallable()
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ForwardingRule forwardingRuleResource = ForwardingRule.newBuilder().build();
InsertGlobalForwardingRuleHttpRequest request = InsertGlobalForwardingRuleHttpRequest.newBuilder()
.setProject(formattedProject)
.setForwardingRuleResource(forwardingRuleResource)
.build();
ApiFuture<Operation> future = globalForwardingRuleClient.insertGlobalForwardingRuleCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse listGlobalForwardingRules(ProjectName project)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (ForwardingRule element : globalForwardingRuleClient.listGlobalForwardingRules(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse listGlobalForwardingRules(String project)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (ForwardingRule element : globalForwardingRuleClient.listGlobalForwardingRules(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.ApiException
- if the remote call fails@BetaApi public final GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse listGlobalForwardingRules(ListGlobalForwardingRulesHttpRequest request)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalForwardingRulesHttpRequest request = ListGlobalForwardingRulesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (ForwardingRule element : globalForwardingRuleClient.listGlobalForwardingRules(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<ListGlobalForwardingRulesHttpRequest,GlobalForwardingRuleClient.ListGlobalForwardingRulesPagedResponse> listGlobalForwardingRulesPagedCallable()
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalForwardingRulesHttpRequest request = ListGlobalForwardingRulesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListGlobalForwardingRulesPagedResponse> future = globalForwardingRuleClient.listGlobalForwardingRulesPagedCallable().futureCall(request);
// Do something
for (ForwardingRule element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final UnaryCallable<ListGlobalForwardingRulesHttpRequest,ForwardingRuleList> listGlobalForwardingRulesCallable()
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListGlobalForwardingRulesHttpRequest request = ListGlobalForwardingRulesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
ForwardingRuleList response = globalForwardingRuleClient.listGlobalForwardingRulesCallable().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 setTargetGlobalForwardingRule(ProjectGlobalForwardingRuleName forwardingRule, TargetReference targetReferenceResource)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
Operation response = globalForwardingRuleClient.setTargetGlobalForwardingRule(forwardingRule, targetReferenceResource);
}
forwardingRule
- Name of the ForwardingRule resource in which target is to be set.targetReferenceResource
- ApiException
- if the remote call fails@BetaApi public final Operation setTargetGlobalForwardingRule(String forwardingRule, TargetReference targetReferenceResource)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
ProjectGlobalForwardingRuleName forwardingRule = ProjectGlobalForwardingRuleName.of("[PROJECT]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
Operation response = globalForwardingRuleClient.setTargetGlobalForwardingRule(forwardingRule.toString(), targetReferenceResource);
}
forwardingRule
- Name of the ForwardingRule resource in which target is to be set.targetReferenceResource
- ApiException
- if the remote call fails@BetaApi public final Operation setTargetGlobalForwardingRule(SetTargetGlobalForwardingRuleHttpRequest request)
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectGlobalForwardingRuleName.format("[PROJECT]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
SetTargetGlobalForwardingRuleHttpRequest request = SetTargetGlobalForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.setTargetReferenceResource(targetReferenceResource)
.build();
Operation response = globalForwardingRuleClient.setTargetGlobalForwardingRule(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi public final UnaryCallable<SetTargetGlobalForwardingRuleHttpRequest,Operation> setTargetGlobalForwardingRuleCallable()
Sample code:
try (GlobalForwardingRuleClient globalForwardingRuleClient = GlobalForwardingRuleClient.create()) {
String formattedForwardingRule = ProjectGlobalForwardingRuleName.format("[PROJECT]", "[FORWARDING_RULE]");
TargetReference targetReferenceResource = TargetReference.newBuilder().build();
SetTargetGlobalForwardingRuleHttpRequest request = SetTargetGlobalForwardingRuleHttpRequest.newBuilder()
.setForwardingRule(formattedForwardingRule)
.setTargetReferenceResource(targetReferenceResource)
.build();
ApiFuture<Operation> future = globalForwardingRuleClient.setTargetGlobalForwardingRuleCallable().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.