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.
+ *
+ *
getPolicyCallable() {
+ return stub.getPolicyCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates a policy.
+ *
+ * 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 (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 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 (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 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 (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 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 (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.v2.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 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 (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.v2.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 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 (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.v2.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 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 (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 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String name = "name3373707";
+ * 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 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * DeletePolicyRequest request =
+ * DeletePolicyRequest.newBuilder().setName("name3373707").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 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * DeletePolicyRequest request =
+ * DeletePolicyRequest.newBuilder().setName("name3373707").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 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * DeletePolicyRequest request =
+ * DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+ * ApiFuture future = policiesClient.deletePolicyCallable().futureCall(request);
+ * // Do something.
+ * Operation response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable deletePolicyCallable() {
+ return stub.deletePolicyCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all the policies that are attached to the specified resource, or anywhere in the
+ * ancestry of the resource. For example, for a project this endpoint would return all the
+ * `denyPolicy` kind policies attached to the project, its parent folder (if any), and its parent
+ * organization (if any). The endpoint requires the same permissions that it would take to call
+ * `ListPolicies` or `GetPolicy`.
+ *
+ * The main reason to use this endpoint is as a policy admin to debug access issues for a
+ * 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String attachmentPoint = "attachmentPoint-686994899";
+ * for (Policy element : policiesClient.listApplicablePolicies(attachmentPoint).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param attachmentPoint Required. The Cloud resource at which the applicable policies are to be
+ * retrieved. Format: `{attachment-point}` Use the URL-encoded full resource name, which means
+ * that the forward-slash character, `/`, must be written as `%2F`. For example,
+ * `cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project`.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListApplicablePoliciesPagedResponse listApplicablePolicies(String attachmentPoint) {
+ ListApplicablePoliciesRequest request =
+ ListApplicablePoliciesRequest.newBuilder().setAttachmentPoint(attachmentPoint).build();
+ return listApplicablePolicies(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all the policies that are attached to the specified resource, or anywhere in the
+ * ancestry of the resource. For example, for a project this endpoint would return all the
+ * `denyPolicy` kind policies attached to the project, its parent folder (if any), and its parent
+ * organization (if any). The endpoint requires the same permissions that it would take to call
+ * `ListPolicies` or `GetPolicy`.
+ *
+ * The main reason to use this endpoint is as a policy admin to debug access issues for a
+ * 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * ListApplicablePoliciesRequest request =
+ * ListApplicablePoliciesRequest.newBuilder()
+ * .setAttachmentPoint("attachmentPoint-686994899")
+ * .setFilter("filter-1274492040")
+ * .setPageToken("pageToken873572522")
+ * .setPageSize(883849137)
+ * .build();
+ * for (Policy element : policiesClient.listApplicablePolicies(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 ListApplicablePoliciesPagedResponse listApplicablePolicies(
+ ListApplicablePoliciesRequest request) {
+ return listApplicablePoliciesPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all the policies that are attached to the specified resource, or anywhere in the
+ * ancestry of the resource. For example, for a project this endpoint would return all the
+ * `denyPolicy` kind policies attached to the project, its parent folder (if any), and its parent
+ * organization (if any). The endpoint requires the same permissions that it would take to call
+ * `ListPolicies` or `GetPolicy`.
+ *
+ * The main reason to use this endpoint is as a policy admin to debug access issues for a
+ * 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * ListApplicablePoliciesRequest request =
+ * ListApplicablePoliciesRequest.newBuilder()
+ * .setAttachmentPoint("attachmentPoint-686994899")
+ * .setFilter("filter-1274492040")
+ * .setPageToken("pageToken873572522")
+ * .setPageSize(883849137)
+ * .build();
+ * ApiFuture future =
+ * policiesClient.listApplicablePoliciesPagedCallable().futureCall(request);
+ * // Do something.
+ * for (Policy element : future.get().iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable
+ listApplicablePoliciesPagedCallable() {
+ return stub.listApplicablePoliciesPagedCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Retrieves all the policies that are attached to the specified resource, or anywhere in the
+ * ancestry of the resource. For example, for a project this endpoint would return all the
+ * `denyPolicy` kind policies attached to the project, its parent folder (if any), and its parent
+ * organization (if any). The endpoint requires the same permissions that it would take to call
+ * `ListPolicies` or `GetPolicy`.
+ *
+ * The main reason to use this endpoint is as a policy admin to debug access issues for a
+ * 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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * ListApplicablePoliciesRequest request =
+ * ListApplicablePoliciesRequest.newBuilder()
+ * .setAttachmentPoint("attachmentPoint-686994899")
+ * .setFilter("filter-1274492040")
+ * .setPageToken("pageToken873572522")
+ * .setPageSize(883849137)
+ * .build();
+ * while (true) {
+ * ListApplicablePoliciesResponse response =
+ * policiesClient.listApplicablePoliciesCallable().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
+ listApplicablePoliciesCallable() {
+ return stub.listApplicablePoliciesCallable();
+ }
+
+ @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);
+ }
+ }
+
+ public static class ListApplicablePoliciesPagedResponse
+ extends AbstractPagedListResponse<
+ ListApplicablePoliciesRequest,
+ ListApplicablePoliciesResponse,
+ Policy,
+ ListApplicablePoliciesPage,
+ ListApplicablePoliciesFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListApplicablePoliciesPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage,
+ input -> new ListApplicablePoliciesPagedResponse(input),
+ MoreExecutors.directExecutor());
+ }
+
+ private ListApplicablePoliciesPagedResponse(ListApplicablePoliciesPage page) {
+ super(page, ListApplicablePoliciesFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListApplicablePoliciesPage
+ extends AbstractPage<
+ ListApplicablePoliciesRequest,
+ ListApplicablePoliciesResponse,
+ Policy,
+ ListApplicablePoliciesPage> {
+
+ private ListApplicablePoliciesPage(
+ PageContext context,
+ ListApplicablePoliciesResponse response) {
+ super(context, response);
+ }
+
+ private static ListApplicablePoliciesPage createEmptyPage() {
+ return new ListApplicablePoliciesPage(null, null);
+ }
+
+ @Override
+ protected ListApplicablePoliciesPage createPage(
+ PageContext context,
+ ListApplicablePoliciesResponse response) {
+ return new ListApplicablePoliciesPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListApplicablePoliciesFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListApplicablePoliciesRequest,
+ ListApplicablePoliciesResponse,
+ Policy,
+ ListApplicablePoliciesPage,
+ ListApplicablePoliciesFixedSizeCollection> {
+
+ private ListApplicablePoliciesFixedSizeCollection(
+ List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListApplicablePoliciesFixedSizeCollection createEmptyCollection() {
+ return new ListApplicablePoliciesFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListApplicablePoliciesFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListApplicablePoliciesFixedSizeCollection(pages, collectionSize);
+ }
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesSettings.java b/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesSettings.java
new file mode 100644
index 00000000..a8e27342
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesSettings.java
@@ -0,0 +1,303 @@
+/*
+ * 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.v2;
+
+import static com.google.iam.v2.PoliciesClient.ListApplicablePoliciesPagedResponse;
+import static com.google.iam.v2.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.httpjson.InstantiatingHttpJsonChannelProvider;
+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.v2.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 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
+ * PoliciesSettings.Builder policiesSettingsBuilder = PoliciesSettings.newBuilder();
+ * policiesSettingsBuilder
+ * .getPolicySettings()
+ * .setRetrySettings(
+ * policiesSettingsBuilder.getPolicySettings().getRetrySettings().toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * PoliciesSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */
+@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();
+ }
+
+ /** Returns the object with the settings used for calls to listApplicablePolicies. */
+ public PagedCallSettings<
+ ListApplicablePoliciesRequest,
+ ListApplicablePoliciesResponse,
+ ListApplicablePoliciesPagedResponse>
+ listApplicablePoliciesSettings() {
+ return ((PoliciesStubSettings) getStubSettings()).listApplicablePoliciesSettings();
+ }
+
+ 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 gRPC ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return PoliciesStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return PoliciesStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
+ 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 gRPC builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new REST builder for this class. */
+ @BetaApi
+ public static Builder newHttpJsonBuilder() {
+ return Builder.createHttpJsonDefault();
+ }
+
+ /** 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());
+ }
+
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(PoliciesStubSettings.newHttpJsonBuilder());
+ }
+
+ 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();
+ }
+
+ /** Returns the builder for the settings used for calls to listApplicablePolicies. */
+ public PagedCallSettings.Builder<
+ ListApplicablePoliciesRequest,
+ ListApplicablePoliciesResponse,
+ ListApplicablePoliciesPagedResponse>
+ listApplicablePoliciesSettings() {
+ return getStubSettingsBuilder().listApplicablePoliciesSettings();
+ }
+
+ @Override
+ public PoliciesSettings build() throws IOException {
+ return new PoliciesSettings(this);
+ }
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2/gapic_metadata.json b/google-iam-policy/src/main/java/com/google/iam/v2/gapic_metadata.json
new file mode 100644
index 00000000..c0965438
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/gapic_metadata.json
@@ -0,0 +1,36 @@
+{
+ "schema": "1.0",
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "java",
+ "protoPackage": "google.iam.v2",
+ "libraryPackage": "com.google.iam.v2",
+ "services": {
+ "Policies": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "PoliciesClient",
+ "rpcs": {
+ "CreatePolicy": {
+ "methods": ["createPolicyAsync", "createPolicyAsync", "createPolicyOperationCallable", "createPolicyCallable"]
+ },
+ "DeletePolicy": {
+ "methods": ["deletePolicyAsync", "deletePolicyAsync", "deletePolicyOperationCallable", "deletePolicyCallable"]
+ },
+ "GetPolicy": {
+ "methods": ["getPolicy", "getPolicy", "getPolicyCallable"]
+ },
+ "ListApplicablePolicies": {
+ "methods": ["listApplicablePolicies", "listApplicablePolicies", "listApplicablePoliciesPagedCallable", "listApplicablePoliciesCallable"]
+ },
+ "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/v2/package-info.java b/google-iam-policy/src/main/java/com/google/iam/v2/package-info.java
new file mode 100644
index 00000000..1994b92c
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/package-info.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ *
+ *
======================= PoliciesClient =======================
+ *
+ *
Service Description: An interface for managing Identity and Access Management (IAM) policies.
+ *
+ *
Sample for PoliciesClient:
+ *
+ *
{@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 (PoliciesClient policiesClient = PoliciesClient.create()) {
+ * String name = "name3373707";
+ * Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.iam.v2;
+
+import javax.annotation.Generated;
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesCallableFactory.java b/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesCallableFactory.java
new file mode 100644
index 00000000..a09e6477
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesCallableFactory.java
@@ -0,0 +1,113 @@
+/*
+ * 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.v2.stub;
+
+import com.google.api.gax.grpc.GrpcCallSettings;
+import com.google.api.gax.grpc.GrpcCallableFactory;
+import com.google.api.gax.grpc.GrpcStubCallableFactory;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.BidiStreamingCallable;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.ClientStreamingCallable;
+import com.google.api.gax.rpc.OperationCallSettings;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.PagedCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallSettings;
+import com.google.api.gax.rpc.ServerStreamingCallable;
+import com.google.api.gax.rpc.StreamingCallSettings;
+import com.google.api.gax.rpc.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import com.google.longrunning.stub.OperationsStub;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * gRPC callable factory implementation for the Policies service API.
+ *
+ * This class is for advanced usage.
+ */
+@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/v2/stub/GrpcPoliciesStub.java b/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesStub.java
new file mode 100644
index 00000000..3a0f0620
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesStub.java
@@ -0,0 +1,384 @@
+/*
+ * 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.v2.stub;
+
+import static com.google.iam.v2.PoliciesClient.ListApplicablePoliciesPagedResponse;
+import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse;
+
+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.v2.CreatePolicyRequest;
+import com.google.iam.v2.DeletePolicyRequest;
+import com.google.iam.v2.GetPolicyRequest;
+import com.google.iam.v2.ListApplicablePoliciesRequest;
+import com.google.iam.v2.ListApplicablePoliciesResponse;
+import com.google.iam.v2.ListPoliciesRequest;
+import com.google.iam.v2.ListPoliciesResponse;
+import com.google.iam.v2.Policy;
+import com.google.iam.v2.PolicyOperationMetadata;
+import com.google.iam.v2.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.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcPoliciesStub extends PoliciesStub {
+ private static final MethodDescriptor
+ listPoliciesMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2.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.v2.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.v2.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.v2.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.v2.Policies/DeletePolicy")
+ .setRequestMarshaller(ProtoUtils.marshaller(DeletePolicyRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor<
+ ListApplicablePoliciesRequest, ListApplicablePoliciesResponse>
+ listApplicablePoliciesMethodDescriptor =
+ MethodDescriptor
+ .newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.iam.v2.Policies/ListApplicablePolicies")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ListApplicablePoliciesRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListApplicablePoliciesResponse.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 UnaryCallable
+ listApplicablePoliciesCallable;
+ private final UnaryCallable
+ listApplicablePoliciesPagedCallable;
+
+ 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();
+ GrpcCallSettings
+ listApplicablePoliciesTransportSettings =
+ GrpcCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listApplicablePoliciesMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ ImmutableMap.Builder params = ImmutableMap.builder();
+ params.put("attachment_point", String.valueOf(request.getAttachmentPoint()));
+ 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.listApplicablePoliciesCallable =
+ callableFactory.createUnaryCallable(
+ listApplicablePoliciesTransportSettings,
+ settings.listApplicablePoliciesSettings(),
+ clientContext);
+ this.listApplicablePoliciesPagedCallable =
+ callableFactory.createPagedCallable(
+ listApplicablePoliciesTransportSettings,
+ settings.listApplicablePoliciesSettings(),
+ clientContext);
+
+ 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 UnaryCallable
+ listApplicablePoliciesCallable() {
+ return listApplicablePoliciesCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listApplicablePoliciesPagedCallable() {
+ return listApplicablePoliciesPagedCallable;
+ }
+
+ @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/v2/stub/HttpJsonPoliciesCallableFactory.java b/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesCallableFactory.java
new file mode 100644
index 00000000..27bd9b72
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesCallableFactory.java
@@ -0,0 +1,105 @@
+/*
+ * 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.v2.stub;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonCallableFactory;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.longrunning.stub.OperationsStub;
+import com.google.api.gax.rpc.BatchingCallSettings;
+import com.google.api.gax.rpc.ClientContext;
+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.UnaryCallSettings;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.longrunning.Operation;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST callable factory implementation for the Policies service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonPoliciesCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesStub.java b/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesStub.java
new file mode 100644
index 00000000..6370f750
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesStub.java
@@ -0,0 +1,552 @@
+/*
+ * 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.v2.stub;
+
+import static com.google.iam.v2.PoliciesClient.ListApplicablePoliciesPagedResponse;
+import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.core.InternalApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.httpjson.ApiMethodDescriptor;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonOperationSnapshot;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
+import com.google.api.gax.httpjson.ProtoMessageResponseParser;
+import com.google.api.gax.httpjson.ProtoRestSerializer;
+import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.iam.v2.CreatePolicyRequest;
+import com.google.iam.v2.DeletePolicyRequest;
+import com.google.iam.v2.GetPolicyRequest;
+import com.google.iam.v2.ListApplicablePoliciesRequest;
+import com.google.iam.v2.ListApplicablePoliciesResponse;
+import com.google.iam.v2.ListPoliciesRequest;
+import com.google.iam.v2.ListPoliciesResponse;
+import com.google.iam.v2.Policy;
+import com.google.iam.v2.PolicyOperationMetadata;
+import com.google.iam.v2.UpdatePolicyRequest;
+import com.google.longrunning.Operation;
+import com.google.protobuf.TypeRegistry;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * REST stub implementation for the Policies service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonPoliciesStub extends PoliciesStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(PolicyOperationMetadata.getDescriptor())
+ .add(Policy.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listPoliciesMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.iam.v2.Policies/ListPolicies")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=policies/*/*}",
+ 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());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListPoliciesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor getPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.iam.v2.Policies/GetPolicy")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=policies/*/*/*}",
+ 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();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Policy.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.iam.v2.Policies/CreatePolicy")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{parent=policies/*/*}",
+ 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, "policyId", request.getPolicyId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("policy", request.getPolicy(), false))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreatePolicyRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ updatePolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.iam.v2.Policies/UpdatePolicy")
+ .setHttpMethod("PUT")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{policy.name=policies/*/*/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "policy.name", request.getPolicy().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("policy", request.getPolicy(), false))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (UpdatePolicyRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ deletePolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.iam.v2.Policies/DeletePolicy")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{name=policies/*/*/*}",
+ 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, "etag", request.getEtag());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeletePolicyRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor<
+ ListApplicablePoliciesRequest, ListApplicablePoliciesResponse>
+ listApplicablePoliciesMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName("google.iam.v2.Policies/ListApplicablePolicies")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v2/{attachmentPoint=*}:listApplicablePolicies",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "attachmentPoint", request.getAttachmentPoint());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListApplicablePoliciesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .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 UnaryCallable
+ listApplicablePoliciesCallable;
+ private final UnaryCallable
+ listApplicablePoliciesPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonPoliciesStub create(PoliciesStubSettings settings)
+ throws IOException {
+ return new HttpJsonPoliciesStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonPoliciesStub create(ClientContext clientContext) throws IOException {
+ return new HttpJsonPoliciesStub(
+ PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonPoliciesStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonPoliciesStub(
+ PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonPoliciesCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub(
+ PoliciesStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings listPoliciesTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listPoliciesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getPolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getPolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings createPolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createPolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updatePolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updatePolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deletePolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deletePolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listApplicablePoliciesTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listApplicablePoliciesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .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,
+ httpJsonOperationsStub);
+ this.updatePolicyCallable =
+ callableFactory.createUnaryCallable(
+ updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext);
+ this.updatePolicyOperationCallable =
+ callableFactory.createOperationCallable(
+ updatePolicyTransportSettings,
+ settings.updatePolicyOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.deletePolicyCallable =
+ callableFactory.createUnaryCallable(
+ deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext);
+ this.deletePolicyOperationCallable =
+ callableFactory.createOperationCallable(
+ deletePolicyTransportSettings,
+ settings.deletePolicyOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.listApplicablePoliciesCallable =
+ callableFactory.createUnaryCallable(
+ listApplicablePoliciesTransportSettings,
+ settings.listApplicablePoliciesSettings(),
+ clientContext);
+ this.listApplicablePoliciesPagedCallable =
+ callableFactory.createPagedCallable(
+ listApplicablePoliciesTransportSettings,
+ settings.listApplicablePoliciesSettings(),
+ clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listPoliciesMethodDescriptor);
+ methodDescriptors.add(getPolicyMethodDescriptor);
+ methodDescriptors.add(createPolicyMethodDescriptor);
+ methodDescriptors.add(updatePolicyMethodDescriptor);
+ methodDescriptors.add(deletePolicyMethodDescriptor);
+ methodDescriptors.add(listApplicablePoliciesMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @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 UnaryCallable
+ listApplicablePoliciesCallable() {
+ return listApplicablePoliciesCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listApplicablePoliciesPagedCallable() {
+ return listApplicablePoliciesPagedCallable;
+ }
+
+ @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/v2/stub/PoliciesStub.java b/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStub.java
new file mode 100644
index 00000000..f00f4af8
--- /dev/null
+++ b/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStub.java
@@ -0,0 +1,108 @@
+/*
+ * 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.v2.stub;
+
+import static com.google.iam.v2.PoliciesClient.ListApplicablePoliciesPagedResponse;
+import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse;
+
+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.v2.CreatePolicyRequest;
+import com.google.iam.v2.DeletePolicyRequest;
+import com.google.iam.v2.GetPolicyRequest;
+import com.google.iam.v2.ListApplicablePoliciesRequest;
+import com.google.iam.v2.ListApplicablePoliciesResponse;
+import com.google.iam.v2.ListPoliciesRequest;
+import com.google.iam.v2.ListPoliciesResponse;
+import com.google.iam.v2.Policy;
+import com.google.iam.v2.PolicyOperationMetadata;
+import com.google.iam.v2.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.
+ */
+@Generated("by gapic-generator-java")
+public abstract class PoliciesStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
+ }
+
+ public UnaryCallable