diff --git a/gapic-libraries-bom/pom.xml b/gapic-libraries-bom/pom.xml
index 03a22b1d67fd..0927f2eb891d 100644
--- a/gapic-libraries-bom/pom.xml
+++ b/gapic-libraries-bom/pom.xml
@@ -763,6 +763,13 @@
pomimport
+
+ com.google.cloud
+ google-cloud-policysimulator-bom
+ 0.0.1-SNAPSHOT
+ pom
+ import
+ com.google.cloudgoogle-cloud-policy-troubleshooter-bom
diff --git a/java-policysimulator/.OwlBot.yaml b/java-policysimulator/.OwlBot.yaml
new file mode 100644
index 000000000000..f7d95f431009
--- /dev/null
+++ b/java-policysimulator/.OwlBot.yaml
@@ -0,0 +1,36 @@
+# 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
+#
+# http://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.
+
+
+deep-remove-regex:
+- "/java-policysimulator/grpc-google-.*/src"
+- "/java-policysimulator/proto-google-.*/src"
+- "/java-policysimulator/google-.*/src"
+- "/java-policysimulator/samples/snippets/generated"
+
+deep-preserve-regex:
+- "/java-policysimulator/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
+
+deep-copy-regex:
+- source: "/google/cloud/policysimulator/(v.*)/.*-java/proto-google-.*/src"
+ dest: "/owl-bot-staging/java-policysimulator/$1/proto-google-cloud-policysimulator-$1/src"
+- source: "/google/cloud/policysimulator/(v.*)/.*-java/grpc-google-.*/src"
+ dest: "/owl-bot-staging/java-policysimulator/$1/grpc-google-cloud-policysimulator-$1/src"
+- source: "/google/cloud/policysimulator/(v.*)/.*-java/gapic-google-.*/src"
+ dest: "/owl-bot-staging/java-policysimulator/$1/google-cloud-policysimulator/src"
+- source: "/google/cloud/policysimulator/(v.*)/.*-java/samples/snippets/generated"
+ dest: "/owl-bot-staging/java-policysimulator/$1/samples/snippets/generated"
+
+
+api-name: policysimulator
\ No newline at end of file
diff --git a/java-policysimulator/.repo-metadata.json b/java-policysimulator/.repo-metadata.json
new file mode 100644
index 000000000000..a3d8f4eeed3d
--- /dev/null
+++ b/java-policysimulator/.repo-metadata.json
@@ -0,0 +1,16 @@
+{
+ "api_shortname": "policysimulator",
+ "name_pretty": "Policy Simulator API",
+ "product_documentation": "https://cloud.google.com/policysimulator/docs/overview",
+ "api_description": "Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay.",
+ "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-policysimulator/latest/overview",
+ "release_level": "preview",
+ "transport": "grpc",
+ "language": "java",
+ "repo": "googleapis/java-policysimulator",
+ "repo_short": "java-policysimulator",
+ "distribution_name": "com.google.cloud:google-cloud-policysimulator",
+ "api_id": "policysimulator.googleapis.com",
+ "library_type": "GAPIC_AUTO",
+ "requires_billing": true
+}
\ No newline at end of file
diff --git a/java-policysimulator/README.md b/java-policysimulator/README.md
new file mode 100644
index 000000000000..29cfc2d88e3a
--- /dev/null
+++ b/java-policysimulator/README.md
@@ -0,0 +1,225 @@
+# Google Policy Simulator API Client for Java
+
+Java idiomatic client for [Policy Simulator API][product-docs].
+
+[![Maven][maven-version-image]][maven-version-link]
+![Stability][stability-image]
+
+- [Product Documentation][product-docs]
+- [Client Library Documentation][javadocs]
+
+> Note: This client is a work-in-progress, and may occasionally
+> make backwards-incompatible changes.
+
+
+## Quickstart
+
+
+If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
+
+```xml
+
+
+
+ com.google.cloud
+ libraries-bom
+ 26.19.0
+ pom
+ import
+
+
+
+
+
+
+ com.google.cloud
+ google-cloud-policysimulator
+
+```
+
+If you are using Maven without the BOM, add this to your dependencies:
+
+
+
+```xml
+
+ com.google.cloud
+ google-cloud-policysimulator
+ 0.0.0
+
+```
+
+If you are using Gradle without BOM, add this to your dependencies:
+
+```Groovy
+implementation 'com.google.cloud:google-cloud-policysimulator:0.0.0'
+```
+
+If you are using SBT, add this to your dependencies:
+
+```Scala
+libraryDependencies += "com.google.cloud" % "google-cloud-policysimulator" % "0.0.0"
+```
+
+
+## Authentication
+
+See the [Authentication][authentication] section in the base directory's README.
+
+## Authorization
+
+The client application making API calls must be granted [authorization scopes][auth-scopes] required for the desired Policy Simulator API APIs, and the authenticated principal must have the [IAM role(s)][predefined-iam-roles] required to access GCP resources using the Policy Simulator API API calls.
+
+## Getting Started
+
+### Prerequisites
+
+You will need a [Google Cloud Platform Console][developer-console] project with the Policy Simulator API [API enabled][enable-api].
+You will need to [enable billing][enable-billing] to use Google Policy Simulator API.
+[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by
+[installing the Google Cloud Command Line Interface][cloud-cli] and running the following commands in command line:
+`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
+
+### Installation and setup
+
+You'll need to obtain the `google-cloud-policysimulator` library. See the [Quickstart](#quickstart) section
+to add `google-cloud-policysimulator` as a dependency in your code.
+
+## About Policy Simulator API
+
+
+[Policy Simulator API][product-docs] Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay.
+
+See the [Policy Simulator API client library docs][javadocs] to learn how to
+use this Policy Simulator API Client Library.
+
+
+
+
+
+
+## Troubleshooting
+
+To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting].
+
+## Transport
+
+Policy Simulator API uses gRPC for the transport layer.
+
+## Supported Java Versions
+
+Java 8 or above is required for using this client.
+
+Google's Java client libraries,
+[Google Cloud Client Libraries][cloudlibs]
+and
+[Google Cloud API Libraries][apilibs],
+follow the
+[Oracle Java SE support roadmap][oracle]
+(see the Oracle Java SE Product Releases section).
+
+### For new development
+
+In general, new feature development occurs with support for the lowest Java
+LTS version covered by Oracle's Premier Support (which typically lasts 5 years
+from initial General Availability). If the minimum required JVM for a given
+library is changed, it is accompanied by a [semver][semver] major release.
+
+Java 11 and (in September 2021) Java 17 are the best choices for new
+development.
+
+### Keeping production systems current
+
+Google tests its client libraries with all current LTS versions covered by
+Oracle's Extended Support (which typically lasts 8 years from initial
+General Availability).
+
+#### Legacy support
+
+Google's client libraries support legacy versions of Java runtimes with long
+term stable libraries that don't receive feature updates on a best efforts basis
+as it may not be possible to backport all patches.
+
+Google provides updates on a best efforts basis to apps that continue to use
+Java 7, though apps might need to upgrade to current versions of the library
+that supports their JVM.
+
+#### Where to find specific information
+
+The latest versions and the supported Java versions are identified on
+the individual GitHub repository `github.com/GoogleAPIs/java-SERVICENAME`
+and on [google-cloud-java][g-c-j].
+
+## Versioning
+
+
+This library follows [Semantic Versioning](http://semver.org/).
+
+
+It is currently in major version zero (``0.y.z``), which means that anything may change at any time
+and the public API should not be considered stable.
+
+
+## Contributing
+
+
+Contributions to this library are always welcome and highly encouraged.
+
+See [CONTRIBUTING][contributing] for more information how to get started.
+
+Please note that this project is released with a Contributor Code of Conduct. By participating in
+this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more
+information.
+
+
+## License
+
+Apache 2.0 - See [LICENSE][license] for more information.
+
+## CI Status
+
+Java Version | Status
+------------ | ------
+Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2]
+Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3]
+Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4]
+Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5]
+
+Java is a registered trademark of Oracle and/or its affiliates.
+
+[product-docs]: https://cloud.google.com/policysimulator/docs/overview
+[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-policysimulator/latest/overview
+[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java7.svg
+[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java7.html
+[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java8.svg
+[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java8.html
+[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java8-osx.svg
+[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java8-osx.html
+[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java8-win.svg
+[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java8-win.html
+[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java11.svg
+[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-policysimulator/java11.html
+[stability-image]: https://img.shields.io/badge/stability-preview-yellow
+[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-policysimulator.svg
+[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-policysimulator/0.0.0
+[authentication]: https://github.com/googleapis/google-cloud-java#authentication
+[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
+[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
+[iam-policy]: https://cloud.google.com/iam/docs/overview#cloud-iam-policy
+[developer-console]: https://console.developers.google.com/
+[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
+[cloud-cli]: https://cloud.google.com/cli
+[troubleshooting]: https://github.com/googleapis/google-cloud-java/blob/main/TROUBLESHOOTING.md
+[contributing]: https://github.com/googleapis/java-policysimulator/blob/main/CONTRIBUTING.md
+[code-of-conduct]: https://github.com/googleapis/java-policysimulator/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct
+[license]: https://github.com/googleapis/java-policysimulator/blob/main/LICENSE
+[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
+[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=policysimulator.googleapis.com
+[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM
+[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
+
+[semver]: https://semver.org/
+[cloudlibs]: https://cloud.google.com/apis/docs/client-libraries-explained
+[apilibs]: https://cloud.google.com/apis/docs/client-libraries-explained#google_api_client_libraries
+[oracle]: https://www.oracle.com/java/technologies/java-se-support-roadmap.html
+[g-c-j]: http://github.com/googleapis/google-cloud-java
diff --git a/java-policysimulator/google-cloud-policysimulator-bom/pom.xml b/java-policysimulator/google-cloud-policysimulator-bom/pom.xml
new file mode 100644
index 000000000000..f397aec0a7e7
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator-bom/pom.xml
@@ -0,0 +1,44 @@
+
+
+ 4.0.0
+ com.google.cloud
+ google-cloud-policysimulator-bom
+ 0.0.1-SNAPSHOT
+ pom
+
+
+ com.google.cloud
+ google-cloud-pom-parent
+ 1.16.0-SNAPSHOT
+ ../../google-cloud-pom-parent/pom.xml
+
+
+ Google Policy Simulator API BOM
+
+ BOM for Policy Simulator API
+
+
+
+ true
+
+
+
+
+
+ com.google.cloud
+ google-cloud-policysimulator
+ 0.0.1-SNAPSHOT
+
+
+ com.google.api.grpc
+ grpc-google-cloud-policysimulator-v1
+ 0.0.1-SNAPSHOT
+
+
+ com.google.api.grpc
+ proto-google-cloud-policysimulator-v1
+ 0.0.1-SNAPSHOT
+
+
+
+
diff --git a/java-policysimulator/google-cloud-policysimulator/pom.xml b/java-policysimulator/google-cloud-policysimulator/pom.xml
new file mode 100644
index 000000000000..7c00bd853674
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/pom.xml
@@ -0,0 +1,113 @@
+
+
+ 4.0.0
+ com.google.cloud
+ google-cloud-policysimulator
+ 0.0.1-SNAPSHOT
+ jar
+ Google Policy Simulator API
+ Policy Simulator API Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay.
+
+ com.google.cloud
+ google-cloud-policysimulator-parent
+ 0.0.1-SNAPSHOT
+
+
+ google-cloud-policysimulator
+
+
+
+ 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-cloud-policysimulator-v1
+
+
+ com.google.guava
+ guava
+
+
+ com.google.api
+ gax
+
+
+ com.google.api
+ gax-grpc
+
+
+ com.google.api
+ gax-httpjson
+
+
+ com.google.api.grpc
+ grpc-google-common-protos
+
+
+ com.google.api.grpc
+ proto-google-iam-v1
+
+
+ com.google.api.grpc
+ grpc-google-iam-v1
+
+
+ org.threeten
+ threetenbp
+
+
+
+
+ junit
+ junit
+ test
+
+
+
+ com.google.api.grpc
+ grpc-google-cloud-policysimulator-v1
+ test
+
+
+
+ com.google.api
+ gax
+ testlib
+ test
+
+
+ com.google.api
+ gax-grpc
+ testlib
+ test
+
+
+ com.google.api
+ gax-httpjson
+ testlib
+ test
+
+
+
diff --git a/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/SimulatorClient.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/SimulatorClient.java
new file mode 100644
index 000000000000..2b000e53bb8c
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/SimulatorClient.java
@@ -0,0 +1,758 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1;
+
+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.httpjson.longrunning.OperationsClient;
+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.cloud.policysimulator.v1.stub.SimulatorStub;
+import com.google.cloud.policysimulator.v1.stub.SimulatorStubSettings;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.longrunning.Operation;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Service Description: Policy Simulator API service.
+ *
+ *
Policy Simulator is a collection of endpoints for creating, running, and viewing a
+ * [Replay][google.cloud.policysimulator.v1.Replay]. A
+ * [Replay][google.cloud.policysimulator.v1.Replay] is a type of simulation that lets you see how
+ * your principals' access to resources might change if you changed your IAM policy.
+ *
+ *
During a [Replay][google.cloud.policysimulator.v1.Replay], Policy Simulator re-evaluates, or
+ * replays, past access attempts under both the current policy and your proposed policy, and
+ * compares those results to determine how your principals' access might change under the proposed
+ * policy.
+ *
+ *
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 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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ReplayName name =
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]");
+ * Replay response = simulatorClient.getReplay(name);
+ * }
+ * }
+ *
+ *
Note: close() needs to be called on the SimulatorClient 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 SimulatorSettings to create().
+ * For example:
+ *
+ *
To customize credentials:
+ *
+ *
{@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
+ * SimulatorSettings simulatorSettings =
+ * SimulatorSettings.newBuilder()
+ * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ * .build();
+ * SimulatorClient simulatorClient = SimulatorClient.create(simulatorSettings);
+ * }
+ *
+ *
To customize the endpoint:
+ *
+ *
{@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
+ * SimulatorSettings simulatorSettings =
+ * SimulatorSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * SimulatorClient simulatorClient = SimulatorClient.create(simulatorSettings);
+ * }
+ *
+ *
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
+ * the wire:
+ *
+ *
{@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
+ * SimulatorSettings simulatorSettings = SimulatorSettings.newHttpJsonBuilder().build();
+ * SimulatorClient simulatorClient = SimulatorClient.create(simulatorSettings);
+ * }
+ *
+ *
Please refer to the GitHub repository's samples for more quickstart code snippets.
+ */
+@Generated("by gapic-generator-java")
+public class SimulatorClient implements BackgroundResource {
+ private final SimulatorSettings settings;
+ private final SimulatorStub stub;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
+
+ /** Constructs an instance of SimulatorClient with default settings. */
+ public static final SimulatorClient create() throws IOException {
+ return create(SimulatorSettings.newBuilder().build());
+ }
+
+ /**
+ * Constructs an instance of SimulatorClient, 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 SimulatorClient create(SimulatorSettings settings) throws IOException {
+ return new SimulatorClient(settings);
+ }
+
+ /**
+ * Constructs an instance of SimulatorClient, using the given stub for making calls. This is for
+ * advanced usage - prefer using create(SimulatorSettings).
+ */
+ public static final SimulatorClient create(SimulatorStub stub) {
+ return new SimulatorClient(stub);
+ }
+
+ /**
+ * Constructs an instance of SimulatorClient, 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 SimulatorClient(SimulatorSettings settings) throws IOException {
+ this.settings = settings;
+ this.stub = ((SimulatorStubSettings) settings.getStubSettings()).createStub();
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
+ }
+
+ protected SimulatorClient(SimulatorStub stub) {
+ this.settings = null;
+ this.stub = stub;
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
+ }
+
+ public final SimulatorSettings getSettings() {
+ return settings;
+ }
+
+ public SimulatorStub 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 com.google.longrunning.OperationsClient getOperationsClient() {
+ return operationsClient;
+ }
+
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ @BetaApi
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each `Replay` is available
+ * for at least 7 days.
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ReplayName name =
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]");
+ * Replay response = simulatorClient.getReplay(name);
+ * }
+ * }
+ *
+ * @param name Required. The name of the [Replay][google.cloud.policysimulator.v1.Replay] to
+ * retrieve, in the following format:
+ *
`{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`,
+ * where `{resource-id}` is the ID of the project, folder, or organization that owns the
+ * `Replay`.
+ *
Example:
+ * `projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Replay getReplay(ReplayName name) {
+ GetReplayRequest request =
+ GetReplayRequest.newBuilder().setName(name == null ? null : name.toString()).build();
+ return getReplay(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each `Replay` is available
+ * for at least 7 days.
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * String name =
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]").toString();
+ * Replay response = simulatorClient.getReplay(name);
+ * }
+ * }
+ *
+ * @param name Required. The name of the [Replay][google.cloud.policysimulator.v1.Replay] to
+ * retrieve, in the following format:
+ *
`{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`,
+ * where `{resource-id}` is the ID of the project, folder, or organization that owns the
+ * `Replay`.
+ *
Example:
+ * `projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final Replay getReplay(String name) {
+ GetReplayRequest request = GetReplayRequest.newBuilder().setName(name).build();
+ return getReplay(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each `Replay` is available
+ * for at least 7 days.
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * GetReplayRequest request =
+ * GetReplayRequest.newBuilder()
+ * .setName(
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]")
+ * .toString())
+ * .build();
+ * Replay response = simulatorClient.getReplay(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 Replay getReplay(GetReplayRequest request) {
+ return getReplayCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Gets the specified [Replay][google.cloud.policysimulator.v1.Replay]. Each `Replay` is available
+ * for at least 7 days.
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * GetReplayRequest request =
+ * GetReplayRequest.newBuilder()
+ * .setName(
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]")
+ * .toString())
+ * .build();
+ * ApiFuture future = simulatorClient.getReplayCallable().futureCall(request);
+ * // Do something.
+ * Replay response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable getReplayCallable() {
+ return stub.getReplayCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using the given
+ * [ReplayConfig][google.cloud.policysimulator.v1.ReplayConfig].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * String parent = "parent-995424086";
+ * Replay replay = Replay.newBuilder().build();
+ * Replay response = simulatorClient.createReplayAsync(parent, replay).get();
+ * }
+ * }
+ *
+ * @param parent Required. The parent resource where this
+ * [Replay][google.cloud.policysimulator.v1.Replay] will be created. This resource must be a
+ * project, folder, or organization with a location.
+ *
Example: `projects/my-example-project/locations/global`
+ * @param replay Required. The [Replay][google.cloud.policysimulator.v1.Replay] to create. Set
+ * `Replay.ReplayConfig` to configure the replay.
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final OperationFuture createReplayAsync(
+ String parent, Replay replay) {
+ CreateReplayRequest request =
+ CreateReplayRequest.newBuilder().setParent(parent).setReplay(replay).build();
+ return createReplayAsync(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using the given
+ * [ReplayConfig][google.cloud.policysimulator.v1.ReplayConfig].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * CreateReplayRequest request =
+ * CreateReplayRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setReplay(Replay.newBuilder().build())
+ * .build();
+ * Replay response = simulatorClient.createReplayAsync(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 createReplayAsync(
+ CreateReplayRequest request) {
+ return createReplayOperationCallable().futureCall(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using the given
+ * [ReplayConfig][google.cloud.policysimulator.v1.ReplayConfig].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * CreateReplayRequest request =
+ * CreateReplayRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setReplay(Replay.newBuilder().build())
+ * .build();
+ * OperationFuture future =
+ * simulatorClient.createReplayOperationCallable().futureCall(request);
+ * // Do something.
+ * Replay response = future.get();
+ * }
+ * }
+ */
+ public final OperationCallable
+ createReplayOperationCallable() {
+ return stub.createReplayOperationCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Creates and starts a [Replay][google.cloud.policysimulator.v1.Replay] using the given
+ * [ReplayConfig][google.cloud.policysimulator.v1.ReplayConfig].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * CreateReplayRequest request =
+ * CreateReplayRequest.newBuilder()
+ * .setParent("parent-995424086")
+ * .setReplay(Replay.newBuilder().build())
+ * .build();
+ * ApiFuture future = simulatorClient.createReplayCallable().futureCall(request);
+ * // Do something.
+ * Operation response = future.get();
+ * }
+ * }
+ */
+ public final UnaryCallable createReplayCallable() {
+ return stub.createReplayCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ReplayName parent =
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]");
+ * for (ReplayResult element : simulatorClient.listReplayResults(parent).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param parent Required. The [Replay][google.cloud.policysimulator.v1.Replay] whose results are
+ * listed, in the following format:
+ *
Example:
+ * `projects/my-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListReplayResultsPagedResponse listReplayResults(ReplayName parent) {
+ ListReplayResultsRequest request =
+ ListReplayResultsRequest.newBuilder()
+ .setParent(parent == null ? null : parent.toString())
+ .build();
+ return listReplayResults(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * String parent =
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]").toString();
+ * for (ReplayResult element : simulatorClient.listReplayResults(parent).iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ *
+ * @param parent Required. The [Replay][google.cloud.policysimulator.v1.Replay] whose results are
+ * listed, in the following format:
+ *
Example:
+ * `projects/my-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails
+ */
+ public final ListReplayResultsPagedResponse listReplayResults(String parent) {
+ ListReplayResultsRequest request =
+ ListReplayResultsRequest.newBuilder().setParent(parent).build();
+ return listReplayResults(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ListReplayResultsRequest request =
+ * ListReplayResultsRequest.newBuilder()
+ * .setParent(
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]")
+ * .toString())
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * for (ReplayResult element : simulatorClient.listReplayResults(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 ListReplayResultsPagedResponse listReplayResults(ListReplayResultsRequest request) {
+ return listReplayResultsPagedCallable().call(request);
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ListReplayResultsRequest request =
+ * ListReplayResultsRequest.newBuilder()
+ * .setParent(
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]")
+ * .toString())
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * ApiFuture future =
+ * simulatorClient.listReplayResultsPagedCallable().futureCall(request);
+ * // Do something.
+ * for (ReplayResult element : future.get().iterateAll()) {
+ * // doThingsWith(element);
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable
+ listReplayResultsPagedCallable() {
+ return stub.listReplayResultsPagedCallable();
+ }
+
+ // AUTO-GENERATED DOCUMENTATION AND METHOD.
+ /**
+ * Lists the results of running a [Replay][google.cloud.policysimulator.v1.Replay].
+ *
+ *
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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ListReplayResultsRequest request =
+ * ListReplayResultsRequest.newBuilder()
+ * .setParent(
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]")
+ * .toString())
+ * .setPageSize(883849137)
+ * .setPageToken("pageToken873572522")
+ * .build();
+ * while (true) {
+ * ListReplayResultsResponse response =
+ * simulatorClient.listReplayResultsCallable().call(request);
+ * for (ReplayResult element : response.getReplayResultsList()) {
+ * // doThingsWith(element);
+ * }
+ * String nextPageToken = response.getNextPageToken();
+ * if (!Strings.isNullOrEmpty(nextPageToken)) {
+ * request = request.toBuilder().setPageToken(nextPageToken).build();
+ * } else {
+ * break;
+ * }
+ * }
+ * }
+ * }
+ */
+ public final UnaryCallable
+ listReplayResultsCallable() {
+ return stub.listReplayResultsCallable();
+ }
+
+ @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 ListReplayResultsPagedResponse
+ extends AbstractPagedListResponse<
+ ListReplayResultsRequest,
+ ListReplayResultsResponse,
+ ReplayResult,
+ ListReplayResultsPage,
+ ListReplayResultsFixedSizeCollection> {
+
+ public static ApiFuture createAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ ApiFuture futurePage =
+ ListReplayResultsPage.createEmptyPage().createPageAsync(context, futureResponse);
+ return ApiFutures.transform(
+ futurePage,
+ input -> new ListReplayResultsPagedResponse(input),
+ MoreExecutors.directExecutor());
+ }
+
+ private ListReplayResultsPagedResponse(ListReplayResultsPage page) {
+ super(page, ListReplayResultsFixedSizeCollection.createEmptyCollection());
+ }
+ }
+
+ public static class ListReplayResultsPage
+ extends AbstractPage<
+ ListReplayResultsRequest,
+ ListReplayResultsResponse,
+ ReplayResult,
+ ListReplayResultsPage> {
+
+ private ListReplayResultsPage(
+ PageContext context,
+ ListReplayResultsResponse response) {
+ super(context, response);
+ }
+
+ private static ListReplayResultsPage createEmptyPage() {
+ return new ListReplayResultsPage(null, null);
+ }
+
+ @Override
+ protected ListReplayResultsPage createPage(
+ PageContext context,
+ ListReplayResultsResponse response) {
+ return new ListReplayResultsPage(context, response);
+ }
+
+ @Override
+ public ApiFuture createPageAsync(
+ PageContext context,
+ ApiFuture futureResponse) {
+ return super.createPageAsync(context, futureResponse);
+ }
+ }
+
+ public static class ListReplayResultsFixedSizeCollection
+ extends AbstractFixedSizeCollection<
+ ListReplayResultsRequest,
+ ListReplayResultsResponse,
+ ReplayResult,
+ ListReplayResultsPage,
+ ListReplayResultsFixedSizeCollection> {
+
+ private ListReplayResultsFixedSizeCollection(
+ List pages, int collectionSize) {
+ super(pages, collectionSize);
+ }
+
+ private static ListReplayResultsFixedSizeCollection createEmptyCollection() {
+ return new ListReplayResultsFixedSizeCollection(null, 0);
+ }
+
+ @Override
+ protected ListReplayResultsFixedSizeCollection createCollection(
+ List pages, int collectionSize) {
+ return new ListReplayResultsFixedSizeCollection(pages, collectionSize);
+ }
+ }
+}
diff --git a/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/SimulatorSettings.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/SimulatorSettings.java
new file mode 100644
index 000000000000..e9e1e6aea6fd
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/SimulatorSettings.java
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1;
+
+import static com.google.cloud.policysimulator.v1.SimulatorClient.ListReplayResultsPagedResponse;
+
+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.cloud.policysimulator.v1.stub.SimulatorStubSettings;
+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 SimulatorClient}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (policysimulator.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 getReplay 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
+ * SimulatorSettings.Builder simulatorSettingsBuilder = SimulatorSettings.newBuilder();
+ * simulatorSettingsBuilder
+ * .getReplaySettings()
+ * .setRetrySettings(
+ * simulatorSettingsBuilder
+ * .getReplaySettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * SimulatorSettings simulatorSettings = simulatorSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class SimulatorSettings extends ClientSettings {
+
+ /** Returns the object with the settings used for calls to getReplay. */
+ public UnaryCallSettings getReplaySettings() {
+ return ((SimulatorStubSettings) getStubSettings()).getReplaySettings();
+ }
+
+ /** Returns the object with the settings used for calls to createReplay. */
+ public UnaryCallSettings createReplaySettings() {
+ return ((SimulatorStubSettings) getStubSettings()).createReplaySettings();
+ }
+
+ /** Returns the object with the settings used for calls to createReplay. */
+ public OperationCallSettings
+ createReplayOperationSettings() {
+ return ((SimulatorStubSettings) getStubSettings()).createReplayOperationSettings();
+ }
+
+ /** Returns the object with the settings used for calls to listReplayResults. */
+ public PagedCallSettings<
+ ListReplayResultsRequest, ListReplayResultsResponse, ListReplayResultsPagedResponse>
+ listReplayResultsSettings() {
+ return ((SimulatorStubSettings) getStubSettings()).listReplayResultsSettings();
+ }
+
+ public static final SimulatorSettings create(SimulatorStubSettings stub) throws IOException {
+ return new SimulatorSettings.Builder(stub.toBuilder()).build();
+ }
+
+ /** Returns a builder for the default ExecutorProvider for this service. */
+ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
+ return SimulatorStubSettings.defaultExecutorProviderBuilder();
+ }
+
+ /** Returns the default service endpoint. */
+ public static String getDefaultEndpoint() {
+ return SimulatorStubSettings.getDefaultEndpoint();
+ }
+
+ /** Returns the default service scopes. */
+ public static List getDefaultServiceScopes() {
+ return SimulatorStubSettings.getDefaultServiceScopes();
+ }
+
+ /** Returns a builder for the default credentials for this service. */
+ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
+ return SimulatorStubSettings.defaultCredentialsProviderBuilder();
+ }
+
+ /** Returns a builder for the default gRPC ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return SimulatorStubSettings.defaultGrpcTransportProviderBuilder();
+ }
+
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return SimulatorStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
+ public static TransportChannelProvider defaultTransportChannelProvider() {
+ return SimulatorStubSettings.defaultTransportChannelProvider();
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return SimulatorStubSettings.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 SimulatorSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+ }
+
+ /** Builder for SimulatorSettings. */
+ public static class Builder extends ClientSettings.Builder {
+
+ protected Builder() throws IOException {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(SimulatorStubSettings.newBuilder(clientContext));
+ }
+
+ protected Builder(SimulatorSettings settings) {
+ super(settings.getStubSettings().toBuilder());
+ }
+
+ protected Builder(SimulatorStubSettings.Builder stubSettings) {
+ super(stubSettings);
+ }
+
+ private static Builder createDefault() {
+ return new Builder(SimulatorStubSettings.newBuilder());
+ }
+
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(SimulatorStubSettings.newHttpJsonBuilder());
+ }
+
+ public SimulatorStubSettings.Builder getStubSettingsBuilder() {
+ return ((SimulatorStubSettings.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 getReplay. */
+ public UnaryCallSettings.Builder getReplaySettings() {
+ return getStubSettingsBuilder().getReplaySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createReplay. */
+ public UnaryCallSettings.Builder createReplaySettings() {
+ return getStubSettingsBuilder().createReplaySettings();
+ }
+
+ /** Returns the builder for the settings used for calls to createReplay. */
+ public OperationCallSettings.Builder
+ createReplayOperationSettings() {
+ return getStubSettingsBuilder().createReplayOperationSettings();
+ }
+
+ /** Returns the builder for the settings used for calls to listReplayResults. */
+ public PagedCallSettings.Builder<
+ ListReplayResultsRequest, ListReplayResultsResponse, ListReplayResultsPagedResponse>
+ listReplayResultsSettings() {
+ return getStubSettingsBuilder().listReplayResultsSettings();
+ }
+
+ @Override
+ public SimulatorSettings build() throws IOException {
+ return new SimulatorSettings(this);
+ }
+ }
+}
diff --git a/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/gapic_metadata.json b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/gapic_metadata.json
new file mode 100644
index 000000000000..c0d7ff8eb0bc
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/gapic_metadata.json
@@ -0,0 +1,27 @@
+{
+ "schema": "1.0",
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "java",
+ "protoPackage": "google.cloud.policysimulator.v1",
+ "libraryPackage": "com.google.cloud.policysimulator.v1",
+ "services": {
+ "Simulator": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "SimulatorClient",
+ "rpcs": {
+ "CreateReplay": {
+ "methods": ["createReplayAsync", "createReplayAsync", "createReplayOperationCallable", "createReplayCallable"]
+ },
+ "GetReplay": {
+ "methods": ["getReplay", "getReplay", "getReplay", "getReplayCallable"]
+ },
+ "ListReplayResults": {
+ "methods": ["listReplayResults", "listReplayResults", "listReplayResults", "listReplayResultsPagedCallable", "listReplayResultsCallable"]
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/package-info.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/package-info.java
new file mode 100644
index 000000000000..3a62af133b09
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/package-info.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2023 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 Policy Simulator API
+ *
+ *
The interfaces provided are listed below, along with usage samples.
+ *
+ *
Service Description: Policy Simulator API service.
+ *
+ *
Policy Simulator is a collection of endpoints for creating, running, and viewing a
+ * [Replay][google.cloud.policysimulator.v1.Replay]. A
+ * [Replay][google.cloud.policysimulator.v1.Replay] is a type of simulation that lets you see how
+ * your principals' access to resources might change if you changed your IAM policy.
+ *
+ *
During a [Replay][google.cloud.policysimulator.v1.Replay], Policy Simulator re-evaluates, or
+ * replays, past access attempts under both the current policy and your proposed policy, and
+ * compares those results to determine how your principals' access might change under the proposed
+ * policy.
+ *
+ *
Sample for SimulatorClient:
+ *
+ *
{@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 (SimulatorClient simulatorClient = SimulatorClient.create()) {
+ * ReplayName name =
+ * ReplayName.ofProjectLocationReplayName("[PROJECT]", "[LOCATION]", "[REPLAY]");
+ * Replay response = simulatorClient.getReplay(name);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.cloud.policysimulator.v1;
+
+import javax.annotation.Generated;
diff --git a/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/GrpcSimulatorCallableFactory.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/GrpcSimulatorCallableFactory.java
new file mode 100644
index 000000000000..f012672673b2
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/GrpcSimulatorCallableFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1.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 Simulator service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcSimulatorCallableFactory 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/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/GrpcSimulatorStub.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/GrpcSimulatorStub.java
new file mode 100644
index 000000000000..27ccd29c7d16
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/GrpcSimulatorStub.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1.stub;
+
+import static com.google.cloud.policysimulator.v1.SimulatorClient.ListReplayResultsPagedResponse;
+
+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.RequestParamsBuilder;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.policysimulator.v1.CreateReplayRequest;
+import com.google.cloud.policysimulator.v1.GetReplayRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsResponse;
+import com.google.cloud.policysimulator.v1.Replay;
+import com.google.cloud.policysimulator.v1.ReplayOperationMetadata;
+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 Simulator service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public class GrpcSimulatorStub extends SimulatorStub {
+ private static final MethodDescriptor getReplayMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.policysimulator.v1.Simulator/GetReplay")
+ .setRequestMarshaller(ProtoUtils.marshaller(GetReplayRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Replay.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ createReplayMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.policysimulator.v1.Simulator/CreateReplay")
+ .setRequestMarshaller(ProtoUtils.marshaller(CreateReplayRequest.getDefaultInstance()))
+ .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
+ .build();
+
+ private static final MethodDescriptor
+ listReplayResultsMethodDescriptor =
+ MethodDescriptor.newBuilder()
+ .setType(MethodDescriptor.MethodType.UNARY)
+ .setFullMethodName("google.cloud.policysimulator.v1.Simulator/ListReplayResults")
+ .setRequestMarshaller(
+ ProtoUtils.marshaller(ListReplayResultsRequest.getDefaultInstance()))
+ .setResponseMarshaller(
+ ProtoUtils.marshaller(ListReplayResultsResponse.getDefaultInstance()))
+ .build();
+
+ private final UnaryCallable getReplayCallable;
+ private final UnaryCallable createReplayCallable;
+ private final OperationCallable
+ createReplayOperationCallable;
+ private final UnaryCallable
+ listReplayResultsCallable;
+ private final UnaryCallable
+ listReplayResultsPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final GrpcOperationsStub operationsStub;
+ private final GrpcStubCallableFactory callableFactory;
+
+ public static final GrpcSimulatorStub create(SimulatorStubSettings settings) throws IOException {
+ return new GrpcSimulatorStub(settings, ClientContext.create(settings));
+ }
+
+ public static final GrpcSimulatorStub create(ClientContext clientContext) throws IOException {
+ return new GrpcSimulatorStub(SimulatorStubSettings.newBuilder().build(), clientContext);
+ }
+
+ public static final GrpcSimulatorStub create(
+ ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
+ return new GrpcSimulatorStub(
+ SimulatorStubSettings.newBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of GrpcSimulatorStub, 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 GrpcSimulatorStub(SimulatorStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new GrpcSimulatorCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of GrpcSimulatorStub, 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 GrpcSimulatorStub(
+ SimulatorStubSettings settings,
+ ClientContext clientContext,
+ GrpcStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
+
+ GrpcCallSettings getReplayTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(getReplayMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("name", String.valueOf(request.getName()));
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings createReplayTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(createReplayMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+ GrpcCallSettings
+ listReplayResultsTransportSettings =
+ GrpcCallSettings.newBuilder()
+ .setMethodDescriptor(listReplayResultsMethodDescriptor)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+
+ this.getReplayCallable =
+ callableFactory.createUnaryCallable(
+ getReplayTransportSettings, settings.getReplaySettings(), clientContext);
+ this.createReplayCallable =
+ callableFactory.createUnaryCallable(
+ createReplayTransportSettings, settings.createReplaySettings(), clientContext);
+ this.createReplayOperationCallable =
+ callableFactory.createOperationCallable(
+ createReplayTransportSettings,
+ settings.createReplayOperationSettings(),
+ clientContext,
+ operationsStub);
+ this.listReplayResultsCallable =
+ callableFactory.createUnaryCallable(
+ listReplayResultsTransportSettings,
+ settings.listReplayResultsSettings(),
+ clientContext);
+ this.listReplayResultsPagedCallable =
+ callableFactory.createPagedCallable(
+ listReplayResultsTransportSettings,
+ settings.listReplayResultsSettings(),
+ clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ public GrpcOperationsStub getOperationsStub() {
+ return operationsStub;
+ }
+
+ @Override
+ public UnaryCallable getReplayCallable() {
+ return getReplayCallable;
+ }
+
+ @Override
+ public UnaryCallable createReplayCallable() {
+ return createReplayCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createReplayOperationCallable() {
+ return createReplayOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listReplayResultsCallable() {
+ return listReplayResultsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listReplayResultsPagedCallable() {
+ return listReplayResultsPagedCallable;
+ }
+
+ @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/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/HttpJsonSimulatorCallableFactory.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/HttpJsonSimulatorCallableFactory.java
new file mode 100644
index 000000000000..a1a144d8a753
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/HttpJsonSimulatorCallableFactory.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1.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 Simulator service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonSimulatorCallableFactory
+ 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/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/HttpJsonSimulatorStub.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/HttpJsonSimulatorStub.java
new file mode 100644
index 000000000000..6c3c519c8ec6
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/HttpJsonSimulatorStub.java
@@ -0,0 +1,420 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1.stub;
+
+import static com.google.cloud.policysimulator.v1.SimulatorClient.ListReplayResultsPagedResponse;
+
+import com.google.api.HttpRule;
+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.RequestParamsBuilder;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.policysimulator.v1.CreateReplayRequest;
+import com.google.cloud.policysimulator.v1.GetReplayRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsResponse;
+import com.google.cloud.policysimulator.v1.Replay;
+import com.google.cloud.policysimulator.v1.ReplayOperationMetadata;
+import com.google.common.collect.ImmutableMap;
+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 Simulator service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonSimulatorStub extends SimulatorStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(Replay.getDescriptor())
+ .add(ReplayOperationMetadata.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor getReplayMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.policysimulator.v1.Simulator/GetReplay")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/*/replays/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1/{name=folders/*/locations/*/replays/*}",
+ "/v1/{name=organizations/*/locations/*/replays/*}")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Replay.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createReplayMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.policysimulator.v1.Simulator/CreateReplay")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*}/replays",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1/{parent=folders/*/locations/*}/replays",
+ "/v1/{parent=organizations/*/locations/*}/replays")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("replay", request.getReplay(), true))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateReplayRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ listReplayResultsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName("google.cloud.policysimulator.v1.Simulator/ListReplayResults")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/*/replays/*}/results",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "parent", request.getParent());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1/{parent=folders/*/locations/*/replays/*}/results",
+ "/v1/{parent=organizations/*/locations/*/replays/*}/results")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListReplayResultsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable getReplayCallable;
+ private final UnaryCallable createReplayCallable;
+ private final OperationCallable
+ createReplayOperationCallable;
+ private final UnaryCallable
+ listReplayResultsCallable;
+ private final UnaryCallable
+ listReplayResultsPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonSimulatorStub create(SimulatorStubSettings settings)
+ throws IOException {
+ return new HttpJsonSimulatorStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonSimulatorStub create(ClientContext clientContext) throws IOException {
+ return new HttpJsonSimulatorStub(
+ SimulatorStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonSimulatorStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonSimulatorStub(
+ SimulatorStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonSimulatorStub, 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 HttpJsonSimulatorStub(SimulatorStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonSimulatorCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonSimulatorStub, 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 HttpJsonSimulatorStub(
+ SimulatorStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(
+ clientContext,
+ callableFactory,
+ typeRegistry,
+ ImmutableMap.builder()
+ .put(
+ "google.longrunning.Operations.GetOperation",
+ HttpRule.newBuilder()
+ .setGet("/v1/{name=operations/**}")
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet("/v1/{name=projects/*/locations/*/replays/*/operations/**}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet("/v1/{name=folders/*/locations/*/replays/*/operations/**}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=organizations/*/locations/*/replays/*/operations/**}")
+ .build())
+ .build())
+ .put(
+ "google.longrunning.Operations.ListOperations",
+ HttpRule.newBuilder()
+ .setGet("/v1/{name=operations}")
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet("/v1/{name=projects/*/locations/*/replays/*/operations}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet("/v1/{name=folders/*/locations/*/replays/*/operations}")
+ .build())
+ .addAdditionalBindings(
+ HttpRule.newBuilder()
+ .setGet(
+ "/v1/{name=organizations/*/locations/*/replays/*/operations}")
+ .build())
+ .build())
+ .build());
+
+ HttpJsonCallSettings getReplayTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getReplayMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("name", String.valueOf(request.getName()));
+ return builder.build();
+ })
+ .build();
+ HttpJsonCallSettings createReplayTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createReplayMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+ HttpJsonCallSettings
+ listReplayResultsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listReplayResultsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .setParamsExtractor(
+ request -> {
+ RequestParamsBuilder builder = RequestParamsBuilder.create();
+ builder.add("parent", String.valueOf(request.getParent()));
+ return builder.build();
+ })
+ .build();
+
+ this.getReplayCallable =
+ callableFactory.createUnaryCallable(
+ getReplayTransportSettings, settings.getReplaySettings(), clientContext);
+ this.createReplayCallable =
+ callableFactory.createUnaryCallable(
+ createReplayTransportSettings, settings.createReplaySettings(), clientContext);
+ this.createReplayOperationCallable =
+ callableFactory.createOperationCallable(
+ createReplayTransportSettings,
+ settings.createReplayOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.listReplayResultsCallable =
+ callableFactory.createUnaryCallable(
+ listReplayResultsTransportSettings,
+ settings.listReplayResultsSettings(),
+ clientContext);
+ this.listReplayResultsPagedCallable =
+ callableFactory.createPagedCallable(
+ listReplayResultsTransportSettings,
+ settings.listReplayResultsSettings(),
+ clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(getReplayMethodDescriptor);
+ methodDescriptors.add(createReplayMethodDescriptor);
+ methodDescriptors.add(listReplayResultsMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable getReplayCallable() {
+ return getReplayCallable;
+ }
+
+ @Override
+ public UnaryCallable createReplayCallable() {
+ return createReplayCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createReplayOperationCallable() {
+ return createReplayOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listReplayResultsCallable() {
+ return listReplayResultsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listReplayResultsPagedCallable() {
+ return listReplayResultsPagedCallable;
+ }
+
+ @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/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/SimulatorStub.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/SimulatorStub.java
new file mode 100644
index 000000000000..f70759deccbe
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/SimulatorStub.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1.stub;
+
+import static com.google.cloud.policysimulator.v1.SimulatorClient.ListReplayResultsPagedResponse;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.policysimulator.v1.CreateReplayRequest;
+import com.google.cloud.policysimulator.v1.GetReplayRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsResponse;
+import com.google.cloud.policysimulator.v1.Replay;
+import com.google.cloud.policysimulator.v1.ReplayOperationMetadata;
+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 Simulator service API.
+ *
+ *
This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class SimulatorStub implements BackgroundResource {
+
+ public OperationsStub getOperationsStub() {
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
+ }
+
+ public UnaryCallable getReplayCallable() {
+ throw new UnsupportedOperationException("Not implemented: getReplayCallable()");
+ }
+
+ public OperationCallable
+ createReplayOperationCallable() {
+ throw new UnsupportedOperationException("Not implemented: createReplayOperationCallable()");
+ }
+
+ public UnaryCallable createReplayCallable() {
+ throw new UnsupportedOperationException("Not implemented: createReplayCallable()");
+ }
+
+ public UnaryCallable
+ listReplayResultsPagedCallable() {
+ throw new UnsupportedOperationException("Not implemented: listReplayResultsPagedCallable()");
+ }
+
+ public UnaryCallable
+ listReplayResultsCallable() {
+ throw new UnsupportedOperationException("Not implemented: listReplayResultsCallable()");
+ }
+
+ @Override
+ public abstract void close();
+}
diff --git a/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/SimulatorStubSettings.java b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/SimulatorStubSettings.java
new file mode 100644
index 000000000000..3e82fe45f0ff
--- /dev/null
+++ b/java-policysimulator/google-cloud-policysimulator/src/main/java/com/google/cloud/policysimulator/v1/stub/SimulatorStubSettings.java
@@ -0,0 +1,509 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.policysimulator.v1.stub;
+
+import static com.google.cloud.policysimulator.v1.SimulatorClient.ListReplayResultsPagedResponse;
+
+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.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.HttpJsonTransportChannel;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
+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.cloud.policysimulator.v1.CreateReplayRequest;
+import com.google.cloud.policysimulator.v1.GetReplayRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsRequest;
+import com.google.cloud.policysimulator.v1.ListReplayResultsResponse;
+import com.google.cloud.policysimulator.v1.Replay;
+import com.google.cloud.policysimulator.v1.ReplayOperationMetadata;
+import com.google.cloud.policysimulator.v1.ReplayResult;
+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.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 SimulatorStub}.
+ *
+ *
The default instance has everything set to sensible defaults:
+ *
+ *
+ *
The default service address (policysimulator.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 getReplay 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
+ * SimulatorStubSettings.Builder simulatorSettingsBuilder = SimulatorStubSettings.newBuilder();
+ * simulatorSettingsBuilder
+ * .getReplaySettings()
+ * .setRetrySettings(
+ * simulatorSettingsBuilder
+ * .getReplaySettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * SimulatorStubSettings simulatorSettings = simulatorSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class SimulatorStubSettings 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 UnaryCallSettings getReplaySettings;
+ private final UnaryCallSettings createReplaySettings;
+ private final OperationCallSettings
+ createReplayOperationSettings;
+ private final PagedCallSettings<
+ ListReplayResultsRequest, ListReplayResultsResponse, ListReplayResultsPagedResponse>
+ listReplayResultsSettings;
+
+ private static final PagedListDescriptor<
+ ListReplayResultsRequest, ListReplayResultsResponse, ReplayResult>
+ LIST_REPLAY_RESULTS_PAGE_STR_DESC =
+ new PagedListDescriptor<
+ ListReplayResultsRequest, ListReplayResultsResponse, ReplayResult>() {
+ @Override
+ public String emptyToken() {
+ return "";
+ }
+
+ @Override
+ public ListReplayResultsRequest injectToken(
+ ListReplayResultsRequest payload, String token) {
+ return ListReplayResultsRequest.newBuilder(payload).setPageToken(token).build();
+ }
+
+ @Override
+ public ListReplayResultsRequest injectPageSize(
+ ListReplayResultsRequest payload, int pageSize) {
+ return ListReplayResultsRequest.newBuilder(payload).setPageSize(pageSize).build();
+ }
+
+ @Override
+ public Integer extractPageSize(ListReplayResultsRequest payload) {
+ return payload.getPageSize();
+ }
+
+ @Override
+ public String extractNextToken(ListReplayResultsResponse payload) {
+ return payload.getNextPageToken();
+ }
+
+ @Override
+ public Iterable extractResources(ListReplayResultsResponse payload) {
+ return payload.getReplayResultsList() == null
+ ? ImmutableList.of()
+ : payload.getReplayResultsList();
+ }
+ };
+
+ private static final PagedListResponseFactory<
+ ListReplayResultsRequest, ListReplayResultsResponse, ListReplayResultsPagedResponse>
+ LIST_REPLAY_RESULTS_PAGE_STR_FACT =
+ new PagedListResponseFactory<
+ ListReplayResultsRequest,
+ ListReplayResultsResponse,
+ ListReplayResultsPagedResponse>() {
+ @Override
+ public ApiFuture getFuturePagedResponse(
+ UnaryCallable callable,
+ ListReplayResultsRequest request,
+ ApiCallContext context,
+ ApiFuture futureResponse) {
+ PageContext
+ pageContext =
+ PageContext.create(
+ callable, LIST_REPLAY_RESULTS_PAGE_STR_DESC, request, context);
+ return ListReplayResultsPagedResponse.createAsync(pageContext, futureResponse);
+ }
+ };
+
+ /** Returns the object with the settings used for calls to getReplay. */
+ public UnaryCallSettings getReplaySettings() {
+ return getReplaySettings;
+ }
+
+ /** Returns the object with the settings used for calls to createReplay. */
+ public UnaryCallSettings createReplaySettings() {
+ return createReplaySettings;
+ }
+
+ /** Returns the object with the settings used for calls to createReplay. */
+ public OperationCallSettings
+ createReplayOperationSettings() {
+ return createReplayOperationSettings;
+ }
+
+ /** Returns the object with the settings used for calls to listReplayResults. */
+ public PagedCallSettings<
+ ListReplayResultsRequest, ListReplayResultsResponse, ListReplayResultsPagedResponse>
+ listReplayResultsSettings() {
+ return listReplayResultsSettings;
+ }
+
+ public SimulatorStub createStub() throws IOException {
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(GrpcTransportChannel.getGrpcTransportName())) {
+ return GrpcSimulatorStub.create(this);
+ }
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonSimulatorStub.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 "policysimulator.googleapis.com:443";
+ }
+
+ /** Returns the default mTLS service endpoint. */
+ public static String getDefaultMtlsEndpoint() {
+ return "policysimulator.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 gRPC ChannelProvider for this service. */
+ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
+ return InstantiatingGrpcChannelProvider.newBuilder()
+ .setMaxInboundMessageSize(Integer.MAX_VALUE);
+ }
+
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return InstantiatingHttpJsonChannelProvider.newBuilder();
+ }
+
+ 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 defaultGrpcApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SimulatorStubSettings.class))
+ .setTransportToken(
+ GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion());
+ }
+
+ @BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
+ public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() {
+ return ApiClientHeaderProvider.newBuilder()
+ .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(SimulatorStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return SimulatorStubSettings.defaultGrpcApiClientHeaderProviderBuilder();
+ }
+
+ /** Returns a new gRPC builder for this class. */
+ public static Builder newBuilder() {
+ return Builder.createDefault();
+ }
+
+ /** Returns a new REST builder for this class. */
+ 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 SimulatorStubSettings(Builder settingsBuilder) throws IOException {
+ super(settingsBuilder);
+
+ getReplaySettings = settingsBuilder.getReplaySettings().build();
+ createReplaySettings = settingsBuilder.createReplaySettings().build();
+ createReplayOperationSettings = settingsBuilder.createReplayOperationSettings().build();
+ listReplayResultsSettings = settingsBuilder.listReplayResultsSettings().build();
+ }
+
+ /** Builder for SimulatorStubSettings. */
+ public static class Builder extends StubSettings.Builder {
+ private final ImmutableList> unaryMethodSettingsBuilders;
+ private final UnaryCallSettings.Builder getReplaySettings;
+ private final UnaryCallSettings.Builder createReplaySettings;
+ private final OperationCallSettings.Builder<
+ CreateReplayRequest, Replay, ReplayOperationMetadata>
+ createReplayOperationSettings;
+ private final PagedCallSettings.Builder<
+ ListReplayResultsRequest, ListReplayResultsResponse, ListReplayResultsPagedResponse>
+ listReplayResultsSettings;
+ 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)));
+ definitions.put(
+ "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList()));
+ 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);
+ settings =
+ RetrySettings.newBuilder()
+ .setInitialRpcTimeout(Duration.ofMillis(60000L))
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ofMillis(60000L))
+ .setTotalTimeout(Duration.ofMillis(60000L))
+ .build();
+ definitions.put("no_retry_1_params", settings);
+ RETRY_PARAM_DEFINITIONS = definitions.build();
+ }
+
+ protected Builder() {
+ this(((ClientContext) null));
+ }
+
+ protected Builder(ClientContext clientContext) {
+ super(clientContext);
+
+ getReplaySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createReplaySettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+ createReplayOperationSettings = OperationCallSettings.newBuilder();
+ listReplayResultsSettings = PagedCallSettings.newBuilder(LIST_REPLAY_RESULTS_PAGE_STR_FACT);
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ getReplaySettings, createReplaySettings, listReplayResultsSettings);
+ initDefaults(this);
+ }
+
+ protected Builder(SimulatorStubSettings settings) {
+ super(settings);
+
+ getReplaySettings = settings.getReplaySettings.toBuilder();
+ createReplaySettings = settings.createReplaySettings.toBuilder();
+ createReplayOperationSettings = settings.createReplayOperationSettings.toBuilder();
+ listReplayResultsSettings = settings.listReplayResultsSettings.toBuilder();
+
+ unaryMethodSettingsBuilders =
+ ImmutableList.>of(
+ getReplaySettings, createReplaySettings, listReplayResultsSettings);
+ }
+
+ 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 createHttpJsonDefault() {
+ Builder builder = new Builder(((ClientContext) null));
+
+ builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build());
+ builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
+ builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build());
+ builder.setEndpoint(getDefaultEndpoint());
+ builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
+ builder.setSwitchToMtlsEndpointAllowed(true);
+
+ return initDefaults(builder);
+ }
+
+ private static Builder initDefaults(Builder builder) {
+ builder
+ .getReplaySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .createReplaySettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"));
+
+ builder
+ .listReplayResultsSettings()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params"));
+
+ builder
+ .createReplayOperationSettings()
+ .setInitialCallSettings(
+ UnaryCallSettings
+ .newUnaryCallSettingsBuilder()
+ .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes"))
+ .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params"))
+ .build())
+ .setResponseTransformer(
+ ProtoOperationTransformers.ResponseTransformer.create(Replay.class))
+ .setMetadataTransformer(
+ ProtoOperationTransformers.MetadataTransformer.create(ReplayOperationMetadata.class))
+ .setPollingAlgorithm(
+ OperationTimedPollAlgorithm.create(
+ RetrySettings.newBuilder()
+ .setInitialRetryDelay(Duration.ofMillis(1000L))
+ .setRetryDelayMultiplier(2.0)
+ .setMaxRetryDelay(Duration.ofMillis(10000L))
+ .setInitialRpcTimeout(Duration.ZERO)
+ .setRpcTimeoutMultiplier(1.0)
+ .setMaxRpcTimeout(Duration.ZERO)
+ .setTotalTimeout(Duration.ofMillis(18000000L))
+ .build()));
+
+ return builder;
+ }
+
+ /**
+ * Applies the given settings updater function to all of the unary API methods in this service.
+ *
+ *