From 8bf4ada29c9ff6e05ce03f785ec69bb65cc76921 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 26 May 2022 00:20:32 +0200 Subject: [PATCH 01/21] chore(deps): update dependency com.google.cloud:google-cloud-translate to v2.2.0 (#1004) 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-translate](https://togithub.com/googleapis/java-translate) | `2.1.13` -> `2.2.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-translate/2.2.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-translate/2.2.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-translate/2.2.0/compatibility-slim/2.1.13)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-translate/2.2.0/confidence-slim/2.1.13)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: 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://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-translate). --- 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 66718519..66449d49 100644 --- a/README.md +++ b/README.md @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-translate - 2.1.13 + 2.2.0 ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-translate:2.1.13' +implementation 'com.google.cloud:google-cloud-translate:2.2.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-translate" % "2.1.13" +libraryDependencies += "com.google.cloud" % "google-cloud-translate" % "2.2.0" ``` ## Authentication diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 86f63ce5..c439c88a 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-translate - 2.1.13 + 2.2.0 From 4871284229d28fe3993b45af937d31961580a97e Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 26 May 2022 00:26:13 +0200 Subject: [PATCH 02/21] deps: update dependency com.google.cloud:google-cloud-storage to v2.7.1 (#1003) 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-storage](https://togithub.com/googleapis/java-storage) | `2.6.1` -> `2.7.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.1/compatibility-slim/2.6.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.1/confidence-slim/2.6.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: 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 these updates 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-translate). --- 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 c439c88a..b469b90f 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -35,7 +35,7 @@ com.google.cloud google-cloud-storage - 2.6.1 + 2.7.1 junit diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 05bed9d9..e743243f 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -34,7 +34,7 @@ com.google.cloud google-cloud-storage - 2.6.1 + 2.7.1 From e2070a9785a029772bbb25109a480bd151003843 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 26 May 2022 18:58:22 +0200 Subject: [PATCH 03/21] deps: update dependency com.google.cloud:google-cloud-core to v2.7.1 (#997) 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.6.1` -> `2.7.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.7.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.7.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.7.1/compatibility-slim/2.6.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.7.1/confidence-slim/2.6.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-core ### [`v2.7.1`](https://togithub.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#​271-httpsgithubcomgoogleapisjava-corecomparev270v271-2022-05-19) [Compare Source](https://togithub.com/googleapis/java-core/compare/v2.7.0...v2.7.1) ### [`v2.7.0`](https://togithub.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#​270-httpsgithubcomgoogleapisjava-corecomparev261v270-2022-05-18) [Compare Source](https://togithub.com/googleapis/java-core/compare/v2.6.1...v2.7.0) ##### Features - **java:** remove native-image-support module ([#​820](https://togithub.com/googleapis/java-core/issues/820)) ([a53ef6d](https://togithub.com/googleapis/java-core/commit/a53ef6d7ba05eeba82998378455f0aea58f24381)) - next release from main branch is 2.7.0 ([#​807](https://togithub.com/googleapis/java-core/issues/807)) ([5a2c608](https://togithub.com/googleapis/java-core/commit/5a2c608e375d15ec83ca71232627bce1f167e750)) ##### Bug Fixes - remove native-image-support module from version.txt ([#​822](https://togithub.com/googleapis/java-core/issues/822)) ([92e7efc](https://togithub.com/googleapis/java-core/commit/92e7efc4974911f7ce30021a280c9002a44dab47)) ##### Dependencies - update dependency com.google.api-client:google-api-client-bom to v1.34.1 ([#​823](https://togithub.com/googleapis/java-core/issues/823)) ([71105c6](https://togithub.com/googleapis/java-core/commit/71105c64918d6444e321fa3de5fc402e577ebc7d)) - update dependency com.google.api:api-common to v2.2.0 ([#​827](https://togithub.com/googleapis/java-core/issues/827)) ([05a02d6](https://togithub.com/googleapis/java-core/commit/05a02d6b16cb06b9f1dea0814912e5a32913fca8)) - update dependency com.google.api:gax-bom to v2.17.0 ([#​826](https://togithub.com/googleapis/java-core/issues/826)) ([c90188e](https://togithub.com/googleapis/java-core/commit/c90188e9a94ae71d71105d908173f1bd7e77c1cb)) - update dependency com.google.api:gax-bom to v2.18.0 ([#​829](https://togithub.com/googleapis/java-core/issues/829)) ([5537e7f](https://togithub.com/googleapis/java-core/commit/5537e7f80d5db94038b24a393e310120fab62e8c)) - update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.2 ([#​805](https://togithub.com/googleapis/java-core/issues/805)) ([493ac03](https://togithub.com/googleapis/java-core/commit/493ac038d3ca9f603cd47969fde0da68a1f9bfd0)) - update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.3 ([#​814](https://togithub.com/googleapis/java-core/issues/814)) ([e809baa](https://togithub.com/googleapis/java-core/commit/e809baa69672d3eca2dc348f55615dc072a8fbe3)) - update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.4 ([#​825](https://togithub.com/googleapis/java-core/issues/825)) ([5ce12ee](https://togithub.com/googleapis/java-core/commit/5ce12ee0c10e2bdb5981e6ca02966d7eb802ca6c)) - update dependency com.google.auth:google-auth-library-bom to v1.7.0 ([#​828](https://togithub.com/googleapis/java-core/issues/828)) ([2abca2c](https://togithub.com/googleapis/java-core/commit/2abca2c135ba2337d546d5c97bcdd5901e91301a)) - update dependency com.google.cloud:native-image-support to v0.14.0 ([#​824](https://togithub.com/googleapis/java-core/issues/824)) ([997a34a](https://togithub.com/googleapis/java-core/commit/997a34a15a59bb1818fff3d1fbce195a05d12da3)) - update dependency com.google.errorprone:error_prone_annotations to v2.13.1 ([#​806](https://togithub.com/googleapis/java-core/issues/806)) ([9fc5811](https://togithub.com/googleapis/java-core/commit/9fc5811eae52288acd9fb0b967e5737848fe7c5e)) - update dependency com.google.http-client:google-http-client-bom to v1.41.8 ([#​821](https://togithub.com/googleapis/java-core/issues/821)) ([c7e3d6e](https://togithub.com/googleapis/java-core/commit/c7e3d6ef437d9f85dab450b54d63f7218b89788b)) - update dependency com.google.protobuf:protobuf-bom to v3.20.1 ([#​813](https://togithub.com/googleapis/java-core/issues/813)) ([a9c8c92](https://togithub.com/googleapis/java-core/commit/a9c8c92086c0266e14f86a957944c0cc4ab26ee6)) - update dependency io.grpc:grpc-bom to v1.46.0 ([#​815](https://togithub.com/googleapis/java-core/issues/815)) ([03c9bfe](https://togithub.com/googleapis/java-core/commit/03c9bfe4210a6c3995adf89be28b7c8aab402fb3)) - update opencensus.version to v0.31.1 ([#​819](https://togithub.com/googleapis/java-core/issues/819)) ([1800d3a](https://togithub.com/googleapis/java-core/commit/1800d3aa3ff7315947681b648f822f2cf9656a3b)) ##### [2.6.1](https://togithub.com/googleapis/java-core/compare/v2.6.0...v2.6.1) (2022-04-14) ##### Dependencies - update dependency com.google.errorprone:error_prone_annotations to v2.13.0 ([#​802](https://togithub.com/googleapis/java-core/issues/802)) ([042b08e](https://togithub.com/googleapis/java-core/commit/042b08e3cf05dba7e006f802dbc60f95b6da99ef))
--- ### Configuration 📅 **Schedule**: 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-translate). --- 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 b469b90f..e5d67673 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.6.1 + 2.7.1 test tests diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index e743243f..e987f750 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.6.1 + 2.7.1 test tests diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 0c0feed1..fdf74e87 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -62,7 +62,7 @@ com.google.cloud google-cloud-core - 2.6.1 + 2.7.1 test tests From 4147f50a30e1d255cce7820221235e7715d2d0a4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 27 May 2022 04:08:24 +0000 Subject: [PATCH 04/21] chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 (#1000) - [ ] Regenerate this pull request now. 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 --- .../google/cloud/translate/v3/TranslationServiceClient.java | 4 ---- .../translate/v3/stub/TranslationServiceStubSettings.java | 1 - .../cloud/translate/v3beta1/TranslationServiceClient.java | 3 --- .../v3beta1/stub/TranslationServiceStubSettings.java | 1 - 4 files changed, 9 deletions(-) diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java index 9394f607..81ee821e 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.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.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; @@ -133,7 +132,6 @@ public static final TranslationServiceClient create(TranslationServiceSettings s * Constructs an instance of TranslationServiceClient, using the given stub for making calls. This * is for advanced usage - prefer using create(TranslationServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final TranslationServiceClient create(TranslationServiceStub stub) { return new TranslationServiceClient(stub); } @@ -149,7 +147,6 @@ protected TranslationServiceClient(TranslationServiceSettings settings) throws I this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected TranslationServiceClient(TranslationServiceStub stub) { this.settings = null; this.stub = stub; @@ -160,7 +157,6 @@ public final TranslationServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public TranslationServiceStub getStub() { return stub; } diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java index ea02a17a..eedd6cdf 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java @@ -290,7 +290,6 @@ public UnaryCallSettings deleteGlossarySetting return deleteGlossaryOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public TranslationServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java index fd2afe94..608e58a5 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java @@ -141,7 +141,6 @@ public static final TranslationServiceClient create(TranslationServiceSettings s * Constructs an instance of TranslationServiceClient, using the given stub for making calls. This * is for advanced usage - prefer using create(TranslationServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final TranslationServiceClient create(TranslationServiceStub stub) { return new TranslationServiceClient(stub); } @@ -157,7 +156,6 @@ protected TranslationServiceClient(TranslationServiceSettings settings) throws I this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected TranslationServiceClient(TranslationServiceStub stub) { this.settings = null; this.stub = stub; @@ -168,7 +166,6 @@ public final TranslationServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public TranslationServiceStub getStub() { return stub; } diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java index 43c44fac..eeae4229 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java @@ -291,7 +291,6 @@ public UnaryCallSettings deleteGlossarySetting return deleteGlossaryOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public TranslationServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() From 1bb4942ab866f8a82a683880668829e34a64725b Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 27 May 2022 17:42:18 +0200 Subject: [PATCH 05/21] deps: update dependency com.google.cloud:google-cloud-storage to v2.7.2 (#1005) 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-storage](https://togithub.com/googleapis/java-storage) | `2.7.1` -> `2.7.2` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.2/compatibility-slim/2.7.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.7.2/confidence-slim/2.7.1)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-storage ### [`v2.7.2`](https://togithub.com/googleapis/java-storage/blob/HEAD/CHANGELOG.md#​272-httpsgithubcomgoogleapisjava-storagecomparev271v272-2022-05-27) [Compare Source](https://togithub.com/googleapis/java-storage/compare/v2.7.1...v2.7.2)
--- ### Configuration 📅 **Schedule**: 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-translate). --- 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 e5d67673..522dacbc 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -35,7 +35,7 @@ com.google.cloud google-cloud-storage - 2.7.1 + 2.7.2 junit diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index e987f750..e1a917f9 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -34,7 +34,7 @@ com.google.cloud google-cloud-storage - 2.7.1 + 2.7.2 From 9ebe7618fd554f12b34e4bd51099fa5374fd4565 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 6 Jun 2022 19:14:18 +0200 Subject: [PATCH 06/21] chore(deps): update dependency com.google.cloud:libraries-bom to v25.4.0 (#1006) 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**: 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-translate). --- samples/snippets/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index fdf74e87..93653290 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import From d7d970518dc73ae4e4b61b40f05f9b7baaa000af Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 13 Jun 2022 18:56:15 +0200 Subject: [PATCH 07/21] deps: update dependency com.google.cloud:google-cloud-storage to v2.8.0 (#1007) 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-storage](https://togithub.com/googleapis/java-storage) | `2.7.2` -> `2.8.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.8.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.8.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.8.0/compatibility-slim/2.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-storage/2.8.0/confidence-slim/2.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/java-storage ### [`v2.8.0`](https://togithub.com/googleapis/java-storage/blob/HEAD/CHANGELOG.md#​280-httpsgithubcomgoogleapisjava-storagecomparev272v280-2022-06-08) [Compare Source](https://togithub.com/googleapis/java-storage/compare/v2.7.2...v2.8.0) ##### Features - Prefix/Suffix Matches Lifecycle Condition ([#​1389](https://togithub.com/googleapis/java-storage/issues/1389)) ([20c8848](https://togithub.com/googleapis/java-storage/commit/20c88489d80d716da28f78fed628b54345f32ca4)) - Support AbortIncompleteMultipartUpload LifecycleAction ([#​1347](https://togithub.com/googleapis/java-storage/issues/1347)) ([7c3aba2](https://togithub.com/googleapis/java-storage/commit/7c3aba2f0a26ac550e4f37f9287ed6b041d75919)) ##### Bug Fixes - update request method of HttpStorageRpc to properly configure offset on requests ([#​1434](https://togithub.com/googleapis/java-storage/issues/1434)) ([72dc0df](https://togithub.com/googleapis/java-storage/commit/72dc0dff20d76875401dac721c0268c32e475e39)) ##### Dependencies - update dependency com.google.apis:google-api-services-storage to v1-rev20220604-1.32.1 ([#​1438](https://togithub.com/googleapis/java-storage/issues/1438)) ([df8fcd9](https://togithub.com/googleapis/java-storage/commit/df8fcd9925ef06c91ebebe0a3a7b5aedeb15ec4d)) - update dependency com.google.cloud:google-cloud-pubsub to v1.119.0 ([#​1426](https://togithub.com/googleapis/java-storage/issues/1426)) ([93ba28c](https://togithub.com/googleapis/java-storage/commit/93ba28cff16d428e0222078dc60dbf49fda7632a)) ##### [2.7.2](https://togithub.com/googleapis/java-storage/compare/v2.7.1...v2.7.2) (2022-05-27) ##### Dependencies - update kms.version to v0.96.1 ([#​1418](https://togithub.com/googleapis/java-storage/issues/1418)) ([d2f325b](https://togithub.com/googleapis/java-storage/commit/d2f325b3d31ac5da367873be1fb530fb6356036a)) ##### [2.7.1](https://togithub.com/googleapis/java-storage/compare/v2.7.0...v2.7.1) (2022-05-24) ##### Dependencies - update kms.version to v0.96.0 ([#​1408](https://togithub.com/googleapis/java-storage/issues/1408)) ([7501ffc](https://togithub.com/googleapis/java-storage/commit/7501ffc97d5a7943d3852ea26133b6c62cbbff1f))
--- ### 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-translate). --- 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 522dacbc..24400ff8 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -35,7 +35,7 @@ com.google.cloud google-cloud-storage - 2.7.2 + 2.8.0 junit diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index e1a917f9..dda7bea0 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -34,7 +34,7 @@ com.google.cloud google-cloud-storage - 2.7.2 + 2.8.0 From cc9f89a8e4dc3ce9efaee9b4dd106ac2f549f262 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 13 Jun 2022 19:02:11 +0200 Subject: [PATCH 08/21] build(deps): update dependency com.google.cloud:google-cloud-shared-config to v1.5.0 (#1010) 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-translate). --- google-cloud-translate-bom/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google-cloud-translate-bom/pom.xml b/google-cloud-translate-bom/pom.xml index e0abba0a..195c1c38 100644 --- a/google-cloud-translate-bom/pom.xml +++ b/google-cloud-translate-bom/pom.xml @@ -8,7 +8,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google Cloud Translate BOM diff --git a/pom.xml b/pom.xml index 38905382..7d906f73 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 7b0563c513dcf609249bbd04f69469ec42df6a2d Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 20:16:21 +0000 Subject: [PATCH 09/21] chore: Integrate new gapic-generator-java and rules_gapic (#1008) - [ ] Regenerate this pull request now. 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 --- .../com/google/cloud/translate/v3/TranslationServiceClient.java | 2 +- .../cloud/translate/v3beta1/TranslationServiceClient.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java index 81ee821e..dbb08e47 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java @@ -1478,7 +1478,7 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re * while (true) { * ListGlossariesResponse response = * translationServiceClient.listGlossariesCallable().call(request); - * for (Glossary element : response.getResponsesList()) { + * for (Glossary element : response.getGlossariesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java index 608e58a5..368a267b 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java @@ -1280,7 +1280,7 @@ public final ListGlossariesPagedResponse listGlossaries(ListGlossariesRequest re * while (true) { * ListGlossariesResponse response = * translationServiceClient.listGlossariesCallable().call(request); - * for (Glossary element : response.getResponsesList()) { + * for (Glossary element : response.getGlossariesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); From a5a2a657738740b2024f216c0ba5539ba67d4bfb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 13 Jun 2022 22:26:27 +0200 Subject: [PATCH 10/21] deps: update dependency com.google.cloud:google-cloud-storage to v2.8.1 (#1011) --- 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 24400ff8..312cb449 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -35,7 +35,7 @@ com.google.cloud google-cloud-storage - 2.8.0 + 2.8.1 junit diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index dda7bea0..7092adc4 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -34,7 +34,7 @@ com.google.cloud google-cloud-storage - 2.8.0 + 2.8.1 From 2c0c99a8d71eb5cb4d013e992922d7db5244215a Mon Sep 17 00:00:00 2001 From: Emily Ball Date: Tue, 14 Jun 2022 21:38:12 +0000 Subject: [PATCH 11/21] chore: include generated samples dir (#1009) --- .github/.OwlBot.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index d30e942d..74c2fb26 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot.yaml @@ -16,6 +16,7 @@ docker: image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest" deep-remove-regex: +- "/samples/snippets/generated" - "/grpc-google-.*/src" - "/proto-google-.*/src" - "/google-.*/src/com/google/cloud/translate/v3" @@ -31,3 +32,5 @@ deep-copy-regex: dest: "/owl-bot-staging/$1/grpc-google-cloud-translate-$1/src" - source: "/google/cloud/translate/(v.*)/.*-java/gapic-google-.*/src" dest: "/owl-bot-staging/$1/google-cloud-translate/src" +- source: "/google/cloud/translate/(v.*)/.*-java/samples/snippets/generated" + dest: "/owl-bot-staging/$1/samples/snippets/generated" From 0fdb776115d90ea0894b0bc92d3a59181fd050e3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 22 Jun 2022 02:46:12 +0200 Subject: [PATCH 12/21] deps: update dependency com.google.cloud:google-cloud-core to v2.8.0 (#1012) 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-translate). --- 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 312cb449..1e8fd3c0 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 test tests diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 7092adc4..0e5d2beb 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 test tests diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 93653290..6d481d0c 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -62,7 +62,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 test tests From 7b1d5d6542806983815c2b84d847721b1951662a Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 23 Jun 2022 17:28:11 +0200 Subject: [PATCH 13/21] deps: update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 (#1013) 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-translate). --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d906f73..c6b4debb 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import From 8befc799748f11c15f4e511c8a65a74401638ffa 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 15:02:16 +0000 Subject: [PATCH 14/21] feat: Enable REST transport for most of Java and Go clients (#1014) - [ ] Regenerate this pull request now. 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 --- google-cloud-translate/pom.xml | 16 + .../v3/TranslationServiceClient.java | 38 +- .../v3/TranslationServiceSettings.java | 23 +- ...JsonTranslationServiceCallableFactory.java | 105 ++ .../stub/HttpJsonTranslationServiceStub.java | 806 +++++++++++ .../v3/stub/TranslationServiceStub.java | 6 +- .../stub/TranslationServiceStubSettings.java | 53 +- .../v3beta1/TranslationServiceClient.java | 38 +- .../v3beta1/TranslationServiceSettings.java | 23 +- ...JsonTranslationServiceCallableFactory.java | 105 ++ .../stub/HttpJsonTranslationServiceStub.java | 812 +++++++++++ .../v3beta1/stub/TranslationServiceStub.java | 6 +- .../stub/TranslationServiceStubSettings.java | 53 +- .../TranslationServiceClientHttpJsonTest.java | 1187 +++++++++++++++++ .../TranslationServiceClientHttpJsonTest.java | 1036 ++++++++++++++ .../translatetext/SyncTranslateText.java | 47 + .../AsyncBatchTranslateDocument.java | 59 + .../AsyncBatchTranslateDocumentLRO.java | 60 + .../SyncBatchTranslateDocument.java | 56 + ...tinputconfigBatchdocumentoutputconfig.java | 56 + ...tinputconfigBatchdocumentoutputconfig.java | 56 + .../AsyncBatchTranslateText.java | 59 + .../AsyncBatchTranslateTextLRO.java | 60 + .../SyncBatchTranslateText.java | 56 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../createglossary/AsyncCreateGlossary.java | 49 + .../AsyncCreateGlossaryLRO.java | 49 + .../createglossary/SyncCreateGlossary.java | 44 + ...yncCreateGlossaryLocationnameGlossary.java | 41 + .../SyncCreateGlossaryStringGlossary.java | 40 + .../deleteglossary/AsyncDeleteGlossary.java | 47 + .../AsyncDeleteGlossaryLRO.java | 48 + .../deleteglossary/SyncDeleteGlossary.java | 43 + .../SyncDeleteGlossaryGlossaryname.java | 39 + .../SyncDeleteGlossaryString.java | 39 + .../detectlanguage/AsyncDetectLanguage.java | 51 + .../detectlanguage/SyncDetectLanguage.java | 47 + ...anguageLocationnameStringStringString.java | 45 + ...etectLanguageStringStringStringString.java | 45 + .../getglossary/AsyncGetGlossary.java | 47 + .../getglossary/SyncGetGlossary.java | 43 + .../SyncGetGlossaryGlossaryname.java | 39 + .../getglossary/SyncGetGlossaryString.java | 39 + .../AsyncGetSupportedLanguages.java | 49 + .../SyncGetSupportedLanguages.java | 45 + ...rtedLanguagesLocationnameStringString.java | 44 + ...tSupportedLanguagesStringStringString.java | 44 + .../listglossaries/AsyncListGlossaries.java | 52 + .../AsyncListGlossariesPaged.java | 60 + .../listglossaries/SyncListGlossaries.java | 48 + .../SyncListGlossariesLocationname.java | 41 + .../SyncListGlossariesString.java | 41 + .../AsyncTranslateDocument.java | 57 + .../SyncTranslateDocument.java | 53 + .../translatetext/AsyncTranslateText.java | 57 + .../translatetext/SyncTranslateText.java | 53 + ...slateTextLocationnameStringListstring.java | 46 + ...ameStringStringStringStringListstring.java | 51 + ...ncTranslateTextStringStringListstring.java | 45 + ...ingStringStringStringStringListstring.java | 50 + .../translatetext/SyncTranslateText.java | 47 + .../translatetext/SyncTranslateText.java | 47 + .../AsyncBatchTranslateDocument.java | 59 + .../AsyncBatchTranslateDocumentLRO.java | 60 + .../SyncBatchTranslateDocument.java | 56 + ...tinputconfigBatchdocumentoutputconfig.java | 56 + ...tinputconfigBatchdocumentoutputconfig.java | 56 + .../AsyncBatchTranslateText.java | 59 + .../AsyncBatchTranslateTextLRO.java | 60 + .../SyncBatchTranslateText.java | 56 + .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 42 + .../create/SyncCreateSetEndpoint.java | 39 + .../createglossary/AsyncCreateGlossary.java | 49 + .../AsyncCreateGlossaryLRO.java | 49 + .../createglossary/SyncCreateGlossary.java | 44 + ...yncCreateGlossaryLocationnameGlossary.java | 42 + .../SyncCreateGlossaryStringGlossary.java | 40 + .../deleteglossary/AsyncDeleteGlossary.java | 47 + .../AsyncDeleteGlossaryLRO.java | 48 + .../deleteglossary/SyncDeleteGlossary.java | 43 + .../SyncDeleteGlossaryGlossaryname.java | 39 + .../SyncDeleteGlossaryString.java | 39 + .../detectlanguage/AsyncDetectLanguage.java | 51 + .../detectlanguage/SyncDetectLanguage.java | 47 + ...etectLanguageLocationnameStringString.java | 44 + .../SyncDetectLanguageStringStringString.java | 44 + .../getglossary/AsyncGetGlossary.java | 47 + .../getglossary/SyncGetGlossary.java | 43 + .../SyncGetGlossaryGlossaryname.java | 39 + .../getglossary/SyncGetGlossaryString.java | 39 + .../AsyncGetSupportedLanguages.java | 49 + .../SyncGetSupportedLanguages.java | 45 + ...rtedLanguagesLocationnameStringString.java | 44 + ...tSupportedLanguagesStringStringString.java | 44 + .../listglossaries/AsyncListGlossaries.java | 52 + .../AsyncListGlossariesPaged.java | 60 + .../listglossaries/SyncListGlossaries.java | 48 + .../SyncListGlossariesLocationnameString.java | 45 + .../SyncListGlossariesStringString.java | 43 + .../AsyncTranslateDocument.java | 57 + .../SyncTranslateDocument.java | 53 + .../translatetext/AsyncTranslateText.java | 57 + .../translatetext/SyncTranslateText.java | 53 + .../translatetext/SyncTranslateText.java | 47 + 107 files changed, 8717 insertions(+), 22 deletions(-) create mode 100644 google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceCallableFactory.java create mode 100644 google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceStub.java create mode 100644 google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceCallableFactory.java create mode 100644 google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceStub.java create mode 100644 google-cloud-translate/src/test/java/com/google/cloud/translate/v3/TranslationServiceClientHttpJsonTest.java create mode 100644 google-cloud-translate/src/test/java/com/google/cloud/translate/v3beta1/TranslationServiceClientHttpJsonTest.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/stub/translationservicestubsettings/translatetext/SyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/AsyncDetectLanguage.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguage.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/AsyncGetGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossaries.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossaries.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesLocationname.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/AsyncTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/SyncTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/AsyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3/translationservicesettings/translatetext/SyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/stub/translationservicestubsettings/translatetext/SyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/AsyncDetectLanguage.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguage.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/AsyncGetGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossary.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossaries.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossaries.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesStringString.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/AsyncTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/SyncTranslateDocument.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/AsyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/SyncTranslateText.java create mode 100644 samples/snippets/generated/com/google/cloud/translate/v3beta1/translationservicesettings/translatetext/SyncTranslateText.java diff --git a/google-cloud-translate/pom.xml b/google-cloud-translate/pom.xml index 6f663f47..501bb129 100644 --- a/google-cloud-translate/pom.xml +++ b/google-cloud-translate/pom.xml @@ -61,6 +61,10 @@ com.google.api gax-grpc + + + com.google.api + gax-httpjson org.threeten @@ -123,12 +127,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-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java index dbb08e47..f57eeebb 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -106,13 +106,29 @@ * TranslationServiceClient.create(translationServiceSettings); * } * + *

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.
+ * TranslationServiceSettings translationServiceSettings =
+ *     TranslationServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * TranslationServiceClient translationServiceClient =
+ *     TranslationServiceClient.create(translationServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class TranslationServiceClient implements BackgroundResource { private final TranslationServiceSettings settings; private final TranslationServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of TranslationServiceClient with default settings. */ public static final TranslationServiceClient create() throws IOException { @@ -144,13 +160,17 @@ public static final TranslationServiceClient create(TranslationServiceStub stub) protected TranslationServiceClient(TranslationServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((TranslationServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected TranslationServiceClient(TranslationServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final TranslationServiceSettings getSettings() { @@ -165,10 +185,18 @@ public TranslationServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Translates input text and returns translated text. diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java index f3b18373..0b1c73e6 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.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; @@ -185,11 +186,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return TranslationServiceStubSettings.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 TranslationServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return TranslationServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return TranslationServiceStubSettings.defaultTransportChannelProvider(); } @@ -199,11 +207,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return TranslationServiceStubSettings.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); @@ -241,6 +255,11 @@ private static Builder createDefault() { return new Builder(TranslationServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(TranslationServiceStubSettings.newHttpJsonBuilder()); + } + public TranslationServiceStubSettings.Builder getStubSettingsBuilder() { return ((TranslationServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceCallableFactory.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceCallableFactory.java new file mode 100644 index 00000000..9c30a3b8 --- /dev/null +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceCallableFactory.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.translate.v3.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 TranslationService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTranslationServiceCallableFactory + 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-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceStub.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceStub.java new file mode 100644 index 00000000..147fd458 --- /dev/null +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/HttpJsonTranslationServiceStub.java @@ -0,0 +1,806 @@ +/* + * 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.translate.v3.stub; + +import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.translate.v3.BatchTranslateDocumentMetadata; +import com.google.cloud.translate.v3.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3.BatchTranslateMetadata; +import com.google.cloud.translate.v3.BatchTranslateResponse; +import com.google.cloud.translate.v3.BatchTranslateTextRequest; +import com.google.cloud.translate.v3.CreateGlossaryMetadata; +import com.google.cloud.translate.v3.CreateGlossaryRequest; +import com.google.cloud.translate.v3.DeleteGlossaryMetadata; +import com.google.cloud.translate.v3.DeleteGlossaryRequest; +import com.google.cloud.translate.v3.DeleteGlossaryResponse; +import com.google.cloud.translate.v3.DetectLanguageRequest; +import com.google.cloud.translate.v3.DetectLanguageResponse; +import com.google.cloud.translate.v3.GetGlossaryRequest; +import com.google.cloud.translate.v3.GetSupportedLanguagesRequest; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.ListGlossariesRequest; +import com.google.cloud.translate.v3.ListGlossariesResponse; +import com.google.cloud.translate.v3.SupportedLanguages; +import com.google.cloud.translate.v3.TranslateDocumentRequest; +import com.google.cloud.translate.v3.TranslateDocumentResponse; +import com.google.cloud.translate.v3.TranslateTextRequest; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the TranslationService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonTranslationServiceStub extends TranslationServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(DeleteGlossaryMetadata.getDescriptor()) + .add(BatchTranslateResponse.getDescriptor()) + .add(BatchTranslateMetadata.getDescriptor()) + .add(Glossary.getDescriptor()) + .add(CreateGlossaryMetadata.getDescriptor()) + .add(BatchTranslateDocumentResponse.getDescriptor()) + .add(DeleteGlossaryResponse.getDescriptor()) + .add(BatchTranslateDocumentMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + translateTextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateText") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}:translateText", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v3/{parent=projects/*}:translateText") + .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(TranslateTextResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + detectLanguageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/DetectLanguage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}:detectLanguage", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v3/{parent=projects/*}:detectLanguage") + .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(DetectLanguageResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getSupportedLanguagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3.TranslationService/GetSupportedLanguages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}/supportedLanguages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v3/{parent=projects/*}/supportedLanguages") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "displayLanguageCode", request.getDisplayLanguageCode()); + serializer.putQueryParam(fields, "model", request.getModel()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SupportedLanguages.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + translateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/TranslateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}:translateDocument", + 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(TranslateDocumentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchTranslateTextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3.TranslationService/BatchTranslateText") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}:batchTranslateText", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchTranslateTextRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchTranslateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3.TranslationService/BatchTranslateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}:batchTranslateDocument", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchTranslateDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createGlossaryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/CreateGlossary") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}/glossaries", + 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("glossary", request.getGlossary())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateGlossaryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listGlossariesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/ListGlossaries") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{parent=projects/*/locations/*}/glossaries", + 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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListGlossariesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getGlossaryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/GetGlossary") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=projects/*/locations/*/glossaries/*}", + 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(Glossary.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteGlossaryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3.TranslationService/DeleteGlossary") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3/{name=projects/*/locations/*/glossaries/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteGlossaryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable translateTextCallable; + private final UnaryCallable detectLanguageCallable; + private final UnaryCallable + getSupportedLanguagesCallable; + private final UnaryCallable + translateDocumentCallable; + private final UnaryCallable batchTranslateTextCallable; + private final OperationCallable< + BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> + batchTranslateTextOperationCallable; + private final UnaryCallable + batchTranslateDocumentCallable; + private final OperationCallable< + BatchTranslateDocumentRequest, + BatchTranslateDocumentResponse, + BatchTranslateDocumentMetadata> + batchTranslateDocumentOperationCallable; + private final UnaryCallable createGlossaryCallable; + private final OperationCallable + createGlossaryOperationCallable; + private final UnaryCallable listGlossariesCallable; + private final UnaryCallable + listGlossariesPagedCallable; + private final UnaryCallable getGlossaryCallable; + private final UnaryCallable deleteGlossaryCallable; + private final OperationCallable< + DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> + deleteGlossaryOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonTranslationServiceStub create(TranslationServiceStubSettings settings) + throws IOException { + return new HttpJsonTranslationServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonTranslationServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonTranslationServiceStub( + TranslationServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonTranslationServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonTranslationServiceStub( + TranslationServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonTranslationServiceStub, 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 HttpJsonTranslationServiceStub( + TranslationServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonTranslationServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonTranslationServiceStub, 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 HttpJsonTranslationServiceStub( + TranslationServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + translateTextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(translateTextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + detectLanguageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(detectLanguageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getSupportedLanguagesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSupportedLanguagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + translateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(translateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchTranslateTextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchTranslateTextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchTranslateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchTranslateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createGlossaryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createGlossaryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listGlossariesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listGlossariesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getGlossaryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getGlossaryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteGlossaryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteGlossaryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.translateTextCallable = + callableFactory.createUnaryCallable( + translateTextTransportSettings, settings.translateTextSettings(), clientContext); + this.detectLanguageCallable = + callableFactory.createUnaryCallable( + detectLanguageTransportSettings, settings.detectLanguageSettings(), clientContext); + this.getSupportedLanguagesCallable = + callableFactory.createUnaryCallable( + getSupportedLanguagesTransportSettings, + settings.getSupportedLanguagesSettings(), + clientContext); + this.translateDocumentCallable = + callableFactory.createUnaryCallable( + translateDocumentTransportSettings, + settings.translateDocumentSettings(), + clientContext); + this.batchTranslateTextCallable = + callableFactory.createUnaryCallable( + batchTranslateTextTransportSettings, + settings.batchTranslateTextSettings(), + clientContext); + this.batchTranslateTextOperationCallable = + callableFactory.createOperationCallable( + batchTranslateTextTransportSettings, + settings.batchTranslateTextOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchTranslateDocumentCallable = + callableFactory.createUnaryCallable( + batchTranslateDocumentTransportSettings, + settings.batchTranslateDocumentSettings(), + clientContext); + this.batchTranslateDocumentOperationCallable = + callableFactory.createOperationCallable( + batchTranslateDocumentTransportSettings, + settings.batchTranslateDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createGlossaryCallable = + callableFactory.createUnaryCallable( + createGlossaryTransportSettings, settings.createGlossarySettings(), clientContext); + this.createGlossaryOperationCallable = + callableFactory.createOperationCallable( + createGlossaryTransportSettings, + settings.createGlossaryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listGlossariesCallable = + callableFactory.createUnaryCallable( + listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext); + this.listGlossariesPagedCallable = + callableFactory.createPagedCallable( + listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext); + this.getGlossaryCallable = + callableFactory.createUnaryCallable( + getGlossaryTransportSettings, settings.getGlossarySettings(), clientContext); + this.deleteGlossaryCallable = + callableFactory.createUnaryCallable( + deleteGlossaryTransportSettings, settings.deleteGlossarySettings(), clientContext); + this.deleteGlossaryOperationCallable = + callableFactory.createOperationCallable( + deleteGlossaryTransportSettings, + settings.deleteGlossaryOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(translateTextMethodDescriptor); + methodDescriptors.add(detectLanguageMethodDescriptor); + methodDescriptors.add(getSupportedLanguagesMethodDescriptor); + methodDescriptors.add(translateDocumentMethodDescriptor); + methodDescriptors.add(batchTranslateTextMethodDescriptor); + methodDescriptors.add(batchTranslateDocumentMethodDescriptor); + methodDescriptors.add(createGlossaryMethodDescriptor); + methodDescriptors.add(listGlossariesMethodDescriptor); + methodDescriptors.add(getGlossaryMethodDescriptor); + methodDescriptors.add(deleteGlossaryMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable translateTextCallable() { + return translateTextCallable; + } + + @Override + public UnaryCallable detectLanguageCallable() { + return detectLanguageCallable; + } + + @Override + public UnaryCallable + getSupportedLanguagesCallable() { + return getSupportedLanguagesCallable; + } + + @Override + public UnaryCallable + translateDocumentCallable() { + return translateDocumentCallable; + } + + @Override + public UnaryCallable batchTranslateTextCallable() { + return batchTranslateTextCallable; + } + + @Override + public OperationCallable< + BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> + batchTranslateTextOperationCallable() { + return batchTranslateTextOperationCallable; + } + + @Override + public UnaryCallable batchTranslateDocumentCallable() { + return batchTranslateDocumentCallable; + } + + @Override + public OperationCallable< + BatchTranslateDocumentRequest, + BatchTranslateDocumentResponse, + BatchTranslateDocumentMetadata> + batchTranslateDocumentOperationCallable() { + return batchTranslateDocumentOperationCallable; + } + + @Override + public UnaryCallable createGlossaryCallable() { + return createGlossaryCallable; + } + + @Override + public OperationCallable + createGlossaryOperationCallable() { + return createGlossaryOperationCallable; + } + + @Override + public UnaryCallable listGlossariesCallable() { + return listGlossariesCallable; + } + + @Override + public UnaryCallable + listGlossariesPagedCallable() { + return listGlossariesPagedCallable; + } + + @Override + public UnaryCallable getGlossaryCallable() { + return getGlossaryCallable; + } + + @Override + public UnaryCallable deleteGlossaryCallable() { + return deleteGlossaryCallable; + } + + @Override + public OperationCallable + deleteGlossaryOperationCallable() { + return deleteGlossaryOperationCallable; + } + + @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-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java index 9beafc60..74e56fe5 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStub.java @@ -58,7 +58,11 @@ public abstract class TranslationServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable translateTextCallable() { diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java index eedd6cdf..8d212900 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/stub/TranslationServiceStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -296,6 +299,11 @@ public TranslationServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcTranslationServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonTranslationServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -328,18 +336,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(TranslationServiceStubSettings.class)) @@ -347,11 +362,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(TranslationServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return TranslationServiceStubSettings.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); @@ -548,6 +582,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 .translateTextSettings() diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java index 368a267b..f9473e1c 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.translate.v3beta1.stub.TranslationServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -114,6 +114,21 @@ * TranslationServiceClient.create(translationServiceSettings); * } * + *

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.
+ * TranslationServiceSettings translationServiceSettings =
+ *     TranslationServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * TranslationServiceClient translationServiceClient =
+ *     TranslationServiceClient.create(translationServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -121,7 +136,8 @@ public class TranslationServiceClient implements BackgroundResource { private final TranslationServiceSettings settings; private final TranslationServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of TranslationServiceClient with default settings. */ public static final TranslationServiceClient create() throws IOException { @@ -153,13 +169,17 @@ public static final TranslationServiceClient create(TranslationServiceStub stub) protected TranslationServiceClient(TranslationServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((TranslationServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected TranslationServiceClient(TranslationServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final TranslationServiceSettings getSettings() { @@ -174,10 +194,18 @@ public TranslationServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Translates input text and returns translated text. diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceSettings.java index 3417095d..fd89310d 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceSettings.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceSettings.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; @@ -186,11 +187,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return TranslationServiceStubSettings.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 TranslationServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return TranslationServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return TranslationServiceStubSettings.defaultTransportChannelProvider(); } @@ -200,11 +208,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return TranslationServiceStubSettings.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(TranslationServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(TranslationServiceStubSettings.newHttpJsonBuilder()); + } + public TranslationServiceStubSettings.Builder getStubSettingsBuilder() { return ((TranslationServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceCallableFactory.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceCallableFactory.java new file mode 100644 index 00000000..4496bf3f --- /dev/null +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceCallableFactory.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.translate.v3beta1.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 TranslationService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonTranslationServiceCallableFactory + 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-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceStub.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceStub.java new file mode 100644 index 00000000..dddc1b5c --- /dev/null +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/HttpJsonTranslationServiceStub.java @@ -0,0 +1,812 @@ +/* + * 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.translate.v3beta1.stub; + +import static com.google.cloud.translate.v3beta1.TranslationServiceClient.ListGlossariesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentMetadata; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.BatchTranslateMetadata; +import com.google.cloud.translate.v3beta1.BatchTranslateResponse; +import com.google.cloud.translate.v3beta1.BatchTranslateTextRequest; +import com.google.cloud.translate.v3beta1.CreateGlossaryMetadata; +import com.google.cloud.translate.v3beta1.CreateGlossaryRequest; +import com.google.cloud.translate.v3beta1.DeleteGlossaryMetadata; +import com.google.cloud.translate.v3beta1.DeleteGlossaryRequest; +import com.google.cloud.translate.v3beta1.DeleteGlossaryResponse; +import com.google.cloud.translate.v3beta1.DetectLanguageRequest; +import com.google.cloud.translate.v3beta1.DetectLanguageResponse; +import com.google.cloud.translate.v3beta1.GetGlossaryRequest; +import com.google.cloud.translate.v3beta1.GetSupportedLanguagesRequest; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.ListGlossariesRequest; +import com.google.cloud.translate.v3beta1.ListGlossariesResponse; +import com.google.cloud.translate.v3beta1.SupportedLanguages; +import com.google.cloud.translate.v3beta1.TranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.TranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.TranslateTextRequest; +import com.google.cloud.translate.v3beta1.TranslateTextResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the TranslationService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonTranslationServiceStub extends TranslationServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(BatchTranslateDocumentResponse.getDescriptor()) + .add(Glossary.getDescriptor()) + .add(DeleteGlossaryMetadata.getDescriptor()) + .add(CreateGlossaryMetadata.getDescriptor()) + .add(BatchTranslateMetadata.getDescriptor()) + .add(BatchTranslateDocumentMetadata.getDescriptor()) + .add(DeleteGlossaryResponse.getDescriptor()) + .add(BatchTranslateResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + translateTextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/TranslateText") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}:translateText", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v3beta1/{parent=projects/*}:translateText") + .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(TranslateTextResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + detectLanguageMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/DetectLanguage") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}:detectLanguage", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v3beta1/{parent=projects/*}:detectLanguage") + .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(DetectLanguageResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getSupportedLanguagesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/GetSupportedLanguages") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}/supportedLanguages", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths("/v3beta1/{parent=projects/*}/supportedLanguages") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "displayLanguageCode", request.getDisplayLanguageCode()); + serializer.putQueryParam(fields, "model", request.getModel()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(SupportedLanguages.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + translateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/TranslateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}:translateDocument", + 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(TranslateDocumentResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchTranslateTextMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/BatchTranslateText") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}:batchTranslateText", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchTranslateTextRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + batchTranslateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/BatchTranslateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}:batchTranslateDocument", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BatchTranslateDocumentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createGlossaryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/CreateGlossary") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}/glossaries", + 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("glossary", request.getGlossary())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateGlossaryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listGlossariesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/ListGlossaries") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{parent=projects/*/locations/*}/glossaries", + 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, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListGlossariesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getGlossaryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.translation.v3beta1.TranslationService/GetGlossary") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{name=projects/*/locations/*/glossaries/*}", + 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(Glossary.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteGlossaryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.translation.v3beta1.TranslationService/DeleteGlossary") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v3beta1/{name=projects/*/locations/*/glossaries/*}", + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteGlossaryRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable translateTextCallable; + private final UnaryCallable detectLanguageCallable; + private final UnaryCallable + getSupportedLanguagesCallable; + private final UnaryCallable + translateDocumentCallable; + private final UnaryCallable batchTranslateTextCallable; + private final OperationCallable< + BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> + batchTranslateTextOperationCallable; + private final UnaryCallable + batchTranslateDocumentCallable; + private final OperationCallable< + BatchTranslateDocumentRequest, + BatchTranslateDocumentResponse, + BatchTranslateDocumentMetadata> + batchTranslateDocumentOperationCallable; + private final UnaryCallable createGlossaryCallable; + private final OperationCallable + createGlossaryOperationCallable; + private final UnaryCallable listGlossariesCallable; + private final UnaryCallable + listGlossariesPagedCallable; + private final UnaryCallable getGlossaryCallable; + private final UnaryCallable deleteGlossaryCallable; + private final OperationCallable< + DeleteGlossaryRequest, DeleteGlossaryResponse, DeleteGlossaryMetadata> + deleteGlossaryOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonTranslationServiceStub create(TranslationServiceStubSettings settings) + throws IOException { + return new HttpJsonTranslationServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonTranslationServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonTranslationServiceStub( + TranslationServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonTranslationServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonTranslationServiceStub( + TranslationServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonTranslationServiceStub, 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 HttpJsonTranslationServiceStub( + TranslationServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonTranslationServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonTranslationServiceStub, 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 HttpJsonTranslationServiceStub( + TranslationServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + translateTextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(translateTextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + detectLanguageTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(detectLanguageMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getSupportedLanguagesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getSupportedLanguagesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + translateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(translateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings batchTranslateTextTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchTranslateTextMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchTranslateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchTranslateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createGlossaryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createGlossaryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listGlossariesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listGlossariesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getGlossaryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getGlossaryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteGlossaryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteGlossaryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.translateTextCallable = + callableFactory.createUnaryCallable( + translateTextTransportSettings, settings.translateTextSettings(), clientContext); + this.detectLanguageCallable = + callableFactory.createUnaryCallable( + detectLanguageTransportSettings, settings.detectLanguageSettings(), clientContext); + this.getSupportedLanguagesCallable = + callableFactory.createUnaryCallable( + getSupportedLanguagesTransportSettings, + settings.getSupportedLanguagesSettings(), + clientContext); + this.translateDocumentCallable = + callableFactory.createUnaryCallable( + translateDocumentTransportSettings, + settings.translateDocumentSettings(), + clientContext); + this.batchTranslateTextCallable = + callableFactory.createUnaryCallable( + batchTranslateTextTransportSettings, + settings.batchTranslateTextSettings(), + clientContext); + this.batchTranslateTextOperationCallable = + callableFactory.createOperationCallable( + batchTranslateTextTransportSettings, + settings.batchTranslateTextOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.batchTranslateDocumentCallable = + callableFactory.createUnaryCallable( + batchTranslateDocumentTransportSettings, + settings.batchTranslateDocumentSettings(), + clientContext); + this.batchTranslateDocumentOperationCallable = + callableFactory.createOperationCallable( + batchTranslateDocumentTransportSettings, + settings.batchTranslateDocumentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createGlossaryCallable = + callableFactory.createUnaryCallable( + createGlossaryTransportSettings, settings.createGlossarySettings(), clientContext); + this.createGlossaryOperationCallable = + callableFactory.createOperationCallable( + createGlossaryTransportSettings, + settings.createGlossaryOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listGlossariesCallable = + callableFactory.createUnaryCallable( + listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext); + this.listGlossariesPagedCallable = + callableFactory.createPagedCallable( + listGlossariesTransportSettings, settings.listGlossariesSettings(), clientContext); + this.getGlossaryCallable = + callableFactory.createUnaryCallable( + getGlossaryTransportSettings, settings.getGlossarySettings(), clientContext); + this.deleteGlossaryCallable = + callableFactory.createUnaryCallable( + deleteGlossaryTransportSettings, settings.deleteGlossarySettings(), clientContext); + this.deleteGlossaryOperationCallable = + callableFactory.createOperationCallable( + deleteGlossaryTransportSettings, + settings.deleteGlossaryOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(translateTextMethodDescriptor); + methodDescriptors.add(detectLanguageMethodDescriptor); + methodDescriptors.add(getSupportedLanguagesMethodDescriptor); + methodDescriptors.add(translateDocumentMethodDescriptor); + methodDescriptors.add(batchTranslateTextMethodDescriptor); + methodDescriptors.add(batchTranslateDocumentMethodDescriptor); + methodDescriptors.add(createGlossaryMethodDescriptor); + methodDescriptors.add(listGlossariesMethodDescriptor); + methodDescriptors.add(getGlossaryMethodDescriptor); + methodDescriptors.add(deleteGlossaryMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable translateTextCallable() { + return translateTextCallable; + } + + @Override + public UnaryCallable detectLanguageCallable() { + return detectLanguageCallable; + } + + @Override + public UnaryCallable + getSupportedLanguagesCallable() { + return getSupportedLanguagesCallable; + } + + @Override + public UnaryCallable + translateDocumentCallable() { + return translateDocumentCallable; + } + + @Override + public UnaryCallable batchTranslateTextCallable() { + return batchTranslateTextCallable; + } + + @Override + public OperationCallable< + BatchTranslateTextRequest, BatchTranslateResponse, BatchTranslateMetadata> + batchTranslateTextOperationCallable() { + return batchTranslateTextOperationCallable; + } + + @Override + public UnaryCallable batchTranslateDocumentCallable() { + return batchTranslateDocumentCallable; + } + + @Override + public OperationCallable< + BatchTranslateDocumentRequest, + BatchTranslateDocumentResponse, + BatchTranslateDocumentMetadata> + batchTranslateDocumentOperationCallable() { + return batchTranslateDocumentOperationCallable; + } + + @Override + public UnaryCallable createGlossaryCallable() { + return createGlossaryCallable; + } + + @Override + public OperationCallable + createGlossaryOperationCallable() { + return createGlossaryOperationCallable; + } + + @Override + public UnaryCallable listGlossariesCallable() { + return listGlossariesCallable; + } + + @Override + public UnaryCallable + listGlossariesPagedCallable() { + return listGlossariesPagedCallable; + } + + @Override + public UnaryCallable getGlossaryCallable() { + return getGlossaryCallable; + } + + @Override + public UnaryCallable deleteGlossaryCallable() { + return deleteGlossaryCallable; + } + + @Override + public OperationCallable + deleteGlossaryOperationCallable() { + return deleteGlossaryOperationCallable; + } + + @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-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStub.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStub.java index e7a4135d..ce71df3b 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStub.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStub.java @@ -60,7 +60,11 @@ public abstract class TranslationServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable translateTextCallable() { diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java index eeae4229..12219409 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/stub/TranslationServiceStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -297,6 +300,11 @@ public TranslationServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcTranslationServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonTranslationServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -329,18 +337,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(TranslationServiceStubSettings.class)) @@ -348,11 +363,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(TranslationServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return TranslationServiceStubSettings.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); @@ -549,6 +583,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 .translateTextSettings() diff --git a/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/TranslationServiceClientHttpJsonTest.java b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/TranslationServiceClientHttpJsonTest.java new file mode 100644 index 00000000..b9552e6e --- /dev/null +++ b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3/TranslationServiceClientHttpJsonTest.java @@ -0,0 +1,1187 @@ +/* + * 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.translate.v3; + +import static com.google.cloud.translate.v3.TranslationServiceClient.ListGlossariesPagedResponse; + +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.translate.v3.stub.HttpJsonTranslationServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +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 TranslationServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static TranslationServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonTranslationServiceStub.getMethodDescriptors(), + TranslationServiceSettings.getDefaultEndpoint()); + TranslationServiceSettings settings = + TranslationServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = TranslationServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void translateTextTest() throws Exception { + TranslateTextResponse expectedResponse = + TranslateTextResponse.newBuilder() + .addAllTranslations(new ArrayList()) + .addAllGlossaryTranslations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + + TranslateTextResponse actualResponse = + client.translateText(parent, targetLanguageCode, contents); + 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 translateTextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + client.translateText(parent, targetLanguageCode, contents); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void translateTextTest2() throws Exception { + TranslateTextResponse expectedResponse = + TranslateTextResponse.newBuilder() + .addAllTranslations(new ArrayList()) + .addAllGlossaryTranslations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + + TranslateTextResponse actualResponse = + client.translateText(parent, targetLanguageCode, contents); + 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 translateTextExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + client.translateText(parent, targetLanguageCode, contents); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void translateTextTest3() throws Exception { + TranslateTextResponse expectedResponse = + TranslateTextResponse.newBuilder() + .addAllTranslations(new ArrayList()) + .addAllGlossaryTranslations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + + TranslateTextResponse actualResponse = + client.translateText( + parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + 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 translateTextExceptionTest3() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + client.translateText( + parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void translateTextTest4() throws Exception { + TranslateTextResponse expectedResponse = + TranslateTextResponse.newBuilder() + .addAllTranslations(new ArrayList()) + .addAllGlossaryTranslations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + + TranslateTextResponse actualResponse = + client.translateText( + parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + 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 translateTextExceptionTest4() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + client.translateText( + parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detectLanguageTest() throws Exception { + DetectLanguageResponse expectedResponse = + DetectLanguageResponse.newBuilder() + .addAllLanguages(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String content = "content951530617"; + + DetectLanguageResponse actualResponse = client.detectLanguage(parent, model, mimeType, content); + 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 detectLanguageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String content = "content951530617"; + client.detectLanguage(parent, model, mimeType, content); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detectLanguageTest2() throws Exception { + DetectLanguageResponse expectedResponse = + DetectLanguageResponse.newBuilder() + .addAllLanguages(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String content = "content951530617"; + + DetectLanguageResponse actualResponse = client.detectLanguage(parent, model, mimeType, content); + 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 detectLanguageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String content = "content951530617"; + client.detectLanguage(parent, model, mimeType, content); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSupportedLanguagesTest() throws Exception { + SupportedLanguages expectedResponse = + SupportedLanguages.newBuilder().addAllLanguages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + + SupportedLanguages actualResponse = + client.getSupportedLanguages(parent, model, displayLanguageCode); + 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 getSupportedLanguagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + client.getSupportedLanguages(parent, model, displayLanguageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSupportedLanguagesTest2() throws Exception { + SupportedLanguages expectedResponse = + SupportedLanguages.newBuilder().addAllLanguages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + + SupportedLanguages actualResponse = + client.getSupportedLanguages(parent, model, displayLanguageCode); + 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 getSupportedLanguagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + client.getSupportedLanguages(parent, model, displayLanguageCode); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void translateDocumentTest() throws Exception { + TranslateDocumentResponse expectedResponse = + TranslateDocumentResponse.newBuilder() + .setDocumentTranslation(DocumentTranslation.newBuilder().build()) + .setGlossaryDocumentTranslation(DocumentTranslation.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("projects/project-5833/locations/location-5833") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + + TranslateDocumentResponse actualResponse = client.translateDocument(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 translateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("projects/project-5833/locations/location-5833") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + client.translateDocument(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchTranslateTextTest() throws Exception { + BatchTranslateResponse expectedResponse = + BatchTranslateResponse.newBuilder() + .setTotalCharacters(-1368640955) + .setTranslatedCharacters(-1337326221) + .setFailedCharacters(1723028396) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchTranslateTextTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + BatchTranslateResponse actualResponse = client.batchTranslateTextAsync(request).get(); + 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 batchTranslateTextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.batchTranslateTextAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchTranslateDocumentTest() throws Exception { + BatchTranslateDocumentResponse expectedResponse = + BatchTranslateDocumentResponse.newBuilder() + .setTotalPages(-396186871) + .setTranslatedPages(-1652747493) + .setFailedPages(-2002254526) + .setTotalBillablePages(1292117569) + .setTotalCharacters(-1368640955) + .setTranslatedCharacters(-1337326221) + .setFailedCharacters(1723028396) + .setTotalBillableCharacters(1242495501) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchTranslateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + + BatchTranslateDocumentResponse actualResponse = + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + 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 batchTranslateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchTranslateDocumentTest2() throws Exception { + BatchTranslateDocumentResponse expectedResponse = + BatchTranslateDocumentResponse.newBuilder() + .setTotalPages(-396186871) + .setTranslatedPages(-1652747493) + .setFailedPages(-2002254526) + .setTotalBillablePages(1292117569) + .setTotalCharacters(-1368640955) + .setTranslatedCharacters(-1337326221) + .setFailedCharacters(1723028396) + .setTotalBillableCharacters(1242495501) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchTranslateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + + BatchTranslateDocumentResponse actualResponse = + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + 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 batchTranslateDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createGlossaryTest() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Glossary glossary = Glossary.newBuilder().build(); + + Glossary actualResponse = client.createGlossaryAsync(parent, glossary).get(); + 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 createGlossaryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Glossary glossary = Glossary.newBuilder().build(); + client.createGlossaryAsync(parent, glossary).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createGlossaryTest2() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Glossary glossary = Glossary.newBuilder().build(); + + Glossary actualResponse = client.createGlossaryAsync(parent, glossary).get(); + 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 createGlossaryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Glossary glossary = Glossary.newBuilder().build(); + client.createGlossaryAsync(parent, glossary).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listGlossariesTest() throws Exception { + Glossary responsesElement = Glossary.newBuilder().build(); + ListGlossariesResponse expectedResponse = + ListGlossariesResponse.newBuilder() + .setNextPageToken("") + .addAllGlossaries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListGlossariesPagedResponse pagedListResponse = client.listGlossaries(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGlossariesList().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 listGlossariesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listGlossaries(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGlossariesTest2() throws Exception { + Glossary responsesElement = Glossary.newBuilder().build(); + ListGlossariesResponse expectedResponse = + ListGlossariesResponse.newBuilder() + .setNextPageToken("") + .addAllGlossaries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListGlossariesPagedResponse pagedListResponse = client.listGlossaries(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGlossariesList().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 listGlossariesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listGlossaries(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGlossaryTest() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + + Glossary actualResponse = client.getGlossary(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 getGlossaryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + client.getGlossary(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGlossaryTest2() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + + Glossary actualResponse = client.getGlossary(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 getGlossaryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + client.getGlossary(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGlossaryTest() throws Exception { + DeleteGlossaryResponse expectedResponse = + DeleteGlossaryResponse.newBuilder() + .setName("name3373707") + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + + DeleteGlossaryResponse actualResponse = client.deleteGlossaryAsync(name).get(); + 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 deleteGlossaryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + client.deleteGlossaryAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteGlossaryTest2() throws Exception { + DeleteGlossaryResponse expectedResponse = + DeleteGlossaryResponse.newBuilder() + .setName("name3373707") + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + + DeleteGlossaryResponse actualResponse = client.deleteGlossaryAsync(name).get(); + 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 deleteGlossaryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + client.deleteGlossaryAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-translate/src/test/java/com/google/cloud/translate/v3beta1/TranslationServiceClientHttpJsonTest.java b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3beta1/TranslationServiceClientHttpJsonTest.java new file mode 100644 index 00000000..c613c472 --- /dev/null +++ b/google-cloud-translate/src/test/java/com/google/cloud/translate/v3beta1/TranslationServiceClientHttpJsonTest.java @@ -0,0 +1,1036 @@ +/* + * 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.translate.v3beta1; + +import static com.google.cloud.translate.v3beta1.TranslationServiceClient.ListGlossariesPagedResponse; + +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.translate.v3beta1.stub.HttpJsonTranslationServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +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 TranslationServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static TranslationServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonTranslationServiceStub.getMethodDescriptors(), + TranslationServiceSettings.getDefaultEndpoint()); + TranslationServiceSettings settings = + TranslationServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = TranslationServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void translateTextTest() throws Exception { + TranslateTextResponse expectedResponse = + TranslateTextResponse.newBuilder() + .addAllTranslations(new ArrayList()) + .addAllGlossaryTranslations(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + TranslateTextRequest request = + TranslateTextRequest.newBuilder() + .addAllContents(new ArrayList()) + .setMimeType("mimeType-1392120434") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + + TranslateTextResponse actualResponse = client.translateText(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 translateTextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TranslateTextRequest request = + TranslateTextRequest.newBuilder() + .addAllContents(new ArrayList()) + .setMimeType("mimeType-1392120434") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + client.translateText(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detectLanguageTest() throws Exception { + DetectLanguageResponse expectedResponse = + DetectLanguageResponse.newBuilder() + .addAllLanguages(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + + DetectLanguageResponse actualResponse = client.detectLanguage(parent, model, mimeType); + 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 detectLanguageExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + client.detectLanguage(parent, model, mimeType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void detectLanguageTest2() throws Exception { + DetectLanguageResponse expectedResponse = + DetectLanguageResponse.newBuilder() + .addAllLanguages(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + + DetectLanguageResponse actualResponse = client.detectLanguage(parent, model, mimeType); + 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 detectLanguageExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + client.detectLanguage(parent, model, mimeType); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSupportedLanguagesTest() throws Exception { + SupportedLanguages expectedResponse = + SupportedLanguages.newBuilder().addAllLanguages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String displayLanguageCode = "displayLanguageCode-1457478841"; + String model = "model104069929"; + + SupportedLanguages actualResponse = + client.getSupportedLanguages(parent, displayLanguageCode, model); + 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 getSupportedLanguagesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String displayLanguageCode = "displayLanguageCode-1457478841"; + String model = "model104069929"; + client.getSupportedLanguages(parent, displayLanguageCode, model); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getSupportedLanguagesTest2() throws Exception { + SupportedLanguages expectedResponse = + SupportedLanguages.newBuilder().addAllLanguages(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + String model = "model104069929"; + + SupportedLanguages actualResponse = + client.getSupportedLanguages(parent, displayLanguageCode, model); + 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 getSupportedLanguagesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + String model = "model104069929"; + client.getSupportedLanguages(parent, displayLanguageCode, model); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void translateDocumentTest() throws Exception { + TranslateDocumentResponse expectedResponse = + TranslateDocumentResponse.newBuilder() + .setDocumentTranslation(DocumentTranslation.newBuilder().build()) + .setGlossaryDocumentTranslation(DocumentTranslation.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("projects/project-5833/locations/location-5833") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + + TranslateDocumentResponse actualResponse = client.translateDocument(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 translateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("projects/project-5833/locations/location-5833") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + client.translateDocument(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchTranslateTextTest() throws Exception { + BatchTranslateResponse expectedResponse = + BatchTranslateResponse.newBuilder() + .setTotalCharacters(-1368640955) + .setTranslatedCharacters(-1337326221) + .setFailedCharacters(1723028396) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchTranslateTextTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + + BatchTranslateResponse actualResponse = client.batchTranslateTextAsync(request).get(); + 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 batchTranslateTextExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + client.batchTranslateTextAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchTranslateDocumentTest() throws Exception { + BatchTranslateDocumentResponse expectedResponse = + BatchTranslateDocumentResponse.newBuilder() + .setTotalPages(-396186871) + .setTranslatedPages(-1652747493) + .setFailedPages(-2002254526) + .setTotalBillablePages(1292117569) + .setTotalCharacters(-1368640955) + .setTranslatedCharacters(-1337326221) + .setFailedCharacters(1723028396) + .setTotalBillableCharacters(1242495501) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchTranslateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + + BatchTranslateDocumentResponse actualResponse = + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + 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 batchTranslateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void batchTranslateDocumentTest2() throws Exception { + BatchTranslateDocumentResponse expectedResponse = + BatchTranslateDocumentResponse.newBuilder() + .setTotalPages(-396186871) + .setTranslatedPages(-1652747493) + .setFailedPages(-2002254526) + .setTotalBillablePages(1292117569) + .setTotalCharacters(-1368640955) + .setTranslatedCharacters(-1337326221) + .setFailedCharacters(1723028396) + .setTotalBillableCharacters(1242495501) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("batchTranslateDocumentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + + BatchTranslateDocumentResponse actualResponse = + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + 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 batchTranslateDocumentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + client + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createGlossaryTest() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Glossary glossary = Glossary.newBuilder().build(); + + Glossary actualResponse = client.createGlossaryAsync(parent, glossary).get(); + 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 createGlossaryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Glossary glossary = Glossary.newBuilder().build(); + client.createGlossaryAsync(parent, glossary).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createGlossaryTest2() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Glossary glossary = Glossary.newBuilder().build(); + + Glossary actualResponse = client.createGlossaryAsync(parent, glossary).get(); + 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 createGlossaryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Glossary glossary = Glossary.newBuilder().build(); + client.createGlossaryAsync(parent, glossary).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listGlossariesTest() throws Exception { + Glossary responsesElement = Glossary.newBuilder().build(); + ListGlossariesResponse expectedResponse = + ListGlossariesResponse.newBuilder() + .setNextPageToken("") + .addAllGlossaries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String filter = "filter-1274492040"; + + ListGlossariesPagedResponse pagedListResponse = client.listGlossaries(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGlossariesList().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 listGlossariesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String filter = "filter-1274492040"; + client.listGlossaries(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGlossariesTest2() throws Exception { + Glossary responsesElement = Glossary.newBuilder().build(); + ListGlossariesResponse expectedResponse = + ListGlossariesResponse.newBuilder() + .setNextPageToken("") + .addAllGlossaries(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + String filter = "filter-1274492040"; + + ListGlossariesPagedResponse pagedListResponse = client.listGlossaries(parent, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGlossariesList().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 listGlossariesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + String filter = "filter-1274492040"; + client.listGlossaries(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGlossaryTest() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + + Glossary actualResponse = client.getGlossary(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 getGlossaryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + client.getGlossary(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGlossaryTest2() throws Exception { + Glossary expectedResponse = + Glossary.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .setInputConfig(GlossaryInputConfig.newBuilder().build()) + .setEntryCount(-811131134) + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + + Glossary actualResponse = client.getGlossary(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 getGlossaryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + client.getGlossary(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGlossaryTest() throws Exception { + DeleteGlossaryResponse expectedResponse = + DeleteGlossaryResponse.newBuilder() + .setName("name3373707") + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + + DeleteGlossaryResponse actualResponse = client.deleteGlossaryAsync(name).get(); + 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 deleteGlossaryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + client.deleteGlossaryAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteGlossaryTest2() throws Exception { + DeleteGlossaryResponse expectedResponse = + DeleteGlossaryResponse.newBuilder() + .setName("name3373707") + .setSubmitTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteGlossaryTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + + DeleteGlossaryResponse actualResponse = client.deleteGlossaryAsync(name).get(); + 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 deleteGlossaryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9868/locations/location-9868/glossaries/glossarie-9868"; + client.deleteGlossaryAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/stub/translationservicestubsettings/translatetext/SyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3/stub/translationservicestubsettings/translatetext/SyncTranslateText.java new file mode 100644 index 00000000..12fcf716 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/stub/translationservicestubsettings/translatetext/SyncTranslateText.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3.stub.samples; + +// [START translation_v3_generated_translationservicestubsettings_translatetext_sync] +import com.google.cloud.translate.v3.stub.TranslationServiceStubSettings; +import java.time.Duration; + +public class SyncTranslateText { + + public static void main(String[] args) throws Exception { + syncTranslateText(); + } + + public static void syncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceStubSettings.Builder translationServiceSettingsBuilder = + TranslationServiceStubSettings.newBuilder(); + translationServiceSettingsBuilder + .translateTextSettings() + .setRetrySettings( + translationServiceSettingsBuilder + .translateTextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TranslationServiceStubSettings translationServiceSettings = + translationServiceSettingsBuilder.build(); + } +} +// [END translation_v3_generated_translationservicestubsettings_translatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java new file mode 100644 index 00000000..cdfb6277 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_batchtranslatedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.BatchDocumentInputConfig; +import com.google.cloud.translate.v3.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateDocument { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateDocument(); + } + + public static void asyncBatchTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateDocumentRequest request = + BatchTranslateDocumentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) + .putAllModels(new HashMap()) + .putAllGlossaries(new HashMap()) + .putAllFormatConversions(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.batchTranslateDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_batchtranslatedocument_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java new file mode 100644 index 00000000..601e6389 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java @@ -0,0 +1,60 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_batchtranslatedocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3.BatchDocumentInputConfig; +import com.google.cloud.translate.v3.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3.BatchTranslateDocumentMetadata; +import com.google.cloud.translate.v3.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateDocumentLRO(); + } + + public static void asyncBatchTranslateDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateDocumentRequest request = + BatchTranslateDocumentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) + .putAllModels(new HashMap()) + .putAllGlossaries(new HashMap()) + .putAllFormatConversions(new HashMap()) + .build(); + OperationFuture future = + translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request); + // Do something. + BatchTranslateDocumentResponse response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_batchtranslatedocument_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java new file mode 100644 index 00000000..fc26e794 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_batchtranslatedocument_sync] +import com.google.cloud.translate.v3.BatchDocumentInputConfig; +import com.google.cloud.translate.v3.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncBatchTranslateDocument { + + public static void main(String[] args) throws Exception { + syncBatchTranslateDocument(); + } + + public static void syncBatchTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateDocumentRequest request = + BatchTranslateDocumentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) + .putAllModels(new HashMap()) + .putAllGlossaries(new HashMap()) + .putAllFormatConversions(new HashMap()) + .build(); + BatchTranslateDocumentResponse response = + translationServiceClient.batchTranslateDocumentAsync(request).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_batchtranslatedocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java new file mode 100644 index 00000000..d026b460 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +import com.google.cloud.translate.v3.BatchDocumentInputConfig; +import com.google.cloud.translate.v3.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public +class SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig { + + public static void main(String[] args) throws Exception { + syncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig(); + } + + public static void + syncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + BatchTranslateDocumentResponse response = + translationServiceClient + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java new file mode 100644 index 00000000..2c3d0653 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +import com.google.cloud.translate.v3.BatchDocumentInputConfig; +import com.google.cloud.translate.v3.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public +class SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig { + + public static void main(String[] args) throws Exception { + syncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig(); + } + + public static void + syncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + BatchTranslateDocumentResponse response = + translationServiceClient + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java new file mode 100644 index 00000000..4f97afc9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_batchtranslatetext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.BatchTranslateTextRequest; +import com.google.cloud.translate.v3.InputConfig; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.OutputConfig; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateText { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateText(); + } + + public static void asyncBatchTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.batchTranslateTextCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_batchtranslatetext_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java new file mode 100644 index 00000000..1201b6ae --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java @@ -0,0 +1,60 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_batchtranslatetext_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3.BatchTranslateMetadata; +import com.google.cloud.translate.v3.BatchTranslateResponse; +import com.google.cloud.translate.v3.BatchTranslateTextRequest; +import com.google.cloud.translate.v3.InputConfig; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.OutputConfig; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateTextLRO { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateTextLRO(); + } + + public static void asyncBatchTranslateTextLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + OperationFuture future = + translationServiceClient.batchTranslateTextOperationCallable().futureCall(request); + // Do something. + BatchTranslateResponse response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_batchtranslatetext_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java new file mode 100644 index 00000000..c947a82e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_batchtranslatetext_sync] +import com.google.cloud.translate.v3.BatchTranslateResponse; +import com.google.cloud.translate.v3.BatchTranslateTextRequest; +import com.google.cloud.translate.v3.InputConfig; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.OutputConfig; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncBatchTranslateText { + + public static void main(String[] args) throws Exception { + syncBatchTranslateText(); + } + + public static void syncBatchTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + BatchTranslateResponse response = + translationServiceClient.batchTranslateTextAsync(request).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_batchtranslatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..16a74786 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.cloud.translate.v3.TranslationServiceSettings; +import com.google.cloud.translate.v3.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings translationServiceSettings = + TranslationServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + TranslationServiceClient translationServiceClient = + TranslationServiceClient.create(translationServiceSettings); + } +} +// [END translation_v3_generated_translationserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..2ee09605 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.cloud.translate.v3.TranslationServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings translationServiceSettings = + TranslationServiceSettings.newBuilder() + .setTransportChannelProvider( + TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + TranslationServiceClient translationServiceClient = + TranslationServiceClient.create(translationServiceSettings); + } +} +// [END translation_v3_generated_translationserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..71d0be95 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_create_setendpoint_sync] +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.cloud.translate.v3.TranslationServiceSettings; +import com.google.cloud.translate.v3.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings translationServiceSettings = + TranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + TranslationServiceClient translationServiceClient = + TranslationServiceClient.create(translationServiceSettings); + } +} +// [END translation_v3_generated_translationserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossary.java new file mode 100644 index 00000000..12101ab0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossary.java @@ -0,0 +1,49 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_createglossary_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.CreateGlossaryRequest; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateGlossary { + + public static void main(String[] args) throws Exception { + asyncCreateGlossary(); + } + + public static void asyncCreateGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + CreateGlossaryRequest request = + CreateGlossaryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGlossary(Glossary.newBuilder().build()) + .build(); + ApiFuture future = + translationServiceClient.createGlossaryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_createglossary_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java new file mode 100644 index 00000000..eb6b8832 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java @@ -0,0 +1,49 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_createglossary_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3.CreateGlossaryMetadata; +import com.google.cloud.translate.v3.CreateGlossaryRequest; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class AsyncCreateGlossaryLRO { + + public static void main(String[] args) throws Exception { + asyncCreateGlossaryLRO(); + } + + public static void asyncCreateGlossaryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + CreateGlossaryRequest request = + CreateGlossaryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGlossary(Glossary.newBuilder().build()) + .build(); + OperationFuture future = + translationServiceClient.createGlossaryOperationCallable().futureCall(request); + // Do something. + Glossary response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_createglossary_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossary.java new file mode 100644 index 00000000..17f5b098 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossary.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_createglossary_sync] +import com.google.cloud.translate.v3.CreateGlossaryRequest; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncCreateGlossary { + + public static void main(String[] args) throws Exception { + syncCreateGlossary(); + } + + public static void syncCreateGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + CreateGlossaryRequest request = + CreateGlossaryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGlossary(Glossary.newBuilder().build()) + .build(); + Glossary response = translationServiceClient.createGlossaryAsync(request).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_createglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java new file mode 100644 index 00000000..22635c43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java @@ -0,0 +1,41 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_createglossary_locationnameglossary_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncCreateGlossaryLocationnameGlossary { + + public static void main(String[] args) throws Exception { + syncCreateGlossaryLocationnameGlossary(); + } + + public static void syncCreateGlossaryLocationnameGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Glossary glossary = Glossary.newBuilder().build(); + Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_createglossary_locationnameglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java new file mode 100644 index 00000000..2e9f301c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_createglossary_stringglossary_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncCreateGlossaryStringGlossary { + + public static void main(String[] args) throws Exception { + syncCreateGlossaryStringGlossary(); + } + + public static void syncCreateGlossaryStringGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Glossary glossary = Glossary.newBuilder().build(); + Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_createglossary_stringglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java new file mode 100644 index 00000000..1ad42b27 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_deleteglossary_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.DeleteGlossaryRequest; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteGlossary { + + public static void main(String[] args) throws Exception { + asyncDeleteGlossary(); + } + + public static void asyncDeleteGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DeleteGlossaryRequest request = + DeleteGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + ApiFuture future = + translationServiceClient.deleteGlossaryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_deleteglossary_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java new file mode 100644 index 00000000..f94c525f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java @@ -0,0 +1,48 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_deleteglossary_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3.DeleteGlossaryMetadata; +import com.google.cloud.translate.v3.DeleteGlossaryRequest; +import com.google.cloud.translate.v3.DeleteGlossaryResponse; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class AsyncDeleteGlossaryLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteGlossaryLRO(); + } + + public static void asyncDeleteGlossaryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DeleteGlossaryRequest request = + DeleteGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + OperationFuture future = + translationServiceClient.deleteGlossaryOperationCallable().futureCall(request); + // Do something. + DeleteGlossaryResponse response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_deleteglossary_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossary.java new file mode 100644 index 00000000..6bd57c6e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossary.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_deleteglossary_sync] +import com.google.cloud.translate.v3.DeleteGlossaryRequest; +import com.google.cloud.translate.v3.DeleteGlossaryResponse; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncDeleteGlossary { + + public static void main(String[] args) throws Exception { + syncDeleteGlossary(); + } + + public static void syncDeleteGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DeleteGlossaryRequest request = + DeleteGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(request).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_deleteglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java new file mode 100644 index 00000000..750faad6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_deleteglossary_glossaryname_sync] +import com.google.cloud.translate.v3.DeleteGlossaryResponse; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncDeleteGlossaryGlossaryname { + + public static void main(String[] args) throws Exception { + syncDeleteGlossaryGlossaryname(); + } + + public static void syncDeleteGlossaryGlossaryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_deleteglossary_glossaryname_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java new file mode 100644 index 00000000..fe1e6ed9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_deleteglossary_string_sync] +import com.google.cloud.translate.v3.DeleteGlossaryResponse; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncDeleteGlossaryString { + + public static void main(String[] args) throws Exception { + syncDeleteGlossaryString(); + } + + public static void syncDeleteGlossaryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString(); + DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_deleteglossary_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/AsyncDetectLanguage.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/AsyncDetectLanguage.java new file mode 100644 index 00000000..4115a959 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/AsyncDetectLanguage.java @@ -0,0 +1,51 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_detectlanguage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.DetectLanguageRequest; +import com.google.cloud.translate.v3.DetectLanguageResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.HashMap; + +public class AsyncDetectLanguage { + + public static void main(String[] args) throws Exception { + asyncDetectLanguage(); + } + + public static void asyncDetectLanguage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DetectLanguageRequest request = + DetectLanguageRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setMimeType("mimeType-1392120434") + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.detectLanguageCallable().futureCall(request); + // Do something. + DetectLanguageResponse response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_detectlanguage_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguage.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguage.java new file mode 100644 index 00000000..56f975a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguage.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_detectlanguage_sync] +import com.google.cloud.translate.v3.DetectLanguageRequest; +import com.google.cloud.translate.v3.DetectLanguageResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.HashMap; + +public class SyncDetectLanguage { + + public static void main(String[] args) throws Exception { + syncDetectLanguage(); + } + + public static void syncDetectLanguage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DetectLanguageRequest request = + DetectLanguageRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setMimeType("mimeType-1392120434") + .putAllLabels(new HashMap()) + .build(); + DetectLanguageResponse response = translationServiceClient.detectLanguage(request); + } + } +} +// [END translation_v3_generated_translationserviceclient_detectlanguage_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java new file mode 100644 index 00000000..38f7d370 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java @@ -0,0 +1,45 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_detectlanguage_locationnamestringstringstring_sync] +import com.google.cloud.translate.v3.DetectLanguageResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncDetectLanguageLocationnameStringStringString { + + public static void main(String[] args) throws Exception { + syncDetectLanguageLocationnameStringStringString(); + } + + public static void syncDetectLanguageLocationnameStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String content = "content951530617"; + DetectLanguageResponse response = + translationServiceClient.detectLanguage(parent, model, mimeType, content); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_detectlanguage_locationnamestringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java new file mode 100644 index 00000000..f71cc1d2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java @@ -0,0 +1,45 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_detectlanguage_stringstringstringstring_sync] +import com.google.cloud.translate.v3.DetectLanguageResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncDetectLanguageStringStringStringString { + + public static void main(String[] args) throws Exception { + syncDetectLanguageStringStringStringString(); + } + + public static void syncDetectLanguageStringStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String content = "content951530617"; + DetectLanguageResponse response = + translationServiceClient.detectLanguage(parent, model, mimeType, content); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_detectlanguage_stringstringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/AsyncGetGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/AsyncGetGlossary.java new file mode 100644 index 00000000..37a5b2a4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/AsyncGetGlossary.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_getglossary_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.GetGlossaryRequest; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class AsyncGetGlossary { + + public static void main(String[] args) throws Exception { + asyncGetGlossary(); + } + + public static void asyncGetGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetGlossaryRequest request = + GetGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + ApiFuture future = + translationServiceClient.getGlossaryCallable().futureCall(request); + // Do something. + Glossary response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_getglossary_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossary.java new file mode 100644 index 00000000..f626a53d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossary.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_getglossary_sync] +import com.google.cloud.translate.v3.GetGlossaryRequest; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncGetGlossary { + + public static void main(String[] args) throws Exception { + syncGetGlossary(); + } + + public static void syncGetGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetGlossaryRequest request = + GetGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + Glossary response = translationServiceClient.getGlossary(request); + } + } +} +// [END translation_v3_generated_translationserviceclient_getglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java new file mode 100644 index 00000000..81c6cddf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_getglossary_glossaryname_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncGetGlossaryGlossaryname { + + public static void main(String[] args) throws Exception { + syncGetGlossaryGlossaryname(); + } + + public static void syncGetGlossaryGlossaryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + Glossary response = translationServiceClient.getGlossary(name); + } + } +} +// [END translation_v3_generated_translationserviceclient_getglossary_glossaryname_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryString.java new file mode 100644 index 00000000..652c5d36 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getglossary/SyncGetGlossaryString.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_getglossary_string_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.GlossaryName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncGetGlossaryString { + + public static void main(String[] args) throws Exception { + syncGetGlossaryString(); + } + + public static void syncGetGlossaryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString(); + Glossary response = translationServiceClient.getGlossary(name); + } + } +} +// [END translation_v3_generated_translationserviceclient_getglossary_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java new file mode 100644 index 00000000..605430c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java @@ -0,0 +1,49 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_getsupportedlanguages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.GetSupportedLanguagesRequest; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.SupportedLanguages; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class AsyncGetSupportedLanguages { + + public static void main(String[] args) throws Exception { + asyncGetSupportedLanguages(); + } + + public static void asyncGetSupportedLanguages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetSupportedLanguagesRequest request = + GetSupportedLanguagesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDisplayLanguageCode("displayLanguageCode-1457478841") + .setModel("model104069929") + .build(); + ApiFuture future = + translationServiceClient.getSupportedLanguagesCallable().futureCall(request); + // Do something. + SupportedLanguages response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_getsupportedlanguages_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java new file mode 100644 index 00000000..cb33cf7e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java @@ -0,0 +1,45 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_getsupportedlanguages_sync] +import com.google.cloud.translate.v3.GetSupportedLanguagesRequest; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.SupportedLanguages; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncGetSupportedLanguages { + + public static void main(String[] args) throws Exception { + syncGetSupportedLanguages(); + } + + public static void syncGetSupportedLanguages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetSupportedLanguagesRequest request = + GetSupportedLanguagesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDisplayLanguageCode("displayLanguageCode-1457478841") + .setModel("model104069929") + .build(); + SupportedLanguages response = translationServiceClient.getSupportedLanguages(request); + } + } +} +// [END translation_v3_generated_translationserviceclient_getsupportedlanguages_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java new file mode 100644 index 00000000..29cfec06 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.SupportedLanguages; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncGetSupportedLanguagesLocationnameStringString { + + public static void main(String[] args) throws Exception { + syncGetSupportedLanguagesLocationnameStringString(); + } + + public static void syncGetSupportedLanguagesLocationnameStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + SupportedLanguages response = + translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java new file mode 100644 index 00000000..51bf91a1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.SupportedLanguages; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncGetSupportedLanguagesStringStringString { + + public static void main(String[] args) throws Exception { + syncGetSupportedLanguagesStringStringString(); + } + + public static void syncGetSupportedLanguagesStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String model = "model104069929"; + String displayLanguageCode = "displayLanguageCode-1457478841"; + SupportedLanguages response = + translationServiceClient.getSupportedLanguages(parent, model, displayLanguageCode); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossaries.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossaries.java new file mode 100644 index 00000000..f7f542ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossaries.java @@ -0,0 +1,52 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_listglossaries_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.ListGlossariesRequest; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class AsyncListGlossaries { + + public static void main(String[] args) throws Exception { + asyncListGlossaries(); + } + + public static void asyncListGlossaries() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + ListGlossariesRequest request = + ListGlossariesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + translationServiceClient.listGlossariesPagedCallable().futureCall(request); + // Do something. + for (Glossary element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3_generated_translationserviceclient_listglossaries_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java new file mode 100644 index 00000000..5271aa2c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java @@ -0,0 +1,60 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_listglossaries_paged_async] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.ListGlossariesRequest; +import com.google.cloud.translate.v3.ListGlossariesResponse; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; +import com.google.common.base.Strings; + +public class AsyncListGlossariesPaged { + + public static void main(String[] args) throws Exception { + asyncListGlossariesPaged(); + } + + public static void asyncListGlossariesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + ListGlossariesRequest request = + ListGlossariesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListGlossariesResponse response = + translationServiceClient.listGlossariesCallable().call(request); + for (Glossary element : response.getGlossariesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END translation_v3_generated_translationserviceclient_listglossaries_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossaries.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossaries.java new file mode 100644 index 00000000..bfa1d27a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossaries.java @@ -0,0 +1,48 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_listglossaries_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.ListGlossariesRequest; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncListGlossaries { + + public static void main(String[] args) throws Exception { + syncListGlossaries(); + } + + public static void syncListGlossaries() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + ListGlossariesRequest request = + ListGlossariesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Glossary element : translationServiceClient.listGlossaries(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3_generated_translationserviceclient_listglossaries_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesLocationname.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesLocationname.java new file mode 100644 index 00000000..8c717701 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesLocationname.java @@ -0,0 +1,41 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_listglossaries_locationname_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncListGlossariesLocationname { + + public static void main(String[] args) throws Exception { + syncListGlossariesLocationname(); + } + + public static void syncListGlossariesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3_generated_translationserviceclient_listglossaries_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesString.java new file mode 100644 index 00000000..0da16ff5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/listglossaries/SyncListGlossariesString.java @@ -0,0 +1,41 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_listglossaries_string_sync] +import com.google.cloud.translate.v3.Glossary; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslationServiceClient; + +public class SyncListGlossariesString { + + public static void main(String[] args) throws Exception { + syncListGlossariesString(); + } + + public static void syncListGlossariesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Glossary element : translationServiceClient.listGlossaries(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3_generated_translationserviceclient_listglossaries_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/AsyncTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/AsyncTranslateDocument.java new file mode 100644 index 00000000..6d52ab89 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/AsyncTranslateDocument.java @@ -0,0 +1,57 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_translatedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.DocumentInputConfig; +import com.google.cloud.translate.v3.DocumentOutputConfig; +import com.google.cloud.translate.v3.TranslateDocumentRequest; +import com.google.cloud.translate.v3.TranslateDocumentResponse; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.HashMap; + +public class AsyncTranslateDocument { + + public static void main(String[] args) throws Exception { + asyncTranslateDocument(); + } + + public static void asyncTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.translateDocumentCallable().futureCall(request); + // Do something. + TranslateDocumentResponse response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_translatedocument_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/SyncTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/SyncTranslateDocument.java new file mode 100644 index 00000000..c9b5ac1e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatedocument/SyncTranslateDocument.java @@ -0,0 +1,53 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_translatedocument_sync] +import com.google.cloud.translate.v3.DocumentInputConfig; +import com.google.cloud.translate.v3.DocumentOutputConfig; +import com.google.cloud.translate.v3.TranslateDocumentRequest; +import com.google.cloud.translate.v3.TranslateDocumentResponse; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.HashMap; + +public class SyncTranslateDocument { + + public static void main(String[] args) throws Exception { + syncTranslateDocument(); + } + + public static void syncTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + TranslateDocumentResponse response = translationServiceClient.translateDocument(request); + } + } +} +// [END translation_v3_generated_translationserviceclient_translatedocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/AsyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/AsyncTranslateText.java new file mode 100644 index 00000000..8e3588f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/AsyncTranslateText.java @@ -0,0 +1,57 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_translatetext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslateTextRequest; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncTranslateText { + + public static void main(String[] args) throws Exception { + asyncTranslateText(); + } + + public static void asyncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateTextRequest request = + TranslateTextRequest.newBuilder() + .addAllContents(new ArrayList()) + .setMimeType("mimeType-1392120434") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.translateTextCallable().futureCall(request); + // Do something. + TranslateTextResponse response = future.get(); + } + } +} +// [END translation_v3_generated_translationserviceclient_translatetext_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateText.java new file mode 100644 index 00000000..2f10cdb1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateText.java @@ -0,0 +1,53 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationserviceclient_translatetext_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3.TranslateTextRequest; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncTranslateText { + + public static void main(String[] args) throws Exception { + syncTranslateText(); + } + + public static void syncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateTextRequest request = + TranslateTextRequest.newBuilder() + .addAllContents(new ArrayList()) + .setMimeType("mimeType-1392120434") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + TranslateTextResponse response = translationServiceClient.translateText(request); + } + } +} +// [END translation_v3_generated_translationserviceclient_translatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java new file mode 100644 index 00000000..7bf728a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java @@ -0,0 +1,46 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_translatetext_locationnamestringliststring_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncTranslateTextLocationnameStringListstring { + + public static void main(String[] args) throws Exception { + syncTranslateTextLocationnameStringListstring(); + } + + public static void syncTranslateTextLocationnameStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + TranslateTextResponse response = + translationServiceClient.translateText(parent, targetLanguageCode, contents); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_translatetext_locationnamestringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java new file mode 100644 index 00000000..07df86e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java @@ -0,0 +1,51 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_translatetext_locationnamestringstringstringstringliststring_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncTranslateTextLocationnameStringStringStringStringListstring { + + public static void main(String[] args) throws Exception { + syncTranslateTextLocationnameStringStringStringStringListstring(); + } + + public static void syncTranslateTextLocationnameStringStringStringStringListstring() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + TranslateTextResponse response = + translationServiceClient.translateText( + parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_translatetext_locationnamestringstringstringstringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java new file mode 100644 index 00000000..fea0e2fb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java @@ -0,0 +1,45 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_translatetext_stringstringliststring_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncTranslateTextStringStringListstring { + + public static void main(String[] args) throws Exception { + syncTranslateTextStringStringListstring(); + } + + public static void syncTranslateTextStringStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + TranslateTextResponse response = + translationServiceClient.translateText(parent, targetLanguageCode, contents); + } + } +} +// [END translation_v3_generated_translationserviceclient_translatetext_stringstringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java new file mode 100644 index 00000000..b73f4df1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java @@ -0,0 +1,50 @@ +/* + * 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.translate.v3.samples; + +// [START +// translation_v3_generated_translationserviceclient_translatetext_stringstringstringstringstringliststring_sync] +import com.google.cloud.translate.v3.LocationName; +import com.google.cloud.translate.v3.TranslateTextResponse; +import com.google.cloud.translate.v3.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncTranslateTextStringStringStringStringStringListstring { + + public static void main(String[] args) throws Exception { + syncTranslateTextStringStringStringStringStringListstring(); + } + + public static void syncTranslateTextStringStringStringStringStringListstring() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + String sourceLanguageCode = "sourceLanguageCode1645917472"; + String targetLanguageCode = "targetLanguageCode-106414698"; + List contents = new ArrayList<>(); + TranslateTextResponse response = + translationServiceClient.translateText( + parent, model, mimeType, sourceLanguageCode, targetLanguageCode, contents); + } + } +} +// [END +// translation_v3_generated_translationserviceclient_translatetext_stringstringstringstringstringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationservicesettings/translatetext/SyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationservicesettings/translatetext/SyncTranslateText.java new file mode 100644 index 00000000..fd4fb672 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationservicesettings/translatetext/SyncTranslateText.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3.samples; + +// [START translation_v3_generated_translationservicesettings_translatetext_sync] +import com.google.cloud.translate.v3.TranslationServiceSettings; +import java.time.Duration; + +public class SyncTranslateText { + + public static void main(String[] args) throws Exception { + syncTranslateText(); + } + + public static void syncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings.Builder translationServiceSettingsBuilder = + TranslationServiceSettings.newBuilder(); + translationServiceSettingsBuilder + .translateTextSettings() + .setRetrySettings( + translationServiceSettingsBuilder + .translateTextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TranslationServiceSettings translationServiceSettings = + translationServiceSettingsBuilder.build(); + } +} +// [END translation_v3_generated_translationservicesettings_translatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/stub/translationservicestubsettings/translatetext/SyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/stub/translationservicestubsettings/translatetext/SyncTranslateText.java new file mode 100644 index 00000000..373c307a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/stub/translationservicestubsettings/translatetext/SyncTranslateText.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3beta1.stub.samples; + +// [START translation_v3beta1_generated_translationservicestubsettings_translatetext_sync] +import com.google.cloud.translate.v3beta1.stub.TranslationServiceStubSettings; +import java.time.Duration; + +public class SyncTranslateText { + + public static void main(String[] args) throws Exception { + syncTranslateText(); + } + + public static void syncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceStubSettings.Builder translationServiceSettingsBuilder = + TranslationServiceStubSettings.newBuilder(); + translationServiceSettingsBuilder + .translateTextSettings() + .setRetrySettings( + translationServiceSettingsBuilder + .translateTextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TranslationServiceStubSettings translationServiceSettings = + translationServiceSettingsBuilder.build(); + } +} +// [END translation_v3beta1_generated_translationservicestubsettings_translatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java new file mode 100644 index 00000000..09511cce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocument.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; +import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateDocument { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateDocument(); + } + + public static void asyncBatchTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateDocumentRequest request = + BatchTranslateDocumentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) + .putAllModels(new HashMap()) + .putAllGlossaries(new HashMap()) + .putAllFormatConversions(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.batchTranslateDocumentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java new file mode 100644 index 00000000..1ccbfd3d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/AsyncBatchTranslateDocumentLRO.java @@ -0,0 +1,60 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; +import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentMetadata; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateDocumentLRO { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateDocumentLRO(); + } + + public static void asyncBatchTranslateDocumentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateDocumentRequest request = + BatchTranslateDocumentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) + .putAllModels(new HashMap()) + .putAllGlossaries(new HashMap()) + .putAllFormatConversions(new HashMap()) + .build(); + OperationFuture future = + translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request); + // Do something. + BatchTranslateDocumentResponse response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java new file mode 100644 index 00000000..91c10c50 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocument.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_sync] +import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; +import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncBatchTranslateDocument { + + public static void main(String[] args) throws Exception { + syncBatchTranslateDocument(); + } + + public static void syncBatchTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateDocumentRequest request = + BatchTranslateDocumentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build()) + .putAllModels(new HashMap()) + .putAllGlossaries(new HashMap()) + .putAllFormatConversions(new HashMap()) + .build(); + BatchTranslateDocumentResponse response = + translationServiceClient.batchTranslateDocumentAsync(request).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java new file mode 100644 index 00000000..4d18c263 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; +import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public +class SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig { + + public static void main(String[] args) throws Exception { + syncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig(); + } + + public static void + syncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + BatchTranslateDocumentResponse response = + translationServiceClient + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java new file mode 100644 index 00000000..3390d6e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; +import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; +import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.List; + +public +class SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig { + + public static void main(String[] args) throws Exception { + syncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig(); + } + + public static void + syncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String sourceLanguageCode = "sourceLanguageCode1645917472"; + List targetLanguageCodes = new ArrayList<>(); + List inputConfigs = new ArrayList<>(); + BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build(); + BatchTranslateDocumentResponse response = + translationServiceClient + .batchTranslateDocumentAsync( + parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig) + .get(); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java new file mode 100644 index 00000000..2e097d5f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateText.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatetext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.BatchTranslateTextRequest; +import com.google.cloud.translate.v3beta1.InputConfig; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.OutputConfig; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.longrunning.Operation; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateText { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateText(); + } + + public static void asyncBatchTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.batchTranslateTextCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatetext_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java new file mode 100644 index 00000000..84a461c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/AsyncBatchTranslateTextLRO.java @@ -0,0 +1,60 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatetext_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3beta1.BatchTranslateMetadata; +import com.google.cloud.translate.v3beta1.BatchTranslateResponse; +import com.google.cloud.translate.v3beta1.BatchTranslateTextRequest; +import com.google.cloud.translate.v3beta1.InputConfig; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.OutputConfig; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncBatchTranslateTextLRO { + + public static void main(String[] args) throws Exception { + asyncBatchTranslateTextLRO(); + } + + public static void asyncBatchTranslateTextLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + OperationFuture future = + translationServiceClient.batchTranslateTextOperationCallable().futureCall(request); + // Do something. + BatchTranslateResponse response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatetext_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java new file mode 100644 index 00000000..04f0dcea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatetext/SyncBatchTranslateText.java @@ -0,0 +1,56 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatetext_sync] +import com.google.cloud.translate.v3beta1.BatchTranslateResponse; +import com.google.cloud.translate.v3beta1.BatchTranslateTextRequest; +import com.google.cloud.translate.v3beta1.InputConfig; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.OutputConfig; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncBatchTranslateText { + + public static void main(String[] args) throws Exception { + syncBatchTranslateText(); + } + + public static void syncBatchTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + BatchTranslateTextRequest request = + BatchTranslateTextRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setSourceLanguageCode("sourceLanguageCode1645917472") + .addAllTargetLanguageCodes(new ArrayList()) + .putAllModels(new HashMap()) + .addAllInputConfigs(new ArrayList()) + .setOutputConfig(OutputConfig.newBuilder().build()) + .putAllGlossaries(new HashMap()) + .putAllLabels(new HashMap()) + .build(); + BatchTranslateResponse response = + translationServiceClient.batchTranslateTextAsync(request).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..deb0f696 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.cloud.translate.v3beta1.TranslationServiceSettings; +import com.google.cloud.translate.v3beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings translationServiceSettings = + TranslationServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + TranslationServiceClient translationServiceClient = + TranslationServiceClient.create(translationServiceSettings); + } +} +// [END translation_v3beta1_generated_translationserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..d518de87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,42 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.cloud.translate.v3beta1.TranslationServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings translationServiceSettings = + TranslationServiceSettings.newBuilder() + .setTransportChannelProvider( + TranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + TranslationServiceClient translationServiceClient = + TranslationServiceClient.create(translationServiceSettings); + } +} +// [END translation_v3beta1_generated_translationserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..307a43d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_create_setendpoint_sync] +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.cloud.translate.v3beta1.TranslationServiceSettings; +import com.google.cloud.translate.v3beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings translationServiceSettings = + TranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + TranslationServiceClient translationServiceClient = + TranslationServiceClient.create(translationServiceSettings); + } +} +// [END translation_v3beta1_generated_translationserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossary.java new file mode 100644 index 00000000..0f9a6911 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossary.java @@ -0,0 +1,49 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_createglossary_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.CreateGlossaryRequest; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateGlossary { + + public static void main(String[] args) throws Exception { + asyncCreateGlossary(); + } + + public static void asyncCreateGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + CreateGlossaryRequest request = + CreateGlossaryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGlossary(Glossary.newBuilder().build()) + .build(); + ApiFuture future = + translationServiceClient.createGlossaryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_createglossary_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java new file mode 100644 index 00000000..cef0e3be --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/AsyncCreateGlossaryLRO.java @@ -0,0 +1,49 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_createglossary_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3beta1.CreateGlossaryMetadata; +import com.google.cloud.translate.v3beta1.CreateGlossaryRequest; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class AsyncCreateGlossaryLRO { + + public static void main(String[] args) throws Exception { + asyncCreateGlossaryLRO(); + } + + public static void asyncCreateGlossaryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + CreateGlossaryRequest request = + CreateGlossaryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGlossary(Glossary.newBuilder().build()) + .build(); + OperationFuture future = + translationServiceClient.createGlossaryOperationCallable().futureCall(request); + // Do something. + Glossary response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_createglossary_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossary.java new file mode 100644 index 00000000..113054c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossary.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_createglossary_sync] +import com.google.cloud.translate.v3beta1.CreateGlossaryRequest; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncCreateGlossary { + + public static void main(String[] args) throws Exception { + syncCreateGlossary(); + } + + public static void syncCreateGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + CreateGlossaryRequest request = + CreateGlossaryRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGlossary(Glossary.newBuilder().build()) + .build(); + Glossary response = translationServiceClient.createGlossaryAsync(request).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_createglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java new file mode 100644 index 00000000..d03bb1f8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java @@ -0,0 +1,42 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_createglossary_locationnameglossary_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncCreateGlossaryLocationnameGlossary { + + public static void main(String[] args) throws Exception { + syncCreateGlossaryLocationnameGlossary(); + } + + public static void syncCreateGlossaryLocationnameGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Glossary glossary = Glossary.newBuilder().build(); + Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get(); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_createglossary_locationnameglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java new file mode 100644 index 00000000..8cc1a253 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryStringGlossary.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_createglossary_stringglossary_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncCreateGlossaryStringGlossary { + + public static void main(String[] args) throws Exception { + syncCreateGlossaryStringGlossary(); + } + + public static void syncCreateGlossaryStringGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Glossary glossary = Glossary.newBuilder().build(); + Glossary response = translationServiceClient.createGlossaryAsync(parent, glossary).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_createglossary_stringglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java new file mode 100644 index 00000000..60debf32 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossary.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_deleteglossary_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.DeleteGlossaryRequest; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteGlossary { + + public static void main(String[] args) throws Exception { + asyncDeleteGlossary(); + } + + public static void asyncDeleteGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DeleteGlossaryRequest request = + DeleteGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + ApiFuture future = + translationServiceClient.deleteGlossaryCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_deleteglossary_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java new file mode 100644 index 00000000..ee99b3ac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/AsyncDeleteGlossaryLRO.java @@ -0,0 +1,48 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_deleteglossary_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.translate.v3beta1.DeleteGlossaryMetadata; +import com.google.cloud.translate.v3beta1.DeleteGlossaryRequest; +import com.google.cloud.translate.v3beta1.DeleteGlossaryResponse; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class AsyncDeleteGlossaryLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteGlossaryLRO(); + } + + public static void asyncDeleteGlossaryLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DeleteGlossaryRequest request = + DeleteGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + OperationFuture future = + translationServiceClient.deleteGlossaryOperationCallable().futureCall(request); + // Do something. + DeleteGlossaryResponse response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_deleteglossary_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossary.java new file mode 100644 index 00000000..a3706b7e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossary.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_deleteglossary_sync] +import com.google.cloud.translate.v3beta1.DeleteGlossaryRequest; +import com.google.cloud.translate.v3beta1.DeleteGlossaryResponse; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncDeleteGlossary { + + public static void main(String[] args) throws Exception { + syncDeleteGlossary(); + } + + public static void syncDeleteGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DeleteGlossaryRequest request = + DeleteGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(request).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_deleteglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java new file mode 100644 index 00000000..a860a706 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryGlossaryname.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_deleteglossary_glossaryname_sync] +import com.google.cloud.translate.v3beta1.DeleteGlossaryResponse; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncDeleteGlossaryGlossaryname { + + public static void main(String[] args) throws Exception { + syncDeleteGlossaryGlossaryname(); + } + + public static void syncDeleteGlossaryGlossaryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_deleteglossary_glossaryname_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java new file mode 100644 index 00000000..b064a201 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/deleteglossary/SyncDeleteGlossaryString.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_deleteglossary_string_sync] +import com.google.cloud.translate.v3beta1.DeleteGlossaryResponse; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncDeleteGlossaryString { + + public static void main(String[] args) throws Exception { + syncDeleteGlossaryString(); + } + + public static void syncDeleteGlossaryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString(); + DeleteGlossaryResponse response = translationServiceClient.deleteGlossaryAsync(name).get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_deleteglossary_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/AsyncDetectLanguage.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/AsyncDetectLanguage.java new file mode 100644 index 00000000..4a1e54dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/AsyncDetectLanguage.java @@ -0,0 +1,51 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_detectlanguage_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.DetectLanguageRequest; +import com.google.cloud.translate.v3beta1.DetectLanguageResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.HashMap; + +public class AsyncDetectLanguage { + + public static void main(String[] args) throws Exception { + asyncDetectLanguage(); + } + + public static void asyncDetectLanguage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DetectLanguageRequest request = + DetectLanguageRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setMimeType("mimeType-1392120434") + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.detectLanguageCallable().futureCall(request); + // Do something. + DetectLanguageResponse response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_detectlanguage_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguage.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguage.java new file mode 100644 index 00000000..30aa84a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguage.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_detectlanguage_sync] +import com.google.cloud.translate.v3beta1.DetectLanguageRequest; +import com.google.cloud.translate.v3beta1.DetectLanguageResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.HashMap; + +public class SyncDetectLanguage { + + public static void main(String[] args) throws Exception { + syncDetectLanguage(); + } + + public static void syncDetectLanguage() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + DetectLanguageRequest request = + DetectLanguageRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setMimeType("mimeType-1392120434") + .putAllLabels(new HashMap()) + .build(); + DetectLanguageResponse response = translationServiceClient.detectLanguage(request); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_detectlanguage_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java new file mode 100644 index 00000000..da5917e7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_detectlanguage_locationnamestringstring_sync] +import com.google.cloud.translate.v3beta1.DetectLanguageResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncDetectLanguageLocationnameStringString { + + public static void main(String[] args) throws Exception { + syncDetectLanguageLocationnameStringString(); + } + + public static void syncDetectLanguageLocationnameStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + DetectLanguageResponse response = + translationServiceClient.detectLanguage(parent, model, mimeType); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_detectlanguage_locationnamestringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java new file mode 100644 index 00000000..b0ad583c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_detectlanguage_stringstringstring_sync] +import com.google.cloud.translate.v3beta1.DetectLanguageResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncDetectLanguageStringStringString { + + public static void main(String[] args) throws Exception { + syncDetectLanguageStringStringString(); + } + + public static void syncDetectLanguageStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String model = "model104069929"; + String mimeType = "mimeType-1392120434"; + DetectLanguageResponse response = + translationServiceClient.detectLanguage(parent, model, mimeType); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_detectlanguage_stringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/AsyncGetGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/AsyncGetGlossary.java new file mode 100644 index 00000000..29e1239a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/AsyncGetGlossary.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_getglossary_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.GetGlossaryRequest; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class AsyncGetGlossary { + + public static void main(String[] args) throws Exception { + asyncGetGlossary(); + } + + public static void asyncGetGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetGlossaryRequest request = + GetGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + ApiFuture future = + translationServiceClient.getGlossaryCallable().futureCall(request); + // Do something. + Glossary response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_getglossary_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossary.java new file mode 100644 index 00000000..ecac547f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossary.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_getglossary_sync] +import com.google.cloud.translate.v3beta1.GetGlossaryRequest; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncGetGlossary { + + public static void main(String[] args) throws Exception { + syncGetGlossary(); + } + + public static void syncGetGlossary() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetGlossaryRequest request = + GetGlossaryRequest.newBuilder() + .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString()) + .build(); + Glossary response = translationServiceClient.getGlossary(request); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_getglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java new file mode 100644 index 00000000..6cbc8ea7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryGlossaryname.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_getglossary_glossaryname_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncGetGlossaryGlossaryname { + + public static void main(String[] args) throws Exception { + syncGetGlossaryGlossaryname(); + } + + public static void syncGetGlossaryGlossaryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GlossaryName name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]"); + Glossary response = translationServiceClient.getGlossary(name); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_getglossary_glossaryname_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryString.java new file mode 100644 index 00000000..538406f5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getglossary/SyncGetGlossaryString.java @@ -0,0 +1,39 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_getglossary_string_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.GlossaryName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncGetGlossaryString { + + public static void main(String[] args) throws Exception { + syncGetGlossaryString(); + } + + public static void syncGetGlossaryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String name = GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString(); + Glossary response = translationServiceClient.getGlossary(name); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_getglossary_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java new file mode 100644 index 00000000..bf2c5c8e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/AsyncGetSupportedLanguages.java @@ -0,0 +1,49 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.GetSupportedLanguagesRequest; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.SupportedLanguages; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class AsyncGetSupportedLanguages { + + public static void main(String[] args) throws Exception { + asyncGetSupportedLanguages(); + } + + public static void asyncGetSupportedLanguages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetSupportedLanguagesRequest request = + GetSupportedLanguagesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDisplayLanguageCode("displayLanguageCode-1457478841") + .setModel("model104069929") + .build(); + ApiFuture future = + translationServiceClient.getSupportedLanguagesCallable().futureCall(request); + // Do something. + SupportedLanguages response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java new file mode 100644 index 00000000..141b90da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguages.java @@ -0,0 +1,45 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_sync] +import com.google.cloud.translate.v3beta1.GetSupportedLanguagesRequest; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.SupportedLanguages; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncGetSupportedLanguages { + + public static void main(String[] args) throws Exception { + syncGetSupportedLanguages(); + } + + public static void syncGetSupportedLanguages() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + GetSupportedLanguagesRequest request = + GetSupportedLanguagesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDisplayLanguageCode("displayLanguageCode-1457478841") + .setModel("model104069929") + .build(); + SupportedLanguages response = translationServiceClient.getSupportedLanguages(request); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java new file mode 100644 index 00000000..88b9e96b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.SupportedLanguages; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncGetSupportedLanguagesLocationnameStringString { + + public static void main(String[] args) throws Exception { + syncGetSupportedLanguagesLocationnameStringString(); + } + + public static void syncGetSupportedLanguagesLocationnameStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String displayLanguageCode = "displayLanguageCode-1457478841"; + String model = "model104069929"; + SupportedLanguages response = + translationServiceClient.getSupportedLanguages(parent, displayLanguageCode, model); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java new file mode 100644 index 00000000..7cb916f9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java @@ -0,0 +1,44 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.SupportedLanguages; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncGetSupportedLanguagesStringStringString { + + public static void main(String[] args) throws Exception { + syncGetSupportedLanguagesStringStringString(); + } + + public static void syncGetSupportedLanguagesStringStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String displayLanguageCode = "displayLanguageCode-1457478841"; + String model = "model104069929"; + SupportedLanguages response = + translationServiceClient.getSupportedLanguages(parent, displayLanguageCode, model); + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossaries.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossaries.java new file mode 100644 index 00000000..5937cc68 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossaries.java @@ -0,0 +1,52 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_listglossaries_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.ListGlossariesRequest; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class AsyncListGlossaries { + + public static void main(String[] args) throws Exception { + asyncListGlossaries(); + } + + public static void asyncListGlossaries() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + ListGlossariesRequest request = + ListGlossariesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + translationServiceClient.listGlossariesPagedCallable().futureCall(request); + // Do something. + for (Glossary element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_listglossaries_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java new file mode 100644 index 00000000..b2f7787c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/AsyncListGlossariesPaged.java @@ -0,0 +1,60 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_listglossaries_paged_async] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.ListGlossariesRequest; +import com.google.cloud.translate.v3beta1.ListGlossariesResponse; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import com.google.common.base.Strings; + +public class AsyncListGlossariesPaged { + + public static void main(String[] args) throws Exception { + asyncListGlossariesPaged(); + } + + public static void asyncListGlossariesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + ListGlossariesRequest request = + ListGlossariesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListGlossariesResponse response = + translationServiceClient.listGlossariesCallable().call(request); + for (Glossary element : response.getGlossariesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_listglossaries_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossaries.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossaries.java new file mode 100644 index 00000000..db1f97c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossaries.java @@ -0,0 +1,48 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_listglossaries_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.ListGlossariesRequest; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncListGlossaries { + + public static void main(String[] args) throws Exception { + syncListGlossaries(); + } + + public static void syncListGlossaries() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + ListGlossariesRequest request = + ListGlossariesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Glossary element : translationServiceClient.listGlossaries(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_listglossaries_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java new file mode 100644 index 00000000..12306a46 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java @@ -0,0 +1,45 @@ +/* + * 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.translate.v3beta1.samples; + +// [START +// translation_v3beta1_generated_translationserviceclient_listglossaries_locationnamestring_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncListGlossariesLocationnameString { + + public static void main(String[] args) throws Exception { + syncListGlossariesLocationnameString(); + } + + public static void syncListGlossariesLocationnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + String filter = "filter-1274492040"; + for (Glossary element : + translationServiceClient.listGlossaries(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END +// translation_v3beta1_generated_translationserviceclient_listglossaries_locationnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesStringString.java new file mode 100644 index 00000000..eef3497f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesStringString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_listglossaries_stringstring_sync] +import com.google.cloud.translate.v3beta1.Glossary; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; + +public class SyncListGlossariesStringString { + + public static void main(String[] args) throws Exception { + syncListGlossariesStringString(); + } + + public static void syncListGlossariesStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + String filter = "filter-1274492040"; + for (Glossary element : + translationServiceClient.listGlossaries(parent, filter).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_listglossaries_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/AsyncTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/AsyncTranslateDocument.java new file mode 100644 index 00000000..021abde8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/AsyncTranslateDocument.java @@ -0,0 +1,57 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_translatedocument_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.DocumentInputConfig; +import com.google.cloud.translate.v3beta1.DocumentOutputConfig; +import com.google.cloud.translate.v3beta1.TranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.TranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.HashMap; + +public class AsyncTranslateDocument { + + public static void main(String[] args) throws Exception { + asyncTranslateDocument(); + } + + public static void asyncTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.translateDocumentCallable().futureCall(request); + // Do something. + TranslateDocumentResponse response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_translatedocument_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/SyncTranslateDocument.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/SyncTranslateDocument.java new file mode 100644 index 00000000..1451afac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatedocument/SyncTranslateDocument.java @@ -0,0 +1,53 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_translatedocument_sync] +import com.google.cloud.translate.v3beta1.DocumentInputConfig; +import com.google.cloud.translate.v3beta1.DocumentOutputConfig; +import com.google.cloud.translate.v3beta1.TranslateDocumentRequest; +import com.google.cloud.translate.v3beta1.TranslateDocumentResponse; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.HashMap; + +public class SyncTranslateDocument { + + public static void main(String[] args) throws Exception { + syncTranslateDocument(); + } + + public static void syncTranslateDocument() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateDocumentRequest request = + TranslateDocumentRequest.newBuilder() + .setParent("parent-995424086") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setDocumentInputConfig(DocumentInputConfig.newBuilder().build()) + .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + TranslateDocumentResponse response = translationServiceClient.translateDocument(request); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_translatedocument_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/AsyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/AsyncTranslateText.java new file mode 100644 index 00000000..c50d3092 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/AsyncTranslateText.java @@ -0,0 +1,57 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_translatetext_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslateTextRequest; +import com.google.cloud.translate.v3beta1.TranslateTextResponse; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class AsyncTranslateText { + + public static void main(String[] args) throws Exception { + asyncTranslateText(); + } + + public static void asyncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateTextRequest request = + TranslateTextRequest.newBuilder() + .addAllContents(new ArrayList()) + .setMimeType("mimeType-1392120434") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + ApiFuture future = + translationServiceClient.translateTextCallable().futureCall(request); + // Do something. + TranslateTextResponse response = future.get(); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_translatetext_async] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/SyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/SyncTranslateText.java new file mode 100644 index 00000000..e9c2ce87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/translatetext/SyncTranslateText.java @@ -0,0 +1,53 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationserviceclient_translatetext_sync] +import com.google.cloud.translate.v3beta1.LocationName; +import com.google.cloud.translate.v3beta1.TranslateTextGlossaryConfig; +import com.google.cloud.translate.v3beta1.TranslateTextRequest; +import com.google.cloud.translate.v3beta1.TranslateTextResponse; +import com.google.cloud.translate.v3beta1.TranslationServiceClient; +import java.util.ArrayList; +import java.util.HashMap; + +public class SyncTranslateText { + + public static void main(String[] args) throws Exception { + syncTranslateText(); + } + + public static void syncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) { + TranslateTextRequest request = + TranslateTextRequest.newBuilder() + .addAllContents(new ArrayList()) + .setMimeType("mimeType-1392120434") + .setSourceLanguageCode("sourceLanguageCode1645917472") + .setTargetLanguageCode("targetLanguageCode-106414698") + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setModel("model104069929") + .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + TranslateTextResponse response = translationServiceClient.translateText(request); + } + } +} +// [END translation_v3beta1_generated_translationserviceclient_translatetext_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationservicesettings/translatetext/SyncTranslateText.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationservicesettings/translatetext/SyncTranslateText.java new file mode 100644 index 00000000..3d570006 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationservicesettings/translatetext/SyncTranslateText.java @@ -0,0 +1,47 @@ +/* + * 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.translate.v3beta1.samples; + +// [START translation_v3beta1_generated_translationservicesettings_translatetext_sync] +import com.google.cloud.translate.v3beta1.TranslationServiceSettings; +import java.time.Duration; + +public class SyncTranslateText { + + public static void main(String[] args) throws Exception { + syncTranslateText(); + } + + public static void syncTranslateText() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + TranslationServiceSettings.Builder translationServiceSettingsBuilder = + TranslationServiceSettings.newBuilder(); + translationServiceSettingsBuilder + .translateTextSettings() + .setRetrySettings( + translationServiceSettingsBuilder + .translateTextSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + TranslationServiceSettings translationServiceSettings = + translationServiceSettingsBuilder.build(); + } +} +// [END translation_v3beta1_generated_translationservicesettings_translatetext_sync] From 883aa479f9ea474e715797bd0afde5c192555aff Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 19:30:23 +0000 Subject: [PATCH 15/21] chore: update dependencies for regapic (#1467) (#1015) * 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 a79f0627..f0625e4d 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 ace89f45..f8f957af 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 ace2700807e5557113bbb1016b54ff7b3d57e59c 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 04:18:15 +0000 Subject: [PATCH 16/21] fix: update gapic-generator-java with mock service generation fixes (#1016) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 457524730 Source-Link: https://github.com/googleapis/googleapis/commit/917e7f21cb1dc062744c6694437cdd46219f28cb Source-Link: https://github.com/googleapis/googleapis-gen/commit/2497f9a069d3f6b2d6810d5a4e239cda1e7e5a39 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjQ5N2Y5YTA2OWQzZjZiMmQ2ODEwZDVhNGUyMzljZGExZTdlNWEzOSJ9 --- .../google/cloud/translate/v3/TranslationServiceClient.java | 2 ++ .../cloud/translate/v3beta1/TranslationServiceClient.java | 1 + ...stbatchdocumentinputconfigBatchdocumentoutputconfig.java | 6 ++---- ...stbatchdocumentinputconfigBatchdocumentoutputconfig.java | 6 ++---- .../SyncCreateGlossaryLocationnameGlossary.java | 3 +-- .../SyncDetectLanguageLocationnameStringStringString.java | 6 ++---- .../SyncDetectLanguageStringStringStringString.java | 6 ++---- .../SyncGetSupportedLanguagesLocationnameStringString.java | 6 ++---- .../SyncGetSupportedLanguagesStringStringString.java | 6 ++---- .../SyncTranslateTextLocationnameStringListstring.java | 6 ++---- ...eTextLocationnameStringStringStringStringListstring.java | 6 ++---- .../SyncTranslateTextStringStringListstring.java | 3 +-- ...anslateTextStringStringStringStringStringListstring.java | 6 ++---- ...stbatchdocumentinputconfigBatchdocumentoutputconfig.java | 6 ++---- ...stbatchdocumentinputconfigBatchdocumentoutputconfig.java | 6 ++---- .../create/SyncCreateSetCredentialsProvider1.java | 3 +-- .../SyncCreateGlossaryLocationnameGlossary.java | 6 ++---- .../SyncDetectLanguageLocationnameStringString.java | 6 ++---- .../SyncDetectLanguageStringStringString.java | 6 ++---- .../SyncGetSupportedLanguagesLocationnameStringString.java | 6 ++---- .../SyncGetSupportedLanguagesStringStringString.java | 6 ++---- .../SyncListGlossariesLocationnameString.java | 6 ++---- 22 files changed, 40 insertions(+), 74 deletions(-) diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java index f57eeebb..851b62b3 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java @@ -18,6 +18,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; @@ -193,6 +194,7 @@ public final com.google.longrunning.OperationsClient getOperationsClient() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ + @BetaApi public final OperationsClient getHttpJsonOperationsClient() { return httpJsonOperationsClient; } diff --git a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java index f9473e1c..9672ea88 100644 --- a/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java +++ b/google-cloud-translate/src/main/java/com/google/cloud/translate/v3beta1/TranslationServiceClient.java @@ -202,6 +202,7 @@ public final com.google.longrunning.OperationsClient getOperationsClient() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ + @BetaApi public final OperationsClient getHttpJsonOperationsClient() { return httpJsonOperationsClient; } diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java index d026b460..db5954cb 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [START translation_v3_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] import com.google.cloud.translate.v3.BatchDocumentInputConfig; import com.google.cloud.translate.v3.BatchDocumentOutputConfig; import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; @@ -52,5 +51,4 @@ public static void main(String[] args) throws Exception { } } } -// [END -// translation_v3_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [END translation_v3_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java index 2c3d0653..4e1bf861 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [START translation_v3_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] import com.google.cloud.translate.v3.BatchDocumentInputConfig; import com.google.cloud.translate.v3.BatchDocumentOutputConfig; import com.google.cloud.translate.v3.BatchTranslateDocumentResponse; @@ -52,5 +51,4 @@ public static void main(String[] args) throws Exception { } } } -// [END -// translation_v3_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [END translation_v3_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java index 22635c43..4d689c0f 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_createglossary_locationnameglossary_sync] +// [START translation_v3_generated_translationserviceclient_createglossary_locationnameglossary_sync] import com.google.cloud.translate.v3.Glossary; import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslationServiceClient; diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java index 38f7d370..68fb37ff 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_detectlanguage_locationnamestringstringstring_sync] +// [START translation_v3_generated_translationserviceclient_detectlanguage_locationnamestringstringstring_sync] import com.google.cloud.translate.v3.DetectLanguageResponse; import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -41,5 +40,4 @@ public static void syncDetectLanguageLocationnameStringStringString() throws Exc } } } -// [END -// translation_v3_generated_translationserviceclient_detectlanguage_locationnamestringstringstring_sync] +// [END translation_v3_generated_translationserviceclient_detectlanguage_locationnamestringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java index f71cc1d2..1201c3ca 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_detectlanguage_stringstringstringstring_sync] +// [START translation_v3_generated_translationserviceclient_detectlanguage_stringstringstringstring_sync] import com.google.cloud.translate.v3.DetectLanguageResponse; import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -41,5 +40,4 @@ public static void syncDetectLanguageStringStringStringString() throws Exception } } } -// [END -// translation_v3_generated_translationserviceclient_detectlanguage_stringstringstringstring_sync] +// [END translation_v3_generated_translationserviceclient_detectlanguage_stringstringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java index 29cfec06..e857149a 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] +// [START translation_v3_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.SupportedLanguages; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -40,5 +39,4 @@ public static void syncGetSupportedLanguagesLocationnameStringString() throws Ex } } } -// [END -// translation_v3_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] +// [END translation_v3_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java index 51bf91a1..0b2eb101 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] +// [START translation_v3_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.SupportedLanguages; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -40,5 +39,4 @@ public static void syncGetSupportedLanguagesStringStringString() throws Exceptio } } } -// [END -// translation_v3_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] +// [END translation_v3_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java index 7bf728a3..31ae08b8 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringListstring.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_translatetext_locationnamestringliststring_sync] +// [START translation_v3_generated_translationserviceclient_translatetext_locationnamestringliststring_sync] import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslateTextResponse; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -42,5 +41,4 @@ public static void syncTranslateTextLocationnameStringListstring() throws Except } } } -// [END -// translation_v3_generated_translationserviceclient_translatetext_locationnamestringliststring_sync] +// [END translation_v3_generated_translationserviceclient_translatetext_locationnamestringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java index 07df86e0..0731cf51 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextLocationnameStringStringStringStringListstring.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_translatetext_locationnamestringstringstringstringliststring_sync] +// [START translation_v3_generated_translationserviceclient_translatetext_locationnamestringstringstringstringliststring_sync] import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslateTextResponse; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -47,5 +46,4 @@ public static void syncTranslateTextLocationnameStringStringStringStringListstri } } } -// [END -// translation_v3_generated_translationserviceclient_translatetext_locationnamestringstringstringstringliststring_sync] +// [END translation_v3_generated_translationserviceclient_translatetext_locationnamestringstringstringstringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java index fea0e2fb..fe7d29cd 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringListstring.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_translatetext_stringstringliststring_sync] +// [START translation_v3_generated_translationserviceclient_translatetext_stringstringliststring_sync] import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslateTextResponse; import com.google.cloud.translate.v3.TranslationServiceClient; diff --git a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java index b73f4df1..bf3fdbb6 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3/translationserviceclient/translatetext/SyncTranslateTextStringStringStringStringStringListstring.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3.samples; -// [START -// translation_v3_generated_translationserviceclient_translatetext_stringstringstringstringstringliststring_sync] +// [START translation_v3_generated_translationserviceclient_translatetext_stringstringstringstringstringliststring_sync] import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslateTextResponse; import com.google.cloud.translate.v3.TranslationServiceClient; @@ -46,5 +45,4 @@ public static void syncTranslateTextStringStringStringStringStringListstring() t } } } -// [END -// translation_v3_generated_translationserviceclient_translatetext_stringstringstringstringstringliststring_sync] +// [END translation_v3_generated_translationserviceclient_translatetext_stringstringstringstringstringliststring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java index 4d18c263..1ea78bc7 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentLocationnameStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; @@ -52,5 +51,4 @@ public static void main(String[] args) throws Exception { } } } -// [END -// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_locationnamestringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java index 3390d6e9..0fd83e38 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/batchtranslatedocument/SyncBatchTranslateDocumentStringStringListstringListbatchdocumentinputconfigBatchdocumentoutputconfig.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [START translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] import com.google.cloud.translate.v3beta1.BatchDocumentInputConfig; import com.google.cloud.translate.v3beta1.BatchDocumentOutputConfig; import com.google.cloud.translate.v3beta1.BatchTranslateDocumentResponse; @@ -52,5 +51,4 @@ public static void main(String[] args) throws Exception { } } } -// [END -// translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] +// [END translation_v3beta1_generated_translationserviceclient_batchtranslatedocument_stringstringliststringlistbatchdocumentinputconfigbatchdocumentoutputconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java index d518de87..d050696b 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_create_setcredentialsprovider1_sync] +// [START translation_v3beta1_generated_translationserviceclient_create_setcredentialsprovider1_sync] import com.google.cloud.translate.v3beta1.TranslationServiceClient; import com.google.cloud.translate.v3beta1.TranslationServiceSettings; diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java index d03bb1f8..abd73013 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/createglossary/SyncCreateGlossaryLocationnameGlossary.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_createglossary_locationnameglossary_sync] +// [START translation_v3beta1_generated_translationserviceclient_createglossary_locationnameglossary_sync] import com.google.cloud.translate.v3beta1.Glossary; import com.google.cloud.translate.v3beta1.LocationName; import com.google.cloud.translate.v3beta1.TranslationServiceClient; @@ -38,5 +37,4 @@ public static void syncCreateGlossaryLocationnameGlossary() throws Exception { } } } -// [END -// translation_v3beta1_generated_translationserviceclient_createglossary_locationnameglossary_sync] +// [END translation_v3beta1_generated_translationserviceclient_createglossary_locationnameglossary_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java index da5917e7..deac9beb 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageLocationnameStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_detectlanguage_locationnamestringstring_sync] +// [START translation_v3beta1_generated_translationserviceclient_detectlanguage_locationnamestringstring_sync] import com.google.cloud.translate.v3beta1.DetectLanguageResponse; import com.google.cloud.translate.v3beta1.LocationName; import com.google.cloud.translate.v3beta1.TranslationServiceClient; @@ -40,5 +39,4 @@ public static void syncDetectLanguageLocationnameStringString() throws Exception } } } -// [END -// translation_v3beta1_generated_translationserviceclient_detectlanguage_locationnamestringstring_sync] +// [END translation_v3beta1_generated_translationserviceclient_detectlanguage_locationnamestringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java index b0ad583c..9e8e52f1 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/detectlanguage/SyncDetectLanguageStringStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_detectlanguage_stringstringstring_sync] +// [START translation_v3beta1_generated_translationserviceclient_detectlanguage_stringstringstring_sync] import com.google.cloud.translate.v3beta1.DetectLanguageResponse; import com.google.cloud.translate.v3beta1.LocationName; import com.google.cloud.translate.v3beta1.TranslationServiceClient; @@ -40,5 +39,4 @@ public static void syncDetectLanguageStringStringString() throws Exception { } } } -// [END -// translation_v3beta1_generated_translationserviceclient_detectlanguage_stringstringstring_sync] +// [END translation_v3beta1_generated_translationserviceclient_detectlanguage_stringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java index 88b9e96b..81072f27 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesLocationnameStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] +// [START translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] import com.google.cloud.translate.v3beta1.LocationName; import com.google.cloud.translate.v3beta1.SupportedLanguages; import com.google.cloud.translate.v3beta1.TranslationServiceClient; @@ -40,5 +39,4 @@ public static void syncGetSupportedLanguagesLocationnameStringString() throws Ex } } } -// [END -// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] +// [END translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_locationnamestringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java index 7cb916f9..05a8f673 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/getsupportedlanguages/SyncGetSupportedLanguagesStringStringString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] +// [START translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] import com.google.cloud.translate.v3beta1.LocationName; import com.google.cloud.translate.v3beta1.SupportedLanguages; import com.google.cloud.translate.v3beta1.TranslationServiceClient; @@ -40,5 +39,4 @@ public static void syncGetSupportedLanguagesStringStringString() throws Exceptio } } } -// [END -// translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] +// [END translation_v3beta1_generated_translationserviceclient_getsupportedlanguages_stringstringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java index 12306a46..ba70bad7 100644 --- a/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java +++ b/samples/snippets/generated/com/google/cloud/translate/v3beta1/translationserviceclient/listglossaries/SyncListGlossariesLocationnameString.java @@ -16,8 +16,7 @@ package com.google.cloud.translate.v3beta1.samples; -// [START -// translation_v3beta1_generated_translationserviceclient_listglossaries_locationnamestring_sync] +// [START translation_v3beta1_generated_translationserviceclient_listglossaries_locationnamestring_sync] import com.google.cloud.translate.v3beta1.Glossary; import com.google.cloud.translate.v3beta1.LocationName; import com.google.cloud.translate.v3beta1.TranslationServiceClient; @@ -41,5 +40,4 @@ public static void syncListGlossariesLocationnameString() throws Exception { } } } -// [END -// translation_v3beta1_generated_translationserviceclient_listglossaries_locationnamestring_sync] +// [END translation_v3beta1_generated_translationserviceclient_listglossaries_locationnamestring_sync] From e4aa990e2506f6f3676fc46aabec5bca6568f055 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:48:46 -0400 Subject: [PATCH 17/21] chore(main): release 2.2.1-SNAPSHOT (#1001) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- google-cloud-translate-bom/pom.xml | 12 ++++++------ google-cloud-translate/pom.xml | 4 ++-- grpc-google-cloud-translate-v3/pom.xml | 4 ++-- grpc-google-cloud-translate-v3beta1/pom.xml | 4 ++-- pom.xml | 12 ++++++------ proto-google-cloud-translate-v3/pom.xml | 4 ++-- proto-google-cloud-translate-v3beta1/pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 10 +++++----- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/google-cloud-translate-bom/pom.xml b/google-cloud-translate-bom/pom.xml index 195c1c38..a77a0b0b 100644 --- a/google-cloud-translate-bom/pom.xml +++ b/google-cloud-translate-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-translate-bom - 2.2.0 + 2.2.1-SNAPSHOT pom com.google.cloud @@ -52,27 +52,27 @@ com.google.cloud google-cloud-translate - 2.2.0 + 2.2.1-SNAPSHOT com.google.api.grpc grpc-google-cloud-translate-v3beta1 - 0.84.0 + 0.84.1-SNAPSHOT com.google.api.grpc grpc-google-cloud-translate-v3 - 2.2.0 + 2.2.1-SNAPSHOT com.google.api.grpc proto-google-cloud-translate-v3beta1 - 0.84.0 + 0.84.1-SNAPSHOT com.google.api.grpc proto-google-cloud-translate-v3 - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/google-cloud-translate/pom.xml b/google-cloud-translate/pom.xml index 501bb129..86bd7df3 100644 --- a/google-cloud-translate/pom.xml +++ b/google-cloud-translate/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-translate - 2.2.0 + 2.2.1-SNAPSHOT jar Google Cloud Translate https://github.com/googleapis/java-translate @@ -11,7 +11,7 @@ com.google.cloud google-cloud-translate-parent - 2.2.0 + 2.2.1-SNAPSHOT google-cloud-translate diff --git a/grpc-google-cloud-translate-v3/pom.xml b/grpc-google-cloud-translate-v3/pom.xml index 98b762b3..45fc301f 100644 --- a/grpc-google-cloud-translate-v3/pom.xml +++ b/grpc-google-cloud-translate-v3/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-translate-v3 - 2.2.0 + 2.2.1-SNAPSHOT grpc-google-cloud-translate-v3 GRPC library for grpc-google-cloud-translate-v3 com.google.cloud google-cloud-translate-parent - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/grpc-google-cloud-translate-v3beta1/pom.xml b/grpc-google-cloud-translate-v3beta1/pom.xml index cd5e577f..5b009e28 100644 --- a/grpc-google-cloud-translate-v3beta1/pom.xml +++ b/grpc-google-cloud-translate-v3beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-translate-v3beta1 - 0.84.0 + 0.84.1-SNAPSHOT grpc-google-cloud-translate-v3beta1 GRPC library for grpc-google-cloud-translate-v3beta1 com.google.cloud google-cloud-translate-parent - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index c6b4debb..94781720 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-translate-parent pom - 2.2.0 + 2.2.1-SNAPSHOT Google Cloud Translate Parent https://github.com/googleapis/java-translate @@ -61,27 +61,27 @@ com.google.api.grpc proto-google-cloud-translate-v3beta1 - 0.84.0 + 0.84.1-SNAPSHOT com.google.api.grpc proto-google-cloud-translate-v3 - 2.2.0 + 2.2.1-SNAPSHOT com.google.api.grpc grpc-google-cloud-translate-v3beta1 - 0.84.0 + 0.84.1-SNAPSHOT com.google.api.grpc grpc-google-cloud-translate-v3 - 2.2.0 + 2.2.1-SNAPSHOT com.google.cloud google-cloud-translate - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/proto-google-cloud-translate-v3/pom.xml b/proto-google-cloud-translate-v3/pom.xml index 9eba5c45..25bf1cc2 100644 --- a/proto-google-cloud-translate-v3/pom.xml +++ b/proto-google-cloud-translate-v3/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-translate-v3 - 2.2.0 + 2.2.1-SNAPSHOT proto-google-cloud-translate-v3 PROTO library for proto-google-cloud-translate-v3 com.google.cloud google-cloud-translate-parent - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/proto-google-cloud-translate-v3beta1/pom.xml b/proto-google-cloud-translate-v3beta1/pom.xml index b1e9ed0f..8537fd92 100644 --- a/proto-google-cloud-translate-v3beta1/pom.xml +++ b/proto-google-cloud-translate-v3beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-translate-v3beta1 - 0.84.0 + 0.84.1-SNAPSHOT proto-google-cloud-translate-v3beta1 PROTO library for proto-google-cloud-translate-v3beta1 com.google.cloud google-cloud-translate-parent - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 0e5d2beb..5a40a1cc 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-translate - 2.2.0 + 2.2.1-SNAPSHOT diff --git a/versions.txt b/versions.txt index 7ee9bd14..82e7c1d4 100644 --- a/versions.txt +++ b/versions.txt @@ -1,8 +1,8 @@ # Format: # module:released-version:current-version -google-cloud-translate:2.2.0:2.2.0 -grpc-google-cloud-translate-v3beta1:0.84.0:0.84.0 -grpc-google-cloud-translate-v3:2.2.0:2.2.0 -proto-google-cloud-translate-v3beta1:0.84.0:0.84.0 -proto-google-cloud-translate-v3:2.2.0:2.2.0 +google-cloud-translate:2.2.0:2.2.1-SNAPSHOT +grpc-google-cloud-translate-v3beta1:0.84.0:0.84.1-SNAPSHOT +grpc-google-cloud-translate-v3:2.2.0:2.2.1-SNAPSHOT +proto-google-cloud-translate-v3beta1:0.84.0:0.84.1-SNAPSHOT +proto-google-cloud-translate-v3:2.2.0:2.2.1-SNAPSHOT From 0361e750d9fb04569c78db3c2646888a78318b37 Mon Sep 17 00:00:00 2001 From: Mridula <66699525+mpeddada1@users.noreply.github.com> Date: Wed, 29 Jun 2022 16:34:15 -0400 Subject: [PATCH 18/21] chore: add native image checks as required (#1018) --- .github/sync-repo-settings.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 6f09d695..0181fcd5 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -17,6 +17,8 @@ branchProtectionRules: - 'Kokoro - Test: Integration' - cla/google - OwlBot Post Processor + - 'Kokoro - Test: Java GraalVM Native Image' + - 'Kokoro - Test: Java 17 GraalVM Native Image' - pattern: java7 isAdminEnforced: true requiredApprovingReviewCount: 1 From d38a566473932796573a1f64ce819358424b4fca Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 29 Jun 2022 22:35:18 +0200 Subject: [PATCH 19/21] deps: update dependency com.google.cloud:google-cloud-core to v2.8.1 (#1017) --- 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 1e8fd3c0..ead6a4ed 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.8.0 + 2.8.1 test tests diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 5a40a1cc..45ce80b1 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.8.0 + 2.8.1 test tests diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 6d481d0c..4bbb5416 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -62,7 +62,7 @@ com.google.cloud google-cloud-core - 2.8.0 + 2.8.1 test tests From 47442336a5a2c3f4fde29f6b881b236a1e44cfd6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 29 Jun 2022 22:37:18 +0200 Subject: [PATCH 20/21] deps: update dependency com.google.cloud:google-cloud-storage to v2.9.0 (#1020) --- 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 ead6a4ed..9a996c0d 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -35,7 +35,7 @@ com.google.cloud google-cloud-storage - 2.8.1 + 2.9.0 junit diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 45ce80b1..d574b0a0 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -34,7 +34,7 @@ com.google.cloud google-cloud-storage - 2.8.1 + 2.9.0 From 8e871c8c9f7e30e7c95b29c3925a3f33ccda5c44 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 29 Jun 2022 21:34:11 +0000 Subject: [PATCH 21/21] chore(main): release 2.3.0 (#1019) :robot: I have created a release *beep* *boop* --- ## [2.3.0](https://github.com/googleapis/java-translate/compare/v2.2.0...v2.3.0) (2022-06-29) ### Features * Enable REST transport for most of Java and Go clients ([#1014](https://github.com/googleapis/java-translate/issues/1014)) ([8befc79](https://github.com/googleapis/java-translate/commit/8befc799748f11c15f4e511c8a65a74401638ffa)) ### Bug Fixes * update gapic-generator-java with mock service generation fixes ([#1016](https://github.com/googleapis/java-translate/issues/1016)) ([ace2700](https://github.com/googleapis/java-translate/commit/ace2700807e5557113bbb1016b54ff7b3d57e59c)) ### Dependencies * update dependency com.google.cloud:google-cloud-core to v2.7.1 ([#997](https://github.com/googleapis/java-translate/issues/997)) ([e2070a9](https://github.com/googleapis/java-translate/commit/e2070a9785a029772bbb25109a480bd151003843)) * update dependency com.google.cloud:google-cloud-core to v2.8.0 ([#1012](https://github.com/googleapis/java-translate/issues/1012)) ([0fdb776](https://github.com/googleapis/java-translate/commit/0fdb776115d90ea0894b0bc92d3a59181fd050e3)) * update dependency com.google.cloud:google-cloud-core to v2.8.1 ([#1017](https://github.com/googleapis/java-translate/issues/1017)) ([d38a566](https://github.com/googleapis/java-translate/commit/d38a566473932796573a1f64ce819358424b4fca)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#1013](https://github.com/googleapis/java-translate/issues/1013)) ([7b1d5d6](https://github.com/googleapis/java-translate/commit/7b1d5d6542806983815c2b84d847721b1951662a)) * update dependency com.google.cloud:google-cloud-storage to v2.7.1 ([#1003](https://github.com/googleapis/java-translate/issues/1003)) ([4871284](https://github.com/googleapis/java-translate/commit/4871284229d28fe3993b45af937d31961580a97e)) * update dependency com.google.cloud:google-cloud-storage to v2.7.2 ([#1005](https://github.com/googleapis/java-translate/issues/1005)) ([1bb4942](https://github.com/googleapis/java-translate/commit/1bb4942ab866f8a82a683880668829e34a64725b)) * update dependency com.google.cloud:google-cloud-storage to v2.8.0 ([#1007](https://github.com/googleapis/java-translate/issues/1007)) ([d7d9705](https://github.com/googleapis/java-translate/commit/d7d970518dc73ae4e4b61b40f05f9b7baaa000af)) * update dependency com.google.cloud:google-cloud-storage to v2.8.1 ([#1011](https://github.com/googleapis/java-translate/issues/1011)) ([a5a2a65](https://github.com/googleapis/java-translate/commit/a5a2a657738740b2024f216c0ba5539ba67d4bfb)) * update dependency com.google.cloud:google-cloud-storage to v2.9.0 ([#1020](https://github.com/googleapis/java-translate/issues/1020)) ([4744233](https://github.com/googleapis/java-translate/commit/47442336a5a2c3f4fde29f6b881b236a1e44cfd6)) --- 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 | 25 ++++++++++++++++++++ google-cloud-translate-bom/pom.xml | 12 +++++----- google-cloud-translate/pom.xml | 4 ++-- grpc-google-cloud-translate-v3/pom.xml | 4 ++-- grpc-google-cloud-translate-v3beta1/pom.xml | 4 ++-- pom.xml | 12 +++++----- proto-google-cloud-translate-v3/pom.xml | 4 ++-- proto-google-cloud-translate-v3beta1/pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 10 ++++---- 10 files changed, 53 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d0fabf1..9cc1256d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## [2.3.0](https://github.com/googleapis/java-translate/compare/v2.2.0...v2.3.0) (2022-06-29) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#1014](https://github.com/googleapis/java-translate/issues/1014)) ([8befc79](https://github.com/googleapis/java-translate/commit/8befc799748f11c15f4e511c8a65a74401638ffa)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#1016](https://github.com/googleapis/java-translate/issues/1016)) ([ace2700](https://github.com/googleapis/java-translate/commit/ace2700807e5557113bbb1016b54ff7b3d57e59c)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-core to v2.7.1 ([#997](https://github.com/googleapis/java-translate/issues/997)) ([e2070a9](https://github.com/googleapis/java-translate/commit/e2070a9785a029772bbb25109a480bd151003843)) +* update dependency com.google.cloud:google-cloud-core to v2.8.0 ([#1012](https://github.com/googleapis/java-translate/issues/1012)) ([0fdb776](https://github.com/googleapis/java-translate/commit/0fdb776115d90ea0894b0bc92d3a59181fd050e3)) +* update dependency com.google.cloud:google-cloud-core to v2.8.1 ([#1017](https://github.com/googleapis/java-translate/issues/1017)) ([d38a566](https://github.com/googleapis/java-translate/commit/d38a566473932796573a1f64ce819358424b4fca)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#1013](https://github.com/googleapis/java-translate/issues/1013)) ([7b1d5d6](https://github.com/googleapis/java-translate/commit/7b1d5d6542806983815c2b84d847721b1951662a)) +* update dependency com.google.cloud:google-cloud-storage to v2.7.1 ([#1003](https://github.com/googleapis/java-translate/issues/1003)) ([4871284](https://github.com/googleapis/java-translate/commit/4871284229d28fe3993b45af937d31961580a97e)) +* update dependency com.google.cloud:google-cloud-storage to v2.7.2 ([#1005](https://github.com/googleapis/java-translate/issues/1005)) ([1bb4942](https://github.com/googleapis/java-translate/commit/1bb4942ab866f8a82a683880668829e34a64725b)) +* update dependency com.google.cloud:google-cloud-storage to v2.8.0 ([#1007](https://github.com/googleapis/java-translate/issues/1007)) ([d7d9705](https://github.com/googleapis/java-translate/commit/d7d970518dc73ae4e4b61b40f05f9b7baaa000af)) +* update dependency com.google.cloud:google-cloud-storage to v2.8.1 ([#1011](https://github.com/googleapis/java-translate/issues/1011)) ([a5a2a65](https://github.com/googleapis/java-translate/commit/a5a2a657738740b2024f216c0ba5539ba67d4bfb)) +* update dependency com.google.cloud:google-cloud-storage to v2.9.0 ([#1020](https://github.com/googleapis/java-translate/issues/1020)) ([4744233](https://github.com/googleapis/java-translate/commit/47442336a5a2c3f4fde29f6b881b236a1e44cfd6)) + ## [2.2.0](https://github.com/googleapis/java-translate/compare/v2.1.13...v2.2.0) (2022-05-19) diff --git a/google-cloud-translate-bom/pom.xml b/google-cloud-translate-bom/pom.xml index a77a0b0b..c7b0a279 100644 --- a/google-cloud-translate-bom/pom.xml +++ b/google-cloud-translate-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-translate-bom - 2.2.1-SNAPSHOT + 2.3.0 pom com.google.cloud @@ -52,27 +52,27 @@ com.google.cloud google-cloud-translate - 2.2.1-SNAPSHOT + 2.3.0 com.google.api.grpc grpc-google-cloud-translate-v3beta1 - 0.84.1-SNAPSHOT + 0.85.0 com.google.api.grpc grpc-google-cloud-translate-v3 - 2.2.1-SNAPSHOT + 2.3.0 com.google.api.grpc proto-google-cloud-translate-v3beta1 - 0.84.1-SNAPSHOT + 0.85.0 com.google.api.grpc proto-google-cloud-translate-v3 - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/google-cloud-translate/pom.xml b/google-cloud-translate/pom.xml index 86bd7df3..dd9ad5a2 100644 --- a/google-cloud-translate/pom.xml +++ b/google-cloud-translate/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-translate - 2.2.1-SNAPSHOT + 2.3.0 jar Google Cloud Translate https://github.com/googleapis/java-translate @@ -11,7 +11,7 @@ com.google.cloud google-cloud-translate-parent - 2.2.1-SNAPSHOT + 2.3.0 google-cloud-translate diff --git a/grpc-google-cloud-translate-v3/pom.xml b/grpc-google-cloud-translate-v3/pom.xml index 45fc301f..99a51987 100644 --- a/grpc-google-cloud-translate-v3/pom.xml +++ b/grpc-google-cloud-translate-v3/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-translate-v3 - 2.2.1-SNAPSHOT + 2.3.0 grpc-google-cloud-translate-v3 GRPC library for grpc-google-cloud-translate-v3 com.google.cloud google-cloud-translate-parent - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/grpc-google-cloud-translate-v3beta1/pom.xml b/grpc-google-cloud-translate-v3beta1/pom.xml index 5b009e28..50f6d7ff 100644 --- a/grpc-google-cloud-translate-v3beta1/pom.xml +++ b/grpc-google-cloud-translate-v3beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-translate-v3beta1 - 0.84.1-SNAPSHOT + 0.85.0 grpc-google-cloud-translate-v3beta1 GRPC library for grpc-google-cloud-translate-v3beta1 com.google.cloud google-cloud-translate-parent - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/pom.xml b/pom.xml index 94781720..f904e709 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-translate-parent pom - 2.2.1-SNAPSHOT + 2.3.0 Google Cloud Translate Parent https://github.com/googleapis/java-translate @@ -61,27 +61,27 @@ com.google.api.grpc proto-google-cloud-translate-v3beta1 - 0.84.1-SNAPSHOT + 0.85.0 com.google.api.grpc proto-google-cloud-translate-v3 - 2.2.1-SNAPSHOT + 2.3.0 com.google.api.grpc grpc-google-cloud-translate-v3beta1 - 0.84.1-SNAPSHOT + 0.85.0 com.google.api.grpc grpc-google-cloud-translate-v3 - 2.2.1-SNAPSHOT + 2.3.0 com.google.cloud google-cloud-translate - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/proto-google-cloud-translate-v3/pom.xml b/proto-google-cloud-translate-v3/pom.xml index 25bf1cc2..7a58f97d 100644 --- a/proto-google-cloud-translate-v3/pom.xml +++ b/proto-google-cloud-translate-v3/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-translate-v3 - 2.2.1-SNAPSHOT + 2.3.0 proto-google-cloud-translate-v3 PROTO library for proto-google-cloud-translate-v3 com.google.cloud google-cloud-translate-parent - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/proto-google-cloud-translate-v3beta1/pom.xml b/proto-google-cloud-translate-v3beta1/pom.xml index 8537fd92..ab729296 100644 --- a/proto-google-cloud-translate-v3beta1/pom.xml +++ b/proto-google-cloud-translate-v3beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-translate-v3beta1 - 0.84.1-SNAPSHOT + 0.85.0 proto-google-cloud-translate-v3beta1 PROTO library for proto-google-cloud-translate-v3beta1 com.google.cloud google-cloud-translate-parent - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index d574b0a0..2442ee06 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-translate - 2.2.1-SNAPSHOT + 2.3.0 diff --git a/versions.txt b/versions.txt index 82e7c1d4..167c5705 100644 --- a/versions.txt +++ b/versions.txt @@ -1,8 +1,8 @@ # Format: # module:released-version:current-version -google-cloud-translate:2.2.0:2.2.1-SNAPSHOT -grpc-google-cloud-translate-v3beta1:0.84.0:0.84.1-SNAPSHOT -grpc-google-cloud-translate-v3:2.2.0:2.2.1-SNAPSHOT -proto-google-cloud-translate-v3beta1:0.84.0:0.84.1-SNAPSHOT -proto-google-cloud-translate-v3:2.2.0:2.2.1-SNAPSHOT +google-cloud-translate:2.3.0:2.3.0 +grpc-google-cloud-translate-v3beta1:0.85.0:0.85.0 +grpc-google-cloud-translate-v3:2.3.0:2.3.0 +proto-google-cloud-translate-v3beta1:0.85.0:0.85.0 +proto-google-cloud-translate-v3:2.3.0:2.3.0