diff --git a/google-cloud-orgpolicy-bom/pom.xml b/google-cloud-orgpolicy-bom/pom.xml
new file mode 100644
index 0000000..e33088f
--- /dev/null
+++ b/google-cloud-orgpolicy-bom/pom.xml
@@ -0,0 +1,101 @@
+
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: + * + *
{@code + * 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: + * + *
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: + * + *
{@code + * OrgPolicySettings orgPolicySettings = + * OrgPolicySettings.newBuilder() + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + * .build(); + * OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings); + * }+ * + *
To customize the endpoint: + * + *
{@code + * 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. + */ +@Generated("by gapic-generator-java") +public class OrgPolicyClient implements BackgroundResource { + private final OrgPolicySettings settings; + private final OrgPolicyStub stub; + + /** Constructs an instance of OrgPolicyClient with default settings. */ + public static final OrgPolicyClient create() throws IOException { + return create(OrgPolicySettings.newBuilder().build()); + } + + /** + * 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. + */ + public static final OrgPolicyClient create(OrgPolicySettings settings) throws IOException { + return new OrgPolicyClient(settings); + } + + /** + * Constructs an instance of OrgPolicyClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(OrgPolicySettings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final OrgPolicyClient create(OrgPolicyStub stub) { + return new OrgPolicyClient(stub); + } + + /** + * 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. + */ + protected OrgPolicyClient(OrgPolicySettings settings) throws IOException { + this.settings = settings; + this.stub = ((OrgPolicyStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected OrgPolicyClient(OrgPolicyStub stub) { + this.settings = null; + this.stub = stub; + } + + public final OrgPolicySettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public OrgPolicyStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * FolderName parent = FolderName.of("[FOLDER]"); + * for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + * for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ProjectName parent = ProjectName.of("[PROJECT]"); + * for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * String parent = + * ConstraintName.ofProjectConstraintName("[PROJECT]", "[CONSTRAINT]").toString(); + * for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ListConstraintsRequest request = + * ListConstraintsRequest.newBuilder() + * .setParent( + * ConstraintName.ofProjectConstraintName("[PROJECT]", "[CONSTRAINT]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Constraint element : orgPolicyClient.listConstraints(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListConstraintsPagedResponse listConstraints(ListConstraintsRequest request) { + return listConstraintsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ListConstraintsRequest request = + * ListConstraintsRequest.newBuilder() + * .setParent( + * ConstraintName.ofProjectConstraintName("[PROJECT]", "[CONSTRAINT]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * orgPolicyClient.listConstraintsPagedCallable().futureCall(request); + * // Do something. + * for (Constraint element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * while (true) { + * ListConstraintsResponse response = orgPolicyClient.listConstraintsCallable().call(request); + * for (Constraint element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * FolderName parent = FolderName.of("[FOLDER]"); + * for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent 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: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + * for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent 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: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ProjectName parent = ProjectName.of("[PROJECT]"); + * for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent 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: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * String parent = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString(); + * for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent 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: + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ListPoliciesRequest request = + * ListPoliciesRequest.newBuilder() + * .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (Policy element : orgPolicyClient.listPolicies(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request) { + return listPoliciesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ListPoliciesRequest request = + * ListPoliciesRequest.newBuilder() + * .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = orgPolicyClient.listPoliciesPagedCallable().futureCall(request); + * // Do something. + * for (Policy element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * while (true) { + * ListPoliciesResponse response = orgPolicyClient.listPoliciesCallable().call(request); + * for (Policy element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + * Policy response = orgPolicyClient.getPolicy(name); + * } + * }+ * + * @param name Required. Resource name of the policy. See `Policy` for naming requirements. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(PolicyName name) { + GetPolicyRequest request = + GetPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString(); + * Policy response = orgPolicyClient.getPolicy(name); + * } + * }+ * + * @param name Required. Resource name of the policy. See `Policy` for naming requirements. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(String name) { + GetPolicyRequest request = GetPolicyRequest.newBuilder().setName(name).build(); + return getPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * GetPolicyRequest request = + * GetPolicyRequest.newBuilder() + * .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .build(); + * Policy response = orgPolicyClient.getPolicy(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(GetPolicyRequest request) { + return getPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * GetPolicyRequest request = + * GetPolicyRequest.newBuilder() + * .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = orgPolicyClient.getPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + * Policy response = orgPolicyClient.getEffectivePolicy(name); + * } + * }+ * + * @param name Required. The effective policy to compute. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getEffectivePolicy(PolicyName name) { + GetEffectivePolicyRequest request = + GetEffectivePolicyRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getEffectivePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString(); + * Policy response = orgPolicyClient.getEffectivePolicy(name); + * } + * }+ * + * @param name Required. The effective policy to compute. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getEffectivePolicy(String name) { + GetEffectivePolicyRequest request = + GetEffectivePolicyRequest.newBuilder().setName(name).build(); + return getEffectivePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * GetEffectivePolicyRequest request = + * GetEffectivePolicyRequest.newBuilder() + * .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .build(); + * Policy response = orgPolicyClient.getEffectivePolicy(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getEffectivePolicy(GetEffectivePolicyRequest request) { + return getEffectivePolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * GetEffectivePolicyRequest request = + * GetEffectivePolicyRequest.newBuilder() + * .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = orgPolicyClient.getEffectivePolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * FolderName parent = FolderName.of("[FOLDER]"); + * Policy policy = Policy.newBuilder().build(); + * Policy response = orgPolicyClient.createPolicy(parent, policy); + * } + * }+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + * Policy policy = Policy.newBuilder().build(); + * Policy response = orgPolicyClient.createPolicy(parent, policy); + * } + * }+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * ProjectName parent = ProjectName.of("[PROJECT]"); + * Policy policy = Policy.newBuilder().build(); + * Policy response = orgPolicyClient.createPolicy(parent, policy); + * } + * }+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * String parent = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString(); + * Policy policy = Policy.newBuilder().build(); + * Policy response = orgPolicyClient.createPolicy(parent, policy); + * } + * }+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * CreatePolicyRequest request = + * CreatePolicyRequest.newBuilder() + * .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * Policy response = orgPolicyClient.createPolicy(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy createPolicy(CreatePolicyRequest request) { + return createPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * CreatePolicyRequest request = + * CreatePolicyRequest.newBuilder() + * .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .setPolicy(Policy.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = orgPolicyClient.createPolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * Policy policy = Policy.newBuilder().build(); + * Policy response = orgPolicyClient.updatePolicy(policy); + * } + * }+ * + * @param policy Required. `Policy` to update. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy updatePolicy(Policy policy) { + UpdatePolicyRequest request = UpdatePolicyRequest.newBuilder().setPolicy(policy).build(); + return updatePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * UpdatePolicyRequest request = + * UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build(); + * Policy response = orgPolicyClient.updatePolicy(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy updatePolicy(UpdatePolicyRequest request) { + return updatePolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * UpdatePolicyRequest request = + * UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build(); + * ApiFuture+ */ + public final UnaryCallablefuture = orgPolicyClient.updatePolicyCallable().futureCall(request); + * // Do something. + * Policy response = future.get(); + * } + * }
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org + * Policy does not exist. + * + *
Sample code: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + * orgPolicyClient.deletePolicy(name); + * } + * }+ * + * @param name Required. Name of the policy to delete. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePolicy(PolicyName name) { + DeletePolicyRequest request = + DeletePolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deletePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString(); + * orgPolicyClient.deletePolicy(name); + * } + * }+ * + * @param name Required. Name of the policy to delete. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePolicy(String name) { + DeletePolicyRequest request = DeletePolicyRequest.newBuilder().setName(name).build(); + deletePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * DeletePolicyRequest request = + * DeletePolicyRequest.newBuilder() + * .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .build(); + * orgPolicyClient.deletePolicy(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePolicy(DeletePolicyRequest request) { + deletePolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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: + * + *
{@code + * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) { + * DeletePolicyRequest request = + * DeletePolicyRequest.newBuilder() + * .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = orgPolicyClient.deletePolicyCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *
For example, to set the total timeout of getPolicy to 30 seconds: + * + *
{@code + * OrgPolicySettings.Builder orgPolicySettingsBuilder = OrgPolicySettings.newBuilder(); + * orgPolicySettingsBuilder + * .getPolicySettings() + * .setRetrySettings( + * orgPolicySettingsBuilder + * .getPolicySettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * OrgPolicySettings orgPolicySettings = orgPolicySettingsBuilder.build(); + * }+ */ +@Generated("by gapic-generator-java") +public class OrgPolicySettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction ======================= OrgPolicyClient =======================
+ *
+ * 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.
+ *
+ * Sample for OrgPolicyClient:
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcOrgPolicyCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcOrgPolicyStub extends OrgPolicyStub {
+ private static final MethodDescriptor This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class OrgPolicyStub implements BackgroundResource {
+
+ public UnaryCallable The default instance has everything set to sensible defaults:
+ *
+ * The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ * For example, to set the total timeout of getPolicy to 30 seconds:
+ *
+ * Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction{@code
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
+ * Policy response = orgPolicyClient.getPolicy(name);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.orgpolicy.v2;
+
+import javax.annotation.Generated;
diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyCallableFactory.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyCallableFactory.java
new file mode 100644
index 0000000..e26ea7e
--- /dev/null
+++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyCallableFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.orgpolicy.v2.stub;
+
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC callable factory implementation for the OrgPolicy service API.
+ *
+ *
+ *
+ *
+ * {@code
+ * OrgPolicyStubSettings.Builder orgPolicySettingsBuilder = OrgPolicyStubSettings.newBuilder();
+ * orgPolicySettingsBuilder
+ * .getPolicySettings()
+ * .setRetrySettings(
+ * orgPolicySettingsBuilder
+ * .getPolicySettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * OrgPolicyStubSettings orgPolicySettings = orgPolicySettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class OrgPolicyStubSettings extends StubSettings