diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml
index 10714b13..b7d331d4 100644
--- a/.github/.OwlBot.yaml
+++ b/.github/.OwlBot.yaml
@@ -31,5 +31,7 @@ deep-copy-regex:
dest: "/owl-bot-staging/v1/proto-google-iam-v1/src"
- source: "/google/iam/v2beta/google-cloud-iam-v2beta-java/grpc-google-cloud-iam-v2beta-java/src"
dest: "/owl-bot-staging/v2beta/grpc-google-iam-v2beta/src"
-- source: "google/iam/v2beta/google-cloud-iam-v2beta-java/proto-google-cloud-iam-v2beta-java/src"
+- source: "/google/iam/v2beta/google-cloud-iam-v2beta-java/proto-google-cloud-iam-v2beta-java/src"
dest: "/owl-bot-staging/v2beta/proto-google-iam-v2beta/src"
+- source: "/google/iam/v2beta/google-cloud-iam-v2beta-java/gapic-google-cloud-iam-v2beta-java/src"
+ dest: "/owl-bot-staging/v2beta/google-iam-policy/src"
\ No newline at end of file
diff --git a/.repo-metadata.json b/.repo-metadata.json
index bb9e05ae..c8064171 100644
--- a/.repo-metadata.json
+++ b/.repo-metadata.json
@@ -12,6 +12,6 @@
"repo_short": "java-iam",
"library_type": "OTHER",
"distribution_name": "com.google.api.grpc:proto-google-iam-v1",
- "excluded_poms": "proto-google-iam-v1-bom",
+ "excluded_poms": "proto-google-iam-v1-bom,google-iam-policy,proto-google-iam-v1",
"excluded_dependencies": "grpc-google-iam-v1"
}
diff --git a/google-iam-policy/pom.xml b/google-iam-policy/pom.xml
new file mode 100644
index 00000000..bae1eb08
--- /dev/null
+++ b/google-iam-policy/pom.xml
@@ -0,0 +1,111 @@
+
+
+ 4.0.0
+ com.google.cloud
+ google-iam-policy
+ 1.4.2-SNAPSHOT
+ jar
+ Google IAM Policy
+ https://github.com/googleapis/java-eventarc
+ Eventarc lets you asynchronously deliver events from Google services, SaaS, and your own apps using loosely coupled services that react to state changes.
+
+ com.google.cloud
+ google-iam-parent
+ 1.4.2-SNAPSHOT
+
+
+ google-iam-policy
+
+
+
+ io.grpc
+ grpc-api
+
+
+ io.grpc
+ grpc-stub
+
+
+ io.grpc
+ grpc-protobuf
+
+
+ com.google.api
+ api-common
+
+
+ com.google.protobuf
+ protobuf-java
+
+
+ com.google.api.grpc
+ proto-google-common-protos
+
+
+
+ com.google.api.grpc
+ proto-google-iam-v2beta
+
+
+ com.google.guava
+ guava
+
+
+ com.google.api
+ gax
+
+
+ com.google.api
+ gax-grpc
+
+
+ org.threeten
+ threetenbp
+
+
+
+
+ junit
+ junit
+ test
+ 4.13.2
+
+
+
+ com.google.api.grpc
+ grpc-google-iam-v2beta
+ test
+
+
+
+ com.google.api
+ gax-grpc
+ testlib
+ test
+
+
+
+
+
+ java9
+
+ [9,)
+
+
+
+ javax.annotation
+ javax.annotation-api
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ flatten-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java
new file mode 100644
index 00000000..582c71e4
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java
@@ -0,0 +1,865 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta;
+
+import com.google.api.core.ApiFuture;
+import com.google.api.core.ApiFutures;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.longrunning.OperationFuture;
+import com.google.api.gax.paging.AbstractFixedSizeCollection;
+import com.google.api.gax.paging.AbstractPage;
+import com.google.api.gax.paging.AbstractPagedListResponse;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.iam.v2beta.stub.PoliciesStub;
+import com.google.iam.v2beta.stub.PoliciesStubSettings;
+import com.google.longrunning.Operation;
+import com.google.longrunning.OperationsClient;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Service Description: An interface for managing Identity and Access Management (IAM) policies.
+ *
+ *
This class provides the ability to make remote calls to the backing service through method
+ * calls that map to API methods. Sample code to get started:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * PolicyName name = PolicyName.of("[POLICY]");
+ * Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ *
+ *
Note: close() needs to be called on the PoliciesClient object to clean up resources such as
+ * threads. In the example above, try-with-resources is used, which automatically calls close().
+ *
+ *
The surface of this class includes several types of Java methods for each of the API's
+ * methods:
+ *
+ *
+ *
A "flattened" method. With this type of method, the fields of the request type have been
+ * converted into function parameters. It may be the case that not all fields are available as
+ * parameters, and not every API method will have a flattened method entry point.
+ *
A "request object" method. This type of method only takes one parameter, a request object,
+ * which must be constructed before the call. Not every API method will have a request object
+ * method.
+ *
A "callable" method. This type of method takes no parameters and returns an immutable API
+ * callable object, which can be used to initiate calls to the service.
+ *
+ *
+ *
See the individual methods for example code.
+ *
+ *
Many parameters require resource names to be formatted in a particular way. To assist with
+ * these names, this class includes a format method for each type of name, and additionally a parse
+ * method to extract the individual identifiers contained within names that are returned.
+ *
+ *
This class can be customized by passing in a custom instance of PoliciesSettings to create().
+ * For example:
+ *
+ *
To customize credentials:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PoliciesSettings policiesSettings =
+ * PoliciesSettings.newBuilder()
+ * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ * .build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ *
+ *
To customize the endpoint:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PoliciesSettings policiesSettings =
+ * PoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ *
+ *
Please refer to the GitHub repository's samples for more quickstart code snippets.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class PoliciesClient implements BackgroundResource {
+ private final PoliciesSettings settings;
+ private final PoliciesStub stub;
+ private final OperationsClient operationsClient;
+
+ /** Constructs an instance of PoliciesClient with default settings. */
+ public static final PoliciesClient create() throws IOException {
+ return create(PoliciesSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of PoliciesClient, using the given settings. The channels are created
+ * based on the settings passed in, or defaults for any settings that are not set.
+ */
+ public static final PoliciesClient create(PoliciesSettings settings) throws IOException {
+ return new PoliciesClient(settings);
+ }
+
+ /**
+ * Constructs an instance of PoliciesClient, using the given stub for making calls. This is for
+ * advanced usage - prefer using create(PoliciesSettings).
+ */
+ public static final PoliciesClient create(PoliciesStub stub) {
+ return new PoliciesClient(stub);
+ }
+
+ /**
+ * Constructs an instance of PoliciesClient, using the given settings. This is protected so that
+ * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
+ */
+ protected PoliciesClient(PoliciesSettings settings) throws IOException {
+ this.settings = settings;
+ this.stub = ((PoliciesStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ protected PoliciesClient(PoliciesStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ }
+
+ public final PoliciesSettings getSettings() {
+ return settings;
+ }
+
+ public PoliciesStub getStub() {
+ return stub;
+ }
+
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ public final OperationsClient getOperationsClient() {
+ return operationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves the policies of the specified kind that are attached to a resource.
+ *
+ *
The response lists only policy metadata. In particular, policy rules are omitted.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String parent = "parent-995424086";
+ * for (Policy element : policiesClient.listPolicies(parent).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param parent Required. The resource that the policy is attached to, along with the kind of
+ * policy to list. Format: `policies/{attachment_point}/denypolicies`
+ *
The attachment point is identified by its URL-encoded full resource name, which means
+ * that the forward-slash character, `/`, must be written as `%2F`. For example,
+ * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
+ *
For organizations and folders, use the numeric ID in the full resource name. For
+ * projects, you can use the alphanumeric or the numeric ID.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListPoliciesPagedResponse listPolicies(String parent) {
+ ListPoliciesRequest request = ListPoliciesRequest.newBuilder().setParent(parent).build();
+ return listPolicies(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves the policies of the specified kind that are attached to a resource.
+ *
+ *
The response lists only policy metadata. In particular, policy rules are omitted.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * ListPoliciesRequest request =
+ * ListPoliciesRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * for (Policy element : policiesClient.listPolicies(request).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request) {
+ return listPoliciesPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves the policies of the specified kind that are attached to a resource.
+ *
+ *
The response lists only policy metadata. In particular, policy rules are omitted.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * ListPoliciesRequest request =
+ * ListPoliciesRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * ApiFuture future = policiesClient.listPoliciesPagedCallable().futureCall(request);
+ * // Do something.
+ * for (Policy element : future.get().iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable
+ listPoliciesPagedCallable() {
+ return stub.listPoliciesPagedCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves the policies of the specified kind that are attached to a resource.
+ *
+ *
The response lists only policy metadata. In particular, policy rules are omitted.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * ListPoliciesRequest request =
+ * ListPoliciesRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * while (true) {
+ * ListPoliciesResponse response = policiesClient.listPoliciesCallable().call(request);
+ * for (Policy element : response.getPoliciesList()) {
+ * // doThingsWith(element);
+ * }
+ * String nextPageToken = response.getNextPageToken();
+ * if (!Strings.isNullOrEmpty(nextPageToken)) {
+ * request = request.toBuilder().setPageToken(nextPageToken).build();
+ * } else {
+ * break;
+ * }
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable listPoliciesCallable() {
+ return stub.listPoliciesCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * PolicyName name = PolicyName.of("[POLICY]");
+ * Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ *
+ * @param name Required. The resource name of the policy to retrieve. Format:
+ * `policies/{attachment_point}/denypolicies/{policy_id}`
+ *
Use the URL-encoded full resource name, which means that the forward-slash character,
+ * `/`, must be written as `%2F`. For example,
+ * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
+ *
For organizations and folders, use the numeric ID in the full resource name. For
+ * projects, you can use the alphanumeric or the numeric ID.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Policy getPolicy(PolicyName name) {
+ GetPolicyRequest request =
+ GetPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
+ return getPolicy(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String name = PolicyName.of("[POLICY]").toString();
+ * Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ *
+ * @param name Required. The resource name of the policy to retrieve. Format:
+ * `policies/{attachment_point}/denypolicies/{policy_id}`
+ *
Use the URL-encoded full resource name, which means that the forward-slash character,
+ * `/`, must be written as `%2F`. For example,
+ * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
+ *
For organizations and folders, use the numeric ID in the full resource name. For
+ * projects, you can use the alphanumeric or the numeric ID.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Policy getPolicy(String name) {
+ GetPolicyRequest request = GetPolicyRequest.newBuilder().setName(name).build();
+ return getPolicy(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * GetPolicyRequest request =
+ * GetPolicyRequest.newBuilder().setName(PolicyName.of("[POLICY]").toString()).build();
+ * Policy response = policiesClient.getPolicy(request);
+ * }
+ * }
+ *
+ * @param request The request object containing all of the parameters for the API call.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Policy getPolicy(GetPolicyRequest request) {
+ return getPolicyCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * GetPolicyRequest request =
+ * GetPolicyRequest.newBuilder().setName(PolicyName.of("[POLICY]").toString()).build();
+ * ApiFuture future = policiesClient.getPolicyCallable().futureCall(request);
+ * // Do something.
+ * Policy response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable getPolicyCallable() {
+ return stub.getPolicyCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String parent = "parent-995424086";
+ * Policy policy = Policy.newBuilder().build();
+ * String policyId = "policyId546908653";
+ * Policy response = policiesClient.createPolicyAsync(parent, policy, policyId).get();
+ * }
+ * }
+ *
+ * @param parent Required. The resource that the policy is attached to, along with the kind of
+ * policy to create. Format: `policies/{attachment_point}/denypolicies`
+ *
The attachment point is identified by its URL-encoded full resource name, which means
+ * that the forward-slash character, `/`, must be written as `%2F`. For example,
+ * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`.
+ *
For organizations and folders, use the numeric ID in the full resource name. For
+ * projects, you can use the alphanumeric or the numeric ID.
+ * @param policy Required. The policy to create.
+ * @param policyId The ID to use for this policy, which will become the final component of the
+ * policy's resource name. The ID must contain 3 to 63 characters. It can contain lowercase
+ * letters and numbers, as well as dashes (`-`) and periods (`.`). The first character must be
+ * a lowercase letter.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture createPolicyAsync(
+ String parent, Policy policy, String policyId) {
+ CreatePolicyRequest request =
+ CreatePolicyRequest.newBuilder()
+ .setParent(parent)
+ .setPolicy(policy)
+ .setPolicyId(policyId)
+ .build();
+ return createPolicyAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * CreatePolicyRequest request =
+ * CreatePolicyRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setPolicy(Policy.newBuilder().build())
+ * .setPolicyId("policyId546908653")
+ * .build();
+ * Policy response = policiesClient.createPolicyAsync(request).get();
+ * }
+ * }
+ *
+ * @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 OperationFuture createPolicyAsync(
+ CreatePolicyRequest request) {
+ return createPolicyOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * CreatePolicyRequest request =
+ * CreatePolicyRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setPolicy(Policy.newBuilder().build())
+ * .setPolicyId("policyId546908653")
+ * .build();
+ * OperationFuture future =
+ * policiesClient.createPolicyOperationCallable().futureCall(request);
+ * // Do something.
+ * Policy response = future.get();
+ * }
+ * }
+ */
+ public final OperationCallable
+ createPolicyOperationCallable() {
+ return stub.createPolicyOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a policy.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * CreatePolicyRequest request =
+ * CreatePolicyRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setPolicy(Policy.newBuilder().build())
+ * .setPolicyId("policyId546908653")
+ * .build();
+ * ApiFuture future = policiesClient.createPolicyCallable().futureCall(request);
+ * // Do something.
+ * Operation response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable createPolicyCallable() {
+ return stub.createPolicyCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Updates the specified policy.
+ *
+ *
You can update only the rules and the display name for the policy.
+ *
+ *
To update a policy, you should use a read-modify-write loop:
+ *
+ *
1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the
+ * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy.
+ *
+ *
This pattern helps prevent conflicts between concurrent updates.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * UpdatePolicyRequest request =
+ * UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+ * Policy response = policiesClient.updatePolicyAsync(request).get();
+ * }
+ * }
+ *
+ * @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 OperationFuture updatePolicyAsync(
+ UpdatePolicyRequest request) {
+ return updatePolicyOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Updates the specified policy.
+ *
+ *
You can update only the rules and the display name for the policy.
+ *
+ *
To update a policy, you should use a read-modify-write loop:
+ *
+ *
1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the
+ * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy.
+ *
+ *
This pattern helps prevent conflicts between concurrent updates.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * UpdatePolicyRequest request =
+ * UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+ * OperationFuture future =
+ * policiesClient.updatePolicyOperationCallable().futureCall(request);
+ * // Do something.
+ * Policy response = future.get();
+ * }
+ * }
+ */
+ public final OperationCallable
+ updatePolicyOperationCallable() {
+ return stub.updatePolicyOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Updates the specified policy.
+ *
+ *
You can update only the rules and the display name for the policy.
+ *
+ *
To update a policy, you should use a read-modify-write loop:
+ *
+ *
1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the
+ * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy.
+ *
+ *
This pattern helps prevent conflicts between concurrent updates.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * UpdatePolicyRequest request =
+ * UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+ * ApiFuture future = policiesClient.updatePolicyCallable().futureCall(request);
+ * // Do something.
+ * Operation response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable updatePolicyCallable() {
+ return stub.updatePolicyCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a policy. This action is permanent.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * PolicyName name = PolicyName.of("[POLICY]");
+ * Policy response = policiesClient.deletePolicyAsync(name).get();
+ * }
+ * }
+ *
+ * @param name Required. The resource name of the policy to delete. Format:
+ * `policies/{attachment_point}/denypolicies/{policy_id}`
+ *
Use the URL-encoded full resource name, which means that the forward-slash character,
+ * `/`, must be written as `%2F`. For example,
+ * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
+ *
For organizations and folders, use the numeric ID in the full resource name. For
+ * projects, you can use the alphanumeric or the numeric ID.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture deletePolicyAsync(PolicyName name) {
+ DeletePolicyRequest request =
+ DeletePolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build();
+ return deletePolicyAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a policy. This action is permanent.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String name = PolicyName.of("[POLICY]").toString();
+ * Policy response = policiesClient.deletePolicyAsync(name).get();
+ * }
+ * }
+ *
+ * @param name Required. The resource name of the policy to delete. Format:
+ * `policies/{attachment_point}/denypolicies/{policy_id}`
+ *
Use the URL-encoded full resource name, which means that the forward-slash character,
+ * `/`, must be written as `%2F`. For example,
+ * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`.
+ *
For organizations and folders, use the numeric ID in the full resource name. For
+ * projects, you can use the alphanumeric or the numeric ID.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture deletePolicyAsync(String name) {
+ DeletePolicyRequest request = DeletePolicyRequest.newBuilder().setName(name).build();
+ return deletePolicyAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a policy. This action is permanent.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * DeletePolicyRequest request =
+ * DeletePolicyRequest.newBuilder()
+ * .setName(PolicyName.of("[POLICY]").toString())
+ * .setEtag("etag3123477")
+ * .build();
+ * Policy response = policiesClient.deletePolicyAsync(request).get();
+ * }
+ * }
+ *
+ * @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 OperationFuture deletePolicyAsync(
+ DeletePolicyRequest request) {
+ return deletePolicyOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a policy. This action is permanent.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * DeletePolicyRequest request =
+ * DeletePolicyRequest.newBuilder()
+ * .setName(PolicyName.of("[POLICY]").toString())
+ * .setEtag("etag3123477")
+ * .build();
+ * OperationFuture future =
+ * policiesClient.deletePolicyOperationCallable().futureCall(request);
+ * // Do something.
+ * Policy response = future.get();
+ * }
+ * }
+ */
+ public final OperationCallable
+ deletePolicyOperationCallable() {
+ return stub.deletePolicyOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Deletes a policy. This action is permanent.
+ *
+ *
Sample code:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * DeletePolicyRequest request =
+ * DeletePolicyRequest.newBuilder()
+ * .setName(PolicyName.of("[POLICY]").toString())
+ * .setEtag("etag3123477")
+ * .build();
+ * ApiFuture future = policiesClient.deletePolicyCallable().futureCall(request);
+ * // Do something.
+ * Operation response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable deletePolicyCallable() {
+ return stub.deletePolicyCallable();
+ }
+
+ @Override
+ public final void close() {
+ stub.close();
+ }
+
+ @Override
+ public void shutdown() {
+ stub.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return stub.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return stub.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ stub.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return stub.awaitTermination(duration, unit);
+ }
+
+ public static class ListPoliciesPagedResponse
+ extends AbstractPagedListResponse<
+ ListPoliciesRequest,
+ ListPoliciesResponse,
+ Policy,
+ ListPoliciesPage,
+ ListPoliciesFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage,
+ input -> new ListPoliciesPagedResponse(input),
+ MoreExecutors.directExecutor());
+ }
+
+ private ListPoliciesPagedResponse(ListPoliciesPage page) {
+ super(page, ListPoliciesFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListPoliciesPage
+ extends AbstractPage {
+
+ private ListPoliciesPage(
+ PageContext context,
+ ListPoliciesResponse response) {
+ super(context, response);
+ }
+
+ private static ListPoliciesPage createEmptyPage() {
+ return new ListPoliciesPage(null, null);
+ }
+
+ @Override
+ protected ListPoliciesPage createPage(
+ PageContext context,
+ ListPoliciesResponse response) {
+ return new ListPoliciesPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListPoliciesFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListPoliciesRequest,
+ ListPoliciesResponse,
+ Policy,
+ ListPoliciesPage,
+ ListPoliciesFixedSizeCollection> {
+
+ private ListPoliciesFixedSizeCollection(List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListPoliciesFixedSizeCollection createEmptyCollection() {
+ return new ListPoliciesFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListPoliciesFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListPoliciesFixedSizeCollection(pages, collectionSize);
+ }
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java
new file mode 100644
index 00000000..82677a3f
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java
@@ -0,0 +1,266 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta;
+
+import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientSettings;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.iam.v2beta.stub.PoliciesStubSettings;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Settings class to configure an instance of {@link PoliciesClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (iam.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of getPolicy to 30 seconds:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PoliciesSettings.Builder policiesSettingsBuilder = PoliciesSettings.newBuilder();
+ * policiesSettingsBuilder
+ * .getPolicySettings()
+ * .setRetrySettings(
+ * policiesSettingsBuilder
+ * .getPolicySettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * PoliciesSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class PoliciesSettings extends ClientSettings {
+
+ /** Returns the object with the settings used for calls to listPolicies. */
+ public PagedCallSettings
+ listPoliciesSettings() {
+ return ((PoliciesStubSettings) getStubSettings()).listPoliciesSettings();
+ }
+
+ /** Returns the object with the settings used for calls to getPolicy. */
+ public UnaryCallSettings getPolicySettings() {
+ return ((PoliciesStubSettings) getStubSettings()).getPolicySettings();
+ }
+
+ /** Returns the object with the settings used for calls to createPolicy. */
+ public UnaryCallSettings createPolicySettings() {
+ return ((PoliciesStubSettings) getStubSettings()).createPolicySettings();
+ }
+
+ /** Returns the object with the settings used for calls to createPolicy. */
+ public OperationCallSettings
+ createPolicyOperationSettings() {
+ return ((PoliciesStubSettings) getStubSettings()).createPolicyOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to updatePolicy. */
+ public UnaryCallSettings updatePolicySettings() {
+ return ((PoliciesStubSettings) getStubSettings()).updatePolicySettings();
+ }
+
+ /** Returns the object with the settings used for calls to updatePolicy. */
+ public OperationCallSettings
+ updatePolicyOperationSettings() {
+ return ((PoliciesStubSettings) getStubSettings()).updatePolicyOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to deletePolicy. */
+ public UnaryCallSettings deletePolicySettings() {
+ return ((PoliciesStubSettings) getStubSettings()).deletePolicySettings();
+ }
+
+ /** Returns the object with the settings used for calls to deletePolicy. */
+ public OperationCallSettings
+ deletePolicyOperationSettings() {
+ return ((PoliciesStubSettings) getStubSettings()).deletePolicyOperationSettings();
+ }
+
+ public static final PoliciesSettings create(PoliciesStubSettings stub) throws IOException {
+ return new PoliciesSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return PoliciesStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return PoliciesStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return PoliciesStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return PoliciesStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return PoliciesStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return PoliciesStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return PoliciesStubSettings.defaultApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected PoliciesSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for PoliciesSettings. */
+ public static class Builder extends ClientSettings.Builder {
+
+ protected Builder() throws IOException {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(PoliciesStubSettings.newBuilder(clientContext));
+ }
+
+ protected Builder(PoliciesSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(PoliciesStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ private static Builder createDefault() {
+ return new Builder(PoliciesStubSettings.newBuilder());
+ }
+
+ public PoliciesStubSettings.Builder getStubSettingsBuilder() {
+ return ((PoliciesStubSettings.Builder) getStubSettings());
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) {
+ super.applyToAllUnaryMethods(
+ getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
+ return this;
+ }
+
+ /** Returns the builder for the settings used for calls to listPolicies. */
+ public PagedCallSettings.Builder<
+ ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>
+ listPoliciesSettings() {
+ return getStubSettingsBuilder().listPoliciesSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to getPolicy. */
+ public UnaryCallSettings.Builder getPolicySettings() {
+ return getStubSettingsBuilder().getPolicySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createPolicy. */
+ public UnaryCallSettings.Builder createPolicySettings() {
+ return getStubSettingsBuilder().createPolicySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createPolicy. */
+ public OperationCallSettings.Builder
+ createPolicyOperationSettings() {
+ return getStubSettingsBuilder().createPolicyOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to updatePolicy. */
+ public UnaryCallSettings.Builder updatePolicySettings() {
+ return getStubSettingsBuilder().updatePolicySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to updatePolicy. */
+ public OperationCallSettings.Builder
+ updatePolicyOperationSettings() {
+ return getStubSettingsBuilder().updatePolicyOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deletePolicy. */
+ public UnaryCallSettings.Builder deletePolicySettings() {
+ return getStubSettingsBuilder().deletePolicySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to deletePolicy. */
+ public OperationCallSettings.Builder
+ deletePolicyOperationSettings() {
+ return getStubSettingsBuilder().deletePolicyOperationSettings();
+ }
+
+ @Override
+ public PoliciesSettings build() throws IOException {
+ return new PoliciesSettings(this);
+ }
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json b/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json
new file mode 100644
index 00000000..a68bf924
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json
@@ -0,0 +1,33 @@
+{
+ "schema": "1.0",
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "java",
+ "protoPackage": "google.iam.v2beta",
+ "libraryPackage": "com.google.iam.v2beta",
+ "services": {
+ "Policies": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "PoliciesClient",
+ "rpcs": {
+ "CreatePolicy": {
+ "methods": ["createPolicyAsync", "createPolicyAsync", "createPolicyOperationCallable", "createPolicyCallable"]
+ },
+ "DeletePolicy": {
+ "methods": ["deletePolicyAsync", "deletePolicyAsync", "deletePolicyAsync", "deletePolicyOperationCallable", "deletePolicyCallable"]
+ },
+ "GetPolicy": {
+ "methods": ["getPolicy", "getPolicy", "getPolicy", "getPolicyCallable"]
+ },
+ "ListPolicies": {
+ "methods": ["listPolicies", "listPolicies", "listPoliciesPagedCallable", "listPoliciesCallable"]
+ },
+ "UpdatePolicy": {
+ "methods": ["updatePolicyAsync", "updatePolicyOperationCallable", "updatePolicyCallable"]
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java
new file mode 100644
index 00000000..1a342b28
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A client to Identity and Access Management (IAM) API
+ *
+ *
The interfaces provided are listed below, along with usage samples.
+ *
+ *
Service Description: An interface for managing Identity and Access Management (IAM) policies.
+ *
+ *
Sample for PoliciesClient:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * PolicyName name = PolicyName.of("[POLICY]");
+ * Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.iam.v2beta;
+
+import javax.annotation.Generated;
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesCallableFactory.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesCallableFactory.java
new file mode 100644
index 00000000..d2ee2059
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesCallableFactory.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC callable factory implementation for the Policies service API.
+ *
+ *
This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcPoliciesCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ GrpcCallSettings grpcCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ GrpcCallSettings grpcCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ GrpcCallSettings grpcCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBatchingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ GrpcCallSettings grpcCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ return GrpcCallableFactory.createOperationCallable(
+ grpcCallSettings, callSettings, clientContext, operationsStub);
+ }
+
+ @Override
+ public
+ BidiStreamingCallable createBidiStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createBidiStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createServerStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ ClientStreamingCallable createClientStreamingCallable(
+ GrpcCallSettings grpcCallSettings,
+ StreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return GrpcCallableFactory.createClientStreamingCallable(
+ grpcCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesStub.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesStub.java
new file mode 100644
index 00000000..0e139631
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesStub.java
@@ -0,0 +1,332 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta.stub;
+
+import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.common.collect.ImmutableMap;
+import com.google.iam.v2beta.CreatePolicyRequest;
+import com.google.iam.v2beta.DeletePolicyRequest;
+import com.google.iam.v2beta.GetPolicyRequest;
+import com.google.iam.v2beta.ListPoliciesRequest;
+import com.google.iam.v2beta.ListPoliciesResponse;
+import com.google.iam.v2beta.Policy;
+import com.google.iam.v2beta.PolicyOperationMetadata;
+import com.google.iam.v2beta.UpdatePolicyRequest;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.GrpcOperationsStub;
+import io.grpc.MethodDescriptor;
+import io.grpc.protobuf.ProtoUtils;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC stub implementation for the Policies service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcPoliciesStub extends PoliciesStub {
+ private static final MethodDescriptor
+ listPoliciesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2beta.Policies/ListPolicies")
+ .setRequestMarshaller(ProtoUtils.marshaller(ListPoliciesRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListPoliciesResponse.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor getPolicyMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2beta.Policies/GetPolicy")
+ .setRequestMarshaller(ProtoUtils.marshaller(GetPolicyRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ createPolicyMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2beta.Policies/CreatePolicy")
+ .setRequestMarshaller(ProtoUtils.marshaller(CreatePolicyRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ updatePolicyMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2beta.Policies/UpdatePolicy")
+ .setRequestMarshaller(ProtoUtils.marshaller(UpdatePolicyRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ deletePolicyMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2beta.Policies/DeletePolicy")
+ .setRequestMarshaller(ProtoUtils.marshaller(DeletePolicyRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private final UnaryCallable listPoliciesCallable;
+ private final UnaryCallable
+ listPoliciesPagedCallable;
+ private final UnaryCallable getPolicyCallable;
+ private final UnaryCallable createPolicyCallable;
+ private final OperationCallable
+ createPolicyOperationCallable;
+ private final UnaryCallable updatePolicyCallable;
+ private final OperationCallable
+ updatePolicyOperationCallable;
+ private final UnaryCallable deletePolicyCallable;
+ private final OperationCallable
+ deletePolicyOperationCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcPoliciesStub create(PoliciesStubSettings settings) throws IOException {
+ return new GrpcPoliciesStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcPoliciesStub create(ClientContext clientContext) throws IOException {
+ return new GrpcPoliciesStub(PoliciesStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcPoliciesStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcPoliciesStub(
+ PoliciesStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcPoliciesStub, using the given settings. This is protected so that
+ * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
+ */
+ protected GrpcPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new GrpcPoliciesCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcPoliciesStub, using the given settings. This is protected so that
+ * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
+ */
+ protected GrpcPoliciesStub(
+ PoliciesStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings listPoliciesTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(listPoliciesMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings getPolicyTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getPolicyMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings createPolicyTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(createPolicyMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("parent", String.valueOf(request.getParent()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings updatePolicyTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(updatePolicyMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("policy.name", String.valueOf(request.getPolicy().getName()));
+ return params.build();
+ })
+ .build();
+ GrpcCallSettings deletePolicyTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(deletePolicyMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("name", String.valueOf(request.getName()));
+ return params.build();
+ })
+ .build();
+
+ this.listPoliciesCallable =
+ callableFactory.createUnaryCallable(
+ listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext);
+ this.listPoliciesPagedCallable =
+ callableFactory.createPagedCallable(
+ listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext);
+ this.getPolicyCallable =
+ callableFactory.createUnaryCallable(
+ getPolicyTransportSettings, settings.getPolicySettings(), clientContext);
+ this.createPolicyCallable =
+ callableFactory.createUnaryCallable(
+ createPolicyTransportSettings, settings.createPolicySettings(), clientContext);
+ this.createPolicyOperationCallable =
+ callableFactory.createOperationCallable(
+ createPolicyTransportSettings,
+ settings.createPolicyOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.updatePolicyCallable =
+ callableFactory.createUnaryCallable(
+ updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext);
+ this.updatePolicyOperationCallable =
+ callableFactory.createOperationCallable(
+ updatePolicyTransportSettings,
+ settings.updatePolicyOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.deletePolicyCallable =
+ callableFactory.createUnaryCallable(
+ deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext);
+ this.deletePolicyOperationCallable =
+ callableFactory.createOperationCallable(
+ deletePolicyTransportSettings,
+ settings.deletePolicyOperationSettings(),
+ clientContext,
+ operationsStub);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @Override
+ public UnaryCallable listPoliciesCallable() {
+ return listPoliciesCallable;
+ }
+
+ @Override
+ public UnaryCallable listPoliciesPagedCallable() {
+ return listPoliciesPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getPolicyCallable() {
+ return getPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable createPolicyCallable() {
+ return createPolicyCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createPolicyOperationCallable() {
+ return createPolicyOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable updatePolicyCallable() {
+ return updatePolicyCallable;
+ }
+
+ @Override
+ public OperationCallable
+ updatePolicyOperationCallable() {
+ return updatePolicyOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable deletePolicyCallable() {
+ return deletePolicyCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deletePolicyOperationCallable() {
+ return deletePolicyOperationCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java
new file mode 100644
index 00000000..9b6fcaff
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta.stub;
+
+import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.iam.v2beta.CreatePolicyRequest;
+import com.google.iam.v2beta.DeletePolicyRequest;
+import com.google.iam.v2beta.GetPolicyRequest;
+import com.google.iam.v2beta.ListPoliciesRequest;
+import com.google.iam.v2beta.ListPoliciesResponse;
+import com.google.iam.v2beta.Policy;
+import com.google.iam.v2beta.PolicyOperationMetadata;
+import com.google.iam.v2beta.UpdatePolicyRequest;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the Policies service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public abstract class PoliciesStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ }
+
+ public UnaryCallable listPoliciesPagedCallable() {
+ throw new UnsupportedOperationException("Not implemented: listPoliciesPagedCallable()");
+ }
+
+ public UnaryCallable listPoliciesCallable() {
+ throw new UnsupportedOperationException("Not implemented: listPoliciesCallable()");
+ }
+
+ public UnaryCallable getPolicyCallable() {
+ throw new UnsupportedOperationException("Not implemented: getPolicyCallable()");
+ }
+
+ public OperationCallable
+ createPolicyOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: createPolicyOperationCallable()");
+ }
+
+ public UnaryCallable createPolicyCallable() {
+ throw new UnsupportedOperationException("Not implemented: createPolicyCallable()");
+ }
+
+ public OperationCallable
+ updatePolicyOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: updatePolicyOperationCallable()");
+ }
+
+ public UnaryCallable updatePolicyCallable() {
+ throw new UnsupportedOperationException("Not implemented: updatePolicyCallable()");
+ }
+
+ public OperationCallable
+ deletePolicyOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: deletePolicyOperationCallable()");
+ }
+
+ public UnaryCallable deletePolicyCallable() {
+ throw new UnsupportedOperationException("Not implemented: deletePolicyCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java
new file mode 100644
index 00000000..ce17087d
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java
@@ -0,0 +1,582 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta.stub;
+
+import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse;
+
+import com.google.api.core.ApiFunction;
+import com.google.api.core.ApiFuture;
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.GaxProperties;
+import com.google.api.gax.core.GoogleCredentialsProvider;
+import com.google.api.gax.core.InstantiatingExecutorProvider;
+import com.google.api.gax.grpc.GaxGrpcProperties;
+import com.google.api.gax.grpc.GrpcTransportChannel;
+import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.grpc.ProtoOperationTransformers;
+import com.google.api.gax.longrunning.OperationSnapshot;
+import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
+import com.google.api.gax.retrying.RetrySettings;
+import com.google.api.gax.rpc.ApiCallContext;
+import com.google.api.gax.rpc.ApiClientHeaderProvider;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.PageContext;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.PagedListDescriptor;
+import com.google.api.gax.rpc.PagedListResponseFactory;
+import com.google.api.gax.rpc.StatusCode;
+import com.google.api.gax.rpc.StubSettings;
+import com.google.api.gax.rpc.TransportChannelProvider;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.iam.v2beta.CreatePolicyRequest;
+import com.google.iam.v2beta.DeletePolicyRequest;
+import com.google.iam.v2beta.GetPolicyRequest;
+import com.google.iam.v2beta.ListPoliciesRequest;
+import com.google.iam.v2beta.ListPoliciesResponse;
+import com.google.iam.v2beta.Policy;
+import com.google.iam.v2beta.PolicyOperationMetadata;
+import com.google.iam.v2beta.UpdatePolicyRequest;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import javax.annotation.Generated;
+import org.threeten.bp.Duration;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Settings class to configure an instance of {@link PoliciesStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (iam.googleapis.com) and default port (443) are used.
+ *
Credentials are acquired automatically through Application Default Credentials.
+ *
Retries are configured for idempotent methods but not for non-idempotent methods.
+ *
+ *
+ *
The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ *
For example, to set the total timeout of getPolicy to 30 seconds:
+ *
+ *
{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PoliciesStubSettings.Builder policiesSettingsBuilder = PoliciesStubSettings.newBuilder();
+ * policiesSettingsBuilder
+ * .getPolicySettings()
+ * .setRetrySettings(
+ * policiesSettingsBuilder
+ * .getPolicySettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * PoliciesStubSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class PoliciesStubSettings extends StubSettings {
+ /** The default scopes of the service. */
+ private static final ImmutableList DEFAULT_SERVICE_SCOPES =
+ ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build();
+
+ private final PagedCallSettings<
+ ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>
+ listPoliciesSettings;
+ private final UnaryCallSettings getPolicySettings;
+ private final UnaryCallSettings createPolicySettings;
+ private final OperationCallSettings
+ createPolicyOperationSettings;
+ private final UnaryCallSettings updatePolicySettings;
+ private final OperationCallSettings
+ updatePolicyOperationSettings;
+ private final UnaryCallSettings deletePolicySettings;
+ private final OperationCallSettings
+ deletePolicyOperationSettings;
+
+ private static final PagedListDescriptor
+ LIST_POLICIES_PAGE_STR_DESC =
+ new PagedListDescriptor() {
+ @Override
+ public String emptyToken() {
+ return "";
+ }
+
+ @Override
+ public ListPoliciesRequest injectToken(ListPoliciesRequest payload, String token) {
+ return ListPoliciesRequest.newBuilder(payload).setPageToken(token).build();
+ }
+
+ @Override
+ public ListPoliciesRequest injectPageSize(ListPoliciesRequest payload, int pageSize) {
+ return ListPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListPoliciesRequest payload) {
+ return payload.getPageSize();
+ }
+
+ @Override
+ public String extractNextToken(ListPoliciesResponse payload) {
+ return payload.getNextPageToken();
+ }
+
+ @Override
+ public Iterable extractResources(ListPoliciesResponse payload) {
+ return payload.getPoliciesList() == null
+ ? ImmutableList.of()
+ : payload.getPoliciesList();
+ }
+ };
+
+ private static final PagedListResponseFactory<
+ ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>
+ LIST_POLICIES_PAGE_STR_FACT =
+ new PagedListResponseFactory<
+ ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>() {
+ @Override
+ public ApiFuture getFuturePagedResponse(
+ UnaryCallable callable,
+ ListPoliciesRequest request,
+ ApiCallContext context,
+ ApiFuture futureResponse) {
+ PageContext pageContext =
+ PageContext.create(callable, LIST_POLICIES_PAGE_STR_DESC, request, context);
+ return ListPoliciesPagedResponse.createAsync(pageContext, futureResponse);
+ }
+ };
+
+ /** Returns the object with the settings used for calls to listPolicies. */
+ public PagedCallSettings
+ listPoliciesSettings() {
+ return listPoliciesSettings;
+ }
+
+ /** Returns the object with the settings used for calls to getPolicy. */
+ public UnaryCallSettings getPolicySettings() {
+ return getPolicySettings;
+ }
+
+ /** Returns the object with the settings used for calls to createPolicy. */
+ public UnaryCallSettings createPolicySettings() {
+ return createPolicySettings;
+ }
+
+ /** Returns the object with the settings used for calls to createPolicy. */
+ public OperationCallSettings
+ createPolicyOperationSettings() {
+ return createPolicyOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to updatePolicy. */
+ public UnaryCallSettings updatePolicySettings() {
+ return updatePolicySettings;
+ }
+
+ /** Returns the object with the settings used for calls to updatePolicy. */
+ public OperationCallSettings
+ updatePolicyOperationSettings() {
+ return updatePolicyOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to deletePolicy. */
+ public UnaryCallSettings deletePolicySettings() {
+ return deletePolicySettings;
+ }
+
+ /** Returns the object with the settings used for calls to deletePolicy. */
+ public OperationCallSettings
+ deletePolicyOperationSettings() {
+ return deletePolicyOperationSettings;
+ }
+
+ public PoliciesStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcPoliciesStub.create(this);
+ }
+ throw new UnsupportedOperationException(
+ String.format(
+ "Transport not supported: %s", getTransportChannelProvider().getTransportName()));
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return InstantiatingExecutorProvider.newBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return "iam.googleapis.com:443";
+ }
+
+ /** Returns the default mTLS service endpoint. */
+ public static String getDefaultMtlsEndpoint() {
+ return "iam.mtls.googleapis.com:443";
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return DEFAULT_SERVICE_SCOPES;
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return GoogleCredentialsProvider.newBuilder()
+ .setScopesToApply(DEFAULT_SERVICE_SCOPES)
+ .setUseJwtAccessWithScope(true);
+ }
+
+ /** Returns a builder for the default ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return defaultGrpcTransportProviderBuilder().build();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new builder for this class. */
+ public static Builder newBuilder(ClientContext clientContext) {
+ return new Builder(clientContext);
+ }
+
+ /** Returns a builder containing all the values of this settings class. */
+ public Builder toBuilder() {
+ return new Builder(this);
+ }
+
+ protected PoliciesStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ listPoliciesSettings = settingsBuilder.listPoliciesSettings().build();
+ getPolicySettings = settingsBuilder.getPolicySettings().build();
+ createPolicySettings = settingsBuilder.createPolicySettings().build();
+ createPolicyOperationSettings = settingsBuilder.createPolicyOperationSettings().build();
+ updatePolicySettings = settingsBuilder.updatePolicySettings().build();
+ updatePolicyOperationSettings = settingsBuilder.updatePolicyOperationSettings().build();
+ deletePolicySettings = settingsBuilder.deletePolicySettings().build();
+ deletePolicyOperationSettings = settingsBuilder.deletePolicyOperationSettings().build();
+ }
+
+ /** Builder for PoliciesStubSettings. */
+ public static class Builder extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+ private final PagedCallSettings.Builder<
+ ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>
+ listPoliciesSettings;
+ private final UnaryCallSettings.Builder getPolicySettings;
+ private final UnaryCallSettings.Builder createPolicySettings;
+ private final OperationCallSettings.Builder<
+ CreatePolicyRequest, Policy, PolicyOperationMetadata>
+ createPolicyOperationSettings;
+ private final UnaryCallSettings.Builder updatePolicySettings;
+ private final OperationCallSettings.Builder<
+ UpdatePolicyRequest, Policy, PolicyOperationMetadata>
+ updatePolicyOperationSettings;
+ private final UnaryCallSettings.Builder deletePolicySettings;
+ private final OperationCallSettings.Builder<
+ DeletePolicyRequest, Policy, PolicyOperationMetadata>
+ deletePolicyOperationSettings;
+ private static final ImmutableMap>
+ RETRYABLE_CODE_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder> definitions =
+ ImmutableMap.builder();
+ definitions.put(
+ "retry_policy_0_codes",
+ ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE)));
+ RETRYABLE_CODE_DEFINITIONS = definitions.build();
+ }
+
+ private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
+
+ static {
+ ImmutableMap.Builder definitions = ImmutableMap.builder();
+ RetrySettings settings = null;
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(1000L))
+ .setRetryDelayMultiplier(1.3)
+ .setMaxRetryDelay(Duration.ofMillis(10000L))
+ .setInitialRpcTimeout(Duration.ofMillis(60000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(60000L))
+ .setTotalTimeout(Duration.ofMillis(60000L))
+ .build();
+ definitions.put("retry_policy_0_params", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ listPoliciesSettings = PagedCallSettings.newBuilder(LIST_POLICIES_PAGE_STR_FACT);
+ getPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createPolicyOperationSettings = OperationCallSettings.newBuilder();
+ updatePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ updatePolicyOperationSettings = OperationCallSettings.newBuilder();
+ deletePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ deletePolicyOperationSettings = OperationCallSettings.newBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ listPoliciesSettings,
+ getPolicySettings,
+ createPolicySettings,
+ updatePolicySettings,
+ deletePolicySettings);
+ initDefaults(this);
+ }
+
+ protected Builder(PoliciesStubSettings settings) {
+ super(settings);
+
+ listPoliciesSettings = settings.listPoliciesSettings.toBuilder();
+ getPolicySettings = settings.getPolicySettings.toBuilder();
+ createPolicySettings = settings.createPolicySettings.toBuilder();
+ createPolicyOperationSettings = settings.createPolicyOperationSettings.toBuilder();
+ updatePolicySettings = settings.updatePolicySettings.toBuilder();
+ updatePolicyOperationSettings = settings.updatePolicyOperationSettings.toBuilder();
+ deletePolicySettings = settings.deletePolicySettings.toBuilder();
+ deletePolicyOperationSettings = settings.deletePolicyOperationSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ listPoliciesSettings,
+ getPolicySettings,
+ createPolicySettings,
+ updatePolicySettings,
+ deletePolicySettings);
+ }
+
+ private static Builder createDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultTransportChannelProvider());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+ builder
+ .listPoliciesSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .getPolicySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .createPolicySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .updatePolicySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .deletePolicySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .createPolicyOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Policy.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ builder
+ .updatePolicyOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Policy.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ builder
+ .deletePolicyOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Policy.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(5000L))
+ .setRetryDelayMultiplier(1.5)
+ .setMaxRetryDelay(Duration.ofMillis(45000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(300000L))
+ .build()));
+
+ return builder;
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction, Void> settingsUpdater) {
+ super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
+ return this;
+ }
+
+ public ImmutableList> unaryMethodSettingsBuilders() {
+ return unaryMethodSettingsBuilders;
+ }
+
+ /** Returns the builder for the settings used for calls to listPolicies. */
+ public PagedCallSettings.Builder<
+ ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>
+ listPoliciesSettings() {
+ return listPoliciesSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to getPolicy. */
+ public UnaryCallSettings.Builder getPolicySettings() {
+ return getPolicySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createPolicy. */
+ public UnaryCallSettings.Builder createPolicySettings() {
+ return createPolicySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to createPolicy. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ createPolicyOperationSettings() {
+ return createPolicyOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to updatePolicy. */
+ public UnaryCallSettings.Builder updatePolicySettings() {
+ return updatePolicySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to updatePolicy. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ updatePolicyOperationSettings() {
+ return updatePolicyOperationSettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deletePolicy. */
+ public UnaryCallSettings.Builder deletePolicySettings() {
+ return deletePolicySettings;
+ }
+
+ /** Returns the builder for the settings used for calls to deletePolicy. */
+ @BetaApi(
+ "The surface for use by generated code is not stable yet and may change in the future.")
+ public OperationCallSettings.Builder
+ deletePolicyOperationSettings() {
+ return deletePolicyOperationSettings;
+ }
+
+ @Override
+ public PoliciesStubSettings build() throws IOException {
+ return new PoliciesStubSettings(this);
+ }
+ }
+}
diff --git a/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPolicies.java b/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPolicies.java
new file mode 100644
index 00000000..d68e4921
--- /dev/null
+++ b/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPolicies.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.grpc.testing.MockGrpcService;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.ServerServiceDefinition;
+import java.util.List;
+import javax.annotation.Generated;
+
+@BetaApi
+@Generated("by gapic-generator-java")
+public class MockPolicies implements MockGrpcService {
+ private final MockPoliciesImpl serviceImpl;
+
+ public MockPolicies() {
+ serviceImpl = new MockPoliciesImpl();
+ }
+
+ @Override
+ public List getRequests() {
+ return serviceImpl.getRequests();
+ }
+
+ @Override
+ public void addResponse(AbstractMessage response) {
+ serviceImpl.addResponse(response);
+ }
+
+ @Override
+ public void addException(Exception exception) {
+ serviceImpl.addException(exception);
+ }
+
+ @Override
+ public ServerServiceDefinition getServiceDefinition() {
+ return serviceImpl.bindService();
+ }
+
+ @Override
+ public void reset() {
+ serviceImpl.reset();
+ }
+}
diff --git a/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPoliciesImpl.java b/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPoliciesImpl.java
new file mode 100644
index 00000000..645a7a86
--- /dev/null
+++ b/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPoliciesImpl.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.iam.v2beta;
+
+import com.google.api.core.BetaApi;
+import com.google.iam.v2beta.PoliciesGrpc.PoliciesImplBase;
+import com.google.longrunning.Operation;
+import com.google.protobuf.AbstractMessage;
+import io.grpc.stub.StreamObserver;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import javax.annotation.Generated;
+
+@BetaApi
+@Generated("by gapic-generator-java")
+public class MockPoliciesImpl extends PoliciesImplBase {
+ private List requests;
+ private Queue