From d269d853f52005bcbe45dbde3e94a576b5679d38 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:48:12 +0000 Subject: [PATCH 01/18] chore(main): release 1.119.2-SNAPSHOT (#1159) :robot: I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- google-cloud-pubsub-bom/pom.xml | 8 ++++---- google-cloud-pubsub/pom.xml | 4 ++-- grpc-google-cloud-pubsub-v1/pom.xml | 4 ++-- pom.xml | 8 ++++---- proto-google-cloud-pubsub-v1/pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/google-cloud-pubsub-bom/pom.xml b/google-cloud-pubsub-bom/pom.xml index 0b01639ba..63a5ac4dc 100644 --- a/google-cloud-pubsub-bom/pom.xml +++ b/google-cloud-pubsub-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-pubsub-bom - 1.119.1 + 1.119.2-SNAPSHOT pom com.google.cloud @@ -52,17 +52,17 @@ com.google.cloud google-cloud-pubsub - 1.119.1 + 1.119.2-SNAPSHOT com.google.api.grpc grpc-google-cloud-pubsub-v1 - 1.101.1 + 1.101.2-SNAPSHOT com.google.api.grpc proto-google-cloud-pubsub-v1 - 1.101.1 + 1.101.2-SNAPSHOT diff --git a/google-cloud-pubsub/pom.xml b/google-cloud-pubsub/pom.xml index d36b93d8d..323ccef69 100644 --- a/google-cloud-pubsub/pom.xml +++ b/google-cloud-pubsub/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-pubsub - 1.119.1 + 1.119.2-SNAPSHOT jar Google Cloud Pub/Sub https://github.com/googleapis/java-pubsub @@ -11,7 +11,7 @@ com.google.cloud google-cloud-pubsub-parent - 1.119.1 + 1.119.2-SNAPSHOT google-cloud-pubsub diff --git a/grpc-google-cloud-pubsub-v1/pom.xml b/grpc-google-cloud-pubsub-v1/pom.xml index e6212cf0b..8e5edf0b9 100644 --- a/grpc-google-cloud-pubsub-v1/pom.xml +++ b/grpc-google-cloud-pubsub-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-pubsub-v1 - 1.101.1 + 1.101.2-SNAPSHOT grpc-google-cloud-pubsub-v1 GRPC library for grpc-google-cloud-pubsub-v1 com.google.cloud google-cloud-pubsub-parent - 1.119.1 + 1.119.2-SNAPSHOT diff --git a/pom.xml b/pom.xml index c9ad18afc..a6f2a5ba4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-pubsub-parent pom - 1.119.1 + 1.119.2-SNAPSHOT Google Cloud Pub/Sub Parent https://github.com/googleapis/java-pubsub @@ -69,17 +69,17 @@ com.google.api.grpc proto-google-cloud-pubsub-v1 - 1.101.1 + 1.101.2-SNAPSHOT com.google.api.grpc grpc-google-cloud-pubsub-v1 - 1.101.1 + 1.101.2-SNAPSHOT com.google.cloud google-cloud-pubsub - 1.119.1 + 1.119.2-SNAPSHOT diff --git a/proto-google-cloud-pubsub-v1/pom.xml b/proto-google-cloud-pubsub-v1/pom.xml index ad43ac99e..638cab637 100644 --- a/proto-google-cloud-pubsub-v1/pom.xml +++ b/proto-google-cloud-pubsub-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-pubsub-v1 - 1.101.1 + 1.101.2-SNAPSHOT proto-google-cloud-pubsub-v1 PROTO library for proto-google-cloud-pubsub-v1 com.google.cloud google-cloud-pubsub-parent - 1.119.1 + 1.119.2-SNAPSHOT diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 511e0ebd5..ac9337294 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -43,7 +43,7 @@ com.google.cloud google-cloud-pubsub - 1.119.1 + 1.119.2-SNAPSHOT diff --git a/versions.txt b/versions.txt index d6109180f..fcbfea377 100644 --- a/versions.txt +++ b/versions.txt @@ -1,6 +1,6 @@ # Format: # module:released-version:current-version -google-cloud-pubsub:1.119.1:1.119.1 -grpc-google-cloud-pubsub-v1:1.101.1:1.101.1 -proto-google-cloud-pubsub-v1:1.101.1:1.101.1 +google-cloud-pubsub:1.119.1:1.119.2-SNAPSHOT +grpc-google-cloud-pubsub-v1:1.101.1:1.101.2-SNAPSHOT +proto-google-cloud-pubsub-v1:1.101.1:1.101.2-SNAPSHOT From c38a0be115f5f966f6292117af7b55e49cc698cc Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 9 Jun 2022 22:49:09 +0200 Subject: [PATCH 02/18] chore(deps): update dependency com.google.cloud:google-cloud-pubsub to v1.119.1 (#1161) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update dependency com.google.cloud:google-cloud-pubsub to v1.119.1 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- README.md | 6 +++--- samples/install-without-bom/pom.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f6110faa6..909bd6e80 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-pubsub - 1.119.0 + 1.119.1 ``` @@ -58,13 +58,13 @@ implementation 'com.google.cloud:google-cloud-pubsub' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-pubsub:1.119.0' +implementation 'com.google.cloud:google-cloud-pubsub:1.119.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.119.0" +libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.119.1" ``` ## Authentication diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 6dac3dbbc..6a4fe37f7 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -44,7 +44,7 @@ com.google.cloud google-cloud-pubsub - 1.119.0 + 1.119.1 From 4956abfbcfcade340c39c887644488a68baa1d22 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 9 Jun 2022 16:50:00 -0400 Subject: [PATCH 03/18] chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 (#1149) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 PiperOrigin-RevId: 450543911 Source-Link: https://github.com/googleapis/googleapis/commit/55283447ab72f10b6c2571d770af0498b593e84f Source-Link: https://github.com/googleapis/googleapis-gen/commit/9f6775cab1958982b88967a43e5e806af0f135db Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWY2Nzc1Y2FiMTk1ODk4MmI4ODk2N2E0M2U1ZTgwNmFmMGYxMzVkYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../java/com/google/cloud/pubsub/v1/SchemaServiceClient.java | 4 ---- .../com/google/cloud/pubsub/v1/SubscriptionAdminClient.java | 4 ---- .../java/com/google/cloud/pubsub/v1/TopicAdminClient.java | 4 ---- .../google/cloud/pubsub/v1/stub/PublisherStubSettings.java | 1 - .../cloud/pubsub/v1/stub/SchemaServiceStubSettings.java | 1 - .../google/cloud/pubsub/v1/stub/SubscriberStubSettings.java | 1 - 6 files changed, 15 deletions(-) diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java index 3ab408e71..f8e0922a4 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java @@ -18,7 +18,6 @@ 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.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -142,7 +141,6 @@ public static final SchemaServiceClient create(SchemaServiceSettings settings) * Constructs an instance of SchemaServiceClient, using the given stub for making calls. This is * for advanced usage - prefer using create(SchemaServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final SchemaServiceClient create(SchemaServiceStub stub) { return new SchemaServiceClient(stub); } @@ -157,7 +155,6 @@ protected SchemaServiceClient(SchemaServiceSettings settings) throws IOException this.stub = ((SchemaServiceStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected SchemaServiceClient(SchemaServiceStub stub) { this.settings = null; this.stub = stub; @@ -167,7 +164,6 @@ public final SchemaServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SchemaServiceStub getStub() { return stub; } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java index f65dba119..1772a7307 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java @@ -18,7 +18,6 @@ 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.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -168,7 +167,6 @@ public static final SubscriptionAdminClient create(SubscriptionAdminSettings set * Constructs an instance of SubscriptionAdminClient, using the given stub for making calls. This * is for advanced usage - prefer using create(SubscriptionAdminSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final SubscriptionAdminClient create(SubscriberStub stub) { return new SubscriptionAdminClient(stub); } @@ -183,7 +181,6 @@ protected SubscriptionAdminClient(SubscriptionAdminSettings settings) throws IOE this.stub = ((SubscriberStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected SubscriptionAdminClient(SubscriberStub stub) { this.settings = null; this.stub = stub; @@ -193,7 +190,6 @@ public final SubscriptionAdminSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SubscriberStub getStub() { return stub; } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java index 0aa458c06..9b3032269 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java @@ -18,7 +18,6 @@ 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.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -146,7 +145,6 @@ public static final TopicAdminClient create(TopicAdminSettings settings) throws * Constructs an instance of TopicAdminClient, using the given stub for making calls. This is for * advanced usage - prefer using create(TopicAdminSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final TopicAdminClient create(PublisherStub stub) { return new TopicAdminClient(stub); } @@ -160,7 +158,6 @@ protected TopicAdminClient(TopicAdminSettings settings) throws IOException { this.stub = ((PublisherStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected TopicAdminClient(PublisherStub stub) { this.settings = null; this.stub = stub; @@ -170,7 +167,6 @@ public final TopicAdminSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public PublisherStub getStub() { return stub; } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java index aaeb343d3..dd5a99740 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java @@ -458,7 +458,6 @@ public UnaryCallSettings getIamPolicySettings() { return testIamPermissionsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public PublisherStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java index a7d8fc4ae..963e9b7ce 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java @@ -222,7 +222,6 @@ public UnaryCallSettings getIamPolicySettings() { return testIamPermissionsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SchemaServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java index 11a87f726..e94378b17 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java @@ -363,7 +363,6 @@ public UnaryCallSettings getIamPolicySettings() { return testIamPermissionsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public SubscriberStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() From f5aa8f802747de1aee0c47f4a80ce4ae54fc616f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 13 Jun 2022 18:58:30 +0200 Subject: [PATCH 04/18] build(deps): update dependency com.google.cloud:google-cloud-shared-config to v1.5.0 (#1163) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-shared-config](https://togithub.com/googleapis/java-shared-config) | `1.4.0` -> `1.5.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.5.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.5.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.5.0/compatibility-slim/1.4.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-config/1.5.0/confidence-slim/1.4.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-shared-config ### [`v1.5.0`](https://togithub.com/googleapis/java-shared-config/blob/HEAD/CHANGELOG.md#​150-httpsgithubcomgoogleapisjava-shared-configcomparev140v150-2022-06-10) [Compare Source](https://togithub.com/googleapis/java-shared-config/compare/v1.4.0...v1.5.0) ##### Features - add build scripts for native image testing in Java 17 ([#​1440](https://togithub.com/googleapis/java-shared-config/issues/1440)) ([#​475](https://togithub.com/googleapis/java-shared-config/issues/475)) ([e4dfc1b](https://togithub.com/googleapis/java-shared-config/commit/e4dfc1ba29295158c78c8fcf94467d2a6a33538a)) - to produce Java 8 compatible bytecode when using JDK 9+ ([2468276](https://togithub.com/googleapis/java-shared-config/commit/2468276145cdfe1ca911b52f765e026e77661a09)) ##### Dependencies - update surefire.version to v3.0.0-m7 ([bbfe663](https://togithub.com/googleapis/java-shared-config/commit/bbfe66393af3e49612c9c1e4334ba39c133ea1d0))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- google-cloud-pubsub-bom/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google-cloud-pubsub-bom/pom.xml b/google-cloud-pubsub-bom/pom.xml index 63a5ac4dc..84e67f52e 100644 --- a/google-cloud-pubsub-bom/pom.xml +++ b/google-cloud-pubsub-bom/pom.xml @@ -8,7 +8,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google Cloud pubsub BOM diff --git a/pom.xml b/pom.xml index a6f2a5ba4..4e9174882 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 From 890987c0b285c9c5a5224f676e070ceefb90fe02 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 15 Jun 2022 15:19:59 -0400 Subject: [PATCH 05/18] docs(sample): clean up README of native image sample (#1166) --- samples/native-image-sample/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/samples/native-image-sample/README.md b/samples/native-image-sample/README.md index ace93bd8e..5f0cd31e9 100644 --- a/samples/native-image-sample/README.md +++ b/samples/native-image-sample/README.md @@ -18,25 +18,25 @@ You will need to follow these prerequisite steps in order to run the samples: **Note:** Authenticating with Application Default Credentials is convenient to use during development, but we recommend [alternate methods of authentication](https://cloud.google.com/docs/authentication/production) during production use. -3. Install the GraalVM compiler. +3. Install the native image compiler. - You can follow the [official installation instructions](https://www.graalvm.org/docs/getting-started/#install-graalvm) from the GraalVM website. + You can follow the [official installation instructions](https://www.graalvm.org/docs/getting-started/#install-graalvm). After following the instructions, ensure that you install the native image extension installed by running: ``` gu install native-image ``` - Once you finish following the instructions, verify that the default version of Java is set to the GraalVM version by running `java -version` in a terminal. + Once you finish following the instructions, verify that the default version of Java is set to the correct version by running `java -version` in a terminal. You will see something similar to the below output: ``` $ java -version - openjdk version "11.0.7" 2020-04-14 - OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02) - OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing) + openjdk version "17.0.3" 2022-04-19 + OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06) + OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 17.0.3+7-jvmci-22.1-b06, mixed mode, sharing) ``` 4. [Enable the Pub/Sub APIs](https://console.cloud.google.com/apis/api/pubsub.googleapis.com). @@ -74,4 +74,4 @@ In order to run the sample integration test as a native image, call the followin ``` mvn test -Pnative - ``` \ No newline at end of file + ``` From e8e93e6c47e2c0a3546453a3aa23263ff3878a55 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 22 Jun 2022 02:06:23 +0200 Subject: [PATCH 06/18] deps: update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 (#1169) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.graalvm.buildtools:junit-platform-native](https://togithub.com/graalvm/native-build-tools) | `0.9.11` -> `0.9.12` | [![age](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:junit-platform-native/0.9.12/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:junit-platform-native/0.9.12/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:junit-platform-native/0.9.12/compatibility-slim/0.9.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:junit-platform-native/0.9.12/confidence-slim/0.9.11)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
graalvm/native-build-tools ### [`v0.9.12`](https://togithub.com/graalvm/native-build-tools/releases/tag/0.9.12) [Compare Source](https://togithub.com/graalvm/native-build-tools/compare/0.9.11...0.9.12) ##### What's Changed Read what's new in the [documentation](https://graalvm.github.io/native-build-tools/latest/index.html#changelog). - Add Mockito / Byte Buddy support documentation by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/236](https://togithub.com/graalvm/native-build-tools/pull/236) - Prevent builds from failing if no test list is present by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/239](https://togithub.com/graalvm/native-build-tools/pull/239) - Support different agent modes in the native-image Gradle plugin by [@​gradinac](https://togithub.com/gradinac) in [https://github.com/graalvm/native-build-tools/pull/230](https://togithub.com/graalvm/native-build-tools/pull/230) - JVM Reachability Metadata support for Maven by [@​alvarosanchez](https://togithub.com/alvarosanchez) in [https://github.com/graalvm/native-build-tools/pull/240](https://togithub.com/graalvm/native-build-tools/pull/240) - Warn about deprecated agent DSL by [@​gradinac](https://togithub.com/gradinac) in [https://github.com/graalvm/native-build-tools/pull/242](https://togithub.com/graalvm/native-build-tools/pull/242) - Rework Maven plugin by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/247](https://togithub.com/graalvm/native-build-tools/pull/247) - Add Gradle rich output support, configure default metadata URL on Maven by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/249](https://togithub.com/graalvm/native-build-tools/pull/249) - Fix wrong scope for test dependencies by [@​melix](https://togithub.com/melix) in [https://github.com/graalvm/native-build-tools/pull/251](https://togithub.com/graalvm/native-build-tools/pull/251) - Add documentation for alternative build systems. by [@​gradinac](https://togithub.com/gradinac) in [https://github.com/graalvm/native-build-tools/pull/248](https://togithub.com/graalvm/native-build-tools/pull/248) **Full Changelog**: https://github.com/graalvm/native-build-tools/compare/0.9.11...0.9.12
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- samples/native-image-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/native-image-sample/pom.xml b/samples/native-image-sample/pom.xml index 543ba126e..2c1ddcaa7 100644 --- a/samples/native-image-sample/pom.xml +++ b/samples/native-image-sample/pom.xml @@ -113,7 +113,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.graalvm.buildtools junit-platform-native - 0.9.11 + 0.9.12 test
From 1327e89e2e491afe0b05fb458bbea296a8ae101f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 22 Jun 2022 02:06:31 +0200 Subject: [PATCH 07/18] deps: update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 (#1170) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.graalvm.buildtools:native-maven-plugin](https://togithub.com/graalvm/native-build-tools) | `0.9.11` -> `0.9.12` | [![age](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:native-maven-plugin/0.9.12/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:native-maven-plugin/0.9.12/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:native-maven-plugin/0.9.12/compatibility-slim/0.9.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.graalvm.buildtools:native-maven-plugin/0.9.12/confidence-slim/0.9.11)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
graalvm/native-build-tools ### [`v0.9.12`](https://togithub.com/graalvm/native-build-tools/releases/tag/0.9.12) [Compare Source](https://togithub.com/graalvm/native-build-tools/compare/0.9.11...0.9.12) ##### What's Changed Read what's new in the [documentation](https://graalvm.github.io/native-build-tools/latest/index.html#changelog). - Add Mockito / Byte Buddy support documentation by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/236](https://togithub.com/graalvm/native-build-tools/pull/236) - Prevent builds from failing if no test list is present by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/239](https://togithub.com/graalvm/native-build-tools/pull/239) - Support different agent modes in the native-image Gradle plugin by [@​gradinac](https://togithub.com/gradinac) in [https://github.com/graalvm/native-build-tools/pull/230](https://togithub.com/graalvm/native-build-tools/pull/230) - JVM Reachability Metadata support for Maven by [@​alvarosanchez](https://togithub.com/alvarosanchez) in [https://github.com/graalvm/native-build-tools/pull/240](https://togithub.com/graalvm/native-build-tools/pull/240) - Warn about deprecated agent DSL by [@​gradinac](https://togithub.com/gradinac) in [https://github.com/graalvm/native-build-tools/pull/242](https://togithub.com/graalvm/native-build-tools/pull/242) - Rework Maven plugin by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/247](https://togithub.com/graalvm/native-build-tools/pull/247) - Add Gradle rich output support, configure default metadata URL on Maven by [@​lazar-mitrovic](https://togithub.com/lazar-mitrovic) in [https://github.com/graalvm/native-build-tools/pull/249](https://togithub.com/graalvm/native-build-tools/pull/249) - Fix wrong scope for test dependencies by [@​melix](https://togithub.com/melix) in [https://github.com/graalvm/native-build-tools/pull/251](https://togithub.com/graalvm/native-build-tools/pull/251) - Add documentation for alternative build systems. by [@​gradinac](https://togithub.com/gradinac) in [https://github.com/graalvm/native-build-tools/pull/248](https://togithub.com/graalvm/native-build-tools/pull/248) **Full Changelog**: https://github.com/graalvm/native-build-tools/compare/0.9.11...0.9.12
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- samples/native-image-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/native-image-sample/pom.xml b/samples/native-image-sample/pom.xml index 2c1ddcaa7..23c0fe428 100644 --- a/samples/native-image-sample/pom.xml +++ b/samples/native-image-sample/pom.xml @@ -134,7 +134,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.graalvm.buildtools native-maven-plugin - 0.9.11 + 0.9.12 true pubsub.NativeImagePubSubSample From 4b7888f582752982e2c9e1fd03472f5172fa9910 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 22 Jun 2022 02:46:12 +0200 Subject: [PATCH 08/18] deps: update dependency com.google.cloud:google-cloud-core to v2.8.0 (#1171) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-core](https://togithub.com/googleapis/java-core) | `2.7.1` -> `2.8.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.0/compatibility-slim/2.7.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.0/confidence-slim/2.7.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-core ### [`v2.8.0`](https://togithub.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#​280-httpsgithubcomgoogleapisjava-corecomparev271v280-2022-06-21) [Compare Source](https://togithub.com/googleapis/java-core/compare/v2.7.1...v2.8.0) ##### Features - add build scripts for native image testing in Java 17 ([#​1440](https://togithub.com/googleapis/java-core/issues/1440)) ([#​836](https://togithub.com/googleapis/java-core/issues/836)) ([8826d9b](https://togithub.com/googleapis/java-core/commit/8826d9bc05eb9e4a54c40e8578de85ed79c50e99)) ##### Dependencies - update dependency com.google.api-client:google-api-client-bom to v1.35.1 ([#​843](https://togithub.com/googleapis/java-core/issues/843)) ([9ffe0c5](https://togithub.com/googleapis/java-core/commit/9ffe0c5b25761abf7ff1bea091aa1db057dff2d0)) - update dependency com.google.api:api-common to v2.2.1 ([#​844](https://togithub.com/googleapis/java-core/issues/844)) ([69dde56](https://togithub.com/googleapis/java-core/commit/69dde5641546b678a385b1ed3a2c7a020f81d285)) - update dependency com.google.api:gax-bom to v2.18.2 ([#​849](https://togithub.com/googleapis/java-core/issues/849)) ([11764b0](https://togithub.com/googleapis/java-core/commit/11764b04629c5bfbc9b0d68174782cc126dc1646)) - update dependency com.google.api.grpc:proto-google-common-protos to v2.9.0 ([#​846](https://togithub.com/googleapis/java-core/issues/846)) ([5dced6d](https://togithub.com/googleapis/java-core/commit/5dced6d25ce0f3e7587d7ac1f6f3713f3b2a18c2)) - update dependency com.google.api.grpc:proto-google-iam-v1 to v1.4.0 ([#​838](https://togithub.com/googleapis/java-core/issues/838)) ([b0a7afe](https://togithub.com/googleapis/java-core/commit/b0a7afe342a5e15436d439b9cc1e3c58f894ab66)) - update dependency com.google.api.grpc:proto-google-iam-v1 to v1.4.1 ([#​848](https://togithub.com/googleapis/java-core/issues/848)) ([8260997](https://togithub.com/googleapis/java-core/commit/826099767b0aabe0db26eff2f612f0847b451366)) - update dependency com.google.errorprone:error_prone_annotations to v2.14.0 ([#​839](https://togithub.com/googleapis/java-core/issues/839)) ([3459fb6](https://togithub.com/googleapis/java-core/commit/3459fb668557b982cef5682ce47d3c978b83d69c)) - update dependency com.google.http-client:google-http-client-bom to v1.42.0 ([#​845](https://togithub.com/googleapis/java-core/issues/845)) ([2d2c873](https://togithub.com/googleapis/java-core/commit/2d2c873e274b26f4687d569cc3b8ae58c3c5ed54)) - update dependency com.google.protobuf:protobuf-bom to v3.21.0 ([#​840](https://togithub.com/googleapis/java-core/issues/840)) ([037da15](https://togithub.com/googleapis/java-core/commit/037da15b2aed1719e768ba5b4e001caf25952adc)) - update dependency com.google.protobuf:protobuf-bom to v3.21.1 ([#​841](https://togithub.com/googleapis/java-core/issues/841)) ([04b8862](https://togithub.com/googleapis/java-core/commit/04b886224128f1525ad8398815dc62dac87680af)) - update dependency io.grpc:grpc-bom to v1.47.0 ([#​842](https://togithub.com/googleapis/java-core/issues/842)) ([40984e2](https://togithub.com/googleapis/java-core/commit/40984e23242ba954b6ca741ca3f02ec89e92ae57)) ##### [2.7.1](https://togithub.com/googleapis/java-core/compare/v2.7.0...v2.7.1) (2022-05-19) ##### Dependencies - update dependency com.google.api:gax-bom to v2.18.1 ([#​833](https://togithub.com/googleapis/java-core/issues/833)) ([7541115](https://togithub.com/googleapis/java-core/commit/7541115095e0ae28d938a4c9621fd0f82892fe55))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- samples/install-without-bom/pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- samples/snippets/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 6a4fe37f7..3b87aef9c 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -80,7 +80,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 tests
diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index ac9337294..20a028bb4 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -79,7 +79,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 tests diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 5f968168a..100ea779e 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -90,7 +90,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 tests From d965075f25537f36f0d4e63841982a7fbfdd438f Mon Sep 17 00:00:00 2001 From: Kamal Aboul-Hosn Date: Wed, 22 Jun 2022 12:29:11 -0400 Subject: [PATCH 09/18] samples: create BigQuery subscription (#1168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Add flow control support to publisher * make suggested fixes * chore: Remove note that ordering keys requires enablements. * feat: Add support for server-side flow control * Revert "chore: Remove note that ordering keys requires enablements." This reverts commit 9c113c3e32c28cf0d1de8aad3409b5c509fb1ada. * fix: Fix import order * fix: Make error message more clear about where ordering must be enabled when publishing. * fix: Ensure that messages that are in pending batches for an ordering key are canceled when a previous publish for the ordering keys fails. * fix: Only check keyHasError if ordering keys is non-empty * fix: Set publish timeouts to be consistent with desired values * samples: create BigQuery subscription * samples: create BigQuery subscription * samples: create BigQuery subscription * Make table ID more clear * Fix string * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Fix pom and test creation/teardown * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- README.md | 3 +- samples/install-without-bom/pom.xml | 5 ++ samples/snapshot/pom.xml | 5 ++ samples/snippets/pom.xml | 8 ++- .../CreateBigQuerySubscriptionExample.java | 62 +++++++++++++++++++ .../src/test/java/pubsub/AdminIT.java | 57 +++++++++++++++++ 6 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 samples/snippets/src/main/java/pubsub/CreateBigQuerySubscriptionExample.java diff --git a/README.md b/README.md index 909bd6e80..8cddd9ef4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -243,6 +243,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-pubsub/tree/m | Native Image Pub Sub Sample | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/native-image-sample/src/main/java/pubsub/NativeImagePubSubSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/native-image-sample/src/main/java/pubsub/NativeImagePubSubSample.java) | | Publish Operations | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/native-image-sample/src/main/java/utilities/PublishOperations.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/native-image-sample/src/main/java/utilities/PublishOperations.java) | | Create Avro Schema Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateAvroSchemaExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateAvroSchemaExample.java) | +| Create Big Query Subscription Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateBigQuerySubscriptionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateBigQuerySubscriptionExample.java) | | Create Proto Schema Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateProtoSchemaExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateProtoSchemaExample.java) | | Create Pull Subscription Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreatePullSubscriptionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreatePullSubscriptionExample.java) | | Create Push Subscription Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreatePushSubscriptionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreatePushSubscriptionExample.java) | diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 3b87aef9c..1504afe90 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -83,6 +83,11 @@ 2.8.0 tests + + com.google.cloud + google-cloud-bigquery + 2.13.3 + diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 20a028bb4..59313662f 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -82,6 +82,11 @@ 2.8.0 tests + + com.google.cloud + google-cloud-bigquery + 2.13.3 + diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 100ea779e..dcba12955 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -45,7 +45,7 @@ com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -57,8 +57,12 @@ com.google.cloud google-cloud-pubsub - + + + com.google.cloud + google-cloud-bigquery + org.apache.avro avro diff --git a/samples/snippets/src/main/java/pubsub/CreateBigQuerySubscriptionExample.java b/samples/snippets/src/main/java/pubsub/CreateBigQuerySubscriptionExample.java new file mode 100644 index 000000000..002b6ef1f --- /dev/null +++ b/samples/snippets/src/main/java/pubsub/CreateBigQuerySubscriptionExample.java @@ -0,0 +1,62 @@ +/* + * 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. + */ + +package pubsub; + +// [START pubsub_create_bigquery_subscription] +import com.google.cloud.pubsub.v1.SubscriptionAdminClient; +import com.google.pubsub.v1.BigQueryConfig; +import com.google.pubsub.v1.ProjectSubscriptionName; +import com.google.pubsub.v1.ProjectTopicName; +import com.google.pubsub.v1.Subscription; +import java.io.IOException; + +public class CreateBigQuerySubscriptionExample { + public static void main(String... args) throws Exception { + // TODO(developer): Replace these variables before running the sample. + String projectId = "your-project-id"; + String topicId = "your-topic-id"; + String subscriptionId = "your-subscription-id"; + String bigqueryTableId = "your-project.your-dataset.your-table"; + + createBigQuerySubscription(projectId, topicId, subscriptionId, bigqueryTableId); + } + + public static void createBigQuerySubscription( + String projectId, String topicId, String subscriptionId, String bigqueryTableId) + throws IOException { + try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { + + ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId); + ProjectSubscriptionName subscriptionName = + ProjectSubscriptionName.of(projectId, subscriptionId); + + BigQueryConfig bigqueryConfig = + BigQueryConfig.newBuilder().setTable(bigqueryTableId).setWriteMetadata(true).build(); + + Subscription subscription = + subscriptionAdminClient.createSubscription( + Subscription.newBuilder() + .setName(subscriptionName.toString()) + .setTopic(topicName.toString()) + .setBigqueryConfig(bigqueryConfig) + .build()); + + System.out.println("Created a BigQuery subscription: " + subscription.getAllFields()); + } + } +} +// [END pubsub_create_bigquery_subscription] diff --git a/samples/snippets/src/test/java/pubsub/AdminIT.java b/samples/snippets/src/test/java/pubsub/AdminIT.java index b84751e0a..e42c81290 100644 --- a/samples/snippets/src/test/java/pubsub/AdminIT.java +++ b/samples/snippets/src/test/java/pubsub/AdminIT.java @@ -20,6 +20,17 @@ import static junit.framework.TestCase.assertNotNull; import com.google.api.gax.rpc.NotFoundException; +import com.google.cloud.bigquery.BigQuery; +import com.google.cloud.bigquery.BigQueryOptions; +import com.google.cloud.bigquery.DatasetId; +import com.google.cloud.bigquery.DatasetInfo; +import com.google.cloud.bigquery.Field; +import com.google.cloud.bigquery.Schema; +import com.google.cloud.bigquery.StandardSQLTypeName; +import com.google.cloud.bigquery.StandardTableDefinition; +import com.google.cloud.bigquery.TableDefinition; +import com.google.cloud.bigquery.TableId; +import com.google.cloud.bigquery.TableInfo; import com.google.cloud.pubsub.v1.SubscriptionAdminClient; import com.google.cloud.pubsub.v1.TopicAdminClient; import com.google.pubsub.v1.SubscriptionName; @@ -48,6 +59,10 @@ public class AdminIT { private static final String exactlyOnceSubscriptionId = "iam-exactly-once-subscription-" + _suffix; private static final String pushEndpoint = "https://my-test-project.appspot.com/push"; + private static final String bigqueryDatasetId = + "java_samples_data_set" + _suffix.replace("-", "_"); + private static final String bigquerySubscriptionId = "iam-bigquery-subscription-" + _suffix; + private static final String bigqueryTableId = "java_samples_table_" + _suffix; private static final TopicName topicName = TopicName.of(projectId, topicId); private static final SubscriptionName pullSubscriptionName = @@ -79,6 +94,9 @@ public void setUp() throws Exception { bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); + + // Create table for BigQuery subscription. + createBigQueryTable(); } @After @@ -102,9 +120,39 @@ public void tearDown() throws Exception { } catch (NotFoundException ignored) { // ignore this as resources may not have been created } + + // Delete BigQuery table. + deleteBigQueryTable(); + System.setOut(null); } + private void createBigQueryTable() throws Exception { + BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); + DatasetInfo datasetInfo = DatasetInfo.newBuilder(projectId, bigqueryDatasetId).build(); + bigquery.create(datasetInfo); + + Schema schema = + Schema.of( + Field.of("data", StandardSQLTypeName.STRING), + Field.of("message_id", StandardSQLTypeName.STRING), + Field.of("attributes", StandardSQLTypeName.STRING), + Field.of("subscription_name", StandardSQLTypeName.STRING), + Field.of("publish_time", StandardSQLTypeName.TIMESTAMP)); + + TableId tableId = TableId.of(projectId, bigqueryDatasetId, bigqueryTableId); + TableDefinition tableDefinition = StandardTableDefinition.of(schema); + TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build(); + + bigquery.create(tableInfo); + } + + private void deleteBigQueryTable() throws Exception { + BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); + DatasetId datasetId = DatasetId.of(projectId, bigqueryDatasetId); + bigquery.delete(datasetId, BigQuery.DatasetDeleteOption.deleteContents()); + } + @Test public void testAdmin() throws Exception { // Test create topic. @@ -208,12 +256,21 @@ public void testAdmin() throws Exception { .contains("Created a subscription with exactly once delivery enabled:"); assertThat(bout.toString()).contains("enable_exactly_once_delivery=true"); + bout.reset(); + // Test create a BigQuery subscription + String bigqueryTablePath = String.join(".", projectId, bigqueryDatasetId, bigqueryTableId); + CreateBigQuerySubscriptionExample.createBigQuerySubscription( + projectId, topicId, bigquerySubscriptionId, bigqueryTablePath); + assertThat(bout.toString()).contains("Created a BigQuery subscription:"); + assertThat(bout.toString()).contains(bigqueryTablePath); + bout.reset(); // Test delete subscription. DeleteSubscriptionExample.deleteSubscriptionExample(projectId, pullSubscriptionId); DeleteSubscriptionExample.deleteSubscriptionExample(projectId, pushSubscriptionId); DeleteSubscriptionExample.deleteSubscriptionExample(projectId, orderedSubscriptionId); DeleteSubscriptionExample.deleteSubscriptionExample(projectId, exactlyOnceSubscriptionId); + DeleteSubscriptionExample.deleteSubscriptionExample(projectId, bigquerySubscriptionId); assertThat(bout.toString()).contains("Deleted subscription."); bout.reset(); From 51f4da048e298e6184e9a6bf931a9f1307534c61 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 23 Jun 2022 18:12:24 +0200 Subject: [PATCH 10/18] deps: update dependency com.google.cloud:google-cloud-bigquery to v2.13.5 (#1172) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-bigquery](https://togithub.com/googleapis/java-bigquery) | `2.13.3` -> `2.13.5` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.5/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.5/compatibility-slim/2.13.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.5/confidence-slim/2.13.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigquery ### [`v2.13.5`](https://togithub.com/googleapis/java-bigquery/blob/HEAD/CHANGELOG.md#​2135-httpsgithubcomgoogleapisjava-bigquerycomparev2134v2135-2022-06-23) [Compare Source](https://togithub.com/googleapis/java-bigquery/compare/v2.13.4...v2.13.5) ##### Dependencies - update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#​2128](https://togithub.com/googleapis/java-bigquery/issues/2128)) ([3043533](https://togithub.com/googleapis/java-bigquery/commit/3043533608c5659be0313f1942d20314d2157fd4)) ### [`v2.13.4`](https://togithub.com/googleapis/java-bigquery/blob/HEAD/CHANGELOG.md#​2134-httpsgithubcomgoogleapisjava-bigquerycomparev2133v2134-2022-06-22) [Compare Source](https://togithub.com/googleapis/java-bigquery/compare/v2.13.3...v2.13.4) ##### Dependencies - update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 ([#​2124](https://togithub.com/googleapis/java-bigquery/issues/2124)) ([4542ce9](https://togithub.com/googleapis/java-bigquery/commit/4542ce9a51d9756a8a06d0e33cf3a40d1e321ade)) - update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 ([#​2125](https://togithub.com/googleapis/java-bigquery/issues/2125)) ([6da965f](https://togithub.com/googleapis/java-bigquery/commit/6da965f540a2cdb2eaf845301cfbfbf34b9a6866))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- samples/install-without-bom/pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 1504afe90..8480feb93 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -86,7 +86,7 @@ com.google.cloud google-cloud-bigquery - 2.13.3 + 2.13.5 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 59313662f..59689bf22 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -85,7 +85,7 @@ com.google.cloud google-cloud-bigquery - 2.13.3 + 2.13.5 From acfd55c1087007124b44480e8671be4c323df40a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 23 Jun 2022 18:14:36 +0200 Subject: [PATCH 11/18] chore(deps): update dependency com.google.cloud:libraries-bom to v25.4.0 (#1158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/GoogleCloudPlatform/cloud-opensource-java)) | `25.3.0` -> `25.4.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.4.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.4.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.4.0/compatibility-slim/25.3.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/25.4.0/confidence-slim/25.3.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- samples/native-image-sample/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/native-image-sample/pom.xml b/samples/native-image-sample/pom.xml index 23c0fe428..c07efee5a 100644 --- a/samples/native-image-sample/pom.xml +++ b/samples/native-image-sample/pom.xml @@ -30,7 +30,7 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import From 938545266b6b15f93fe82aa253b55ca4d4fd7e22 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 24 Jun 2022 17:06:22 +0200 Subject: [PATCH 12/18] deps: update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 (#1175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-bigquery](https://togithub.com/googleapis/java-bigquery) | `2.13.5` -> `2.13.6` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.6/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.6/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.6/compatibility-slim/2.13.5)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-bigquery/2.13.6/confidence-slim/2.13.5)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-bigquery ### [`v2.13.6`](https://togithub.com/googleapis/java-bigquery/blob/HEAD/CHANGELOG.md#​2136-httpsgithubcomgoogleapisjava-bigquerycomparev2135v2136-2022-06-24) [Compare Source](https://togithub.com/googleapis/java-bigquery/compare/v2.13.5...v2.13.6) ##### Dependencies - update dependency com.google.apis:google-api-services-bigquery to v2-rev20220611-1.32.1 ([#​2132](https://togithub.com/googleapis/java-bigquery/issues/2132)) ([bddefcf](https://togithub.com/googleapis/java-bigquery/commit/bddefcf647d50ee12fffea80c04613b38b8d02d0)) - update dependency com.google.cloud:google-cloud-datacatalog-bom to v1.8.3 ([#​2135](https://togithub.com/googleapis/java-bigquery/issues/2135)) ([0bd5ddc](https://togithub.com/googleapis/java-bigquery/commit/0bd5ddc0df0a978692252e50c37c94f41a3c4e1d))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- samples/install-without-bom/pom.xml | 2 +- samples/snapshot/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 8480feb93..230725486 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -86,7 +86,7 @@ com.google.cloud google-cloud-bigquery - 2.13.5 + 2.13.6 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 59689bf22..511502a0c 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -85,7 +85,7 @@ com.google.cloud google-cloud-bigquery - 2.13.5 + 2.13.6 From c8ebb1319b7714c03308d8e7af53912b6b6a0d44 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 24 Jun 2022 12:10:09 -0400 Subject: [PATCH 13/18] feat: Enable REST transport for most of Java and Go clients (#1162) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Integrate new gapic-generator-java and rules_gapic PiperOrigin-RevId: 454027580 Source-Link: https://github.com/googleapis/googleapis/commit/1b222777baa702e7135610355706570ed2b56318 Source-Link: https://github.com/googleapis/googleapis-gen/commit/e04cea20d0d12eb5c3bdb360a9e72b654edcb638 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTA0Y2VhMjBkMGQxMmViNWMzYmRiMzYwYTllNzJiNjU0ZWRjYjYzOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Enable REST transport for most of Java and Go clients PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update pom.xml Co-authored-by: Owl Bot Co-authored-by: Neenu Shaji --- google-cloud-pubsub/pom.xml | 16 + .../cloud/pubsub/v1/SchemaServiceClient.java | 28 +- .../pubsub/v1/SchemaServiceSettings.java | 23 +- .../pubsub/v1/SubscriptionAdminClient.java | 31 +- .../pubsub/v1/SubscriptionAdminSettings.java | 23 +- .../cloud/pubsub/v1/TopicAdminClient.java | 32 +- .../cloud/pubsub/v1/TopicAdminSettings.java | 23 +- .../HttpJsonPublisherCallableFactory.java | 105 + .../pubsub/v1/stub/HttpJsonPublisherStub.java | 825 +++++++ .../HttpJsonSchemaServiceCallableFactory.java | 105 + .../v1/stub/HttpJsonSchemaServiceStub.java | 639 ++++++ .../HttpJsonSubscriberCallableFactory.java | 105 + .../v1/stub/HttpJsonSubscriberStub.java | 1124 ++++++++++ .../pubsub/v1/stub/PublisherStubSettings.java | 52 +- .../v1/stub/SchemaServiceStubSettings.java | 53 +- .../v1/stub/SubscriberStubSettings.java | 53 +- .../v1/SchemaServiceClientHttpJsonTest.java | 764 +++++++ .../pubsub/v1/SchemaServiceClientTest.java | 12 +- .../SubscriptionAdminClientHttpJsonTest.java | 1966 +++++++++++++++++ .../v1/SubscriptionAdminClientTest.java | 13 +- .../v1/TopicAdminClientHttpJsonTest.java | 1060 +++++++++ .../cloud/pubsub/v1/TopicAdminClientTest.java | 13 +- 22 files changed, 7008 insertions(+), 57 deletions(-) create mode 100644 google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherCallableFactory.java create mode 100644 google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherStub.java create mode 100644 google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceCallableFactory.java create mode 100644 google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceStub.java create mode 100644 google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberCallableFactory.java create mode 100644 google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberStub.java create mode 100644 google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientHttpJsonTest.java create mode 100644 google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientHttpJsonTest.java create mode 100644 google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientHttpJsonTest.java diff --git a/google-cloud-pubsub/pom.xml b/google-cloud-pubsub/pom.xml index 323ccef69..395ba8898 100644 --- a/google-cloud-pubsub/pom.xml +++ b/google-cloud-pubsub/pom.xml @@ -65,6 +65,10 @@ com.google.api gax-grpc
+ + com.google.api + gax-httpjson + org.threeten threetenbp @@ -136,12 +140,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java index f8e0922a4..0877de078 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceClient.java @@ -116,6 +116,20 @@ * SchemaServiceClient schemaServiceClient = SchemaServiceClient.create(schemaServiceSettings); * } * + *

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 for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SchemaServiceSettings schemaServiceSettings =
+ *     SchemaServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SchemaServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SchemaServiceClient schemaServiceClient = SchemaServiceClient.create(schemaServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -531,7 +545,7 @@ public final ListSchemasPagedResponse listSchemas(ListSchemasRequest request) { * .build(); * while (true) { * ListSchemasResponse response = schemaServiceClient.listSchemasCallable().call(request); - * for (Schema element : response.getResponsesList()) { + * for (Schema element : response.getSchemasList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -825,7 +839,7 @@ public final ValidateMessageResponse validateMessage(ValidateMessageRequest requ * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -854,7 +868,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -881,7 +895,7 @@ public final UnaryCallable setIamPolicyCallable() { * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * Policy response = schemaServiceClient.getIamPolicy(request); @@ -908,7 +922,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * ApiFuture future = schemaServiceClient.getIamPolicyCallable().futureCall(request); @@ -938,7 +952,7 @@ public final UnaryCallable getIamPolicyCallable() { * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * TestIamPermissionsResponse response = schemaServiceClient.testIamPermissions(request); @@ -969,7 +983,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * ApiFuture future = diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceSettings.java index 597c33bc6..128405e64 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SchemaServiceSettings.java @@ -23,6 +23,7 @@ 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; @@ -159,11 +160,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SchemaServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SchemaServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SchemaServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SchemaServiceStubSettings.defaultTransportChannelProvider(); } @@ -173,11 +181,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SchemaServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** 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); @@ -215,6 +229,11 @@ private static Builder createDefault() { return new Builder(SchemaServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SchemaServiceStubSettings.newHttpJsonBuilder()); + } + public SchemaServiceStubSettings.Builder getStubSettingsBuilder() { return ((SchemaServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java index 1772a7307..85556d5de 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminClient.java @@ -142,6 +142,21 @@ * SubscriptionAdminClient.create(subscriptionAdminSettings); * } * + *

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 for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * SubscriptionAdminSettings subscriptionAdminSettings =
+ *     SubscriptionAdminSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             SubscriptionAdminSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * SubscriptionAdminClient subscriptionAdminClient =
+ *     SubscriptionAdminClient.create(subscriptionAdminSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -1091,7 +1106,7 @@ public final ListSubscriptionsPagedResponse listSubscriptions(ListSubscriptionsR * while (true) { * ListSubscriptionsResponse response = * subscriptionAdminClient.listSubscriptionsCallable().call(request); - * for (Subscription element : response.getResponsesList()) { + * for (Subscription element : response.getSubscriptionsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2383,7 +2398,7 @@ public final ListSnapshotsPagedResponse listSnapshots(ListSnapshotsRequest reque * while (true) { * ListSnapshotsResponse response = * subscriptionAdminClient.listSnapshotsCallable().call(request); - * for (Snapshot element : response.getResponsesList()) { + * for (Snapshot element : response.getSnapshotsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -3114,7 +3129,7 @@ public final UnaryCallable seekCallable() { * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -3174,7 +3189,7 @@ public final Policy setIamPolicy(String resource, Policy policy) { * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -3201,7 +3216,7 @@ public final UnaryCallable setIamPolicyCallable() { * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * Policy response = subscriptionAdminClient.getIamPolicy(request); @@ -3253,7 +3268,7 @@ public final Policy getIamPolicy(String resource) { * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * ApiFuture future = subscriptionAdminClient.getIamPolicyCallable().futureCall(request); @@ -3283,7 +3298,7 @@ public final UnaryCallable getIamPolicyCallable() { * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * TestIamPermissionsResponse response = subscriptionAdminClient.testIamPermissions(request); @@ -3352,7 +3367,7 @@ public final TestIamPermissionsResponse testIamPermissions( * try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * ApiFuture future = diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java index c658184ab..c5c56f91d 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriptionAdminSettings.java @@ -24,6 +24,7 @@ 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; @@ -226,11 +227,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return SubscriberStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return SubscriberStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return SubscriberStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return SubscriberStubSettings.defaultTransportChannelProvider(); } @@ -240,11 +248,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return SubscriberStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** 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); @@ -282,6 +296,11 @@ private static Builder createDefault() { return new Builder(SubscriberStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(SubscriberStubSettings.newHttpJsonBuilder()); + } + public SubscriberStubSettings.Builder getStubSettingsBuilder() { return ((SubscriberStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java index 9b3032269..d1120f246 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminClient.java @@ -121,6 +121,20 @@ * TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings); * } * + *

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 for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * TopicAdminSettings topicAdminSettings =
+ *     TopicAdminSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             TopicAdminSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * TopicAdminClient topicAdminClient = TopicAdminClient.create(topicAdminSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -731,7 +745,7 @@ public final UnaryCallable listTopic * .build(); * while (true) { * ListTopicsResponse response = topicAdminClient.listTopicsCallable().call(request); - * for (Topic element : response.getResponsesList()) { + * for (Topic element : response.getTopicsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -912,7 +926,7 @@ public final ListTopicSubscriptionsPagedResponse listTopicSubscriptions( * while (true) { * ListTopicSubscriptionsResponse response = * topicAdminClient.listTopicSubscriptionsCallable().call(request); - * for (String element : response.getResponsesList()) { + * for (String element : response.getSubscriptionsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1080,7 +1094,7 @@ public final ListTopicSnapshotsPagedResponse listTopicSnapshots( * while (true) { * ListTopicSnapshotsResponse response = * topicAdminClient.listTopicSnapshotsCallable().call(request); - * for (String element : response.getResponsesList()) { + * for (String element : response.getSnapshotsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1305,7 +1319,7 @@ public final DetachSubscriptionResponse detachSubscription(DetachSubscriptionReq * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -1365,7 +1379,7 @@ public final Policy setIamPolicy(String resource, Policy policy) { * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { * SetIamPolicyRequest request = * SetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setPolicy(Policy.newBuilder().build()) * .setUpdateMask(FieldMask.newBuilder().build()) * .build(); @@ -1392,7 +1406,7 @@ public final UnaryCallable setIamPolicyCallable() { * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * Policy response = topicAdminClient.getIamPolicy(request); @@ -1444,7 +1458,7 @@ public final Policy getIamPolicy(String resource) { * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { * GetIamPolicyRequest request = * GetIamPolicyRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .setOptions(GetPolicyOptions.newBuilder().build()) * .build(); * ApiFuture future = topicAdminClient.getIamPolicyCallable().futureCall(request); @@ -1474,7 +1488,7 @@ public final UnaryCallable getIamPolicyCallable() { * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * TestIamPermissionsResponse response = topicAdminClient.testIamPermissions(request); @@ -1543,7 +1557,7 @@ public final TestIamPermissionsResponse testIamPermissions( * try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) { * TestIamPermissionsRequest request = * TestIamPermissionsRequest.newBuilder() - * .setResource(ProjectName.of("[PROJECT]").toString()) + * .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) * .addAllPermissions(new ArrayList()) * .build(); * ApiFuture future = diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java index d0efac54f..ecb1cf70a 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/TopicAdminSettings.java @@ -25,6 +25,7 @@ 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.BatchingCallSettings; import com.google.api.gax.rpc.ClientContext; @@ -186,11 +187,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PublisherStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return PublisherStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PublisherStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PublisherStubSettings.defaultTransportChannelProvider(); } @@ -200,11 +208,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PublisherStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** 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); @@ -242,6 +256,11 @@ private static Builder createDefault() { return new Builder(PublisherStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PublisherStubSettings.newHttpJsonBuilder()); + } + public PublisherStubSettings.Builder getStubSettingsBuilder() { return ((PublisherStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherCallableFactory.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherCallableFactory.java new file mode 100644 index 000000000..a6ee5b58b --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.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 Publisher service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPublisherCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherStub.java new file mode 100644 index 000000000..96f674f54 --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonPublisherStub.java @@ -0,0 +1,825 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.v1.stub; + +import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicSnapshotsPagedResponse; +import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicSubscriptionsPagedResponse; +import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicsPagedResponse; + +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.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.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import com.google.pubsub.v1.DeleteTopicRequest; +import com.google.pubsub.v1.DetachSubscriptionRequest; +import com.google.pubsub.v1.DetachSubscriptionResponse; +import com.google.pubsub.v1.GetTopicRequest; +import com.google.pubsub.v1.ListTopicSnapshotsRequest; +import com.google.pubsub.v1.ListTopicSnapshotsResponse; +import com.google.pubsub.v1.ListTopicSubscriptionsRequest; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsRequest; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.PublishRequest; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.Topic; +import com.google.pubsub.v1.UpdateTopicRequest; +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 Publisher service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPublisherStub extends PublisherStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor createTopicMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/CreateTopic") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/topics/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Topic.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor updateTopicMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/UpdateTopic") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{topic.name=projects/*/topics/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "topic.name", request.getTopic().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Topic.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + publishMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/Publish") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{topic=projects/*/topics/*}:publish", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "topic", request.getTopic()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearTopic().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PublishResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getTopicMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/GetTopic") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{topic=projects/*/topics/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "topic", request.getTopic()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Topic.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listTopicsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/ListTopics") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{project=projects/*}/topics", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "project", request.getProject()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTopicsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse> + listTopicSubscriptionsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/ListTopicSubscriptions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{topic=projects/*/topics/*}/subscriptions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "topic", request.getTopic()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTopicSubscriptionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listTopicSnapshotsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/ListTopicSnapshots") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{topic=projects/*/topics/*}/snapshots", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "topic", request.getTopic()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListTopicSnapshotsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteTopicMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/DeleteTopic") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{topic=projects/*/topics/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "topic", request.getTopic()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + detachSubscriptionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Publisher/DetachSubscription") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}:detach", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DetachSubscriptionResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/topics/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/subscriptions/*}:setIamPolicy", + "/v1/{resource=projects/*/snapshots/*}:setIamPolicy", + "/v1/{resource=projects/*/schemas/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/topics/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/subscriptions/*}:getIamPolicy", + "/v1/{resource=projects/*/snapshots/*}:getIamPolicy", + "/v1/{resource=projects/*/schemas/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/subscriptions/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/topics/*}:testIamPermissions", + "/v1/{resource=projects/*/snapshots/*}:testIamPermissions", + "/v1/{resource=projects/*/schemas/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createTopicCallable; + private final UnaryCallable updateTopicCallable; + private final UnaryCallable publishCallable; + private final UnaryCallable getTopicCallable; + private final UnaryCallable listTopicsCallable; + private final UnaryCallable listTopicsPagedCallable; + private final UnaryCallable + listTopicSubscriptionsCallable; + private final UnaryCallable + listTopicSubscriptionsPagedCallable; + private final UnaryCallable + listTopicSnapshotsCallable; + private final UnaryCallable + listTopicSnapshotsPagedCallable; + private final UnaryCallable deleteTopicCallable; + private final UnaryCallable + detachSubscriptionCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPublisherStub create(PublisherStubSettings settings) + throws IOException { + return new HttpJsonPublisherStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPublisherStub create(ClientContext clientContext) throws IOException { + return new HttpJsonPublisherStub( + PublisherStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPublisherStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPublisherStub( + PublisherStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPublisherStub, 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 HttpJsonPublisherStub(PublisherStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonPublisherCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPublisherStub, 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 HttpJsonPublisherStub( + PublisherStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createTopicTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createTopicMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateTopicTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateTopicMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings publishTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(publishMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getTopicTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getTopicMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listTopicsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTopicsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listTopicSubscriptionsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listTopicSubscriptionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listTopicSnapshotsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTopicSnapshotsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteTopicTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteTopicMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + detachSubscriptionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(detachSubscriptionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createTopicCallable = + callableFactory.createUnaryCallable( + createTopicTransportSettings, settings.createTopicSettings(), clientContext); + this.updateTopicCallable = + callableFactory.createUnaryCallable( + updateTopicTransportSettings, settings.updateTopicSettings(), clientContext); + this.publishCallable = + callableFactory.createBatchingCallable( + publishTransportSettings, settings.publishSettings(), clientContext); + this.getTopicCallable = + callableFactory.createUnaryCallable( + getTopicTransportSettings, settings.getTopicSettings(), clientContext); + this.listTopicsCallable = + callableFactory.createUnaryCallable( + listTopicsTransportSettings, settings.listTopicsSettings(), clientContext); + this.listTopicsPagedCallable = + callableFactory.createPagedCallable( + listTopicsTransportSettings, settings.listTopicsSettings(), clientContext); + this.listTopicSubscriptionsCallable = + callableFactory.createUnaryCallable( + listTopicSubscriptionsTransportSettings, + settings.listTopicSubscriptionsSettings(), + clientContext); + this.listTopicSubscriptionsPagedCallable = + callableFactory.createPagedCallable( + listTopicSubscriptionsTransportSettings, + settings.listTopicSubscriptionsSettings(), + clientContext); + this.listTopicSnapshotsCallable = + callableFactory.createUnaryCallable( + listTopicSnapshotsTransportSettings, + settings.listTopicSnapshotsSettings(), + clientContext); + this.listTopicSnapshotsPagedCallable = + callableFactory.createPagedCallable( + listTopicSnapshotsTransportSettings, + settings.listTopicSnapshotsSettings(), + clientContext); + this.deleteTopicCallable = + callableFactory.createUnaryCallable( + deleteTopicTransportSettings, settings.deleteTopicSettings(), clientContext); + this.detachSubscriptionCallable = + callableFactory.createUnaryCallable( + detachSubscriptionTransportSettings, + settings.detachSubscriptionSettings(), + clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createTopicMethodDescriptor); + methodDescriptors.add(updateTopicMethodDescriptor); + methodDescriptors.add(publishMethodDescriptor); + methodDescriptors.add(getTopicMethodDescriptor); + methodDescriptors.add(listTopicsMethodDescriptor); + methodDescriptors.add(listTopicSubscriptionsMethodDescriptor); + methodDescriptors.add(listTopicSnapshotsMethodDescriptor); + methodDescriptors.add(deleteTopicMethodDescriptor); + methodDescriptors.add(detachSubscriptionMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createTopicCallable() { + return createTopicCallable; + } + + @Override + public UnaryCallable updateTopicCallable() { + return updateTopicCallable; + } + + @Override + public UnaryCallable publishCallable() { + return publishCallable; + } + + @Override + public UnaryCallable getTopicCallable() { + return getTopicCallable; + } + + @Override + public UnaryCallable listTopicsCallable() { + return listTopicsCallable; + } + + @Override + public UnaryCallable listTopicsPagedCallable() { + return listTopicsPagedCallable; + } + + @Override + public UnaryCallable + listTopicSubscriptionsCallable() { + return listTopicSubscriptionsCallable; + } + + @Override + public UnaryCallable + listTopicSubscriptionsPagedCallable() { + return listTopicSubscriptionsPagedCallable; + } + + @Override + public UnaryCallable + listTopicSnapshotsCallable() { + return listTopicSnapshotsCallable; + } + + @Override + public UnaryCallable + listTopicSnapshotsPagedCallable() { + return listTopicSnapshotsPagedCallable; + } + + @Override + public UnaryCallable deleteTopicCallable() { + return deleteTopicCallable; + } + + @Override + public UnaryCallable + detachSubscriptionCallable() { + return detachSubscriptionCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceCallableFactory.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceCallableFactory.java new file mode 100644 index 000000000..3eef08b20 --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.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 SchemaService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSchemaServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceStub.java new file mode 100644 index 000000000..b4d220f61 --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSchemaServiceStub.java @@ -0,0 +1,639 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.v1.stub; + +import static com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse; + +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.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.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import com.google.pubsub.v1.CreateSchemaRequest; +import com.google.pubsub.v1.DeleteSchemaRequest; +import com.google.pubsub.v1.GetSchemaRequest; +import com.google.pubsub.v1.ListSchemasRequest; +import com.google.pubsub.v1.ListSchemasResponse; +import com.google.pubsub.v1.Schema; +import com.google.pubsub.v1.ValidateMessageRequest; +import com.google.pubsub.v1.ValidateMessageResponse; +import com.google.pubsub.v1.ValidateSchemaRequest; +import com.google.pubsub.v1.ValidateSchemaResponse; +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 SchemaService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSchemaServiceStub extends SchemaServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createSchemaMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.SchemaService/CreateSchema") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/schemas", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "schemaId", request.getSchemaId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("schema", request.getSchema())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Schema.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getSchemaMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.SchemaService/GetSchema") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/schemas/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Schema.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSchemasMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.SchemaService/ListSchemas") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/schemas", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSchemasResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteSchemaMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.SchemaService/DeleteSchema") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/schemas/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + validateSchemaMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.SchemaService/ValidateSchema") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/schemas:validate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ValidateSchemaResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + validateMessageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.SchemaService/ValidateMessage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/schemas:validateMessage", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ValidateMessageResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/topics/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/subscriptions/*}:setIamPolicy", + "/v1/{resource=projects/*/snapshots/*}:setIamPolicy", + "/v1/{resource=projects/*/schemas/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/topics/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/subscriptions/*}:getIamPolicy", + "/v1/{resource=projects/*/snapshots/*}:getIamPolicy", + "/v1/{resource=projects/*/schemas/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/subscriptions/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/topics/*}:testIamPermissions", + "/v1/{resource=projects/*/snapshots/*}:testIamPermissions", + "/v1/{resource=projects/*/schemas/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createSchemaCallable; + private final UnaryCallable getSchemaCallable; + private final UnaryCallable listSchemasCallable; + private final UnaryCallable + listSchemasPagedCallable; + private final UnaryCallable deleteSchemaCallable; + private final UnaryCallable validateSchemaCallable; + private final UnaryCallable + validateMessageCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSchemaServiceStub create(SchemaServiceStubSettings settings) + throws IOException { + return new HttpJsonSchemaServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSchemaServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSchemaServiceStub( + SchemaServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSchemaServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSchemaServiceStub( + SchemaServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSchemaServiceStub, 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 HttpJsonSchemaServiceStub( + SchemaServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonSchemaServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSchemaServiceStub, 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 HttpJsonSchemaServiceStub( + SchemaServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createSchemaTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSchemaMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getSchemaTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSchemaMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listSchemasTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSchemasMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteSchemaTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteSchemaMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + validateSchemaTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(validateSchemaMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + validateMessageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(validateMessageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createSchemaCallable = + callableFactory.createUnaryCallable( + createSchemaTransportSettings, settings.createSchemaSettings(), clientContext); + this.getSchemaCallable = + callableFactory.createUnaryCallable( + getSchemaTransportSettings, settings.getSchemaSettings(), clientContext); + this.listSchemasCallable = + callableFactory.createUnaryCallable( + listSchemasTransportSettings, settings.listSchemasSettings(), clientContext); + this.listSchemasPagedCallable = + callableFactory.createPagedCallable( + listSchemasTransportSettings, settings.listSchemasSettings(), clientContext); + this.deleteSchemaCallable = + callableFactory.createUnaryCallable( + deleteSchemaTransportSettings, settings.deleteSchemaSettings(), clientContext); + this.validateSchemaCallable = + callableFactory.createUnaryCallable( + validateSchemaTransportSettings, settings.validateSchemaSettings(), clientContext); + this.validateMessageCallable = + callableFactory.createUnaryCallable( + validateMessageTransportSettings, settings.validateMessageSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createSchemaMethodDescriptor); + methodDescriptors.add(getSchemaMethodDescriptor); + methodDescriptors.add(listSchemasMethodDescriptor); + methodDescriptors.add(deleteSchemaMethodDescriptor); + methodDescriptors.add(validateSchemaMethodDescriptor); + methodDescriptors.add(validateMessageMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createSchemaCallable() { + return createSchemaCallable; + } + + @Override + public UnaryCallable getSchemaCallable() { + return getSchemaCallable; + } + + @Override + public UnaryCallable listSchemasCallable() { + return listSchemasCallable; + } + + @Override + public UnaryCallable listSchemasPagedCallable() { + return listSchemasPagedCallable; + } + + @Override + public UnaryCallable deleteSchemaCallable() { + return deleteSchemaCallable; + } + + @Override + public UnaryCallable validateSchemaCallable() { + return validateSchemaCallable; + } + + @Override + public UnaryCallable validateMessageCallable() { + return validateMessageCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberCallableFactory.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberCallableFactory.java new file mode 100644 index 000000000..5eb399a0e --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.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 Subscriber service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSubscriberCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberStub.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberStub.java new file mode 100644 index 000000000..354ea15f3 --- /dev/null +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/HttpJsonSubscriberStub.java @@ -0,0 +1,1124 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.v1.stub; + +import static com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSubscriptionsPagedResponse; + +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.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.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import com.google.pubsub.v1.AcknowledgeRequest; +import com.google.pubsub.v1.CreateSnapshotRequest; +import com.google.pubsub.v1.DeleteSnapshotRequest; +import com.google.pubsub.v1.DeleteSubscriptionRequest; +import com.google.pubsub.v1.GetSnapshotRequest; +import com.google.pubsub.v1.GetSubscriptionRequest; +import com.google.pubsub.v1.ListSnapshotsRequest; +import com.google.pubsub.v1.ListSnapshotsResponse; +import com.google.pubsub.v1.ListSubscriptionsRequest; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ModifyAckDeadlineRequest; +import com.google.pubsub.v1.ModifyPushConfigRequest; +import com.google.pubsub.v1.PullRequest; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.SeekRequest; +import com.google.pubsub.v1.SeekResponse; +import com.google.pubsub.v1.Snapshot; +import com.google.pubsub.v1.Subscription; +import com.google.pubsub.v1.UpdateSnapshotRequest; +import com.google.pubsub.v1.UpdateSubscriptionRequest; +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 Subscriber service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonSubscriberStub extends SubscriberStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + createSubscriptionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/CreateSubscription") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/subscriptions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Subscription.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getSubscriptionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/GetSubscription") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Subscription.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSubscriptionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/UpdateSubscription") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription.name=projects/*/subscriptions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "subscription.name", request.getSubscription().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Subscription.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSubscriptionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/ListSubscriptions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{project=projects/*}/subscriptions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "project", request.getProject()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSubscriptionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteSubscriptionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/DeleteSubscription") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + modifyAckDeadlineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/ModifyAckDeadline") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSubscription().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor acknowledgeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/Acknowledge") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}:acknowledge", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSubscription().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor pullMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/Pull") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}:pull", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSubscription().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PullResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + modifyPushConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/ModifyPushConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSubscription().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getSnapshotMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/GetSnapshot") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{snapshot=projects/*/snapshots/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "snapshot", request.getSnapshot()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Snapshot.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listSnapshotsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/ListSnapshots") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{project=projects/*}/snapshots", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "project", request.getProject()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListSnapshotsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createSnapshotMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/CreateSnapshot") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/snapshots/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Snapshot.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateSnapshotMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/UpdateSnapshot") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{snapshot.name=projects/*/snapshots/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "snapshot.name", request.getSnapshot().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Snapshot.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteSnapshotMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/DeleteSnapshot") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{snapshot=projects/*/snapshots/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "snapshot", request.getSnapshot()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor seekMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.pubsub.v1.Subscriber/Seek") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{subscription=projects/*/subscriptions/*}:seek", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "subscription", request.getSubscription()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearSubscription().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SeekResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + setIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/SetIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/topics/*}:setIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/subscriptions/*}:setIamPolicy", + "/v1/{resource=projects/*/snapshots/*}:setIamPolicy", + "/v1/{resource=projects/*/schemas/*}:setIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/GetIamPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/topics/*}:getIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/subscriptions/*}:getIamPolicy", + "/v1/{resource=projects/*/snapshots/*}:getIamPolicy", + "/v1/{resource=projects/*/schemas/*}:getIamPolicy") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + testIamPermissionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v1.IAMPolicy/TestIamPermissions") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=projects/*/subscriptions/*}:testIamPermissions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .setAdditionalPaths( + "/v1/{resource=projects/*/topics/*}:testIamPermissions", + "/v1/{resource=projects/*/snapshots/*}:testIamPermissions", + "/v1/{resource=projects/*/schemas/*}:testIamPermissions") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearResource().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createSubscriptionCallable; + private final UnaryCallable getSubscriptionCallable; + private final UnaryCallable updateSubscriptionCallable; + private final UnaryCallable + listSubscriptionsCallable; + private final UnaryCallable + listSubscriptionsPagedCallable; + private final UnaryCallable deleteSubscriptionCallable; + private final UnaryCallable modifyAckDeadlineCallable; + private final UnaryCallable acknowledgeCallable; + private final UnaryCallable pullCallable; + private final UnaryCallable modifyPushConfigCallable; + private final UnaryCallable getSnapshotCallable; + private final UnaryCallable listSnapshotsCallable; + private final UnaryCallable + listSnapshotsPagedCallable; + private final UnaryCallable createSnapshotCallable; + private final UnaryCallable updateSnapshotCallable; + private final UnaryCallable deleteSnapshotCallable; + private final UnaryCallable seekCallable; + private final UnaryCallable setIamPolicyCallable; + private final UnaryCallable getIamPolicyCallable; + private final UnaryCallable + testIamPermissionsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonSubscriberStub create(SubscriberStubSettings settings) + throws IOException { + return new HttpJsonSubscriberStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonSubscriberStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonSubscriberStub( + SubscriberStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonSubscriberStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonSubscriberStub( + SubscriberStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonSubscriberStub, 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 HttpJsonSubscriberStub(SubscriberStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonSubscriberCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonSubscriberStub, 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 HttpJsonSubscriberStub( + SubscriberStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings createSubscriptionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSubscriptionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getSubscriptionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSubscriptionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateSubscriptionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSubscriptionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listSubscriptionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSubscriptionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteSubscriptionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteSubscriptionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings modifyAckDeadlineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(modifyAckDeadlineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings acknowledgeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(acknowledgeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings pullTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(pullMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings modifyPushConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(modifyPushConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getSnapshotTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSnapshotMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listSnapshotsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listSnapshotsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createSnapshotTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createSnapshotMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateSnapshotTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateSnapshotMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteSnapshotTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteSnapshotMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings seekTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(seekMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings setIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(setIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + testIamPermissionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testIamPermissionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createSubscriptionCallable = + callableFactory.createUnaryCallable( + createSubscriptionTransportSettings, + settings.createSubscriptionSettings(), + clientContext); + this.getSubscriptionCallable = + callableFactory.createUnaryCallable( + getSubscriptionTransportSettings, settings.getSubscriptionSettings(), clientContext); + this.updateSubscriptionCallable = + callableFactory.createUnaryCallable( + updateSubscriptionTransportSettings, + settings.updateSubscriptionSettings(), + clientContext); + this.listSubscriptionsCallable = + callableFactory.createUnaryCallable( + listSubscriptionsTransportSettings, + settings.listSubscriptionsSettings(), + clientContext); + this.listSubscriptionsPagedCallable = + callableFactory.createPagedCallable( + listSubscriptionsTransportSettings, + settings.listSubscriptionsSettings(), + clientContext); + this.deleteSubscriptionCallable = + callableFactory.createUnaryCallable( + deleteSubscriptionTransportSettings, + settings.deleteSubscriptionSettings(), + clientContext); + this.modifyAckDeadlineCallable = + callableFactory.createUnaryCallable( + modifyAckDeadlineTransportSettings, + settings.modifyAckDeadlineSettings(), + clientContext); + this.acknowledgeCallable = + callableFactory.createUnaryCallable( + acknowledgeTransportSettings, settings.acknowledgeSettings(), clientContext); + this.pullCallable = + callableFactory.createUnaryCallable( + pullTransportSettings, settings.pullSettings(), clientContext); + this.modifyPushConfigCallable = + callableFactory.createUnaryCallable( + modifyPushConfigTransportSettings, settings.modifyPushConfigSettings(), clientContext); + this.getSnapshotCallable = + callableFactory.createUnaryCallable( + getSnapshotTransportSettings, settings.getSnapshotSettings(), clientContext); + this.listSnapshotsCallable = + callableFactory.createUnaryCallable( + listSnapshotsTransportSettings, settings.listSnapshotsSettings(), clientContext); + this.listSnapshotsPagedCallable = + callableFactory.createPagedCallable( + listSnapshotsTransportSettings, settings.listSnapshotsSettings(), clientContext); + this.createSnapshotCallable = + callableFactory.createUnaryCallable( + createSnapshotTransportSettings, settings.createSnapshotSettings(), clientContext); + this.updateSnapshotCallable = + callableFactory.createUnaryCallable( + updateSnapshotTransportSettings, settings.updateSnapshotSettings(), clientContext); + this.deleteSnapshotCallable = + callableFactory.createUnaryCallable( + deleteSnapshotTransportSettings, settings.deleteSnapshotSettings(), clientContext); + this.seekCallable = + callableFactory.createUnaryCallable( + seekTransportSettings, settings.seekSettings(), clientContext); + this.setIamPolicyCallable = + callableFactory.createUnaryCallable( + setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); + this.getIamPolicyCallable = + callableFactory.createUnaryCallable( + getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); + this.testIamPermissionsCallable = + callableFactory.createUnaryCallable( + testIamPermissionsTransportSettings, + settings.testIamPermissionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createSubscriptionMethodDescriptor); + methodDescriptors.add(getSubscriptionMethodDescriptor); + methodDescriptors.add(updateSubscriptionMethodDescriptor); + methodDescriptors.add(listSubscriptionsMethodDescriptor); + methodDescriptors.add(deleteSubscriptionMethodDescriptor); + methodDescriptors.add(modifyAckDeadlineMethodDescriptor); + methodDescriptors.add(acknowledgeMethodDescriptor); + methodDescriptors.add(pullMethodDescriptor); + methodDescriptors.add(modifyPushConfigMethodDescriptor); + methodDescriptors.add(getSnapshotMethodDescriptor); + methodDescriptors.add(listSnapshotsMethodDescriptor); + methodDescriptors.add(createSnapshotMethodDescriptor); + methodDescriptors.add(updateSnapshotMethodDescriptor); + methodDescriptors.add(deleteSnapshotMethodDescriptor); + methodDescriptors.add(seekMethodDescriptor); + methodDescriptors.add(setIamPolicyMethodDescriptor); + methodDescriptors.add(getIamPolicyMethodDescriptor); + methodDescriptors.add(testIamPermissionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable createSubscriptionCallable() { + return createSubscriptionCallable; + } + + @Override + public UnaryCallable getSubscriptionCallable() { + return getSubscriptionCallable; + } + + @Override + public UnaryCallable updateSubscriptionCallable() { + return updateSubscriptionCallable; + } + + @Override + public UnaryCallable + listSubscriptionsCallable() { + return listSubscriptionsCallable; + } + + @Override + public UnaryCallable + listSubscriptionsPagedCallable() { + return listSubscriptionsPagedCallable; + } + + @Override + public UnaryCallable deleteSubscriptionCallable() { + return deleteSubscriptionCallable; + } + + @Override + public UnaryCallable modifyAckDeadlineCallable() { + return modifyAckDeadlineCallable; + } + + @Override + public UnaryCallable acknowledgeCallable() { + return acknowledgeCallable; + } + + @Override + public UnaryCallable pullCallable() { + return pullCallable; + } + + @Override + public UnaryCallable modifyPushConfigCallable() { + return modifyPushConfigCallable; + } + + @Override + public UnaryCallable getSnapshotCallable() { + return getSnapshotCallable; + } + + @Override + public UnaryCallable listSnapshotsCallable() { + return listSnapshotsCallable; + } + + @Override + public UnaryCallable + listSnapshotsPagedCallable() { + return listSnapshotsPagedCallable; + } + + @Override + public UnaryCallable createSnapshotCallable() { + return createSnapshotCallable; + } + + @Override + public UnaryCallable updateSnapshotCallable() { + return updateSnapshotCallable; + } + + @Override + public UnaryCallable deleteSnapshotCallable() { + return deleteSnapshotCallable; + } + + @Override + public UnaryCallable seekCallable() { + return seekCallable; + } + + @Override + public UnaryCallable setIamPolicyCallable() { + return setIamPolicyCallable; + } + + @Override + public UnaryCallable getIamPolicyCallable() { + return getIamPolicyCallable; + } + + @Override + public UnaryCallable + testIamPermissionsCallable() { + return testIamPermissionsCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java index dd5a99740..573fd9597 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/PublisherStubSettings.java @@ -34,6 +34,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -464,6 +467,11 @@ public PublisherStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPublisherStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPublisherStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -496,29 +504,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** 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 defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PublisherStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @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(PublisherStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PublisherStubSettings.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); @@ -725,6 +758,19 @@ private static Builder createDefault() { 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 .createTopicSettings() diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java index 963e9b7ce..5c470e241 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SchemaServiceStubSettings.java @@ -27,6 +27,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -228,6 +231,11 @@ public SchemaServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSchemaServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSchemaServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -260,18 +268,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** 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 defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SchemaServiceStubSettings.class)) @@ -279,11 +294,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @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(SchemaServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SchemaServiceStubSettings.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); @@ -415,6 +449,19 @@ private static Builder createDefault() { 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 .createSchemaSettings() diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java index e94378b17..e9ae4617f 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/stub/SubscriberStubSettings.java @@ -28,6 +28,9 @@ 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.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -369,6 +372,11 @@ public SubscriberStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcSubscriberStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonSubscriberStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -401,17 +409,24 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder().setMaxInboundMessageSize(20 << 20); } + /** 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 defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(SubscriberStubSettings.class)) @@ -419,11 +434,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @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(SubscriberStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return SubscriberStubSettings.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); @@ -666,6 +700,19 @@ private static Builder createDefault() { 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 .createSubscriptionSettings() diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientHttpJsonTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientHttpJsonTest.java new file mode 100644 index 000000000..c34c46f9d --- /dev/null +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientHttpJsonTest.java @@ -0,0 +1,764 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.v1; + +import static com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.pubsub.v1.stub.HttpJsonSchemaServiceStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.pubsub.v1.Encoding; +import com.google.pubsub.v1.ListSchemasResponse; +import com.google.pubsub.v1.ProjectName; +import com.google.pubsub.v1.Schema; +import com.google.pubsub.v1.SchemaName; +import com.google.pubsub.v1.ValidateMessageRequest; +import com.google.pubsub.v1.ValidateMessageResponse; +import com.google.pubsub.v1.ValidateSchemaResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SchemaServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static SchemaServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSchemaServiceStub.getMethodDescriptors(), + SchemaServiceSettings.getDefaultEndpoint()); + SchemaServiceSettings settings = + SchemaServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SchemaServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SchemaServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createSchemaTest() throws Exception { + Schema expectedResponse = + Schema.newBuilder() + .setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setDefinition("definition-1014418093") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Schema schema = Schema.newBuilder().build(); + String schemaId = "schemaId-697673060"; + + Schema actualResponse = client.createSchema(parent, schema, schemaId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSchemaExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Schema schema = Schema.newBuilder().build(); + String schemaId = "schemaId-697673060"; + client.createSchema(parent, schema, schemaId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSchemaTest2() throws Exception { + Schema expectedResponse = + Schema.newBuilder() + .setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setDefinition("definition-1014418093") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + Schema schema = Schema.newBuilder().build(); + String schemaId = "schemaId-697673060"; + + Schema actualResponse = client.createSchema(parent, schema, schemaId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSchemaExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + Schema schema = Schema.newBuilder().build(); + String schemaId = "schemaId-697673060"; + client.createSchema(parent, schema, schemaId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSchemaTest() throws Exception { + Schema expectedResponse = + Schema.newBuilder() + .setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setDefinition("definition-1014418093") + .build(); + mockService.addResponse(expectedResponse); + + SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]"); + + Schema actualResponse = client.getSchema(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSchemaExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]"); + client.getSchema(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSchemaTest2() throws Exception { + Schema expectedResponse = + Schema.newBuilder() + .setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setDefinition("definition-1014418093") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5662/schemas/schema-5662"; + + Schema actualResponse = client.getSchema(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSchemaExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5662/schemas/schema-5662"; + client.getSchema(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSchemasTest() throws Exception { + Schema responsesElement = Schema.newBuilder().build(); + ListSchemasResponse expectedResponse = + ListSchemasResponse.newBuilder() + .setNextPageToken("") + .addAllSchemas(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSchemasExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listSchemas(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSchemasTest2() throws Exception { + Schema responsesElement = Schema.newBuilder().build(); + ListSchemasResponse expectedResponse = + ListSchemasResponse.newBuilder() + .setNextPageToken("") + .addAllSchemas(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSchemasExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listSchemas(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSchemaTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]"); + + client.deleteSchema(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSchemaExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]"); + client.deleteSchema(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSchemaTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5662/schemas/schema-5662"; + + client.deleteSchema(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSchemaExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5662/schemas/schema-5662"; + client.deleteSchema(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void validateSchemaTest() throws Exception { + ValidateSchemaResponse expectedResponse = ValidateSchemaResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Schema schema = Schema.newBuilder().build(); + + ValidateSchemaResponse actualResponse = client.validateSchema(parent, schema); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void validateSchemaExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Schema schema = Schema.newBuilder().build(); + client.validateSchema(parent, schema); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void validateSchemaTest2() throws Exception { + ValidateSchemaResponse expectedResponse = ValidateSchemaResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + Schema schema = Schema.newBuilder().build(); + + ValidateSchemaResponse actualResponse = client.validateSchema(parent, schema); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void validateSchemaExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + Schema schema = Schema.newBuilder().build(); + client.validateSchema(parent, schema); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void validateMessageTest() throws Exception { + ValidateMessageResponse expectedResponse = ValidateMessageResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ValidateMessageRequest request = + ValidateMessageRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setMessage(ByteString.EMPTY) + .setEncoding(Encoding.forNumber(0)) + .build(); + + ValidateMessageResponse actualResponse = client.validateMessage(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void validateMessageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ValidateMessageRequest request = + ValidateMessageRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setMessage(ByteString.EMPTY) + .setEncoding(Encoding.forNumber(0)) + .build(); + client.validateMessage(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java index 92673b9d9..60fadbced 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SchemaServiceClientTest.java @@ -568,7 +568,7 @@ public void setIamPolicyTest() throws Exception { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); @@ -597,7 +597,7 @@ public void setIamPolicyExceptionTest() throws Exception { try { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); @@ -621,7 +621,7 @@ public void getIamPolicyTest() throws Exception { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); @@ -648,7 +648,7 @@ public void getIamPolicyExceptionTest() throws Exception { try { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); client.getIamPolicy(request); @@ -666,7 +666,7 @@ public void testIamPermissionsTest() throws Exception { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .addAllPermissions(new ArrayList()) .build(); @@ -693,7 +693,7 @@ public void testIamPermissionsExceptionTest() throws Exception { try { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .addAllPermissions(new ArrayList()) .build(); client.testIamPermissions(request); diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientHttpJsonTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientHttpJsonTest.java new file mode 100644 index 000000000..aee7e10ed --- /dev/null +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientHttpJsonTest.java @@ -0,0 +1,1966 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.v1; + +import static com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSnapshotsPagedResponse; +import static com.google.cloud.pubsub.v1.SubscriptionAdminClient.ListSubscriptionsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.pubsub.v1.stub.HttpJsonSubscriberStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.pubsub.v1.BigQueryConfig; +import com.google.pubsub.v1.DeadLetterPolicy; +import com.google.pubsub.v1.ExpirationPolicy; +import com.google.pubsub.v1.ListSnapshotsResponse; +import com.google.pubsub.v1.ListSubscriptionsResponse; +import com.google.pubsub.v1.ProjectName; +import com.google.pubsub.v1.PullResponse; +import com.google.pubsub.v1.PushConfig; +import com.google.pubsub.v1.ReceivedMessage; +import com.google.pubsub.v1.RetryPolicy; +import com.google.pubsub.v1.SchemaName; +import com.google.pubsub.v1.SeekRequest; +import com.google.pubsub.v1.SeekResponse; +import com.google.pubsub.v1.Snapshot; +import com.google.pubsub.v1.SnapshotName; +import com.google.pubsub.v1.Subscription; +import com.google.pubsub.v1.SubscriptionName; +import com.google.pubsub.v1.TopicName; +import com.google.pubsub.v1.UpdateSnapshotRequest; +import com.google.pubsub.v1.UpdateSubscriptionRequest; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class SubscriptionAdminClientHttpJsonTest { + private static MockHttpService mockService; + private static SubscriptionAdminClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonSubscriberStub.getMethodDescriptors(), + SubscriptionAdminSettings.getDefaultEndpoint()); + SubscriptionAdminSettings settings = + SubscriptionAdminSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + SubscriptionAdminSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = SubscriptionAdminClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createSubscriptionTest() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SubscriptionName name = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + + Subscription actualResponse = + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSubscriptionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName name = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSubscriptionTest2() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SubscriptionName name = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + String topic = "topic110546223"; + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + + Subscription actualResponse = + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSubscriptionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName name = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + String topic = "topic110546223"; + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSubscriptionTest3() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7298/subscriptions/subscription-7298"; + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + + Subscription actualResponse = + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSubscriptionExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7298/subscriptions/subscription-7298"; + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSubscriptionTest4() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7298/subscriptions/subscription-7298"; + String topic = "topic110546223"; + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + + Subscription actualResponse = + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSubscriptionExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7298/subscriptions/subscription-7298"; + String topic = "topic110546223"; + PushConfig pushConfig = PushConfig.newBuilder().build(); + int ackDeadlineSeconds = 2135351438; + client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSubscriptionTest() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + + Subscription actualResponse = client.getSubscription(subscription); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSubscriptionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + client.getSubscription(subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSubscriptionTest2() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + + Subscription actualResponse = client.getSubscription(subscription); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSubscriptionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + client.getSubscription(subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSubscriptionTest() throws Exception { + Subscription expectedResponse = + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + UpdateSubscriptionRequest request = + UpdateSubscriptionRequest.newBuilder() + .setSubscription( + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Subscription actualResponse = client.updateSubscription(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSubscriptionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateSubscriptionRequest request = + UpdateSubscriptionRequest.newBuilder() + .setSubscription( + Subscription.newBuilder() + .setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setPushConfig(PushConfig.newBuilder().build()) + .setBigqueryConfig(BigQueryConfig.newBuilder().build()) + .setAckDeadlineSeconds(2135351438) + .setRetainAckedMessages(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEnableMessageOrdering(true) + .setExpirationPolicy(ExpirationPolicy.newBuilder().build()) + .setFilter("filter-1274492040") + .setDeadLetterPolicy(DeadLetterPolicy.newBuilder().build()) + .setRetryPolicy(RetryPolicy.newBuilder().build()) + .setDetached(true) + .setEnableExactlyOnceDelivery(true) + .setTopicMessageRetentionDuration(Duration.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateSubscription(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSubscriptionsTest() throws Exception { + Subscription responsesElement = Subscription.newBuilder().build(); + ListSubscriptionsResponse expectedResponse = + ListSubscriptionsResponse.newBuilder() + .setNextPageToken("") + .addAllSubscriptions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName project = ProjectName.of("[PROJECT]"); + + ListSubscriptionsPagedResponse pagedListResponse = client.listSubscriptions(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSubscriptionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName project = ProjectName.of("[PROJECT]"); + client.listSubscriptions(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSubscriptionsTest2() throws Exception { + Subscription responsesElement = Subscription.newBuilder().build(); + ListSubscriptionsResponse expectedResponse = + ListSubscriptionsResponse.newBuilder() + .setNextPageToken("") + .addAllSubscriptions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String project = "projects/project-7934"; + + ListSubscriptionsPagedResponse pagedListResponse = client.listSubscriptions(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSubscriptionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String project = "projects/project-7934"; + client.listSubscriptions(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSubscriptionTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + + client.deleteSubscription(subscription); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSubscriptionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + client.deleteSubscription(subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSubscriptionTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + + client.deleteSubscription(subscription); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSubscriptionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + client.deleteSubscription(subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void modifyAckDeadlineTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + List ackIds = new ArrayList<>(); + int ackDeadlineSeconds = 2135351438; + + client.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void modifyAckDeadlineExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + List ackIds = new ArrayList<>(); + int ackDeadlineSeconds = 2135351438; + client.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void modifyAckDeadlineTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + List ackIds = new ArrayList<>(); + int ackDeadlineSeconds = 2135351438; + + client.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void modifyAckDeadlineExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + List ackIds = new ArrayList<>(); + int ackDeadlineSeconds = 2135351438; + client.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void acknowledgeTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + List ackIds = new ArrayList<>(); + + client.acknowledge(subscription, ackIds); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void acknowledgeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + List ackIds = new ArrayList<>(); + client.acknowledge(subscription, ackIds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void acknowledgeTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + List ackIds = new ArrayList<>(); + + client.acknowledge(subscription, ackIds); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void acknowledgeExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + List ackIds = new ArrayList<>(); + client.acknowledge(subscription, ackIds); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pullTest() throws Exception { + PullResponse expectedResponse = + PullResponse.newBuilder().addAllReceivedMessages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + int maxMessages = 496131527; + + PullResponse actualResponse = client.pull(subscription, maxMessages); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void pullExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + int maxMessages = 496131527; + client.pull(subscription, maxMessages); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pullTest2() throws Exception { + PullResponse expectedResponse = + PullResponse.newBuilder().addAllReceivedMessages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + int maxMessages = 496131527; + + PullResponse actualResponse = client.pull(subscription, maxMessages); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void pullExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + int maxMessages = 496131527; + client.pull(subscription, maxMessages); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pullTest3() throws Exception { + PullResponse expectedResponse = + PullResponse.newBuilder().addAllReceivedMessages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + boolean returnImmediately = true; + int maxMessages = 496131527; + + PullResponse actualResponse = client.pull(subscription, returnImmediately, maxMessages); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void pullExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + boolean returnImmediately = true; + int maxMessages = 496131527; + client.pull(subscription, returnImmediately, maxMessages); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pullTest4() throws Exception { + PullResponse expectedResponse = + PullResponse.newBuilder().addAllReceivedMessages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + boolean returnImmediately = true; + int maxMessages = 496131527; + + PullResponse actualResponse = client.pull(subscription, returnImmediately, maxMessages); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void pullExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + boolean returnImmediately = true; + int maxMessages = 496131527; + client.pull(subscription, returnImmediately, maxMessages); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void streamingPullUnsupportedMethodTest() throws Exception { + // The streamingPull() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } + + @Test + public void modifyPushConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + PushConfig pushConfig = PushConfig.newBuilder().build(); + + client.modifyPushConfig(subscription, pushConfig); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void modifyPushConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + PushConfig pushConfig = PushConfig.newBuilder().build(); + client.modifyPushConfig(subscription, pushConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void modifyPushConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + PushConfig pushConfig = PushConfig.newBuilder().build(); + + client.modifyPushConfig(subscription, pushConfig); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void modifyPushConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String subscription = "projects/project-1980/subscriptions/subscription-1980"; + PushConfig pushConfig = PushConfig.newBuilder().build(); + client.modifyPushConfig(subscription, pushConfig); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSnapshotTest() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + + Snapshot actualResponse = client.getSnapshot(snapshot); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSnapshotExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + client.getSnapshot(snapshot); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSnapshotTest2() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String snapshot = "projects/project-2020/snapshots/snapshot-2020"; + + Snapshot actualResponse = client.getSnapshot(snapshot); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getSnapshotExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String snapshot = "projects/project-2020/snapshots/snapshot-2020"; + client.getSnapshot(snapshot); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSnapshotsTest() throws Exception { + Snapshot responsesElement = Snapshot.newBuilder().build(); + ListSnapshotsResponse expectedResponse = + ListSnapshotsResponse.newBuilder() + .setNextPageToken("") + .addAllSnapshots(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName project = ProjectName.of("[PROJECT]"); + + ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSnapshotsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName project = ProjectName.of("[PROJECT]"); + client.listSnapshots(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listSnapshotsTest2() throws Exception { + Snapshot responsesElement = Snapshot.newBuilder().build(); + ListSnapshotsResponse expectedResponse = + ListSnapshotsResponse.newBuilder() + .setNextPageToken("") + .addAllSnapshots(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String project = "projects/project-7934"; + + ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listSnapshotsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String project = "projects/project-7934"; + client.listSnapshots(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSnapshotTest() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + + Snapshot actualResponse = client.createSnapshot(name, subscription); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSnapshotExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + client.createSnapshot(name, subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSnapshotTest2() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + String subscription = "subscription341203229"; + + Snapshot actualResponse = client.createSnapshot(name, subscription); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSnapshotExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + String subscription = "subscription341203229"; + client.createSnapshot(name, subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSnapshotTest3() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4389/snapshots/snapshot-4389"; + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + + Snapshot actualResponse = client.createSnapshot(name, subscription); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSnapshotExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4389/snapshots/snapshot-4389"; + SubscriptionName subscription = SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]"); + client.createSnapshot(name, subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createSnapshotTest4() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4389/snapshots/snapshot-4389"; + String subscription = "subscription341203229"; + + Snapshot actualResponse = client.createSnapshot(name, subscription); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createSnapshotExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4389/snapshots/snapshot-4389"; + String subscription = "subscription341203229"; + client.createSnapshot(name, subscription); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateSnapshotTest() throws Exception { + Snapshot expectedResponse = + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + UpdateSnapshotRequest request = + UpdateSnapshotRequest.newBuilder() + .setSnapshot( + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Snapshot actualResponse = client.updateSnapshot(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateSnapshotExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateSnapshotRequest request = + UpdateSnapshotRequest.newBuilder() + .setSnapshot( + Snapshot.newBuilder() + .setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()) + .setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .setExpireTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateSnapshot(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSnapshotTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + + client.deleteSnapshot(snapshot); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSnapshotExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]"); + client.deleteSnapshot(snapshot); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteSnapshotTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String snapshot = "projects/project-2020/snapshots/snapshot-2020"; + + client.deleteSnapshot(snapshot); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteSnapshotExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String snapshot = "projects/project-2020/snapshots/snapshot-2020"; + client.deleteSnapshot(snapshot); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void seekTest() throws Exception { + SeekResponse expectedResponse = SeekResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + SeekRequest request = + SeekRequest.newBuilder() + .setSubscription(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .build(); + + SeekResponse actualResponse = client.seek(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void seekExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SeekRequest request = + SeekRequest.newBuilder() + .setSubscription(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .build(); + client.seek(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java index e3476adf7..f70afe778 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriptionAdminClientTest.java @@ -66,6 +66,7 @@ import com.google.pubsub.v1.PushConfig; import com.google.pubsub.v1.ReceivedMessage; import com.google.pubsub.v1.RetryPolicy; +import com.google.pubsub.v1.SchemaName; import com.google.pubsub.v1.SeekRequest; import com.google.pubsub.v1.SeekResponse; import com.google.pubsub.v1.Snapshot; @@ -1695,7 +1696,7 @@ public void setIamPolicyTest() throws Exception { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); @@ -1724,7 +1725,7 @@ public void setIamPolicyExceptionTest() throws Exception { try { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); @@ -1748,7 +1749,7 @@ public void getIamPolicyTest() throws Exception { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); @@ -1775,7 +1776,7 @@ public void getIamPolicyExceptionTest() throws Exception { try { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); client.getIamPolicy(request); @@ -1793,7 +1794,7 @@ public void testIamPermissionsTest() throws Exception { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .addAllPermissions(new ArrayList()) .build(); @@ -1820,7 +1821,7 @@ public void testIamPermissionsExceptionTest() throws Exception { try { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .addAllPermissions(new ArrayList()) .build(); client.testIamPermissions(request); diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientHttpJsonTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientHttpJsonTest.java new file mode 100644 index 000000000..a41d12d64 --- /dev/null +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientHttpJsonTest.java @@ -0,0 +1,1060 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.pubsub.v1; + +import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicSnapshotsPagedResponse; +import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicSubscriptionsPagedResponse; +import static com.google.cloud.pubsub.v1.TopicAdminClient.ListTopicsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.pubsub.v1.stub.HttpJsonPublisherStub; +import com.google.common.collect.Lists; +import com.google.iam.v1.AuditConfig; +import com.google.iam.v1.Binding; +import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; +import com.google.iam.v1.Policy; +import com.google.iam.v1.SetIamPolicyRequest; +import com.google.iam.v1.TestIamPermissionsRequest; +import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.pubsub.v1.DetachSubscriptionRequest; +import com.google.pubsub.v1.DetachSubscriptionResponse; +import com.google.pubsub.v1.ListTopicSnapshotsResponse; +import com.google.pubsub.v1.ListTopicSubscriptionsResponse; +import com.google.pubsub.v1.ListTopicsResponse; +import com.google.pubsub.v1.MessageStoragePolicy; +import com.google.pubsub.v1.ProjectName; +import com.google.pubsub.v1.PublishResponse; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.SchemaName; +import com.google.pubsub.v1.SchemaSettings; +import com.google.pubsub.v1.SubscriptionName; +import com.google.pubsub.v1.Topic; +import com.google.pubsub.v1.TopicName; +import com.google.pubsub.v1.UpdateTopicRequest; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class TopicAdminClientHttpJsonTest { + private static MockHttpService mockService; + private static TopicAdminClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPublisherStub.getMethodDescriptors(), TopicAdminSettings.getDefaultEndpoint()); + TopicAdminSettings settings = + TopicAdminSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + TopicAdminSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = TopicAdminClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createTopicTest() throws Exception { + Topic expectedResponse = + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + TopicName name = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + + Topic actualResponse = client.createTopic(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createTopicExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TopicName name = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + client.createTopic(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createTopicTest2() throws Exception { + Topic expectedResponse = + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7550/topics/topic-7550"; + + Topic actualResponse = client.createTopic(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createTopicExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7550/topics/topic-7550"; + client.createTopic(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateTopicTest() throws Exception { + Topic expectedResponse = + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + UpdateTopicRequest request = + UpdateTopicRequest.newBuilder() + .setTopic( + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Topic actualResponse = client.updateTopic(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateTopicExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateTopicRequest request = + UpdateTopicRequest.newBuilder() + .setTopic( + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateTopic(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void publishTest() throws Exception { + PublishResponse expectedResponse = + PublishResponse.newBuilder().addAllMessageIds(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + List messages = new ArrayList<>(); + + PublishResponse actualResponse = client.publish(topic, messages); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void publishExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + List messages = new ArrayList<>(); + client.publish(topic, messages); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void publishTest2() throws Exception { + PublishResponse expectedResponse = + PublishResponse.newBuilder().addAllMessageIds(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String topic = "projects/project-2486/topics/topic-2486"; + List messages = new ArrayList<>(); + + PublishResponse actualResponse = client.publish(topic, messages); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void publishExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String topic = "projects/project-2486/topics/topic-2486"; + List messages = new ArrayList<>(); + client.publish(topic, messages); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTopicTest() throws Exception { + Topic expectedResponse = + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + + Topic actualResponse = client.getTopic(topic); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getTopicExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + client.getTopic(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTopicTest2() throws Exception { + Topic expectedResponse = + Topic.newBuilder() + .setName(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()) + .putAllLabels(new HashMap()) + .setMessageStoragePolicy(MessageStoragePolicy.newBuilder().build()) + .setKmsKeyName("kmsKeyName412586233") + .setSchemaSettings(SchemaSettings.newBuilder().build()) + .setSatisfiesPzs(true) + .setMessageRetentionDuration(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String topic = "projects/project-2486/topics/topic-2486"; + + Topic actualResponse = client.getTopic(topic); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getTopicExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String topic = "projects/project-2486/topics/topic-2486"; + client.getTopic(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTopicsTest() throws Exception { + Topic responsesElement = Topic.newBuilder().build(); + ListTopicsResponse expectedResponse = + ListTopicsResponse.newBuilder() + .setNextPageToken("") + .addAllTopics(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName project = ProjectName.of("[PROJECT]"); + + ListTopicsPagedResponse pagedListResponse = client.listTopics(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTopicsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTopicsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName project = ProjectName.of("[PROJECT]"); + client.listTopics(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTopicsTest2() throws Exception { + Topic responsesElement = Topic.newBuilder().build(); + ListTopicsResponse expectedResponse = + ListTopicsResponse.newBuilder() + .setNextPageToken("") + .addAllTopics(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String project = "projects/project-7934"; + + ListTopicsPagedResponse pagedListResponse = client.listTopics(project); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTopicsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTopicsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String project = "projects/project-7934"; + client.listTopics(project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTopicSubscriptionsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListTopicSubscriptionsResponse expectedResponse = + ListTopicSubscriptionsResponse.newBuilder() + .setNextPageToken("") + .addAllSubscriptions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + + ListTopicSubscriptionsPagedResponse pagedListResponse = client.listTopicSubscriptions(topic); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTopicSubscriptionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + client.listTopicSubscriptions(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTopicSubscriptionsTest2() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListTopicSubscriptionsResponse expectedResponse = + ListTopicSubscriptionsResponse.newBuilder() + .setNextPageToken("") + .addAllSubscriptions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String topic = "projects/project-2486/topics/topic-2486"; + + ListTopicSubscriptionsPagedResponse pagedListResponse = client.listTopicSubscriptions(topic); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTopicSubscriptionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String topic = "projects/project-2486/topics/topic-2486"; + client.listTopicSubscriptions(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTopicSnapshotsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListTopicSnapshotsResponse expectedResponse = + ListTopicSnapshotsResponse.newBuilder() + .setNextPageToken("") + .addAllSnapshots(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + + ListTopicSnapshotsPagedResponse pagedListResponse = client.listTopicSnapshots(topic); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTopicSnapshotsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + client.listTopicSnapshots(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTopicSnapshotsTest2() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListTopicSnapshotsResponse expectedResponse = + ListTopicSnapshotsResponse.newBuilder() + .setNextPageToken("") + .addAllSnapshots(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String topic = "projects/project-2486/topics/topic-2486"; + + ListTopicSnapshotsPagedResponse pagedListResponse = client.listTopicSnapshots(topic); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listTopicSnapshotsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String topic = "projects/project-2486/topics/topic-2486"; + client.listTopicSnapshots(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteTopicTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + + client.deleteTopic(topic); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteTopicExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TopicName topic = TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]"); + client.deleteTopic(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteTopicTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String topic = "projects/project-2486/topics/topic-2486"; + + client.deleteTopic(topic); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteTopicExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String topic = "projects/project-2486/topics/topic-2486"; + client.deleteTopic(topic); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detachSubscriptionTest() throws Exception { + DetachSubscriptionResponse expectedResponse = DetachSubscriptionResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DetachSubscriptionRequest request = + DetachSubscriptionRequest.newBuilder() + .setSubscription(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .build(); + + DetachSubscriptionResponse actualResponse = client.detachSubscription(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void detachSubscriptionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DetachSubscriptionRequest request = + DetachSubscriptionRequest.newBuilder() + .setSubscription(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString()) + .build(); + client.detachSubscription(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Policy actualResponse = client.setIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void setIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + SetIamPolicyRequest request = + SetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setPolicy(Policy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.setIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .addAllAuditConfigs(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockService.addResponse(expectedResponse); + + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + + Policy actualResponse = client.getIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIamPolicyRequest request = + GetIamPolicyRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); + client.getIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void testIamPermissionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TestIamPermissionsRequest request = + TestIamPermissionsRequest.newBuilder() + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) + .addAllPermissions(new ArrayList()) + .build(); + client.testIamPermissions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientTest.java index 0d50563fe..a28995e2a 100644 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientTest.java +++ b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/TopicAdminClientTest.java @@ -56,6 +56,7 @@ import com.google.pubsub.v1.PublishRequest; import com.google.pubsub.v1.PublishResponse; import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.SchemaName; import com.google.pubsub.v1.SchemaSettings; import com.google.pubsub.v1.SubscriptionName; import com.google.pubsub.v1.Topic; @@ -812,7 +813,7 @@ public void setIamPolicyTest() throws Exception { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); @@ -841,7 +842,7 @@ public void setIamPolicyExceptionTest() throws Exception { try { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setPolicy(Policy.newBuilder().build()) .setUpdateMask(FieldMask.newBuilder().build()) .build(); @@ -865,7 +866,7 @@ public void getIamPolicyTest() throws Exception { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); @@ -892,7 +893,7 @@ public void getIamPolicyExceptionTest() throws Exception { try { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .setOptions(GetPolicyOptions.newBuilder().build()) .build(); client.getIamPolicy(request); @@ -910,7 +911,7 @@ public void testIamPermissionsTest() throws Exception { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .addAllPermissions(new ArrayList()) .build(); @@ -937,7 +938,7 @@ public void testIamPermissionsExceptionTest() throws Exception { try { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(ProjectName.of("[PROJECT]").toString()) + .setResource(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()) .addAllPermissions(new ArrayList()) .build(); client.testIamPermissions(request); From fce9c0e2fc9d93a47549c08bb9be632c8c63a538 Mon Sep 17 00:00:00 2001 From: Mike Micatka <31972785+mmicatka@users.noreply.github.com> Date: Mon, 27 Jun 2022 13:19:15 -0400 Subject: [PATCH 14/18] style: expanding wildcard imports for clarity (#1174) --- .../cloud/pubsub/v1/MessageDispatcher.java | 14 ++++++++-- .../v1/StreamingSubscriberConnection.java | 26 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/MessageDispatcher.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/MessageDispatcher.java index 31693a189..de51d3bf5 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/MessageDispatcher.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/MessageDispatcher.java @@ -28,8 +28,18 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.ReceivedMessage; -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.Executor; +import java.util.concurrent.Future; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java index b19a1cbbe..1067fa7e5 100644 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java +++ b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/StreamingSubscriberConnection.java @@ -18,13 +18,22 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor; -import com.google.api.core.*; +import com.google.api.core.AbstractApiService; +import com.google.api.core.ApiClock; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +import com.google.api.core.SettableApiFuture; import com.google.api.gax.batching.FlowControlSettings; import com.google.api.gax.batching.FlowController; import com.google.api.gax.core.Distribution; import com.google.api.gax.grpc.GrpcCallContext; import com.google.api.gax.grpc.GrpcStatusCode; -import com.google.api.gax.rpc.*; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.StreamController; import com.google.cloud.pubsub.v1.MessageDispatcher.AckProcessor; import com.google.cloud.pubsub.v1.stub.SubscriberStub; import com.google.common.collect.Lists; @@ -32,11 +41,20 @@ import com.google.protobuf.Any; import com.google.protobuf.Empty; import com.google.protobuf.InvalidProtocolBufferException; -import com.google.pubsub.v1.*; +import com.google.pubsub.v1.AcknowledgeRequest; +import com.google.pubsub.v1.ModifyAckDeadlineRequest; +import com.google.pubsub.v1.StreamingPullRequest; +import com.google.pubsub.v1.StreamingPullResponse; import com.google.rpc.ErrorInfo; import io.grpc.Status; import io.grpc.protobuf.StatusProto; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; From 925be095bd8a227f4b49d357dcd386b4149a86f9 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 27 Jun 2022 21:06:11 +0200 Subject: [PATCH 15/18] deps: update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 (#1173) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-shared-dependencies](https://togithub.com/googleapis/java-shared-dependencies) | `2.12.0` -> `2.13.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.13.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.13.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.13.0/compatibility-slim/2.12.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/2.13.0/confidence-slim/2.12.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes

googleapis/java-shared-dependencies ### [`v2.13.0`](https://togithub.com/googleapis/java-shared-dependencies/blob/HEAD/CHANGELOG.md#​2130-httpsgithubcomgoogleapisjava-shared-dependenciescomparev2120v2130-2022-06-22) [Compare Source](https://togithub.com/googleapis/java-shared-dependencies/compare/v2.12.0...v2.13.0) ##### Dependencies - update dependency com.google.api-client:google-api-client-bom to v1.35.0 ([#​709](https://togithub.com/googleapis/java-shared-dependencies/issues/709)) ([239f8c3](https://togithub.com/googleapis/java-shared-dependencies/commit/239f8c33a11e233e6af79aee8c7e68cd156a0554)) - update dependency com.google.api-client:google-api-client-bom to v1.35.1 ([#​713](https://togithub.com/googleapis/java-shared-dependencies/issues/713)) ([6559b45](https://togithub.com/googleapis/java-shared-dependencies/commit/6559b45b027dba783a9525d35e32183d78773cbe)) - update dependency com.google.api:api-common to v2.2.1 ([#​710](https://togithub.com/googleapis/java-shared-dependencies/issues/710)) ([650d4c5](https://togithub.com/googleapis/java-shared-dependencies/commit/650d4c5f8c3cfce711257d47280ad773cd2e2414)) - update dependency com.google.errorprone:error_prone_annotations to v2.14.0 ([#​701](https://togithub.com/googleapis/java-shared-dependencies/issues/701)) ([d24730f](https://togithub.com/googleapis/java-shared-dependencies/commit/d24730f78669f80b109e590b903446e5552e3e36)) - update dependency com.google.http-client:google-http-client-bom to v1.42.0 ([#​711](https://togithub.com/googleapis/java-shared-dependencies/issues/711)) ([5168a18](https://togithub.com/googleapis/java-shared-dependencies/commit/5168a181722128d434a0d0d2ab5cc485686bbc78)) - update dependency com.google.oauth-client:google-oauth-client-bom to v1.34.0 ([#​708](https://togithub.com/googleapis/java-shared-dependencies/issues/708)) ([620336e](https://togithub.com/googleapis/java-shared-dependencies/commit/620336e6733e2017116e5e8a7b403b183a728bc1)) - update dependency com.google.oauth-client:google-oauth-client-bom to v1.34.1 ([#​712](https://togithub.com/googleapis/java-shared-dependencies/issues/712)) ([a2c18a5](https://togithub.com/googleapis/java-shared-dependencies/commit/a2c18a5bc4152cc9034cec691a29f54a35c38a51)) - update dependency com.google.protobuf:protobuf-bom to v3.21.0 ([#​703](https://togithub.com/googleapis/java-shared-dependencies/issues/703)) ([5f9fe12](https://togithub.com/googleapis/java-shared-dependencies/commit/5f9fe1200b4bdf4c54bf947c21bd3ed02f26f990)) - update dependency com.google.protobuf:protobuf-bom to v3.21.1 ([#​705](https://togithub.com/googleapis/java-shared-dependencies/issues/705)) ([c68edfb](https://togithub.com/googleapis/java-shared-dependencies/commit/c68edfbe7e1993e1112640b867b29aa2fbcf7579)) - update dependency io.grpc:grpc-bom to v1.47.0 ([#​707](https://togithub.com/googleapis/java-shared-dependencies/issues/707)) ([d02918a](https://togithub.com/googleapis/java-shared-dependencies/commit/d02918a0418cd65d1d247f27afb0637f1f8f5666)) - update dependency org.checkerframework:checker-qual to v3.22.1 ([#​706](https://togithub.com/googleapis/java-shared-dependencies/issues/706)) ([545843b](https://togithub.com/googleapis/java-shared-dependencies/commit/545843b492cead230b8cc72a1dae7d4922f33b39)) - update dependency org.checkerframework:checker-qual to v3.22.2 ([#​717](https://togithub.com/googleapis/java-shared-dependencies/issues/717)) ([142852a](https://togithub.com/googleapis/java-shared-dependencies/commit/142852a37140f221197f5c71aed451def353b1e0)) - update gax.version to v2.18.2 ([#​718](https://togithub.com/googleapis/java-shared-dependencies/issues/718)) ([5f8156e](https://togithub.com/googleapis/java-shared-dependencies/commit/5f8156e55c6a07b018a8c5efafa68be781b4288b)) - update google.common-protos.version to v2.9.0 ([#​714](https://togithub.com/googleapis/java-shared-dependencies/issues/714)) ([9e5591e](https://togithub.com/googleapis/java-shared-dependencies/commit/9e5591ec3035350450ecbfebd00e08216433b06c)) - update google.core.version to v2.8.0 ([#​719](https://togithub.com/googleapis/java-shared-dependencies/issues/719)) ([4023c60](https://togithub.com/googleapis/java-shared-dependencies/commit/4023c6063a2c5b5308da531df1a08c90c491965d)) - update iam.version to v1.4.0 ([#​700](https://togithub.com/googleapis/java-shared-dependencies/issues/700)) ([c1097a4](https://togithub.com/googleapis/java-shared-dependencies/commit/c1097a46ab0739b0b7234bc510e4c3d9ce2c2861)) - update iam.version to v1.4.1 ([#​716](https://togithub.com/googleapis/java-shared-dependencies/issues/716)) ([e2dc7c2](https://togithub.com/googleapis/java-shared-dependencies/commit/e2dc7c21c39e007878841e2664d548ec44a72d54))
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-pubsub). --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e9174882..7f84a23f5 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import From db53cd8665e1a55fe201a58a1479ba72a6b24945 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 18:58:13 +0000 Subject: [PATCH 16/18] chore: update dependencies for regapic (#1467) (#1177) * chore: update dependencies for regapic * add more dependencies and trigger comment * update goldens * fix indentation * remove duplicate gax-httpjson dependency * remove duplicated dependencies Source-Link: https://github.com/googleapis/synthtool/commit/fa54eb2a78c6ee48613fd33152e2130e949dcbd9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/common.sh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index a79f06271..f0625e4d9 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:2567a120ce90fadb6201999b87d649d9f67459de28815ad239bce9ebfaa18a74 -# created: 2022-05-19T15:12:45.278246753Z + digest: sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 +# created: 2022-06-27T15:01:06.405564326Z diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ace89f45a..f8f957af1 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -55,4 +55,6 @@ function retry_with_backoff { ## Helper functionss function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } \ No newline at end of file +function println() { printf '%s\n' "$(now) $*"; } + +## Helper comment to trigger updated repo dependency release \ No newline at end of file From e5555633bf4dc4ee543eb2596bafacdd78ea9d16 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 02:22:21 +0000 Subject: [PATCH 17/18] chore: Disable CLIRR checks on releas (#1474) (#1181) Source-Link: https://github.com/googleapis/synthtool/commit/7a220e27993a25ab3cda26510d5619d97b6952a9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/release/stage.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index f0625e4d9..a454a61e8 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 -# created: 2022-06-27T15:01:06.405564326Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f0..1dba8de10 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi From 2333370d24669c9bbc09c6f34122cc9bc7301031 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 17:34:34 +0000 Subject: [PATCH 18/18] chore(main): release 1.120.0 (#1167) :robot: I have created a release *beep* *boop* --- ## [1.120.0](https://github.com/googleapis/java-pubsub/compare/v1.119.1...v1.120.0) (2022-06-30) ### Features * Enable REST transport for most of Java and Go clients ([#1162](https://github.com/googleapis/java-pubsub/issues/1162)) ([c8ebb13](https://github.com/googleapis/java-pubsub/commit/c8ebb1319b7714c03308d8e7af53912b6b6a0d44)) ### Documentation * **sample:** clean up README of native image sample ([#1166](https://github.com/googleapis/java-pubsub/issues/1166)) ([890987c](https://github.com/googleapis/java-pubsub/commit/890987c0b285c9c5a5224f676e070ceefb90fe02)) ### Dependencies * update dependency com.google.cloud:google-cloud-bigquery to v2.13.5 ([#1172](https://github.com/googleapis/java-pubsub/issues/1172)) ([51f4da0](https://github.com/googleapis/java-pubsub/commit/51f4da048e298e6184e9a6bf931a9f1307534c61)) * update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 ([#1175](https://github.com/googleapis/java-pubsub/issues/1175)) ([9385452](https://github.com/googleapis/java-pubsub/commit/938545266b6b15f93fe82aa253b55ca4d4fd7e22)) * update dependency com.google.cloud:google-cloud-core to v2.8.0 ([#1171](https://github.com/googleapis/java-pubsub/issues/1171)) ([4b7888f](https://github.com/googleapis/java-pubsub/commit/4b7888f582752982e2c9e1fd03472f5172fa9910)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#1173](https://github.com/googleapis/java-pubsub/issues/1173)) ([925be09](https://github.com/googleapis/java-pubsub/commit/925be095bd8a227f4b49d357dcd386b4149a86f9)) * update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 ([#1169](https://github.com/googleapis/java-pubsub/issues/1169)) ([e8e93e6](https://github.com/googleapis/java-pubsub/commit/e8e93e6c47e2c0a3546453a3aa23263ff3878a55)) * update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 ([#1170](https://github.com/googleapis/java-pubsub/issues/1170)) ([1327e89](https://github.com/googleapis/java-pubsub/commit/1327e89e2e491afe0b05fb458bbea296a8ae101f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 22 ++++++++++++++++++++++ google-cloud-pubsub-bom/pom.xml | 8 ++++---- google-cloud-pubsub/pom.xml | 4 ++-- grpc-google-cloud-pubsub-v1/pom.xml | 4 ++-- pom.xml | 8 ++++---- proto-google-cloud-pubsub-v1/pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 6 +++--- 8 files changed, 40 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f04ff7ef..7f5c90633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [1.120.0](https://github.com/googleapis/java-pubsub/compare/v1.119.1...v1.120.0) (2022-06-30) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#1162](https://github.com/googleapis/java-pubsub/issues/1162)) ([c8ebb13](https://github.com/googleapis/java-pubsub/commit/c8ebb1319b7714c03308d8e7af53912b6b6a0d44)) + + +### Documentation + +* **sample:** clean up README of native image sample ([#1166](https://github.com/googleapis/java-pubsub/issues/1166)) ([890987c](https://github.com/googleapis/java-pubsub/commit/890987c0b285c9c5a5224f676e070ceefb90fe02)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-bigquery to v2.13.5 ([#1172](https://github.com/googleapis/java-pubsub/issues/1172)) ([51f4da0](https://github.com/googleapis/java-pubsub/commit/51f4da048e298e6184e9a6bf931a9f1307534c61)) +* update dependency com.google.cloud:google-cloud-bigquery to v2.13.6 ([#1175](https://github.com/googleapis/java-pubsub/issues/1175)) ([9385452](https://github.com/googleapis/java-pubsub/commit/938545266b6b15f93fe82aa253b55ca4d4fd7e22)) +* update dependency com.google.cloud:google-cloud-core to v2.8.0 ([#1171](https://github.com/googleapis/java-pubsub/issues/1171)) ([4b7888f](https://github.com/googleapis/java-pubsub/commit/4b7888f582752982e2c9e1fd03472f5172fa9910)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#1173](https://github.com/googleapis/java-pubsub/issues/1173)) ([925be09](https://github.com/googleapis/java-pubsub/commit/925be095bd8a227f4b49d357dcd386b4149a86f9)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 ([#1169](https://github.com/googleapis/java-pubsub/issues/1169)) ([e8e93e6](https://github.com/googleapis/java-pubsub/commit/e8e93e6c47e2c0a3546453a3aa23263ff3878a55)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 ([#1170](https://github.com/googleapis/java-pubsub/issues/1170)) ([1327e89](https://github.com/googleapis/java-pubsub/commit/1327e89e2e491afe0b05fb458bbea296a8ae101f)) + ## [1.119.1](https://github.com/googleapis/java-pubsub/compare/v1.119.0...v1.119.1) (2022-06-06) diff --git a/google-cloud-pubsub-bom/pom.xml b/google-cloud-pubsub-bom/pom.xml index 84e67f52e..600b20970 100644 --- a/google-cloud-pubsub-bom/pom.xml +++ b/google-cloud-pubsub-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-pubsub-bom - 1.119.2-SNAPSHOT + 1.120.0 pom com.google.cloud @@ -52,17 +52,17 @@ com.google.cloud google-cloud-pubsub - 1.119.2-SNAPSHOT + 1.120.0 com.google.api.grpc grpc-google-cloud-pubsub-v1 - 1.101.2-SNAPSHOT + 1.102.0 com.google.api.grpc proto-google-cloud-pubsub-v1 - 1.101.2-SNAPSHOT + 1.102.0 diff --git a/google-cloud-pubsub/pom.xml b/google-cloud-pubsub/pom.xml index 395ba8898..8efb3034b 100644 --- a/google-cloud-pubsub/pom.xml +++ b/google-cloud-pubsub/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-pubsub - 1.119.2-SNAPSHOT + 1.120.0 jar Google Cloud Pub/Sub https://github.com/googleapis/java-pubsub @@ -11,7 +11,7 @@ com.google.cloud google-cloud-pubsub-parent - 1.119.2-SNAPSHOT + 1.120.0 google-cloud-pubsub diff --git a/grpc-google-cloud-pubsub-v1/pom.xml b/grpc-google-cloud-pubsub-v1/pom.xml index 8e5edf0b9..5b5f90f1a 100644 --- a/grpc-google-cloud-pubsub-v1/pom.xml +++ b/grpc-google-cloud-pubsub-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-pubsub-v1 - 1.101.2-SNAPSHOT + 1.102.0 grpc-google-cloud-pubsub-v1 GRPC library for grpc-google-cloud-pubsub-v1 com.google.cloud google-cloud-pubsub-parent - 1.119.2-SNAPSHOT + 1.120.0 diff --git a/pom.xml b/pom.xml index 7f84a23f5..395b1e235 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-pubsub-parent pom - 1.119.2-SNAPSHOT + 1.120.0 Google Cloud Pub/Sub Parent https://github.com/googleapis/java-pubsub @@ -69,17 +69,17 @@ com.google.api.grpc proto-google-cloud-pubsub-v1 - 1.101.2-SNAPSHOT + 1.102.0 com.google.api.grpc grpc-google-cloud-pubsub-v1 - 1.101.2-SNAPSHOT + 1.102.0 com.google.cloud google-cloud-pubsub - 1.119.2-SNAPSHOT + 1.120.0 diff --git a/proto-google-cloud-pubsub-v1/pom.xml b/proto-google-cloud-pubsub-v1/pom.xml index 638cab637..f737e2f1e 100644 --- a/proto-google-cloud-pubsub-v1/pom.xml +++ b/proto-google-cloud-pubsub-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-pubsub-v1 - 1.101.2-SNAPSHOT + 1.102.0 proto-google-cloud-pubsub-v1 PROTO library for proto-google-cloud-pubsub-v1 com.google.cloud google-cloud-pubsub-parent - 1.119.2-SNAPSHOT + 1.120.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 511502a0c..5e45d581d 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -43,7 +43,7 @@ com.google.cloud google-cloud-pubsub - 1.119.2-SNAPSHOT + 1.120.0 diff --git a/versions.txt b/versions.txt index fcbfea377..0fd7bc0f6 100644 --- a/versions.txt +++ b/versions.txt @@ -1,6 +1,6 @@ # Format: # module:released-version:current-version -google-cloud-pubsub:1.119.1:1.119.2-SNAPSHOT -grpc-google-cloud-pubsub-v1:1.101.1:1.101.2-SNAPSHOT -proto-google-cloud-pubsub-v1:1.101.1:1.101.2-SNAPSHOT +google-cloud-pubsub:1.120.0:1.120.0 +grpc-google-cloud-pubsub-v1:1.102.0:1.102.0 +proto-google-cloud-pubsub-v1:1.102.0:1.102.0