@Generated(value="by gapic-generator") @BetaApi public class SecurityPolicyClient 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 (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource);
}
Note: close() needs to be called on the securityPolicyClient 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 SecurityPolicySettings to create(). For example:
To customize credentials:
SecurityPolicySettings securityPolicySettings =
SecurityPolicySettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SecurityPolicyClient securityPolicyClient =
SecurityPolicyClient.create(securityPolicySettings);
To customize the endpoint:
SecurityPolicySettings securityPolicySettings =
SecurityPolicySettings.newBuilder().setEndpoint(myEndpoint).build();
SecurityPolicyClient securityPolicyClient =
SecurityPolicyClient.create(securityPolicySettings);
Modifier and Type | Class and Description |
---|---|
static class |
SecurityPolicyClient.ListSecurityPoliciesFixedSizeCollection |
static class |
SecurityPolicyClient.ListSecurityPoliciesPage |
static class |
SecurityPolicyClient.ListSecurityPoliciesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
SecurityPolicyClient(SecurityPolicySettings settings)
Constructs an instance of SecurityPolicyClient, using the given settings.
|
protected |
SecurityPolicyClient(SecurityPolicyStub stub) |
Modifier and Type | Method and Description |
---|---|
Operation |
addRuleSecurityPolicy(AddRuleSecurityPolicyHttpRequest request)
Inserts a rule into a security policy.
|
Operation |
addRuleSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy,
SecurityPolicyRule securityPolicyRuleResource)
Inserts a rule into a security policy.
|
Operation |
addRuleSecurityPolicy(String securityPolicy,
SecurityPolicyRule securityPolicyRuleResource)
Inserts a rule into a security policy.
|
com.google.api.gax.rpc.UnaryCallable<AddRuleSecurityPolicyHttpRequest,Operation> |
addRuleSecurityPolicyCallable()
Inserts a rule into a security policy.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SecurityPolicyClient |
create()
Constructs an instance of SecurityPolicyClient with default settings.
|
static SecurityPolicyClient |
create(SecurityPolicySettings settings)
Constructs an instance of SecurityPolicyClient, using the given settings.
|
static SecurityPolicyClient |
create(SecurityPolicyStub stub)
Constructs an instance of SecurityPolicyClient, using the given stub for making calls.
|
Operation |
deleteSecurityPolicy(DeleteSecurityPolicyHttpRequest request)
Deletes the specified policy.
|
Operation |
deleteSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy)
Deletes the specified policy.
|
Operation |
deleteSecurityPolicy(String securityPolicy)
Deletes the specified policy.
|
com.google.api.gax.rpc.UnaryCallable<DeleteSecurityPolicyHttpRequest,Operation> |
deleteSecurityPolicyCallable()
Deletes the specified policy.
|
SecurityPolicyRule |
getRuleSecurityPolicy(GetRuleSecurityPolicyHttpRequest request)
Gets a rule at the specified priority.
|
SecurityPolicyRule |
getRuleSecurityPolicy(Integer priority,
ProjectGlobalSecurityPolicyName securityPolicy)
Gets a rule at the specified priority.
|
SecurityPolicyRule |
getRuleSecurityPolicy(Integer priority,
String securityPolicy)
Gets a rule at the specified priority.
|
com.google.api.gax.rpc.UnaryCallable<GetRuleSecurityPolicyHttpRequest,SecurityPolicyRule> |
getRuleSecurityPolicyCallable()
Gets a rule at the specified priority.
|
SecurityPolicy |
getSecurityPolicy(GetSecurityPolicyHttpRequest request)
List all of the ordered rules present in a single specified policy.
|
SecurityPolicy |
getSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy)
List all of the ordered rules present in a single specified policy.
|
SecurityPolicy |
getSecurityPolicy(String securityPolicy)
List all of the ordered rules present in a single specified policy.
|
com.google.api.gax.rpc.UnaryCallable<GetSecurityPolicyHttpRequest,SecurityPolicy> |
getSecurityPolicyCallable()
List all of the ordered rules present in a single specified policy.
|
SecurityPolicySettings |
getSettings() |
SecurityPolicyStub |
getStub() |
Operation |
insertSecurityPolicy(InsertSecurityPolicyHttpRequest request)
Creates a new policy in the specified project using the data included in the request.
|
Operation |
insertSecurityPolicy(ProjectName project,
SecurityPolicy securityPolicyResource)
Creates a new policy in the specified project using the data included in the request.
|
Operation |
insertSecurityPolicy(String project,
SecurityPolicy securityPolicyResource)
Creates a new policy in the specified project using the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<InsertSecurityPolicyHttpRequest,Operation> |
insertSecurityPolicyCallable()
Creates a new policy in the specified project using the data included in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
SecurityPolicyClient.ListSecurityPoliciesPagedResponse |
listSecurityPolicies(ListSecurityPoliciesHttpRequest request)
List all the policies that have been configured for the specified project.
|
SecurityPolicyClient.ListSecurityPoliciesPagedResponse |
listSecurityPolicies(ProjectName project)
List all the policies that have been configured for the specified project.
|
SecurityPolicyClient.ListSecurityPoliciesPagedResponse |
listSecurityPolicies(String project)
List all the policies that have been configured for the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListSecurityPoliciesHttpRequest,SecurityPolicyList> |
listSecurityPoliciesCallable()
List all the policies that have been configured for the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListSecurityPoliciesHttpRequest,SecurityPolicyClient.ListSecurityPoliciesPagedResponse> |
listSecurityPoliciesPagedCallable()
List all the policies that have been configured for the specified project.
|
Operation |
patchRuleSecurityPolicy(Integer priority,
ProjectGlobalSecurityPolicyName securityPolicy,
SecurityPolicyRule securityPolicyRuleResource)
Patches a rule at the specified priority.
|
Operation |
patchRuleSecurityPolicy(Integer priority,
String securityPolicy,
SecurityPolicyRule securityPolicyRuleResource)
Patches a rule at the specified priority.
|
Operation |
patchRuleSecurityPolicy(PatchRuleSecurityPolicyHttpRequest request)
Patches a rule at the specified priority.
|
com.google.api.gax.rpc.UnaryCallable<PatchRuleSecurityPolicyHttpRequest,Operation> |
patchRuleSecurityPolicyCallable()
Patches a rule at the specified priority.
|
Operation |
patchSecurityPolicy(PatchSecurityPolicyHttpRequest request)
Patches the specified policy with the data included in the request.
|
Operation |
patchSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy,
SecurityPolicy securityPolicyResource,
List<String> fieldMask)
Patches the specified policy with the data included in the request.
|
Operation |
patchSecurityPolicy(String securityPolicy,
SecurityPolicy securityPolicyResource,
List<String> fieldMask)
Patches the specified policy with the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<PatchSecurityPolicyHttpRequest,Operation> |
patchSecurityPolicyCallable()
Patches the specified policy with the data included in the request.
|
Operation |
removeRuleSecurityPolicy(Integer priority,
ProjectGlobalSecurityPolicyName securityPolicy)
Deletes a rule at the specified priority.
|
Operation |
removeRuleSecurityPolicy(Integer priority,
String securityPolicy)
Deletes a rule at the specified priority.
|
Operation |
removeRuleSecurityPolicy(RemoveRuleSecurityPolicyHttpRequest request)
Deletes a rule at the specified priority.
|
com.google.api.gax.rpc.UnaryCallable<RemoveRuleSecurityPolicyHttpRequest,Operation> |
removeRuleSecurityPolicyCallable()
Deletes a rule at the specified priority.
|
void |
shutdown() |
void |
shutdownNow() |
protected SecurityPolicyClient(SecurityPolicySettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected SecurityPolicyClient(SecurityPolicyStub stub)
public static final SecurityPolicyClient create() throws IOException
IOException
public static final SecurityPolicyClient create(SecurityPolicySettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final SecurityPolicyClient create(SecurityPolicyStub stub)
public final SecurityPolicySettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public SecurityPolicyStub getStub()
@BetaApi public final Operation addRuleSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy, SecurityPolicyRule securityPolicyRuleResource)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy, securityPolicyRuleResource);
}
securityPolicy
- Name of the security policy to update.securityPolicyRuleResource
- Represents a rule that describes one or more match conditions
along with the action to be taken when traffic matches this condition (allow or deny).com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation addRuleSecurityPolicy(String securityPolicy, SecurityPolicyRule securityPolicyRuleResource)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
Operation response = securityPolicyClient.addRuleSecurityPolicy(securityPolicy.toString(), securityPolicyRuleResource);
}
securityPolicy
- Name of the security policy to update.securityPolicyRuleResource
- Represents a rule that describes one or more match conditions
along with the action to be taken when traffic matches this condition (allow or deny).com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation addRuleSecurityPolicy(AddRuleSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
AddRuleSecurityPolicyHttpRequest request = AddRuleSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.setSecurityPolicyRuleResource(securityPolicyRuleResource)
.build();
Operation response = securityPolicyClient.addRuleSecurityPolicy(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<AddRuleSecurityPolicyHttpRequest,Operation> addRuleSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
AddRuleSecurityPolicyHttpRequest request = AddRuleSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.setSecurityPolicyRuleResource(securityPolicyRuleResource)
.build();
ApiFuture<Operation> future = securityPolicyClient.addRuleSecurityPolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation deleteSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
Operation response = securityPolicyClient.deleteSecurityPolicy(securityPolicy);
}
securityPolicy
- Name of the security policy to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteSecurityPolicy(String securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
Operation response = securityPolicyClient.deleteSecurityPolicy(securityPolicy.toString());
}
securityPolicy
- Name of the security policy to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteSecurityPolicy(DeleteSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
DeleteSecurityPolicyHttpRequest request = DeleteSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.build();
Operation response = securityPolicyClient.deleteSecurityPolicy(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<DeleteSecurityPolicyHttpRequest,Operation> deleteSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
DeleteSecurityPolicyHttpRequest request = DeleteSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.build();
ApiFuture<Operation> future = securityPolicyClient.deleteSecurityPolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final SecurityPolicy getSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicy response = securityPolicyClient.getSecurityPolicy(securityPolicy);
}
securityPolicy
- Name of the security policy to get.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SecurityPolicy getSecurityPolicy(String securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicy response = securityPolicyClient.getSecurityPolicy(securityPolicy.toString());
}
securityPolicy
- Name of the security policy to get.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SecurityPolicy getSecurityPolicy(GetSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
GetSecurityPolicyHttpRequest request = GetSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.build();
SecurityPolicy response = securityPolicyClient.getSecurityPolicy(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<GetSecurityPolicyHttpRequest,SecurityPolicy> getSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
GetSecurityPolicyHttpRequest request = GetSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.build();
ApiFuture<SecurityPolicy> future = securityPolicyClient.getSecurityPolicyCallable().futureCall(request);
// Do something
SecurityPolicy response = future.get();
}
@BetaApi public final SecurityPolicyRule getRuleSecurityPolicy(Integer priority, ProjectGlobalSecurityPolicyName securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule response = securityPolicyClient.getRuleSecurityPolicy(priority, securityPolicy);
}
priority
- The priority of the rule to get from the security policy.securityPolicy
- Name of the security policy to which the queried rule belongs.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SecurityPolicyRule getRuleSecurityPolicy(Integer priority, String securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule response = securityPolicyClient.getRuleSecurityPolicy(priority, securityPolicy.toString());
}
priority
- The priority of the rule to get from the security policy.securityPolicy
- Name of the security policy to which the queried rule belongs.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SecurityPolicyRule getRuleSecurityPolicy(GetRuleSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
GetRuleSecurityPolicyHttpRequest request = GetRuleSecurityPolicyHttpRequest.newBuilder()
.setPriority(priority)
.setSecurityPolicy(formattedSecurityPolicy)
.build();
SecurityPolicyRule response = securityPolicyClient.getRuleSecurityPolicy(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<GetRuleSecurityPolicyHttpRequest,SecurityPolicyRule> getRuleSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
GetRuleSecurityPolicyHttpRequest request = GetRuleSecurityPolicyHttpRequest.newBuilder()
.setPriority(priority)
.setSecurityPolicy(formattedSecurityPolicy)
.build();
ApiFuture<SecurityPolicyRule> future = securityPolicyClient.getRuleSecurityPolicyCallable().futureCall(request);
// Do something
SecurityPolicyRule response = future.get();
}
@BetaApi public final Operation insertSecurityPolicy(ProjectName project, SecurityPolicy securityPolicyResource)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
Operation response = securityPolicyClient.insertSecurityPolicy(project, securityPolicyResource);
}
project
- Project ID for this request.securityPolicyResource
- Represents a Cloud Armor Security Policy resource.
Only external backend services that use load balancers can reference a Security Policy. For more information, read Cloud Armor Security Policy Concepts. (== resource_for v1.securityPolicies ==) (== resource_for beta.securityPolicies ==)
com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertSecurityPolicy(String project, SecurityPolicy securityPolicyResource)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
Operation response = securityPolicyClient.insertSecurityPolicy(project.toString(), securityPolicyResource);
}
project
- Project ID for this request.securityPolicyResource
- Represents a Cloud Armor Security Policy resource.
Only external backend services that use load balancers can reference a Security Policy. For more information, read Cloud Armor Security Policy Concepts. (== resource_for v1.securityPolicies ==) (== resource_for beta.securityPolicies ==)
com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation insertSecurityPolicy(InsertSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
InsertSecurityPolicyHttpRequest request = InsertSecurityPolicyHttpRequest.newBuilder()
.setProject(formattedProject)
.setSecurityPolicyResource(securityPolicyResource)
.build();
Operation response = securityPolicyClient.insertSecurityPolicy(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<InsertSecurityPolicyHttpRequest,Operation> insertSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
InsertSecurityPolicyHttpRequest request = InsertSecurityPolicyHttpRequest.newBuilder()
.setProject(formattedProject)
.setSecurityPolicyResource(securityPolicyResource)
.build();
ApiFuture<Operation> future = securityPolicyClient.insertSecurityPolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final SecurityPolicyClient.ListSecurityPoliciesPagedResponse listSecurityPolicies(ProjectName project)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (SecurityPolicy element : securityPolicyClient.listSecurityPolicies(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SecurityPolicyClient.ListSecurityPoliciesPagedResponse listSecurityPolicies(String project)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (SecurityPolicy element : securityPolicyClient.listSecurityPolicies(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 SecurityPolicyClient.ListSecurityPoliciesPagedResponse listSecurityPolicies(ListSecurityPoliciesHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListSecurityPoliciesHttpRequest request = ListSecurityPoliciesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (SecurityPolicy element : securityPolicyClient.listSecurityPolicies(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<ListSecurityPoliciesHttpRequest,SecurityPolicyClient.ListSecurityPoliciesPagedResponse> listSecurityPoliciesPagedCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListSecurityPoliciesHttpRequest request = ListSecurityPoliciesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListSecurityPoliciesPagedResponse> future = securityPolicyClient.listSecurityPoliciesPagedCallable().futureCall(request);
// Do something
for (SecurityPolicy element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListSecurityPoliciesHttpRequest,SecurityPolicyList> listSecurityPoliciesCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListSecurityPoliciesHttpRequest request = ListSecurityPoliciesHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
SecurityPolicyList response = securityPolicyClient.listSecurityPoliciesCallable().call(request);
for (SecurityPolicy 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 patchSecurityPolicy(ProjectGlobalSecurityPolicyName securityPolicy, SecurityPolicy securityPolicyResource, List<String> fieldMask)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = securityPolicyClient.patchSecurityPolicy(securityPolicy, securityPolicyResource, fieldMask);
}
securityPolicy
- Name of the security policy to update.securityPolicyResource
- Represents a Cloud Armor Security Policy resource.
Only external backend services that use load balancers can reference a Security Policy. For more information, read Cloud Armor Security Policy Concepts. (== resource_for v1.securityPolicies ==) (== resource_for beta.securityPolicies ==)
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 patchSecurityPolicy(String securityPolicy, SecurityPolicy securityPolicyResource, List<String> fieldMask)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
Operation response = securityPolicyClient.patchSecurityPolicy(securityPolicy.toString(), securityPolicyResource, fieldMask);
}
securityPolicy
- Name of the security policy to update.securityPolicyResource
- Represents a Cloud Armor Security Policy resource.
Only external backend services that use load balancers can reference a Security Policy. For more information, read Cloud Armor Security Policy Concepts. (== resource_for v1.securityPolicies ==) (== resource_for beta.securityPolicies ==)
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 patchSecurityPolicy(PatchSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchSecurityPolicyHttpRequest request = PatchSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.setSecurityPolicyResource(securityPolicyResource)
.addAllFieldMask(fieldMask)
.build();
Operation response = securityPolicyClient.patchSecurityPolicy(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<PatchSecurityPolicyHttpRequest,Operation> patchSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicy securityPolicyResource = SecurityPolicy.newBuilder().build();
List<String> fieldMask = new ArrayList<>();
PatchSecurityPolicyHttpRequest request = PatchSecurityPolicyHttpRequest.newBuilder()
.setSecurityPolicy(formattedSecurityPolicy)
.setSecurityPolicyResource(securityPolicyResource)
.addAllFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = securityPolicyClient.patchSecurityPolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation patchRuleSecurityPolicy(Integer priority, ProjectGlobalSecurityPolicyName securityPolicy, SecurityPolicyRule securityPolicyRuleResource)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
Operation response = securityPolicyClient.patchRuleSecurityPolicy(priority, securityPolicy, securityPolicyRuleResource);
}
priority
- The priority of the rule to patch.securityPolicy
- Name of the security policy to update.securityPolicyRuleResource
- Represents a rule that describes one or more match conditions
along with the action to be taken when traffic matches this condition (allow or deny).com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation patchRuleSecurityPolicy(Integer priority, String securityPolicy, SecurityPolicyRule securityPolicyRuleResource)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
Operation response = securityPolicyClient.patchRuleSecurityPolicy(priority, securityPolicy.toString(), securityPolicyRuleResource);
}
priority
- The priority of the rule to patch.securityPolicy
- Name of the security policy to update.securityPolicyRuleResource
- Represents a rule that describes one or more match conditions
along with the action to be taken when traffic matches this condition (allow or deny).com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation patchRuleSecurityPolicy(PatchRuleSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
PatchRuleSecurityPolicyHttpRequest request = PatchRuleSecurityPolicyHttpRequest.newBuilder()
.setPriority(priority)
.setSecurityPolicy(formattedSecurityPolicy)
.setSecurityPolicyRuleResource(securityPolicyRuleResource)
.build();
Operation response = securityPolicyClient.patchRuleSecurityPolicy(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<PatchRuleSecurityPolicyHttpRequest,Operation> patchRuleSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
SecurityPolicyRule securityPolicyRuleResource = SecurityPolicyRule.newBuilder().build();
PatchRuleSecurityPolicyHttpRequest request = PatchRuleSecurityPolicyHttpRequest.newBuilder()
.setPriority(priority)
.setSecurityPolicy(formattedSecurityPolicy)
.setSecurityPolicyRuleResource(securityPolicyRuleResource)
.build();
ApiFuture<Operation> future = securityPolicyClient.patchRuleSecurityPolicyCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Operation removeRuleSecurityPolicy(Integer priority, ProjectGlobalSecurityPolicyName securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
Operation response = securityPolicyClient.removeRuleSecurityPolicy(priority, securityPolicy);
}
priority
- The priority of the rule to remove from the security policy.securityPolicy
- Name of the security policy to update.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation removeRuleSecurityPolicy(Integer priority, String securityPolicy)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
ProjectGlobalSecurityPolicyName securityPolicy = ProjectGlobalSecurityPolicyName.of("[PROJECT]", "[SECURITY_POLICY]");
Operation response = securityPolicyClient.removeRuleSecurityPolicy(priority, securityPolicy.toString());
}
priority
- The priority of the rule to remove from the security policy.securityPolicy
- Name of the security policy to update.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation removeRuleSecurityPolicy(RemoveRuleSecurityPolicyHttpRequest request)
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
RemoveRuleSecurityPolicyHttpRequest request = RemoveRuleSecurityPolicyHttpRequest.newBuilder()
.setPriority(priority)
.setSecurityPolicy(formattedSecurityPolicy)
.build();
Operation response = securityPolicyClient.removeRuleSecurityPolicy(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<RemoveRuleSecurityPolicyHttpRequest,Operation> removeRuleSecurityPolicyCallable()
Sample code:
try (SecurityPolicyClient securityPolicyClient = SecurityPolicyClient.create()) {
Integer priority = 0;
String formattedSecurityPolicy = ProjectGlobalSecurityPolicyName.format("[PROJECT]", "[SECURITY_POLICY]");
RemoveRuleSecurityPolicyHttpRequest request = RemoveRuleSecurityPolicyHttpRequest.newBuilder()
.setPriority(priority)
.setSecurityPolicy(formattedSecurityPolicy)
.build();
ApiFuture<Operation> future = securityPolicyClient.removeRuleSecurityPolicyCallable().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.