listPolici
* }
* }
*
- * @param name Required. Resource name of the policy. See `Policy` for naming requirements.
+ * @param name Required. Resource name of the policy. See
+ * [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getPolicy(PolicyName name) {
@@ -729,10 +729,10 @@ public final Policy getPolicy(PolicyName name) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Gets a `Policy` on a resource.
+ * 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.
+ *
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:
*
@@ -748,7 +748,8 @@ public final Policy getPolicy(PolicyName name) {
* }
* }
*
- * @param name Required. Resource name of the policy. See `Policy` for naming requirements.
+ * @param name Required. Resource name of the policy. See
+ * [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getPolicy(String name) {
@@ -758,10 +759,10 @@ public final Policy getPolicy(String name) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Gets a `Policy` on a resource.
+ * 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.
+ *
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:
*
@@ -789,10 +790,10 @@ public final Policy getPolicy(GetPolicyRequest request) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Gets a `Policy` on a resource.
+ * 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.
+ *
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:
*
@@ -819,10 +820,10 @@ public final UnaryCallable getPolicyCallable() {
// 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.
+ * 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 an evaluated policy across multiple resources. Subtrees of Resource Manager
+ * resource hierarchy with 'under:' prefix will not be expanded.
*
* Sample code:
*
@@ -838,7 +839,8 @@ public final UnaryCallable getPolicyCallable() {
* }
* }
*
- * @param name Required. The effective policy to compute. See `Policy` for naming rules.
+ * @param name Required. The effective policy to compute. See
+ * [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getEffectivePolicy(PolicyName name) {
@@ -851,10 +853,10 @@ public final Policy getEffectivePolicy(PolicyName name) {
// 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.
+ * 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 an evaluated policy across multiple resources. Subtrees of Resource Manager
+ * resource hierarchy with 'under:' prefix will not be expanded.
*
* Sample code:
*
@@ -870,7 +872,8 @@ public final Policy getEffectivePolicy(PolicyName name) {
* }
* }
*
- * @param name Required. The effective policy to compute. See `Policy` for naming rules.
+ * @param name Required. The effective policy to compute. See
+ * [Policy][google.cloud.orgpolicy.v2.Policy] for naming requirements.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy getEffectivePolicy(String name) {
@@ -881,10 +884,10 @@ public final Policy getEffectivePolicy(String name) {
// 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.
+ * 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 an evaluated policy across multiple resources. Subtrees of Resource Manager
+ * resource hierarchy with 'under:' prefix will not be expanded.
*
*
Sample code:
*
@@ -912,10 +915,10 @@ public final Policy getEffectivePolicy(GetEffectivePolicyRequest 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.
+ * 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 an evaluated policy across multiple resources. Subtrees of Resource Manager
+ * resource hierarchy with 'under:' prefix will not be expanded.
*
*
Sample code:
*
@@ -942,11 +945,11 @@ public final UnaryCallable getEffectivePolicy
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Creates a 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.
+ * already exists on the given Google Cloud resource.
*
*
Sample code:
*
@@ -963,8 +966,8 @@ public final UnaryCallable getEffectivePolicy
* }
* }
*
- * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of
- * the following forms:
+ * @param parent Required. The Google Cloud resource that will parent the new policy. Must be in
+ * one of the following forms:
*
* - `projects/{project_number}`
*
- `projects/{project_id}`
@@ -972,7 +975,7 @@ public final UnaryCallable getEffectivePolicy
*
- `organizations/{organization_id}`
*
*
- * @param policy Required. `Policy` to create.
+ * @param policy Required. Policy to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy createPolicy(FolderName parent, Policy policy) {
@@ -986,11 +989,11 @@ public final Policy createPolicy(FolderName parent, Policy policy) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Creates a 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.
+ * already exists on the given Google Cloud resource.
*
*
Sample code:
*
@@ -1007,8 +1010,8 @@ public final Policy createPolicy(FolderName parent, Policy policy) {
* }
* }
*
- * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of
- * the following forms:
+ * @param parent Required. The Google Cloud resource that will parent the new policy. Must be in
+ * one of the following forms:
*
* - `projects/{project_number}`
*
- `projects/{project_id}`
@@ -1016,7 +1019,7 @@ public final Policy createPolicy(FolderName parent, Policy policy) {
*
- `organizations/{organization_id}`
*
*
- * @param policy Required. `Policy` to create.
+ * @param policy Required. Policy to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy createPolicy(OrganizationName parent, Policy policy) {
@@ -1030,11 +1033,11 @@ public final Policy createPolicy(OrganizationName parent, Policy policy) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Creates a 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.
+ * already exists on the given Google Cloud resource.
*
*
Sample code:
*
@@ -1051,8 +1054,8 @@ public final Policy createPolicy(OrganizationName parent, Policy policy) {
* }
* }
*
- * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of
- * the following forms:
+ * @param parent Required. The Google Cloud resource that will parent the new policy. Must be in
+ * one of the following forms:
*
* - `projects/{project_number}`
*
- `projects/{project_id}`
@@ -1060,7 +1063,7 @@ public final Policy createPolicy(OrganizationName parent, Policy policy) {
*
- `organizations/{organization_id}`
*
*
- * @param policy Required. `Policy` to create.
+ * @param policy Required. Policy to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy createPolicy(ProjectName parent, Policy policy) {
@@ -1074,11 +1077,11 @@ public final Policy createPolicy(ProjectName parent, Policy policy) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Creates a 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.
+ * already exists on the given Google Cloud resource.
*
*
Sample code:
*
@@ -1095,8 +1098,8 @@ public final Policy createPolicy(ProjectName parent, Policy policy) {
* }
* }
*
- * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of
- * the following forms:
+ * @param parent Required. The Google Cloud resource that will parent the new policy. Must be in
+ * one of the following forms:
*
* - `projects/{project_number}`
*
- `projects/{project_id}`
@@ -1104,7 +1107,7 @@ public final Policy createPolicy(ProjectName parent, Policy policy) {
*
- `organizations/{organization_id}`
*
*
- * @param policy Required. `Policy` to create.
+ * @param policy Required. Policy to create.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy createPolicy(String parent, Policy policy) {
@@ -1115,11 +1118,11 @@ public final Policy createPolicy(String parent, Policy policy) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Creates a 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.
+ * already exists on the given Google Cloud resource.
*
*
Sample code:
*
@@ -1148,11 +1151,11 @@ public final Policy createPolicy(CreatePolicyRequest request) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Creates a 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.
+ * already exists on the given Google Cloud resource.
*
*
Sample code:
*
@@ -1180,7 +1183,7 @@ public final UnaryCallable createPolicyCallable() {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Updates a 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
@@ -1202,7 +1205,7 @@ public final UnaryCallable createPolicyCallable() {
* }
* }
*
- * @param policy Required. `Policy` to update.
+ * @param policy Required. Policy to update.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Policy updatePolicy(Policy policy) {
@@ -1212,7 +1215,7 @@ public final Policy updatePolicy(Policy policy) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Updates a 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
@@ -1247,7 +1250,7 @@ public final Policy updatePolicy(UpdatePolicyRequest request) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Updates a 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
@@ -1281,10 +1284,10 @@ public final UnaryCallable updatePolicyCallable() {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Deletes a Policy.
+ * Deletes a policy.
*
- * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org
- * Policy does not exist.
+ *
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or
+ * organization policy does not exist.
*
*
Sample code:
*
@@ -1300,7 +1303,7 @@ public final UnaryCallable updatePolicyCallable() {
* }
* }
*
- * @param name Required. Name of the policy to delete. See `Policy` for naming rules.
+ * @param name Required. Name of the policy to delete. See the policy entry for naming rules.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deletePolicy(PolicyName name) {
@@ -1311,10 +1314,10 @@ public final void deletePolicy(PolicyName name) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Deletes a Policy.
+ * Deletes a policy.
*
- * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org
- * Policy does not exist.
+ *
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or
+ * organization policy does not exist.
*
*
Sample code:
*
@@ -1330,7 +1333,7 @@ public final void deletePolicy(PolicyName name) {
* }
* }
*
- * @param name Required. Name of the policy to delete. See `Policy` for naming rules.
+ * @param name Required. Name of the policy to delete. See the policy entry for naming rules.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deletePolicy(String name) {
@@ -1340,10 +1343,10 @@ public final void deletePolicy(String name) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Deletes a Policy.
+ * Deletes a policy.
*
- *
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org
- * Policy does not exist.
+ *
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or
+ * organization policy does not exist.
*
*
Sample code:
*
@@ -1357,6 +1360,7 @@ public final void deletePolicy(String name) {
* DeletePolicyRequest request =
* DeletePolicyRequest.newBuilder()
* .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+ * .setEtag("etag3123477")
* .build();
* orgPolicyClient.deletePolicy(request);
* }
@@ -1371,10 +1375,10 @@ public final void deletePolicy(DeletePolicyRequest request) {
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
- * Deletes a Policy.
+ * Deletes a policy.
*
- *
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org
- * Policy does not exist.
+ *
Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or
+ * organization policy does not exist.
*
*
Sample code:
*
@@ -1388,6 +1392,7 @@ public final void deletePolicy(DeletePolicyRequest request) {
* DeletePolicyRequest request =
* DeletePolicyRequest.newBuilder()
* .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+ * .setEtag("etag3123477")
* .build();
* ApiFuture future = orgPolicyClient.deletePolicyCallable().futureCall(request);
* // Do something.
@@ -1399,6 +1404,684 @@ public final UnaryCallable deletePolicyCallable() {
return stub.deletePolicyCallable();
}
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the organization does not
+ * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the constraint
+ * already exists on the given organization.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ * CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ * CustomConstraint response = orgPolicyClient.createCustomConstraint(parent, customConstraint);
+ * }
+ * }
+ *
+ * @param parent Required. Must be in the following form:
+ *
+ * - `organizations/{organization_id}`
+ *
+ *
+ * @param customConstraint Required. Custom constraint to create.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CustomConstraint createCustomConstraint(
+ OrganizationName parent, CustomConstraint customConstraint) {
+ CreateCustomConstraintRequest request =
+ CreateCustomConstraintRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .setCustomConstraint(customConstraint)
+ .build();
+ return createCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the organization does not
+ * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the constraint
+ * already exists on the given organization.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * String parent = OrganizationName.of("[ORGANIZATION]").toString();
+ * CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ * CustomConstraint response = orgPolicyClient.createCustomConstraint(parent, customConstraint);
+ * }
+ * }
+ *
+ * @param parent Required. Must be in the following form:
+ *
+ * - `organizations/{organization_id}`
+ *
+ *
+ * @param customConstraint Required. Custom constraint to create.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CustomConstraint createCustomConstraint(
+ String parent, CustomConstraint customConstraint) {
+ CreateCustomConstraintRequest request =
+ CreateCustomConstraintRequest.newBuilder()
+ .setParent(parent)
+ .setCustomConstraint(customConstraint)
+ .build();
+ return createCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the organization does not
+ * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the constraint
+ * already exists on the given organization.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * CreateCustomConstraintRequest request =
+ * CreateCustomConstraintRequest.newBuilder()
+ * .setParent(OrganizationName.of("[ORGANIZATION]").toString())
+ * .setCustomConstraint(CustomConstraint.newBuilder().build())
+ * .build();
+ * CustomConstraint response = orgPolicyClient.createCustomConstraint(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 CustomConstraint createCustomConstraint(CreateCustomConstraintRequest request) {
+ return createCustomConstraintCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the organization does not
+ * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the constraint
+ * already exists on the given organization.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * CreateCustomConstraintRequest request =
+ * CreateCustomConstraintRequest.newBuilder()
+ * .setParent(OrganizationName.of("[ORGANIZATION]").toString())
+ * .setCustomConstraint(CustomConstraint.newBuilder().build())
+ * .build();
+ * ApiFuture future =
+ * orgPolicyClient.createCustomConstraintCallable().futureCall(request);
+ * // Do something.
+ * CustomConstraint response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable
+ createCustomConstraintCallable() {
+ return stub.createCustomConstraintCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Updates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Note: the supplied policy will perform a full overwrite of all fields.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ * CustomConstraint response = orgPolicyClient.updateCustomConstraint(customConstraint);
+ * }
+ * }
+ *
+ * @param customConstraint Required. `CustomConstraint` to update.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CustomConstraint updateCustomConstraint(CustomConstraint customConstraint) {
+ UpdateCustomConstraintRequest request =
+ UpdateCustomConstraintRequest.newBuilder().setCustomConstraint(customConstraint).build();
+ return updateCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Updates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Note: the supplied policy will perform a full overwrite of all fields.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * UpdateCustomConstraintRequest request =
+ * UpdateCustomConstraintRequest.newBuilder()
+ * .setCustomConstraint(CustomConstraint.newBuilder().build())
+ * .build();
+ * CustomConstraint response = orgPolicyClient.updateCustomConstraint(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 CustomConstraint updateCustomConstraint(UpdateCustomConstraintRequest request) {
+ return updateCustomConstraintCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Updates a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Note: the supplied policy will perform a full overwrite of all fields.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * UpdateCustomConstraintRequest request =
+ * UpdateCustomConstraintRequest.newBuilder()
+ * .setCustomConstraint(CustomConstraint.newBuilder().build())
+ * .build();
+ * ApiFuture future =
+ * orgPolicyClient.updateCustomConstraintCallable().futureCall(request);
+ * // Do something.
+ * CustomConstraint response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable
+ updateCustomConstraintCallable() {
+ return stub.updateCustomConstraintCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the custom constraint does
+ * not exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
+ * CustomConstraint response = orgPolicyClient.getCustomConstraint(name);
+ * }
+ * }
+ *
+ * @param name Required. Resource name of the custom constraint. See the custom constraint entry
+ * for naming requirements.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CustomConstraint getCustomConstraint(CustomConstraintName name) {
+ GetCustomConstraintRequest request =
+ GetCustomConstraintRequest.newBuilder()
+ .setName(name == null ? null : name.toString())
+ .build();
+ return getCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the custom constraint does
+ * not exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * String name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString();
+ * CustomConstraint response = orgPolicyClient.getCustomConstraint(name);
+ * }
+ * }
+ *
+ * @param name Required. Resource name of the custom constraint. See the custom constraint entry
+ * for naming requirements.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final CustomConstraint getCustomConstraint(String name) {
+ GetCustomConstraintRequest request =
+ GetCustomConstraintRequest.newBuilder().setName(name).build();
+ return getCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the custom constraint does
+ * not exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * GetCustomConstraintRequest request =
+ * GetCustomConstraintRequest.newBuilder()
+ * .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ * .build();
+ * CustomConstraint response = orgPolicyClient.getCustomConstraint(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 CustomConstraint getCustomConstraint(GetCustomConstraintRequest request) {
+ return getCustomConstraintCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the custom constraint does
+ * not exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * GetCustomConstraintRequest request =
+ * GetCustomConstraintRequest.newBuilder()
+ * .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ * .build();
+ * ApiFuture future =
+ * orgPolicyClient.getCustomConstraintCallable().futureCall(request);
+ * // Do something.
+ * CustomConstraint response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable
+ getCustomConstraintCallable() {
+ return stub.getCustomConstraintCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all of the custom constraints that exist on a particular organization resource.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ * for (CustomConstraint element : orgPolicyClient.listCustomConstraints(parent).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param parent Required. The target Google Cloud resource that parents the set of custom
+ * constraints that will be returned from this call. Must be in one of the following forms:
+ *
+ * - `organizations/{organization_id}`
+ *
+ *
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListCustomConstraintsPagedResponse listCustomConstraints(OrganizationName parent) {
+ ListCustomConstraintsRequest request =
+ ListCustomConstraintsRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .build();
+ return listCustomConstraints(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all of the custom constraints that exist on a particular organization resource.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * String parent = OrganizationName.of("[ORGANIZATION]").toString();
+ * for (CustomConstraint element : orgPolicyClient.listCustomConstraints(parent).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param parent Required. The target Google Cloud resource that parents the set of custom
+ * constraints that will be returned from this call. Must be in one of the following forms:
+ *
+ * - `organizations/{organization_id}`
+ *
+ *
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListCustomConstraintsPagedResponse listCustomConstraints(String parent) {
+ ListCustomConstraintsRequest request =
+ ListCustomConstraintsRequest.newBuilder().setParent(parent).build();
+ return listCustomConstraints(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all of the custom constraints that exist on a particular organization resource.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * ListCustomConstraintsRequest request =
+ * ListCustomConstraintsRequest.newBuilder()
+ * .setParent(OrganizationName.of("[ORGANIZATION]").toString())
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * for (CustomConstraint element : orgPolicyClient.listCustomConstraints(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 ListCustomConstraintsPagedResponse listCustomConstraints(
+ ListCustomConstraintsRequest request) {
+ return listCustomConstraintsPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all of the custom constraints that exist on a particular organization resource.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * ListCustomConstraintsRequest request =
+ * ListCustomConstraintsRequest.newBuilder()
+ * .setParent(OrganizationName.of("[ORGANIZATION]").toString())
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * ApiFuture future =
+ * orgPolicyClient.listCustomConstraintsPagedCallable().futureCall(request);
+ * // Do something.
+ * for (CustomConstraint element : future.get().iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable
+ listCustomConstraintsPagedCallable() {
+ return stub.listCustomConstraintsPagedCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all of the custom constraints that exist on a particular organization resource.
+ *
+ * Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * ListCustomConstraintsRequest request =
+ * ListCustomConstraintsRequest.newBuilder()
+ * .setParent(OrganizationName.of("[ORGANIZATION]").toString())
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * while (true) {
+ * ListCustomConstraintsResponse response =
+ * orgPolicyClient.listCustomConstraintsCallable().call(request);
+ * for (CustomConstraint element : response.getCustomConstraintsList()) {
+ * // doThingsWith(element);
+ * }
+ * String nextPageToken = response.getNextPageToken();
+ * if (!Strings.isNullOrEmpty(nextPageToken)) {
+ * request = request.toBuilder().setPageToken(nextPageToken).build();
+ * } else {
+ * break;
+ * }
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable
+ listCustomConstraintsCallable() {
+ return stub.listCustomConstraintsCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
+ * orgPolicyClient.deleteCustomConstraint(name);
+ * }
+ * }
+ *
+ * @param name Required. Name of the custom constraint to delete. See the custom constraint entry
+ * for naming rules.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final void deleteCustomConstraint(CustomConstraintName name) {
+ DeleteCustomConstraintRequest request =
+ DeleteCustomConstraintRequest.newBuilder()
+ .setName(name == null ? null : name.toString())
+ .build();
+ deleteCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * String name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString();
+ * orgPolicyClient.deleteCustomConstraint(name);
+ * }
+ * }
+ *
+ * @param name Required. Name of the custom constraint to delete. See the custom constraint entry
+ * for naming rules.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final void deleteCustomConstraint(String name) {
+ DeleteCustomConstraintRequest request =
+ DeleteCustomConstraintRequest.newBuilder().setName(name).build();
+ deleteCustomConstraint(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * DeleteCustomConstraintRequest request =
+ * DeleteCustomConstraintRequest.newBuilder()
+ * .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ * .build();
+ * orgPolicyClient.deleteCustomConstraint(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 deleteCustomConstraint(DeleteCustomConstraintRequest request) {
+ deleteCustomConstraintCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a custom constraint.
+ *
+ * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not
+ * exist.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ * DeleteCustomConstraintRequest request =
+ * DeleteCustomConstraintRequest.newBuilder()
+ * .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ * .build();
+ * ApiFuture future =
+ * orgPolicyClient.deleteCustomConstraintCallable().futureCall(request);
+ * // Do something.
+ * future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable
+ deleteCustomConstraintCallable() {
+ return stub.deleteCustomConstraintCallable();
+ }
+
@Override
public final void close() {
stub.close();
@@ -1580,4 +2263,88 @@ protected ListPoliciesFixedSizeCollection createCollection(
return new ListPoliciesFixedSizeCollection(pages, collectionSize);
}
}
+
+ public static class ListCustomConstraintsPagedResponse
+ extends AbstractPagedListResponse<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ CustomConstraint,
+ ListCustomConstraintsPage,
+ ListCustomConstraintsFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext
+ context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListCustomConstraintsPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage,
+ input -> new ListCustomConstraintsPagedResponse(input),
+ MoreExecutors.directExecutor());
+ }
+
+ private ListCustomConstraintsPagedResponse(ListCustomConstraintsPage page) {
+ super(page, ListCustomConstraintsFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListCustomConstraintsPage
+ extends AbstractPage<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ CustomConstraint,
+ ListCustomConstraintsPage> {
+
+ private ListCustomConstraintsPage(
+ PageContext
+ context,
+ ListCustomConstraintsResponse response) {
+ super(context, response);
+ }
+
+ private static ListCustomConstraintsPage createEmptyPage() {
+ return new ListCustomConstraintsPage(null, null);
+ }
+
+ @Override
+ protected ListCustomConstraintsPage createPage(
+ PageContext
+ context,
+ ListCustomConstraintsResponse response) {
+ return new ListCustomConstraintsPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext
+ context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListCustomConstraintsFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ CustomConstraint,
+ ListCustomConstraintsPage,
+ ListCustomConstraintsFixedSizeCollection> {
+
+ private ListCustomConstraintsFixedSizeCollection(
+ List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListCustomConstraintsFixedSizeCollection createEmptyCollection() {
+ return new ListCustomConstraintsFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListCustomConstraintsFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListCustomConstraintsFixedSizeCollection(pages, collectionSize);
+ }
+ }
}
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java
index 3f8f772358d9..e2504a3e2d48 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java
@@ -17,6 +17,7 @@
package com.google.cloud.orgpolicy.v2;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.core.ApiFunction;
@@ -114,6 +115,38 @@ public UnaryCallSettings deletePolicySettings() {
return ((OrgPolicyStubSettings) getStubSettings()).deletePolicySettings();
}
+ /** Returns the object with the settings used for calls to createCustomConstraint. */
+ public UnaryCallSettings
+ createCustomConstraintSettings() {
+ return ((OrgPolicyStubSettings) getStubSettings()).createCustomConstraintSettings();
+ }
+
+ /** Returns the object with the settings used for calls to updateCustomConstraint. */
+ public UnaryCallSettings
+ updateCustomConstraintSettings() {
+ return ((OrgPolicyStubSettings) getStubSettings()).updateCustomConstraintSettings();
+ }
+
+ /** Returns the object with the settings used for calls to getCustomConstraint. */
+ public UnaryCallSettings
+ getCustomConstraintSettings() {
+ return ((OrgPolicyStubSettings) getStubSettings()).getCustomConstraintSettings();
+ }
+
+ /** Returns the object with the settings used for calls to listCustomConstraints. */
+ public PagedCallSettings<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ listCustomConstraintsSettings() {
+ return ((OrgPolicyStubSettings) getStubSettings()).listCustomConstraintsSettings();
+ }
+
+ /** Returns the object with the settings used for calls to deleteCustomConstraint. */
+ public UnaryCallSettings deleteCustomConstraintSettings() {
+ return ((OrgPolicyStubSettings) getStubSettings()).deleteCustomConstraintSettings();
+ }
+
public static final OrgPolicySettings create(OrgPolicyStubSettings stub) throws IOException {
return new OrgPolicySettings.Builder(stub.toBuilder()).build();
}
@@ -268,6 +301,39 @@ public UnaryCallSettings.Builder deletePolicySetting
return getStubSettingsBuilder().deletePolicySettings();
}
+ /** Returns the builder for the settings used for calls to createCustomConstraint. */
+ public UnaryCallSettings.Builder
+ createCustomConstraintSettings() {
+ return getStubSettingsBuilder().createCustomConstraintSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to updateCustomConstraint. */
+ public UnaryCallSettings.Builder
+ updateCustomConstraintSettings() {
+ return getStubSettingsBuilder().updateCustomConstraintSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to getCustomConstraint. */
+ public UnaryCallSettings.Builder
+ getCustomConstraintSettings() {
+ return getStubSettingsBuilder().getCustomConstraintSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to listCustomConstraints. */
+ public PagedCallSettings.Builder<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ listCustomConstraintsSettings() {
+ return getStubSettingsBuilder().listCustomConstraintsSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deleteCustomConstraint. */
+ public UnaryCallSettings.Builder
+ deleteCustomConstraintSettings() {
+ return getStubSettingsBuilder().deleteCustomConstraintSettings();
+ }
+
@Override
public OrgPolicySettings build() throws IOException {
return new OrgPolicySettings(this);
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json
index 6be4d578b167..c139c72c1800 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json
@@ -10,12 +10,21 @@
"grpc": {
"libraryClient": "OrgPolicyClient",
"rpcs": {
+ "CreateCustomConstraint": {
+ "methods": ["createCustomConstraint", "createCustomConstraint", "createCustomConstraint", "createCustomConstraintCallable"]
+ },
"CreatePolicy": {
"methods": ["createPolicy", "createPolicy", "createPolicy", "createPolicy", "createPolicy", "createPolicyCallable"]
},
+ "DeleteCustomConstraint": {
+ "methods": ["deleteCustomConstraint", "deleteCustomConstraint", "deleteCustomConstraint", "deleteCustomConstraintCallable"]
+ },
"DeletePolicy": {
"methods": ["deletePolicy", "deletePolicy", "deletePolicy", "deletePolicyCallable"]
},
+ "GetCustomConstraint": {
+ "methods": ["getCustomConstraint", "getCustomConstraint", "getCustomConstraint", "getCustomConstraintCallable"]
+ },
"GetEffectivePolicy": {
"methods": ["getEffectivePolicy", "getEffectivePolicy", "getEffectivePolicy", "getEffectivePolicyCallable"]
},
@@ -25,9 +34,15 @@
"ListConstraints": {
"methods": ["listConstraints", "listConstraints", "listConstraints", "listConstraints", "listConstraints", "listConstraintsPagedCallable", "listConstraintsCallable"]
},
+ "ListCustomConstraints": {
+ "methods": ["listCustomConstraints", "listCustomConstraints", "listCustomConstraints", "listCustomConstraintsPagedCallable", "listCustomConstraintsCallable"]
+ },
"ListPolicies": {
"methods": ["listPolicies", "listPolicies", "listPolicies", "listPolicies", "listPolicies", "listPoliciesPagedCallable", "listPoliciesCallable"]
},
+ "UpdateCustomConstraint": {
+ "methods": ["updateCustomConstraint", "updateCustomConstraint", "updateCustomConstraintCallable"]
+ },
"UpdatePolicy": {
"methods": ["updatePolicy", "updatePolicy", "updatePolicyCallable"]
}
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java
index 8e4569602d56..38b814f4b3a6 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java
@@ -23,21 +23,20 @@
*
* 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.
+ *
The Organization Policy Service provides a simple mechanism for organizations to restrict the
+ * allowed configurations across their entire 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.
+ *
You can use a policy to configure restrictions on resources. For example, you can enforce a
+ * policy that restricts which Google Cloud 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
+ *
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.
+ *
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:
*
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java
index cce4f6e5a07d..6bcb510bf349 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java
@@ -17,6 +17,7 @@
package com.google.cloud.orgpolicy.v2.stub;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.gax.core.BackgroundResource;
@@ -26,15 +27,22 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.CreatePolicyRequest;
+import com.google.cloud.orgpolicy.v2.CustomConstraint;
+import com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.DeletePolicyRequest;
+import com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest;
import com.google.cloud.orgpolicy.v2.GetPolicyRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsResponse;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse;
import com.google.cloud.orgpolicy.v2.ListPoliciesRequest;
import com.google.cloud.orgpolicy.v2.ListPoliciesResponse;
import com.google.cloud.orgpolicy.v2.Policy;
+import com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest;
import com.google.longrunning.stub.GrpcOperationsStub;
import com.google.protobuf.Empty;
@@ -115,6 +123,57 @@ public class GrpcOrgPolicyStub extends OrgPolicyStub {
.setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
.build();
+ private static final MethodDescriptor
+ createCustomConstraintMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/CreateCustomConstraint")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(CreateCustomConstraintRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(CustomConstraint.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ updateCustomConstraintMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/UpdateCustomConstraint")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(UpdateCustomConstraintRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(CustomConstraint.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ getCustomConstraintMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/GetCustomConstraint")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(GetCustomConstraintRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(CustomConstraint.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ listCustomConstraintsMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/ListCustomConstraints")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ListCustomConstraintsRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListCustomConstraintsResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ deleteCustomConstraintMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/DeleteCustomConstraint")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(DeleteCustomConstraintRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
+ .build();
+
private final UnaryCallable
listConstraintsCallable;
private final UnaryCallable
@@ -127,6 +186,17 @@ public class GrpcOrgPolicyStub extends OrgPolicyStub {
private final UnaryCallable createPolicyCallable;
private final UnaryCallable updatePolicyCallable;
private final UnaryCallable deletePolicyCallable;
+ private final UnaryCallable
+ createCustomConstraintCallable;
+ private final UnaryCallable
+ updateCustomConstraintCallable;
+ private final UnaryCallable
+ getCustomConstraintCallable;
+ private final UnaryCallable
+ listCustomConstraintsCallable;
+ private final UnaryCallable
+ listCustomConstraintsPagedCallable;
+ private final UnaryCallable deleteCustomConstraintCallable;
private final BackgroundResource backgroundResources;
private final GrpcOperationsStub operationsStub;
@@ -240,6 +310,63 @@ protected GrpcOrgPolicyStub(
return builder.build();
})
.build();
+ GrpcCallSettings
+ createCustomConstraintTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(createCustomConstraintMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings
+ updateCustomConstraintTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(updateCustomConstraintMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(
+ "custom_constraint.name",
+ String.valueOf(request.getCustomConstraint().getName()));
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings
+ getCustomConstraintTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getCustomConstraintMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("name", String.valueOf(request.getName()));
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings
+ listCustomConstraintsTransportSettings =
+ GrpcCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listCustomConstraintsMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings deleteCustomConstraintTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(deleteCustomConstraintMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("name", String.valueOf(request.getName()));
+ return builder.build();
+ })
+ .build();
this.listConstraintsCallable =
callableFactory.createUnaryCallable(
@@ -270,6 +397,36 @@ protected GrpcOrgPolicyStub(
this.deletePolicyCallable =
callableFactory.createUnaryCallable(
deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext);
+ this.createCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ createCustomConstraintTransportSettings,
+ settings.createCustomConstraintSettings(),
+ clientContext);
+ this.updateCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ updateCustomConstraintTransportSettings,
+ settings.updateCustomConstraintSettings(),
+ clientContext);
+ this.getCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ getCustomConstraintTransportSettings,
+ settings.getCustomConstraintSettings(),
+ clientContext);
+ this.listCustomConstraintsCallable =
+ callableFactory.createUnaryCallable(
+ listCustomConstraintsTransportSettings,
+ settings.listCustomConstraintsSettings(),
+ clientContext);
+ this.listCustomConstraintsPagedCallable =
+ callableFactory.createPagedCallable(
+ listCustomConstraintsTransportSettings,
+ settings.listCustomConstraintsSettings(),
+ clientContext);
+ this.deleteCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ deleteCustomConstraintTransportSettings,
+ settings.deleteCustomConstraintSettings(),
+ clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
@@ -325,6 +482,40 @@ public UnaryCallable deletePolicyCallable() {
return deletePolicyCallable;
}
+ @Override
+ public UnaryCallable
+ createCustomConstraintCallable() {
+ return createCustomConstraintCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ updateCustomConstraintCallable() {
+ return updateCustomConstraintCallable;
+ }
+
+ @Override
+ public UnaryCallable getCustomConstraintCallable() {
+ return getCustomConstraintCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listCustomConstraintsCallable() {
+ return listCustomConstraintsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listCustomConstraintsPagedCallable() {
+ return listCustomConstraintsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteCustomConstraintCallable() {
+ return deleteCustomConstraintCallable;
+ }
+
@Override
public final void close() {
try {
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/HttpJsonOrgPolicyStub.java b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/HttpJsonOrgPolicyStub.java
index 45dd1555ebfb..1a8f75d3b88d 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/HttpJsonOrgPolicyStub.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/HttpJsonOrgPolicyStub.java
@@ -17,6 +17,7 @@
package com.google.cloud.orgpolicy.v2.stub;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.core.BetaApi;
@@ -32,15 +33,22 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.CreatePolicyRequest;
+import com.google.cloud.orgpolicy.v2.CustomConstraint;
+import com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.DeletePolicyRequest;
+import com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest;
import com.google.cloud.orgpolicy.v2.GetPolicyRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsResponse;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse;
import com.google.cloud.orgpolicy.v2.ListPoliciesRequest;
import com.google.cloud.orgpolicy.v2.ListPoliciesResponse;
import com.google.cloud.orgpolicy.v2.Policy;
+import com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
@@ -320,6 +328,190 @@ public class HttpJsonOrgPolicyStub extends OrgPolicyStub {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "etag", request.getEtag());
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createCustomConstraintMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/CreateCustomConstraint")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=organizations/*}/customConstraints",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("customConstraint", request.getCustomConstraint(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(CustomConstraint.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateCustomConstraintMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/UpdateCustomConstraint")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{customConstraint.name=organizations/*/customConstraints/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields,
+ "customConstraint.name",
+ request.getCustomConstraint().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("customConstraint", request.getCustomConstraint(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(CustomConstraint.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getCustomConstraintMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/GetCustomConstraint")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=organizations/*/customConstraints/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(CustomConstraint.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ ListCustomConstraintsRequest, ListCustomConstraintsResponse>
+ listCustomConstraintsMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/ListCustomConstraints")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=organizations/*}/customConstraints",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListCustomConstraintsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteCustomConstraintMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/DeleteCustomConstraint")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=organizations/*/customConstraints/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
@@ -344,6 +536,17 @@ public class HttpJsonOrgPolicyStub extends OrgPolicyStub {
private final UnaryCallable createPolicyCallable;
private final UnaryCallable updatePolicyCallable;
private final UnaryCallable deletePolicyCallable;
+ private final UnaryCallable
+ createCustomConstraintCallable;
+ private final UnaryCallable
+ updateCustomConstraintCallable;
+ private final UnaryCallable
+ getCustomConstraintCallable;
+ private final UnaryCallable
+ listCustomConstraintsCallable;
+ private final UnaryCallable
+ listCustomConstraintsPagedCallable;
+ private final UnaryCallable deleteCustomConstraintCallable;
private final BackgroundResource backgroundResources;
private final HttpJsonStubCallableFactory callableFactory;
@@ -464,6 +667,69 @@ protected HttpJsonOrgPolicyStub(
return builder.build();
})
.build();
+ HttpJsonCallSettings
+ createCustomConstraintTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createCustomConstraintMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+ HttpJsonCallSettings
+ updateCustomConstraintTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateCustomConstraintMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add(
+ "custom_constraint.name",
+ String.valueOf(request.getCustomConstraint().getName()));
+ return builder.build();
+ })
+ .build();
+ HttpJsonCallSettings
+ getCustomConstraintTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getCustomConstraintMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("name", String.valueOf(request.getName()));
+ return builder.build();
+ })
+ .build();
+ HttpJsonCallSettings
+ listCustomConstraintsTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listCustomConstraintsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+ HttpJsonCallSettings
+ deleteCustomConstraintTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteCustomConstraintMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("name", String.valueOf(request.getName()));
+ return builder.build();
+ })
+ .build();
this.listConstraintsCallable =
callableFactory.createUnaryCallable(
@@ -494,6 +760,36 @@ protected HttpJsonOrgPolicyStub(
this.deletePolicyCallable =
callableFactory.createUnaryCallable(
deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext);
+ this.createCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ createCustomConstraintTransportSettings,
+ settings.createCustomConstraintSettings(),
+ clientContext);
+ this.updateCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ updateCustomConstraintTransportSettings,
+ settings.updateCustomConstraintSettings(),
+ clientContext);
+ this.getCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ getCustomConstraintTransportSettings,
+ settings.getCustomConstraintSettings(),
+ clientContext);
+ this.listCustomConstraintsCallable =
+ callableFactory.createUnaryCallable(
+ listCustomConstraintsTransportSettings,
+ settings.listCustomConstraintsSettings(),
+ clientContext);
+ this.listCustomConstraintsPagedCallable =
+ callableFactory.createPagedCallable(
+ listCustomConstraintsTransportSettings,
+ settings.listCustomConstraintsSettings(),
+ clientContext);
+ this.deleteCustomConstraintCallable =
+ callableFactory.createUnaryCallable(
+ deleteCustomConstraintTransportSettings,
+ settings.deleteCustomConstraintSettings(),
+ clientContext);
this.backgroundResources =
new BackgroundResourceAggregation(clientContext.getBackgroundResources());
@@ -509,6 +805,11 @@ public static List getMethodDescriptors() {
methodDescriptors.add(createPolicyMethodDescriptor);
methodDescriptors.add(updatePolicyMethodDescriptor);
methodDescriptors.add(deletePolicyMethodDescriptor);
+ methodDescriptors.add(createCustomConstraintMethodDescriptor);
+ methodDescriptors.add(updateCustomConstraintMethodDescriptor);
+ methodDescriptors.add(getCustomConstraintMethodDescriptor);
+ methodDescriptors.add(listCustomConstraintsMethodDescriptor);
+ methodDescriptors.add(deleteCustomConstraintMethodDescriptor);
return methodDescriptors;
}
@@ -558,6 +859,40 @@ public UnaryCallable deletePolicyCallable() {
return deletePolicyCallable;
}
+ @Override
+ public UnaryCallable
+ createCustomConstraintCallable() {
+ return createCustomConstraintCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ updateCustomConstraintCallable() {
+ return updateCustomConstraintCallable;
+ }
+
+ @Override
+ public UnaryCallable getCustomConstraintCallable() {
+ return getCustomConstraintCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listCustomConstraintsCallable() {
+ return listCustomConstraintsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listCustomConstraintsPagedCallable() {
+ return listCustomConstraintsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteCustomConstraintCallable() {
+ return deleteCustomConstraintCallable;
+ }
+
@Override
public final void close() {
try {
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java
index 87f2a6de2485..eada2c3ce902 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java
@@ -17,19 +17,27 @@
package com.google.cloud.orgpolicy.v2.stub;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.CreatePolicyRequest;
+import com.google.cloud.orgpolicy.v2.CustomConstraint;
+import com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.DeletePolicyRequest;
+import com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest;
import com.google.cloud.orgpolicy.v2.GetPolicyRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsResponse;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse;
import com.google.cloud.orgpolicy.v2.ListPoliciesRequest;
import com.google.cloud.orgpolicy.v2.ListPoliciesResponse;
import com.google.cloud.orgpolicy.v2.Policy;
+import com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest;
import com.google.protobuf.Empty;
import javax.annotation.Generated;
@@ -80,6 +88,35 @@ public UnaryCallable deletePolicyCallable() {
throw new UnsupportedOperationException("Not implemented: deletePolicyCallable()");
}
+ public UnaryCallable
+ createCustomConstraintCallable() {
+ throw new UnsupportedOperationException("Not implemented: createCustomConstraintCallable()");
+ }
+
+ public UnaryCallable
+ updateCustomConstraintCallable() {
+ throw new UnsupportedOperationException("Not implemented: updateCustomConstraintCallable()");
+ }
+
+ public UnaryCallable getCustomConstraintCallable() {
+ throw new UnsupportedOperationException("Not implemented: getCustomConstraintCallable()");
+ }
+
+ public UnaryCallable
+ listCustomConstraintsPagedCallable() {
+ throw new UnsupportedOperationException(
+ "Not implemented: listCustomConstraintsPagedCallable()");
+ }
+
+ public UnaryCallable
+ listCustomConstraintsCallable() {
+ throw new UnsupportedOperationException("Not implemented: listCustomConstraintsCallable()");
+ }
+
+ public UnaryCallable deleteCustomConstraintCallable() {
+ throw new UnsupportedOperationException("Not implemented: deleteCustomConstraintCallable()");
+ }
+
@Override
public abstract void close();
}
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java
index f517b5f631cc..c8312ff6892b 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java
@@ -17,6 +17,7 @@
package com.google.cloud.orgpolicy.v2.stub;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.core.ApiFunction;
@@ -45,15 +46,22 @@
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.orgpolicy.v2.Constraint;
+import com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.CreatePolicyRequest;
+import com.google.cloud.orgpolicy.v2.CustomConstraint;
+import com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.DeletePolicyRequest;
+import com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest;
import com.google.cloud.orgpolicy.v2.GetPolicyRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsRequest;
import com.google.cloud.orgpolicy.v2.ListConstraintsResponse;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest;
+import com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse;
import com.google.cloud.orgpolicy.v2.ListPoliciesRequest;
import com.google.cloud.orgpolicy.v2.ListPoliciesResponse;
import com.google.cloud.orgpolicy.v2.Policy;
+import com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest;
import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -118,6 +126,19 @@ public class OrgPolicyStubSettings extends StubSettings {
private final UnaryCallSettings createPolicySettings;
private final UnaryCallSettings updatePolicySettings;
private final UnaryCallSettings deletePolicySettings;
+ private final UnaryCallSettings
+ createCustomConstraintSettings;
+ private final UnaryCallSettings
+ updateCustomConstraintSettings;
+ private final UnaryCallSettings
+ getCustomConstraintSettings;
+ private final PagedCallSettings<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ listCustomConstraintsSettings;
+ private final UnaryCallSettings
+ deleteCustomConstraintSettings;
private static final PagedListDescriptor<
ListConstraintsRequest, ListConstraintsResponse, Constraint>
@@ -194,6 +215,47 @@ public Iterable extractResources(ListPoliciesResponse payload) {
}
};
+ private static final PagedListDescriptor<
+ ListCustomConstraintsRequest, ListCustomConstraintsResponse, CustomConstraint>
+ LIST_CUSTOM_CONSTRAINTS_PAGE_STR_DESC =
+ new PagedListDescriptor<
+ ListCustomConstraintsRequest, ListCustomConstraintsResponse, CustomConstraint>() {
+ @Override
+ public String emptyToken() {
+ return "";
+ }
+
+ @Override
+ public ListCustomConstraintsRequest injectToken(
+ ListCustomConstraintsRequest payload, String token) {
+ return ListCustomConstraintsRequest.newBuilder(payload).setPageToken(token).build();
+ }
+
+ @Override
+ public ListCustomConstraintsRequest injectPageSize(
+ ListCustomConstraintsRequest payload, int pageSize) {
+ return ListCustomConstraintsRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListCustomConstraintsRequest payload) {
+ return payload.getPageSize();
+ }
+
+ @Override
+ public String extractNextToken(ListCustomConstraintsResponse payload) {
+ return payload.getNextPageToken();
+ }
+
+ @Override
+ public Iterable extractResources(
+ ListCustomConstraintsResponse payload) {
+ return payload.getCustomConstraintsList() == null
+ ? ImmutableList.of()
+ : payload.getCustomConstraintsList();
+ }
+ };
+
private static final PagedListResponseFactory<
ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse>
LIST_CONSTRAINTS_PAGE_STR_FACT =
@@ -228,6 +290,30 @@ public ApiFuture getFuturePagedResponse(
}
};
+ private static final PagedListResponseFactory<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ LIST_CUSTOM_CONSTRAINTS_PAGE_STR_FACT =
+ new PagedListResponseFactory<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>() {
+ @Override
+ public ApiFuture getFuturePagedResponse(
+ UnaryCallable callable,
+ ListCustomConstraintsRequest request,
+ ApiCallContext context,
+ ApiFuture futureResponse) {
+ PageContext<
+ ListCustomConstraintsRequest, ListCustomConstraintsResponse, CustomConstraint>
+ pageContext =
+ PageContext.create(
+ callable, LIST_CUSTOM_CONSTRAINTS_PAGE_STR_DESC, request, context);
+ return ListCustomConstraintsPagedResponse.createAsync(pageContext, futureResponse);
+ }
+ };
+
/** Returns the object with the settings used for calls to listConstraints. */
public PagedCallSettings<
ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse>
@@ -266,6 +352,38 @@ public UnaryCallSettings deletePolicySettings() {
return deletePolicySettings;
}
+ /** Returns the object with the settings used for calls to createCustomConstraint. */
+ public UnaryCallSettings
+ createCustomConstraintSettings() {
+ return createCustomConstraintSettings;
+ }
+
+ /** Returns the object with the settings used for calls to updateCustomConstraint. */
+ public UnaryCallSettings
+ updateCustomConstraintSettings() {
+ return updateCustomConstraintSettings;
+ }
+
+ /** Returns the object with the settings used for calls to getCustomConstraint. */
+ public UnaryCallSettings
+ getCustomConstraintSettings() {
+ return getCustomConstraintSettings;
+ }
+
+ /** Returns the object with the settings used for calls to listCustomConstraints. */
+ public PagedCallSettings<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ listCustomConstraintsSettings() {
+ return listCustomConstraintsSettings;
+ }
+
+ /** Returns the object with the settings used for calls to deleteCustomConstraint. */
+ public UnaryCallSettings deleteCustomConstraintSettings() {
+ return deleteCustomConstraintSettings;
+ }
+
public OrgPolicyStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
@@ -377,6 +495,11 @@ protected OrgPolicyStubSettings(Builder settingsBuilder) throws IOException {
createPolicySettings = settingsBuilder.createPolicySettings().build();
updatePolicySettings = settingsBuilder.updatePolicySettings().build();
deletePolicySettings = settingsBuilder.deletePolicySettings().build();
+ createCustomConstraintSettings = settingsBuilder.createCustomConstraintSettings().build();
+ updateCustomConstraintSettings = settingsBuilder.updateCustomConstraintSettings().build();
+ getCustomConstraintSettings = settingsBuilder.getCustomConstraintSettings().build();
+ listCustomConstraintsSettings = settingsBuilder.listCustomConstraintsSettings().build();
+ deleteCustomConstraintSettings = settingsBuilder.deleteCustomConstraintSettings().build();
}
/** Builder for OrgPolicyStubSettings. */
@@ -394,6 +517,19 @@ public static class Builder extends StubSettings.Builder createPolicySettings;
private final UnaryCallSettings.Builder updatePolicySettings;
private final UnaryCallSettings.Builder deletePolicySettings;
+ private final UnaryCallSettings.Builder
+ createCustomConstraintSettings;
+ private final UnaryCallSettings.Builder
+ updateCustomConstraintSettings;
+ private final UnaryCallSettings.Builder
+ getCustomConstraintSettings;
+ private final PagedCallSettings.Builder<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ listCustomConstraintsSettings;
+ private final UnaryCallSettings.Builder
+ deleteCustomConstraintSettings;
private static final ImmutableMap>
RETRYABLE_CODE_DEFINITIONS;
@@ -441,6 +577,12 @@ protected Builder(ClientContext clientContext) {
createPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
updatePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
deletePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createCustomConstraintSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ updateCustomConstraintSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ getCustomConstraintSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ listCustomConstraintsSettings =
+ PagedCallSettings.newBuilder(LIST_CUSTOM_CONSTRAINTS_PAGE_STR_FACT);
+ deleteCustomConstraintSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
unaryMethodSettingsBuilders =
ImmutableList.>of(
@@ -450,7 +592,12 @@ protected Builder(ClientContext clientContext) {
getEffectivePolicySettings,
createPolicySettings,
updatePolicySettings,
- deletePolicySettings);
+ deletePolicySettings,
+ createCustomConstraintSettings,
+ updateCustomConstraintSettings,
+ getCustomConstraintSettings,
+ listCustomConstraintsSettings,
+ deleteCustomConstraintSettings);
initDefaults(this);
}
@@ -464,6 +611,11 @@ protected Builder(OrgPolicyStubSettings settings) {
createPolicySettings = settings.createPolicySettings.toBuilder();
updatePolicySettings = settings.updatePolicySettings.toBuilder();
deletePolicySettings = settings.deletePolicySettings.toBuilder();
+ createCustomConstraintSettings = settings.createCustomConstraintSettings.toBuilder();
+ updateCustomConstraintSettings = settings.updateCustomConstraintSettings.toBuilder();
+ getCustomConstraintSettings = settings.getCustomConstraintSettings.toBuilder();
+ listCustomConstraintsSettings = settings.listCustomConstraintsSettings.toBuilder();
+ deleteCustomConstraintSettings = settings.deleteCustomConstraintSettings.toBuilder();
unaryMethodSettingsBuilders =
ImmutableList.>of(
@@ -473,7 +625,12 @@ protected Builder(OrgPolicyStubSettings settings) {
getEffectivePolicySettings,
createPolicySettings,
updatePolicySettings,
- deletePolicySettings);
+ deletePolicySettings,
+ createCustomConstraintSettings,
+ updateCustomConstraintSettings,
+ getCustomConstraintSettings,
+ listCustomConstraintsSettings,
+ deleteCustomConstraintSettings);
}
private static Builder createDefault() {
@@ -538,6 +695,31 @@ private static Builder initDefaults(Builder builder) {
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+ builder
+ .createCustomConstraintSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .updateCustomConstraintSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .getCustomConstraintSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .listCustomConstraintsSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .deleteCustomConstraintSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
return builder;
}
@@ -596,6 +778,39 @@ public UnaryCallSettings.Builder deletePolicySetting
return deletePolicySettings;
}
+ /** Returns the builder for the settings used for calls to createCustomConstraint. */
+ public UnaryCallSettings.Builder
+ createCustomConstraintSettings() {
+ return createCustomConstraintSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to updateCustomConstraint. */
+ public UnaryCallSettings.Builder
+ updateCustomConstraintSettings() {
+ return updateCustomConstraintSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to getCustomConstraint. */
+ public UnaryCallSettings.Builder
+ getCustomConstraintSettings() {
+ return getCustomConstraintSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to listCustomConstraints. */
+ public PagedCallSettings.Builder<
+ ListCustomConstraintsRequest,
+ ListCustomConstraintsResponse,
+ ListCustomConstraintsPagedResponse>
+ listCustomConstraintsSettings() {
+ return listCustomConstraintsSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deleteCustomConstraint. */
+ public UnaryCallSettings.Builder
+ deleteCustomConstraintSettings() {
+ return deleteCustomConstraintSettings;
+ }
+
@Override
public OrgPolicyStubSettings build() throws IOException {
return new OrgPolicyStubSettings(this);
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/main/resources/META-INF/native-image/com.google.cloud.orgpolicy.v2/reflect-config.json b/java-orgpolicy/google-cloud-orgpolicy/src/main/resources/META-INF/native-image/com.google.cloud.orgpolicy.v2/reflect-config.json
index d78c12b3c0fa..362f63e74d0a 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/main/resources/META-INF/native-image/com.google.cloud.orgpolicy.v2/reflect-config.json
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/main/resources/META-INF/native-image/com.google.cloud.orgpolicy.v2/reflect-config.json
@@ -458,6 +458,24 @@
"allDeclaredClasses": true,
"allPublicClasses": true
},
+ {
+ "name": "com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.CreateCustomConstraintRequest$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
{
"name": "com.google.cloud.orgpolicy.v2.CreatePolicyRequest",
"queryAllDeclaredConstructors": true,
@@ -476,6 +494,60 @@
"allDeclaredClasses": true,
"allPublicClasses": true
},
+ {
+ "name": "com.google.cloud.orgpolicy.v2.CustomConstraint",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.CustomConstraint$ActionType",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.CustomConstraint$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.CustomConstraint$MethodType",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.DeleteCustomConstraintRequest$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
{
"name": "com.google.cloud.orgpolicy.v2.DeletePolicyRequest",
"queryAllDeclaredConstructors": true,
@@ -494,6 +566,24 @@
"allDeclaredClasses": true,
"allPublicClasses": true
},
+ {
+ "name": "com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.GetCustomConstraintRequest$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
{
"name": "com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest",
"queryAllDeclaredConstructors": true,
@@ -566,6 +656,42 @@
"allDeclaredClasses": true,
"allPublicClasses": true
},
+ {
+ "name": "com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.ListCustomConstraintsRequest$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.ListCustomConstraintsResponse$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
{
"name": "com.google.cloud.orgpolicy.v2.ListPoliciesRequest",
"queryAllDeclaredConstructors": true,
@@ -674,6 +800,24 @@
"allDeclaredClasses": true,
"allPublicClasses": true
},
+ {
+ "name": "com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
+ {
+ "name": "com.google.cloud.orgpolicy.v2.UpdateCustomConstraintRequest$Builder",
+ "queryAllDeclaredConstructors": true,
+ "queryAllPublicConstructors": true,
+ "queryAllDeclaredMethods": true,
+ "allPublicMethods": true,
+ "allDeclaredClasses": true,
+ "allPublicClasses": true
+ },
{
"name": "com.google.cloud.orgpolicy.v2.UpdatePolicyRequest",
"queryAllDeclaredConstructors": true,
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java b/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java
index 4e59f51be1d2..0155f6d87595 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java
@@ -201,4 +201,110 @@ public void deletePolicy(DeletePolicyRequest request, StreamObserver resp
Exception.class.getName())));
}
}
+
+ @Override
+ public void createCustomConstraint(
+ CreateCustomConstraintRequest request, StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof CustomConstraint) {
+ requests.add(request);
+ responseObserver.onNext(((CustomConstraint) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method CreateCustomConstraint, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ CustomConstraint.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
+ @Override
+ public void updateCustomConstraint(
+ UpdateCustomConstraintRequest request, StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof CustomConstraint) {
+ requests.add(request);
+ responseObserver.onNext(((CustomConstraint) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method UpdateCustomConstraint, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ CustomConstraint.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
+ @Override
+ public void getCustomConstraint(
+ GetCustomConstraintRequest request, StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof CustomConstraint) {
+ requests.add(request);
+ responseObserver.onNext(((CustomConstraint) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method GetCustomConstraint, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ CustomConstraint.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
+ @Override
+ public void listCustomConstraints(
+ ListCustomConstraintsRequest request,
+ StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof ListCustomConstraintsResponse) {
+ requests.add(request);
+ responseObserver.onNext(((ListCustomConstraintsResponse) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method ListCustomConstraints, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ ListCustomConstraintsResponse.class.getName(),
+ Exception.class.getName())));
+ }
+ }
+
+ @Override
+ public void deleteCustomConstraint(
+ DeleteCustomConstraintRequest request, StreamObserver responseObserver) {
+ Object response = responses.poll();
+ if (response instanceof Empty) {
+ requests.add(request);
+ responseObserver.onNext(((Empty) response));
+ responseObserver.onCompleted();
+ } else if (response instanceof Exception) {
+ responseObserver.onError(((Exception) response));
+ } else {
+ responseObserver.onError(
+ new IllegalArgumentException(
+ String.format(
+ "Unrecognized response type %s for method DeleteCustomConstraint, expected %s or %s",
+ response == null ? "null" : response.getClass().getName(),
+ Empty.class.getName(),
+ Exception.class.getName())));
+ }
+ }
}
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientHttpJsonTest.java b/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientHttpJsonTest.java
index d48802394133..069bd609ff1b 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientHttpJsonTest.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientHttpJsonTest.java
@@ -17,6 +17,7 @@
package com.google.cloud.orgpolicy.v2;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.gax.core.NoCredentialsProvider;
@@ -31,7 +32,9 @@
import com.google.cloud.orgpolicy.v2.stub.HttpJsonOrgPolicyStub;
import com.google.common.collect.Lists;
import com.google.protobuf.Empty;
+import com.google.protobuf.Timestamp;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Generated;
@@ -484,6 +487,7 @@ public void getPolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -531,6 +535,7 @@ public void getPolicyTest2() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -578,6 +583,7 @@ public void getEffectivePolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -625,6 +631,7 @@ public void getEffectivePolicyTest2() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -672,6 +679,7 @@ public void createPolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -721,6 +729,7 @@ public void createPolicyTest2() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -770,6 +779,7 @@ public void createPolicyTest3() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -819,6 +829,7 @@ public void createPolicyTest4() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -868,6 +879,7 @@ public void updatePolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockService.addResponse(expectedResponse);
@@ -877,6 +889,7 @@ public void updatePolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
Policy actualResponse = client.updatePolicy(policy);
@@ -911,6 +924,7 @@ public void updatePolicyExceptionTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
client.updatePolicy(policy);
Assert.fail("No exception raised");
@@ -998,4 +1012,456 @@ public void deletePolicyExceptionTest2() throws Exception {
// Expected exception.
}
}
+
+ @Test
+ public void createCustomConstraintTest() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+
+ CustomConstraint actualResponse = client.createCustomConstraint(parent, customConstraint);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void createCustomConstraintExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ client.createCustomConstraint(parent, customConstraint);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createCustomConstraintTest2() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "organizations/organization-8287";
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+
+ CustomConstraint actualResponse = client.createCustomConstraint(parent, customConstraint);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void createCustomConstraintExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "organizations/organization-8287";
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ client.createCustomConstraint(parent, customConstraint);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void updateCustomConstraintTest() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ CustomConstraint customConstraint =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+
+ CustomConstraint actualResponse = client.updateCustomConstraint(customConstraint);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void updateCustomConstraintExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ CustomConstraint customConstraint =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ client.updateCustomConstraint(customConstraint);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getCustomConstraintTest() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
+
+ CustomConstraint actualResponse = client.getCustomConstraint(name);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void getCustomConstraintExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
+ client.getCustomConstraint(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getCustomConstraintTest2() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "organizations/organization-7217/customConstraints/customConstraint-7217";
+
+ CustomConstraint actualResponse = client.getCustomConstraint(name);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void getCustomConstraintExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name = "organizations/organization-7217/customConstraints/customConstraint-7217";
+ client.getCustomConstraint(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listCustomConstraintsTest() throws Exception {
+ CustomConstraint responsesElement = CustomConstraint.newBuilder().build();
+ ListCustomConstraintsResponse expectedResponse =
+ ListCustomConstraintsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllCustomConstraints(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+
+ ListCustomConstraintsPagedResponse pagedListResponse = client.listCustomConstraints(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getCustomConstraintsList().get(0), resources.get(0));
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void listCustomConstraintsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ client.listCustomConstraints(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listCustomConstraintsTest2() throws Exception {
+ CustomConstraint responsesElement = CustomConstraint.newBuilder().build();
+ ListCustomConstraintsResponse expectedResponse =
+ ListCustomConstraintsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllCustomConstraints(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "organizations/organization-8287";
+
+ ListCustomConstraintsPagedResponse pagedListResponse = client.listCustomConstraints(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getCustomConstraintsList().get(0), resources.get(0));
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void listCustomConstraintsExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "organizations/organization-8287";
+ client.listCustomConstraints(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteCustomConstraintTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
+
+ client.deleteCustomConstraint(name);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void deleteCustomConstraintExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ CustomConstraintName name = CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]");
+ client.deleteCustomConstraint(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteCustomConstraintTest2() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "organizations/organization-7217/customConstraints/customConstraint-7217";
+
+ client.deleteCustomConstraint(name);
+
+ List actualRequests = mockService.getRequestPaths();
+ Assert.assertEquals(1, actualRequests.size());
+
+ String apiClientHeaderKey =
+ mockService
+ .getRequestHeaders()
+ .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey())
+ .iterator()
+ .next();
+ Assert.assertTrue(
+ GaxHttpJsonProperties.getDefaultApiClientHeaderPattern()
+ .matcher(apiClientHeaderKey)
+ .matches());
+ }
+
+ @Test
+ public void deleteCustomConstraintExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name = "organizations/organization-7217/customConstraints/customConstraint-7217";
+ client.deleteCustomConstraint(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
}
diff --git a/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java b/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java
index 299df8e58c87..cdf608764ee9 100644
--- a/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java
+++ b/java-orgpolicy/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java
@@ -17,6 +17,7 @@
package com.google.cloud.orgpolicy.v2;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse;
+import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListCustomConstraintsPagedResponse;
import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse;
import com.google.api.gax.core.NoCredentialsProvider;
@@ -29,8 +30,10 @@
import com.google.common.collect.Lists;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.Empty;
+import com.google.protobuf.Timestamp;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@@ -440,6 +443,7 @@ public void getPolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -481,6 +485,7 @@ public void getPolicyTest2() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -522,6 +527,7 @@ public void getEffectivePolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -563,6 +569,7 @@ public void getEffectivePolicyTest2() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -604,6 +611,7 @@ public void createPolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -648,6 +656,7 @@ public void createPolicyTest2() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -692,6 +701,7 @@ public void createPolicyTest3() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -736,6 +746,7 @@ public void createPolicyTest4() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -780,6 +791,7 @@ public void updatePolicyTest() throws Exception {
.setSpec(PolicySpec.newBuilder().build())
.setAlternate(AlternatePolicySpec.newBuilder().build())
.setDryRunSpec(PolicySpec.newBuilder().build())
+ .setEtag("etag3123477")
.build();
mockOrgPolicy.addResponse(expectedResponse);
@@ -880,4 +892,393 @@ public void deletePolicyExceptionTest2() throws Exception {
// Expected exception.
}
}
+
+ @Test
+ public void createCustomConstraintTest() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockOrgPolicy.addResponse(expectedResponse);
+
+ OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+
+ CustomConstraint actualResponse = client.createCustomConstraint(parent, customConstraint);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockOrgPolicy.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateCustomConstraintRequest actualRequest =
+ ((CreateCustomConstraintRequest) actualRequests.get(0));
+
+ Assert.assertEquals(parent.toString(), actualRequest.getParent());
+ Assert.assertEquals(customConstraint, actualRequest.getCustomConstraint());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void createCustomConstraintExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockOrgPolicy.addException(exception);
+
+ try {
+ OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ client.createCustomConstraint(parent, customConstraint);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createCustomConstraintTest2() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockOrgPolicy.addResponse(expectedResponse);
+
+ String parent = "parent-995424086";
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+
+ CustomConstraint actualResponse = client.createCustomConstraint(parent, customConstraint);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockOrgPolicy.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ CreateCustomConstraintRequest actualRequest =
+ ((CreateCustomConstraintRequest) actualRequests.get(0));
+
+ Assert.assertEquals(parent, actualRequest.getParent());
+ Assert.assertEquals(customConstraint, actualRequest.getCustomConstraint());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void createCustomConstraintExceptionTest2() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockOrgPolicy.addException(exception);
+
+ try {
+ String parent = "parent-995424086";
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ client.createCustomConstraint(parent, customConstraint);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void updateCustomConstraintTest() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList())
+ .addAllMethodTypes(new ArrayList())
+ .setCondition("condition-861311717")
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .build();
+ mockOrgPolicy.addResponse(expectedResponse);
+
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+
+ CustomConstraint actualResponse = client.updateCustomConstraint(customConstraint);
+ Assert.assertEquals(expectedResponse, actualResponse);
+
+ List actualRequests = mockOrgPolicy.getRequests();
+ Assert.assertEquals(1, actualRequests.size());
+ UpdateCustomConstraintRequest actualRequest =
+ ((UpdateCustomConstraintRequest) actualRequests.get(0));
+
+ Assert.assertEquals(customConstraint, actualRequest.getCustomConstraint());
+ Assert.assertTrue(
+ channelProvider.isHeaderSent(
+ ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
+ GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
+ }
+
+ @Test
+ public void updateCustomConstraintExceptionTest() throws Exception {
+ StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
+ mockOrgPolicy.addException(exception);
+
+ try {
+ CustomConstraint customConstraint = CustomConstraint.newBuilder().build();
+ client.updateCustomConstraint(customConstraint);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getCustomConstraintTest() throws Exception {
+ CustomConstraint expectedResponse =
+ CustomConstraint.newBuilder()
+ .setName(CustomConstraintName.of("[ORGANIZATION]", "[CUSTOM_CONSTRAINT]").toString())
+ .addAllResourceTypes(new ArrayList