@Generated(value="by gapic-generator") @BetaApi public class FirewallClient 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 (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Operation response = firewallClient.deleteFirewall(firewall);
}
Note: close() needs to be called on the firewallClient 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 FirewallSettings to create(). For example:
To customize credentials:
FirewallSettings firewallSettings =
FirewallSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
FirewallClient firewallClient =
FirewallClient.create(firewallSettings);
To customize the endpoint:
FirewallSettings firewallSettings =
FirewallSettings.newBuilder().setEndpoint(myEndpoint).build();
FirewallClient firewallClient =
FirewallClient.create(firewallSettings);
Modifier and Type | Class and Description |
---|---|
static class |
FirewallClient.ListFirewallsFixedSizeCollection |
static class |
FirewallClient.ListFirewallsPage |
static class |
FirewallClient.ListFirewallsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
FirewallClient(FirewallSettings settings)
Constructs an instance of FirewallClient, using the given settings.
|
protected |
FirewallClient(FirewallStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static FirewallClient |
create()
Constructs an instance of FirewallClient with default settings.
|
static FirewallClient |
create(FirewallSettings settings)
Constructs an instance of FirewallClient, using the given settings.
|
static FirewallClient |
create(FirewallStub stub)
Constructs an instance of FirewallClient, using the given stub for making calls.
|
Operation |
deleteFirewall(DeleteFirewallHttpRequest request)
Deletes the specified firewall.
|
Operation |
deleteFirewall(ProjectGlobalFirewallName firewall)
Deletes the specified firewall.
|
Operation |
deleteFirewall(String firewall)
Deletes the specified firewall.
|
com.google.api.gax.rpc.UnaryCallable<DeleteFirewallHttpRequest,Operation> |
deleteFirewallCallable()
Deletes the specified firewall.
|
Firewall |
getFirewall(GetFirewallHttpRequest request)
Returns the specified firewall.
|
Firewall |
getFirewall(ProjectGlobalFirewallName firewall)
Returns the specified firewall.
|
Firewall |
getFirewall(String firewall)
Returns the specified firewall.
|
com.google.api.gax.rpc.UnaryCallable<GetFirewallHttpRequest,Firewall> |
getFirewallCallable()
Returns the specified firewall.
|
FirewallSettings |
getSettings() |
FirewallStub |
getStub() |
Operation |
insertFirewall(InsertFirewallHttpRequest request)
Creates a firewall rule in the specified project using the data included in the request.
|
Operation |
insertFirewall(ProjectName project,
Firewall firewallResource)
Creates a firewall rule in the specified project using the data included in the request.
|
Operation |
insertFirewall(String project,
Firewall firewallResource)
Creates a firewall rule in the specified project using the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<InsertFirewallHttpRequest,Operation> |
insertFirewallCallable()
Creates a firewall rule in the specified project using the data included in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
FirewallClient.ListFirewallsPagedResponse |
listFirewalls(ListFirewallsHttpRequest request)
Retrieves the list of firewall rules available to the specified project.
|
FirewallClient.ListFirewallsPagedResponse |
listFirewalls(ProjectName project)
Retrieves the list of firewall rules available to the specified project.
|
FirewallClient.ListFirewallsPagedResponse |
listFirewalls(String project)
Retrieves the list of firewall rules available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListFirewallsHttpRequest,FirewallList> |
listFirewallsCallable()
Retrieves the list of firewall rules available to the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListFirewallsHttpRequest,FirewallClient.ListFirewallsPagedResponse> |
listFirewallsPagedCallable()
Retrieves the list of firewall rules available to the specified project.
|
Operation |
patchFirewall(PatchFirewallHttpRequest request)
Updates the specified firewall rule with the data included in the request.
|
Operation |
patchFirewall(ProjectGlobalFirewallName firewall,
Firewall firewallResource,
List<String> fieldMask)
Updates the specified firewall rule with the data included in the request.
|
Operation |
patchFirewall(String firewall,
Firewall firewallResource,
List<String> fieldMask)
Updates the specified firewall rule with the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<PatchFirewallHttpRequest,Operation> |
patchFirewallCallable()
Updates the specified firewall rule with the data included in the request.
|
void |
shutdown() |
void |
shutdownNow() |
Operation |
updateFirewall(ProjectGlobalFirewallName firewall,
Firewall firewallResource,
List<String> fieldMask)
Updates the specified firewall rule with the data included in the request.
|
Operation |
updateFirewall(String firewall,
Firewall firewallResource,
List<String> fieldMask)
Updates the specified firewall rule with the data included in the request.
|
Operation |
updateFirewall(UpdateFirewallHttpRequest request)
Updates the specified firewall rule with the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<UpdateFirewallHttpRequest,Operation> |
updateFirewallCallable()
Updates the specified firewall rule with the data included in the request.
|
protected FirewallClient(FirewallSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected FirewallClient(FirewallStub stub)
public static final FirewallClient create() throws IOException
IOException
public static final FirewallClient create(FirewallSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final FirewallClient create(FirewallStub stub)
public final FirewallSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public FirewallStub getStub()
@BetaApi public final Operation deleteFirewall(ProjectGlobalFirewallName firewall)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Operation response = firewallClient.deleteFirewall(firewall);
}
firewall
- Name of the firewall rule to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteFirewall(String firewall)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Operation response = firewallClient.deleteFirewall(firewall.toString());
}
firewall
- Name of the firewall rule to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteFirewall(DeleteFirewallHttpRequest request)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
DeleteFirewallHttpRequest request = DeleteFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.build();
Operation response = firewallClient.deleteFirewall(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<DeleteFirewallHttpRequest,Operation> deleteFirewallCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
DeleteFirewallHttpRequest request = DeleteFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.build();
ApiFuture<Operation> future = firewallClient.deleteFirewallCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Firewall getFirewall(ProjectGlobalFirewallName firewall)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Firewall response = firewallClient.getFirewall(firewall);
}
firewall
- Name of the firewall rule to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Firewall getFirewall(String firewall)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Firewall response = firewallClient.getFirewall(firewall.toString());
}
firewall
- Name of the firewall rule to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Firewall getFirewall(GetFirewallHttpRequest request)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
GetFirewallHttpRequest request = GetFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.build();
Firewall response = firewallClient.getFirewall(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<GetFirewallHttpRequest,Firewall> getFirewallCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
GetFirewallHttpRequest request = GetFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.build();
ApiFuture<Firewall> future = firewallClient.getFirewallCallable().futureCall(request);
// Do something
Firewall response = future.get();
}
@BetaApi public final Operation insertFirewall(ProjectName project, Firewall firewallResource)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
Firewall firewallResource = Firewall.newBuilder().build();
Operation response = firewallClient.insertFirewall(project, firewallResource);
}
project
- Project ID for this request.firewallResource
- Represents a Firewall Rule resource.
Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules.
com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertFirewall(String project, Firewall firewallResource)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
Firewall firewallResource = Firewall.newBuilder().build();
Operation response = firewallClient.insertFirewall(project.toString(), firewallResource);
}
project
- Project ID for this request.firewallResource
- Represents a Firewall Rule resource.
Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules.
com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertFirewall(InsertFirewallHttpRequest request)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
Firewall firewallResource = Firewall.newBuilder().build();
InsertFirewallHttpRequest request = InsertFirewallHttpRequest.newBuilder()
.setProject(formattedProject)
.setFirewallResource(firewallResource)
.build();
Operation response = firewallClient.insertFirewall(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<InsertFirewallHttpRequest,Operation> insertFirewallCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
Firewall firewallResource = Firewall.newBuilder().build();
InsertFirewallHttpRequest request = InsertFirewallHttpRequest.newBuilder()
.setProject(formattedProject)
.setFirewallResource(firewallResource)
.build();
ApiFuture<Operation> future = firewallClient.insertFirewallCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final FirewallClient.ListFirewallsPagedResponse listFirewalls(ProjectName project)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Firewall element : firewallClient.listFirewalls(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final FirewallClient.ListFirewallsPagedResponse listFirewalls(String project)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Firewall element : firewallClient.listFirewalls(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 FirewallClient.ListFirewallsPagedResponse listFirewalls(ListFirewallsHttpRequest request)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListFirewallsHttpRequest request = ListFirewallsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (Firewall element : firewallClient.listFirewalls(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<ListFirewallsHttpRequest,FirewallClient.ListFirewallsPagedResponse> listFirewallsPagedCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListFirewallsHttpRequest request = ListFirewallsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListFirewallsPagedResponse> future = firewallClient.listFirewallsPagedCallable().futureCall(request);
// Do something
for (Firewall element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListFirewallsHttpRequest,FirewallList> listFirewallsCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListFirewallsHttpRequest request = ListFirewallsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
FirewallList response = firewallClient.listFirewallsCallable().call(request);
for (Firewall 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 patchFirewall(ProjectGlobalFirewallName firewall, Firewall firewallResource, List<String> fieldMask)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = firewallClient.patchFirewall(firewall, firewallResource, fieldMask);
}
firewall
- Name of the firewall rule to patch.firewallResource
- Represents a Firewall Rule resource.
Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules.
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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation patchFirewall(String firewall, Firewall firewallResource, List<String> fieldMask)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = firewallClient.patchFirewall(firewall.toString(), firewallResource, fieldMask);
}
firewall
- Name of the firewall rule to patch.firewallResource
- Represents a Firewall Rule resource.
Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules.
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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation patchFirewall(PatchFirewallHttpRequest request)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchFirewallHttpRequest request = PatchFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.setFirewallResource(firewallResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = firewallClient.patchFirewall(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<PatchFirewallHttpRequest,Operation> patchFirewallCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchFirewallHttpRequest request = PatchFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.setFirewallResource(firewallResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = firewallClient.patchFirewallCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation updateFirewall(ProjectGlobalFirewallName firewall, Firewall firewallResource, List<String> fieldMask)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = firewallClient.updateFirewall(firewall, firewallResource, fieldMask);
}
firewall
- Name of the firewall rule to update.firewallResource
- Represents a Firewall Rule resource.
Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules.
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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation updateFirewall(String firewall, Firewall firewallResource, List<String> fieldMask)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
ProjectGlobalFirewallName firewall = ProjectGlobalFirewallName.of("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = firewallClient.updateFirewall(firewall.toString(), firewallResource, fieldMask);
}
firewall
- Name of the firewall rule to update.firewallResource
- Represents a Firewall Rule resource.
Firewall rules allow or deny ingress traffic to, and egress traffic from your instances. For more information, read Firewall rules.
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.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation updateFirewall(UpdateFirewallHttpRequest request)
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
UpdateFirewallHttpRequest request = UpdateFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.setFirewallResource(firewallResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = firewallClient.updateFirewall(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<UpdateFirewallHttpRequest,Operation> updateFirewallCallable()
Sample code:
try (FirewallClient firewallClient = FirewallClient.create()) {
String formattedFirewall = ProjectGlobalFirewallName.format("[PROJECT]", "[FIREWALL]");
Firewall firewallResource = Firewall.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
UpdateFirewallHttpRequest request = UpdateFirewallHttpRequest.newBuilder()
.setFirewall(formattedFirewall)
.setFirewallResource(firewallResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = firewallClient.updateFirewallCallable().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.