- 2.53.0 (latest)
- 2.52.0
- 2.51.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.40.0
- 2.39.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.28.0
- 2.27.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.7-SNAPSHOT
- 2.2.1
- 2.1.2
- 2.0.10
public class OrgPolicyClient implements BackgroundResource
Service Description: An interface for managing organization policies.
The Cloud Org Policy service provides a simple mechanism for organizations to restrict the allowed configurations across their entire Cloud Resource hierarchy.
You can use a policy
to configure restrictions in Cloud resources. For example, you can
enforce a policy
that restricts which Google Cloud Platform APIs can be activated in a certain
part of your resource hierarchy, or prevents serial port access to VM instances in a particular
folder.
Policies
are inherited down through the resource hierarchy. A policy
applied to a parent
resource automatically applies to all its child resources unless overridden with a policy
lower
in the hierarchy.
A constraint
defines an aspect of a resource's configuration that can be controlled by an
organization's policy administrator. Policies
are a collection of constraints
that defines
their allowable configuration on a particular resource and its child resources.
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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
Policy response = orgPolicyClient.getPolicy(name);
}
Note: close() needs to be called on the OrgPolicyClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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 OrgPolicySettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
OrgPolicySettings orgPolicySettings =
OrgPolicySettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
OrgPolicySettings orgPolicySettings =
OrgPolicySettings.newBuilder().setEndpoint(myEndpoint).build();
OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final OrgPolicyClient create()
Constructs an instance of OrgPolicyClient with default settings.
Type | Description |
OrgPolicyClient |
Type | Description |
IOException |
create(OrgPolicySettings settings)
public static final OrgPolicyClient create(OrgPolicySettings settings)
Constructs an instance of OrgPolicyClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | OrgPolicySettings |
Type | Description |
OrgPolicyClient |
Type | Description |
IOException |
create(OrgPolicyStub stub)
public static final OrgPolicyClient create(OrgPolicyStub stub)
Constructs an instance of OrgPolicyClient, using the given stub for making calls. This is for advanced usage - prefer using create(OrgPolicySettings).
Name | Description |
stub | OrgPolicyStub |
Type | Description |
OrgPolicyClient |
Constructors
OrgPolicyClient(OrgPolicySettings settings)
protected OrgPolicyClient(OrgPolicySettings settings)
Constructs an instance of OrgPolicyClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | OrgPolicySettings |
OrgPolicyClient(OrgPolicyStub stub)
protected OrgPolicyClient(OrgPolicyStub stub)
Name | Description |
stub | OrgPolicyStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createPolicy(CreatePolicyRequest request)
public final Policy createPolicy(CreatePolicyRequest request)
Creates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint does not
exist. Returns a google.rpc.Status
with google.rpc.Code.ALREADY_EXISTS
if the policy
already exists on the given Cloud resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
CreatePolicyRequest request =
CreatePolicyRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
Policy response = orgPolicyClient.createPolicy(request);
}
Name | Description |
request | CreatePolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
Policy |
createPolicy(FolderName parent, Policy policy)
public final Policy createPolicy(FolderName parent, Policy policy)
Creates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint does not
exist. Returns a google.rpc.Status
with google.rpc.Code.ALREADY_EXISTS
if the policy
already exists on the given Cloud resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
FolderName parent = FolderName.of("[FOLDER]");
Policy policy = Policy.newBuilder().build();
Policy response = orgPolicyClient.createPolicy(parent, policy);
}
Name | Description |
parent | FolderName Required. The Cloud resource that will parent the new Policy. Must be in one of the following forms:
|
policy | Policy Required. |
Type | Description |
Policy |
createPolicy(OrganizationName parent, Policy policy)
public final Policy createPolicy(OrganizationName parent, Policy policy)
Creates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint does not
exist. Returns a google.rpc.Status
with google.rpc.Code.ALREADY_EXISTS
if the policy
already exists on the given Cloud resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
Policy policy = Policy.newBuilder().build();
Policy response = orgPolicyClient.createPolicy(parent, policy);
}
Name | Description |
parent | OrganizationName Required. The Cloud resource that will parent the new Policy. Must be in one of the following forms:
|
policy | Policy Required. |
Type | Description |
Policy |
createPolicy(ProjectName parent, Policy policy)
public final Policy createPolicy(ProjectName parent, Policy policy)
Creates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint does not
exist. Returns a google.rpc.Status
with google.rpc.Code.ALREADY_EXISTS
if the policy
already exists on the given Cloud resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Policy policy = Policy.newBuilder().build();
Policy response = orgPolicyClient.createPolicy(parent, policy);
}
Name | Description |
parent | ProjectName Required. The Cloud resource that will parent the new Policy. Must be in one of the following forms:
|
policy | Policy Required. |
Type | Description |
Policy |
createPolicy(String parent, Policy policy)
public final Policy createPolicy(String parent, Policy policy)
Creates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint does not
exist. Returns a google.rpc.Status
with google.rpc.Code.ALREADY_EXISTS
if the policy
already exists on the given Cloud resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
Policy policy = Policy.newBuilder().build();
Policy response = orgPolicyClient.createPolicy(parent, policy);
}
Name | Description |
parent | String Required. The Cloud resource that will parent the new Policy. Must be in one of the following forms:
|
policy | Policy Required. |
Type | Description |
Policy |
createPolicyCallable()
public final UnaryCallable<CreatePolicyRequest,Policy> createPolicyCallable()
Creates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint does not
exist. Returns a google.rpc.Status
with google.rpc.Code.ALREADY_EXISTS
if the policy
already exists on the given Cloud resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
CreatePolicyRequest request =
CreatePolicyRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
ApiFuture<Policy> future = orgPolicyClient.createPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<CreatePolicyRequest,Policy> |
deletePolicy(DeletePolicyRequest request)
public final void deletePolicy(DeletePolicyRequest request)
Deletes a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or Org
Policy does not exist.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
DeletePolicyRequest request =
DeletePolicyRequest.newBuilder()
.setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
.build();
orgPolicyClient.deletePolicy(request);
}
Name | Description |
request | DeletePolicyRequest The request object containing all of the parameters for the API call. |
deletePolicy(PolicyName name)
public final void deletePolicy(PolicyName name)
Deletes a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or Org
Policy does not exist.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
orgPolicyClient.deletePolicy(name);
}
Name | Description |
name | PolicyName Required. Name of the policy to delete. See |
deletePolicy(String name)
public final void deletePolicy(String name)
Deletes a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or Org
Policy does not exist.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
orgPolicyClient.deletePolicy(name);
}
Name | Description |
name | String Required. Name of the policy to delete. See |
deletePolicyCallable()
public final UnaryCallable<DeletePolicyRequest,Empty> deletePolicyCallable()
Deletes a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or Org
Policy does not exist.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
DeletePolicyRequest request =
DeletePolicyRequest.newBuilder()
.setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
.build();
ApiFuture<Empty> future = orgPolicyClient.deletePolicyCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeletePolicyRequest,Empty> |
getEffectivePolicy(GetEffectivePolicyRequest request)
public final Policy getEffectivePolicy(GetEffectivePolicyRequest request)
Gets the effective Policy
on a resource. This is the result of merging Policies
in the
resource hierarchy and evaluating conditions. The returned Policy
will not have an etag
or
condition
set because it is a computed Policy
across multiple resources. Subtrees of
Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
GetEffectivePolicyRequest request =
GetEffectivePolicyRequest.newBuilder()
.setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
.build();
Policy response = orgPolicyClient.getEffectivePolicy(request);
}
Name | Description |
request | GetEffectivePolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
Policy |
getEffectivePolicy(PolicyName name)
public final Policy getEffectivePolicy(PolicyName name)
Gets the effective Policy
on a resource. This is the result of merging Policies
in the
resource hierarchy and evaluating conditions. The returned Policy
will not have an etag
or
condition
set because it is a computed Policy
across multiple resources. Subtrees of
Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
Policy response = orgPolicyClient.getEffectivePolicy(name);
}
Name | Description |
name | PolicyName Required. The effective policy to compute. See |
Type | Description |
Policy |
getEffectivePolicy(String name)
public final Policy getEffectivePolicy(String name)
Gets the effective Policy
on a resource. This is the result of merging Policies
in the
resource hierarchy and evaluating conditions. The returned Policy
will not have an etag
or
condition
set because it is a computed Policy
across multiple resources. Subtrees of
Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
Policy response = orgPolicyClient.getEffectivePolicy(name);
}
Name | Description |
name | String Required. The effective policy to compute. See |
Type | Description |
Policy |
getEffectivePolicyCallable()
public final UnaryCallable<GetEffectivePolicyRequest,Policy> getEffectivePolicyCallable()
Gets the effective Policy
on a resource. This is the result of merging Policies
in the
resource hierarchy and evaluating conditions. The returned Policy
will not have an etag
or
condition
set because it is a computed Policy
across multiple resources. Subtrees of
Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
GetEffectivePolicyRequest request =
GetEffectivePolicyRequest.newBuilder()
.setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
.build();
ApiFuture<Policy> future = orgPolicyClient.getEffectivePolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<GetEffectivePolicyRequest,Policy> |
getPolicy(GetPolicyRequest request)
public final Policy getPolicy(GetPolicyRequest request)
Gets a Policy
on a resource.
If no Policy
is set on the resource, NOT_FOUND is returned. The etag
value can be used
with UpdatePolicy()
to update a Policy
during read-modify-write.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
GetPolicyRequest request =
GetPolicyRequest.newBuilder()
.setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
.build();
Policy response = orgPolicyClient.getPolicy(request);
}
Name | Description |
request | GetPolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
Policy |
getPolicy(PolicyName name)
public final Policy getPolicy(PolicyName name)
Gets a Policy
on a resource.
If no Policy
is set on the resource, NOT_FOUND is returned. The etag
value can be used
with UpdatePolicy()
to update a Policy
during read-modify-write.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
Policy response = orgPolicyClient.getPolicy(name);
}
Name | Description |
name | PolicyName Required. Resource name of the policy. See |
Type | Description |
Policy |
getPolicy(String name)
public final Policy getPolicy(String name)
Gets a Policy
on a resource.
If no Policy
is set on the resource, NOT_FOUND is returned. The etag
value can be used
with UpdatePolicy()
to update a Policy
during read-modify-write.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
Policy response = orgPolicyClient.getPolicy(name);
}
Name | Description |
name | String Required. Resource name of the policy. See |
Type | Description |
Policy |
getPolicyCallable()
public final UnaryCallable<GetPolicyRequest,Policy> getPolicyCallable()
Gets a Policy
on a resource.
If no Policy
is set on the resource, NOT_FOUND is returned. The etag
value can be used
with UpdatePolicy()
to update a Policy
during read-modify-write.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
GetPolicyRequest request =
GetPolicyRequest.newBuilder()
.setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
.build();
ApiFuture<Policy> future = orgPolicyClient.getPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<GetPolicyRequest,Policy> |
getSettings()
public final OrgPolicySettings getSettings()
Type | Description |
OrgPolicySettings |
getStub()
public OrgPolicyStub getStub()
Type | Description |
OrgPolicyStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listConstraints(FolderName parent)
public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(FolderName parent)
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
FolderName parent = FolderName.of("[FOLDER]");
for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | FolderName Required. The Cloud resource that parents the constraint. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListConstraintsPagedResponse |
listConstraints(ListConstraintsRequest request)
public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(ListConstraintsRequest request)
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ListConstraintsRequest request =
ListConstraintsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Constraint element : orgPolicyClient.listConstraints(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListConstraintsRequest The request object containing all of the parameters for the API call. |
Type | Description |
OrgPolicyClient.ListConstraintsPagedResponse |
listConstraints(OrganizationName parent)
public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(OrganizationName parent)
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | OrganizationName Required. The Cloud resource that parents the constraint. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListConstraintsPagedResponse |
listConstraints(ProjectName parent)
public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(ProjectName parent)
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | ProjectName Required. The Cloud resource that parents the constraint. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListConstraintsPagedResponse |
listConstraints(String parent)
public final OrgPolicyClient.ListConstraintsPagedResponse listConstraints(String parent)
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The Cloud resource that parents the constraint. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListConstraintsPagedResponse |
listConstraintsCallable()
public final UnaryCallable<ListConstraintsRequest,ListConstraintsResponse> listConstraintsCallable()
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ListConstraintsRequest request =
ListConstraintsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListConstraintsResponse response = orgPolicyClient.listConstraintsCallable().call(request);
for (Constraint element : response.getConstraintsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListConstraintsRequest,ListConstraintsResponse> |
listConstraintsPagedCallable()
public final UnaryCallable<ListConstraintsRequest,OrgPolicyClient.ListConstraintsPagedResponse> listConstraintsPagedCallable()
Lists Constraints
that could be applied on the specified resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ListConstraintsRequest request =
ListConstraintsRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Constraint> future =
orgPolicyClient.listConstraintsPagedCallable().futureCall(request);
// Do something.
for (Constraint element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListConstraintsRequest,ListConstraintsPagedResponse> |
listPolicies(FolderName parent)
public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(FolderName parent)
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
FolderName parent = FolderName.of("[FOLDER]");
for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | FolderName Required. The target Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListPoliciesPagedResponse |
listPolicies(ListPoliciesRequest request)
public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request)
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ListPoliciesRequest request =
ListPoliciesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Policy element : orgPolicyClient.listPolicies(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListPoliciesRequest The request object containing all of the parameters for the API call. |
Type | Description |
OrgPolicyClient.ListPoliciesPagedResponse |
listPolicies(OrganizationName parent)
public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(OrganizationName parent)
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | OrganizationName Required. The target Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListPoliciesPagedResponse |
listPolicies(ProjectName parent)
public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(ProjectName parent)
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | ProjectName Required. The target Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListPoliciesPagedResponse |
listPolicies(String parent)
public final OrgPolicyClient.ListPoliciesPagedResponse listPolicies(String parent)
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The target Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:
|
Type | Description |
OrgPolicyClient.ListPoliciesPagedResponse |
listPoliciesCallable()
public final UnaryCallable<ListPoliciesRequest,ListPoliciesResponse> listPoliciesCallable()
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ListPoliciesRequest request =
ListPoliciesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListPoliciesResponse response = orgPolicyClient.listPoliciesCallable().call(request);
for (Policy element : response.getPoliciesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListPoliciesRequest,ListPoliciesResponse> |
listPoliciesPagedCallable()
public final UnaryCallable<ListPoliciesRequest,OrgPolicyClient.ListPoliciesPagedResponse> listPoliciesPagedCallable()
Retrieves all of the Policies
that exist on a particular resource.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
ListPoliciesRequest request =
ListPoliciesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Policy> future = orgPolicyClient.listPoliciesPagedCallable().futureCall(request);
// Do something.
for (Policy element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListPoliciesRequest,ListPoliciesPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updatePolicy(Policy policy)
public final Policy updatePolicy(Policy policy)
Updates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or the
policy do not exist. Returns a google.rpc.Status
with google.rpc.Code.ABORTED
if the etag
supplied in the request does not match the persisted etag of the policy
Note: the supplied policy will perform a full overwrite of all fields.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
Policy policy = Policy.newBuilder().build();
Policy response = orgPolicyClient.updatePolicy(policy);
}
Name | Description |
policy | Policy Required. |
Type | Description |
Policy |
updatePolicy(UpdatePolicyRequest request)
public final Policy updatePolicy(UpdatePolicyRequest request)
Updates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or the
policy do not exist. Returns a google.rpc.Status
with google.rpc.Code.ABORTED
if the etag
supplied in the request does not match the persisted etag of the policy
Note: the supplied policy will perform a full overwrite of all fields.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
UpdatePolicyRequest request =
UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
Policy response = orgPolicyClient.updatePolicy(request);
}
Name | Description |
request | UpdatePolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
Policy |
updatePolicyCallable()
public final UnaryCallable<UpdatePolicyRequest,Policy> updatePolicyCallable()
Updates a Policy.
Returns a google.rpc.Status
with google.rpc.Code.NOT_FOUND
if the constraint or the
policy do not exist. Returns a google.rpc.Status
with google.rpc.Code.ABORTED
if the etag
supplied in the request does not match the persisted etag of the policy
Note: the supplied policy will perform a full overwrite of all fields.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
UpdatePolicyRequest request =
UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
ApiFuture<Policy> future = orgPolicyClient.updatePolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<UpdatePolicyRequest,Policy> |