From 01c14d41d4195963c0ed46f310360f39eec6d420 Mon Sep 17 00:00:00 2001
From: Alice <65933803+alicejli@users.noreply.github.com>
Date: Thu, 13 Oct 2022 18:04:21 -0400
Subject: [PATCH] fix: update sample region tag to parse host instead of proto
package (#1040)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: update sample region tag to parse host instead of proto package
* update goldens
* update to lowerCamelCase
* use explicit imports
* remove setting default host where it's not needed for samples and refactor parseDefaultHost
* fix(deps): update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 (#1039)
[![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) | `3.0.2` -> `3.0.3` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.3/compatibility-slim/3.0.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.3/confidence-slim/3.0.2)](https://docs.renovatebot.com/merge-confidence/) |
---
### Release Notes
googleapis/java-shared-dependencies
### [`v3.0.3`](https://togithub.com/googleapis/java-shared-dependencies/blob/HEAD/CHANGELOG.md#303-httpsgithubcomgoogleapisjava-shared-dependenciescomparev302v303-2022-09-14)
[Compare Source](https://togithub.com/googleapis/java-shared-dependencies/compare/v3.0.2...v3.0.3)
##### Dependencies
- Google-cloud-core 2.8.12 ([#799](https://togithub.com/googleapis/java-shared-dependencies/issues/799)) ([1b3db8d](https://togithub.com/googleapis/java-shared-dependencies/commit/1b3db8d1e17c49ebae79fc96164fa9058e1df6e3))
- Moving gson to first-party-dependencies ([#800](https://togithub.com/googleapis/java-shared-dependencies/issues/800)) ([a41fcc1](https://togithub.com/googleapis/java-shared-dependencies/commit/a41fcc11d32e02e5af2837561792e3919f6d4b3f))
- Update dependency com.google.protobuf:protobuf-bom to v3.21.6 ([#797](https://togithub.com/googleapis/java-shared-dependencies/issues/797)) ([bc5fdc9](https://togithub.com/googleapis/java-shared-dependencies/commit/bc5fdc9b3af7973c28f063a9ac156fe2af562814))
- Update gax.version to v2.19.1 ([#798](https://togithub.com/googleapis/java-shared-dependencies/issues/798)) ([84e5487](https://togithub.com/googleapis/java-shared-dependencies/commit/84e5487b2e3dce4bb60badecebde788c3cb702b8))
- Update google.core.version to v2.8.11 ([#793](https://togithub.com/googleapis/java-shared-dependencies/issues/793)) ([63c1297](https://togithub.com/googleapis/java-shared-dependencies/commit/63c129722aa0b821031ff5b4c11004adf7b12044))
---
### 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/gapic-generator-java).
* chore(deps): update dependency org.apache.maven.plugins:maven-shade-plugin to v3.4.0 (#1038)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.apache.maven.plugins:maven-shade-plugin](https://maven.apache.org/plugins/) ([source](https://togithub.com/apache/maven-shade-plugin)) | `3.3.0` -> `3.4.0` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-shade-plugin/3.4.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-shade-plugin/3.4.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-shade-plugin/3.4.0/compatibility-slim/3.3.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-shade-plugin/3.4.0/confidence-slim/3.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/gapic-generator-java).
* update iam oneoff
* linter
* fix(deps): update dependency org.yaml:snakeyaml to v1.33 (#1043)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.yaml:snakeyaml](https://bitbucket.org/snakeyaml/snakeyaml/src) | `1.32` -> `1.33` | [![age](https://badges.renovateapi.com/packages/maven/org.yaml:snakeyaml/1.33/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.yaml:snakeyaml/1.33/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.yaml:snakeyaml/1.33/compatibility-slim/1.32)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.yaml:snakeyaml/1.33/confidence-slim/1.32)](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/gapic-generator-java).
* refactor prepareExecutableSamples
* fix imports
* update name of unit test
* update comment
* fix(deps): update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 (#1050)
[![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) | `3.0.3` -> `3.0.4` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.4/compatibility-slim/3.0.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-shared-dependencies/3.0.4/confidence-slim/3.0.3)](https://docs.renovatebot.com/merge-confidence/) |
---
### Release Notes
googleapis/java-shared-dependencies
### [`v3.0.4`](https://togithub.com/googleapis/java-shared-dependencies/blob/HEAD/CHANGELOG.md#304-httpsgithubcomgoogleapisjava-shared-dependenciescomparev303v304-2022-10-03)
[Compare Source](https://togithub.com/googleapis/java-shared-dependencies/compare/v3.0.3...v3.0.4)
##### Dependencies
- Update dependency cachetools to v5 ([#816](https://togithub.com/googleapis/java-shared-dependencies/issues/816)) ([3f6c408](https://togithub.com/googleapis/java-shared-dependencies/commit/3f6c408210c931c286235f61c7aadea5bf5cfe4d))
- Update dependency certifi to v2022.9.24 ([#818](https://togithub.com/googleapis/java-shared-dependencies/issues/818)) ([5f04b97](https://togithub.com/googleapis/java-shared-dependencies/commit/5f04b97c2343146600e8c9ee65afdeb58f5743a6))
- Update dependency charset-normalizer to v2.1.1 ([#822](https://togithub.com/googleapis/java-shared-dependencies/issues/822)) ([6997c5a](https://togithub.com/googleapis/java-shared-dependencies/commit/6997c5acad937ebe3594330de73261a424d42cf3))
- Update dependency click to v8.1.3 ([#823](https://togithub.com/googleapis/java-shared-dependencies/issues/823)) ([42bf9f8](https://togithub.com/googleapis/java-shared-dependencies/commit/42bf9f834fdafea60f2be7ccbf7d363e058cd7c2))
- Update dependency com.google.protobuf:protobuf-bom to v3.21.7 ([#837](https://togithub.com/googleapis/java-shared-dependencies/issues/837)) ([d31e507](https://togithub.com/googleapis/java-shared-dependencies/commit/d31e5077c7e036de5e238e9a611df7ced527574a))
- Update dependency gcp-releasetool to v1.8.8 ([#819](https://togithub.com/googleapis/java-shared-dependencies/issues/819)) ([8245d97](https://togithub.com/googleapis/java-shared-dependencies/commit/8245d975fb12e81454ec7664f9a7c9809bbac697))
- Update dependency gcp-releasetool to v1.8.9 ([#846](https://togithub.com/googleapis/java-shared-dependencies/issues/846)) ([04e3283](https://togithub.com/googleapis/java-shared-dependencies/commit/04e32831c6e87c372444901013a747d2d02ce38d))
- Update dependency google-api-core to v2.10.1 ([#824](https://togithub.com/googleapis/java-shared-dependencies/issues/824)) ([818b9aa](https://togithub.com/googleapis/java-shared-dependencies/commit/818b9aa2ac99d8b1f9b39a74b626122aed5f1d94))
- Update dependency google-auth to v2.12.0 ([#825](https://togithub.com/googleapis/java-shared-dependencies/issues/825)) ([07c544b](https://togithub.com/googleapis/java-shared-dependencies/commit/07c544b5e0fa9f7110bbc957570f7a405962072e))
- Update dependency google-cloud-core to v2.3.2 ([#820](https://togithub.com/googleapis/java-shared-dependencies/issues/820)) ([2a219e8](https://togithub.com/googleapis/java-shared-dependencies/commit/2a219e86f187ba5ad72f2570bd58ca6100128c43))
- Update dependency google-cloud-storage to v2.5.0 ([#826](https://togithub.com/googleapis/java-shared-dependencies/issues/826)) ([bb10d18](https://togithub.com/googleapis/java-shared-dependencies/commit/bb10d1858a515f09d365362ffa0110a5b362c96b))
- Update dependency google-crc32c to v1.5.0 ([#827](https://togithub.com/googleapis/java-shared-dependencies/issues/827)) ([7e5dae6](https://togithub.com/googleapis/java-shared-dependencies/commit/7e5dae60d667cb84b9ee4f6c977bdc35e79e4cf6))
- Update dependency google-resumable-media to v2.4.0 ([#838](https://togithub.com/googleapis/java-shared-dependencies/issues/838)) ([ad82d63](https://togithub.com/googleapis/java-shared-dependencies/commit/ad82d6378f64039da383509638fb4782908eb4bc))
- Update dependency googleapis-common-protos to v1.56.4 ([#821](https://togithub.com/googleapis/java-shared-dependencies/issues/821)) ([93d7745](https://togithub.com/googleapis/java-shared-dependencies/commit/93d77458c9bbf84ec367cdb4caaa41e6f71675c6))
- Update dependency importlib-metadata to v4.12.0 ([#832](https://togithub.com/googleapis/java-shared-dependencies/issues/832)) ([ee19fb1](https://togithub.com/googleapis/java-shared-dependencies/commit/ee19fb1ca5a2a2e1985297e3b72d44de68bc72e3))
- Update dependency importlib-metadata to v4.13.0 ([#843](https://togithub.com/googleapis/java-shared-dependencies/issues/843)) ([d2ede60](https://togithub.com/googleapis/java-shared-dependencies/commit/d2ede601eee8c875780c7eb5924623537480c509))
- Update dependency importlib-metadata to v5 ([#845](https://togithub.com/googleapis/java-shared-dependencies/issues/845)) ([03ac7e8](https://togithub.com/googleapis/java-shared-dependencies/commit/03ac7e800274c5f58d2bc4ddd0561bfcdea1bb27))
- Update dependency io.grpc:grpc-bom to v1.49.1 ([#802](https://togithub.com/googleapis/java-shared-dependencies/issues/802)) ([b8c54bf](https://togithub.com/googleapis/java-shared-dependencies/commit/b8c54bf8f1ddecc788cee151f8afe42de45bdc9d))
- Update dependency io.grpc:grpc-bom to v1.49.2 ([#842](https://togithub.com/googleapis/java-shared-dependencies/issues/842)) ([1b1cfa2](https://togithub.com/googleapis/java-shared-dependencies/commit/1b1cfa27d05f7732da12721305cf41dcbebda232))
- Update dependency jeepney to v0.8.0 ([#833](https://togithub.com/googleapis/java-shared-dependencies/issues/833)) ([15d2f9f](https://togithub.com/googleapis/java-shared-dependencies/commit/15d2f9f52b5a3259db0813df3d2424e256ccb372))
- Update dependency jinja2 to v3.1.2 ([#834](https://togithub.com/googleapis/java-shared-dependencies/issues/834)) ([c188f95](https://togithub.com/googleapis/java-shared-dependencies/commit/c188f95acdb3349f1c4b3ed56e5fffb75e8fbc8d))
- Update dependency keyring to v23.9.3 ([#828](https://togithub.com/googleapis/java-shared-dependencies/issues/828)) ([b185aaa](https://togithub.com/googleapis/java-shared-dependencies/commit/b185aaae716d4d97cb64f0426cac0e778f11223d))
- Update dependency markupsafe to v2.1.1 ([#829](https://togithub.com/googleapis/java-shared-dependencies/issues/829)) ([add2825](https://togithub.com/googleapis/java-shared-dependencies/commit/add2825bd34cd80f529dbe0dadb3c84219177916))
- Update dependency org.threeten:threetenbp to v1.6.2 ([#808](https://togithub.com/googleapis/java-shared-dependencies/issues/808)) ([2d2eabd](https://togithub.com/googleapis/java-shared-dependencies/commit/2d2eabd14d8150207885ea47280c0f7ff3d2962f))
- Update dependency protobuf to v3.20.2 ([#830](https://togithub.com/googleapis/java-shared-dependencies/issues/830)) ([5afa76f](https://togithub.com/googleapis/java-shared-dependencies/commit/5afa76f9ef4705aecba49abc7bb93982fb1ecf3e))
- Update dependency protobuf to v3.20.3 ([#839](https://togithub.com/googleapis/java-shared-dependencies/issues/839)) ([d9fc7dd](https://togithub.com/googleapis/java-shared-dependencies/commit/d9fc7ddd3e663458e6ea3f78a3c6241377df0319))
- Update dependency protobuf to v4 ([#817](https://togithub.com/googleapis/java-shared-dependencies/issues/817)) ([ee8d154](https://togithub.com/googleapis/java-shared-dependencies/commit/ee8d154287ccd256b4dcfa48f28f5ec61a91fe3e))
- Update dependency pyjwt to v2.5.0 ([#812](https://togithub.com/googleapis/java-shared-dependencies/issues/812)) ([4d4528e](https://togithub.com/googleapis/java-shared-dependencies/commit/4d4528e8ce269d49b99d2dbc4fcda2dc37a058cb))
- Update dependency requests to v2.28.1 ([#813](https://togithub.com/googleapis/java-shared-dependencies/issues/813)) ([a3a8d89](https://togithub.com/googleapis/java-shared-dependencies/commit/a3a8d89b0117007a7108553c70aa82dd289e1691))
- Update dependency typing-extensions to v4.3.0 ([#814](https://togithub.com/googleapis/java-shared-dependencies/issues/814)) ([da875e5](https://togithub.com/googleapis/java-shared-dependencies/commit/da875e5e91fa9d8c177e6c3afc9e34242eb914b7))
- Update dependency zipp to v3.8.1 ([#815](https://togithub.com/googleapis/java-shared-dependencies/issues/815)) ([15585fd](https://togithub.com/googleapis/java-shared-dependencies/commit/15585fd0216013fe93be011f93f391f6269aa777))
- Update gax.version to v2.19.2 ([#847](https://togithub.com/googleapis/java-shared-dependencies/issues/847)) ([c4afe1f](https://togithub.com/googleapis/java-shared-dependencies/commit/c4afe1fdc88af29ab039cea618d52c15c90e43e9))
- Update google.common-protos.version to v2.9.3 ([#803](https://togithub.com/googleapis/java-shared-dependencies/issues/803)) ([a3e8e5e](https://togithub.com/googleapis/java-shared-dependencies/commit/a3e8e5eb53a8da14abf3b8d81a4f34fbb2f3b8f9))
- Update google.common-protos.version to v2.9.5 ([#831](https://togithub.com/googleapis/java-shared-dependencies/issues/831)) ([1c901db](https://togithub.com/googleapis/java-shared-dependencies/commit/1c901db8a7740afaec3e809e51d4d369fbf469c4))
- Update google.common-protos.version to v2.9.6 ([#844](https://togithub.com/googleapis/java-shared-dependencies/issues/844)) ([9e156be](https://togithub.com/googleapis/java-shared-dependencies/commit/9e156be59bd89959f04252c3045b8cd7a8be8070))
- Update google.core.version to v2.8.13 ([#804](https://togithub.com/googleapis/java-shared-dependencies/issues/804)) ([45ae571](https://togithub.com/googleapis/java-shared-dependencies/commit/45ae57142bd6d5334eedd46243736b200a459795))
- Update google.core.version to v2.8.14 ([#805](https://togithub.com/googleapis/java-shared-dependencies/issues/805)) ([02c9397](https://togithub.com/googleapis/java-shared-dependencies/commit/02c9397a84bf3fcca8d04e4c9867cc47689abde2))
- Update google.core.version to v2.8.15 ([#807](https://togithub.com/googleapis/java-shared-dependencies/issues/807)) ([980856c](https://togithub.com/googleapis/java-shared-dependencies/commit/980856c43981992a3d08f69eac83aeada752d244))
- Update google.core.version to v2.8.16 ([#810](https://togithub.com/googleapis/java-shared-dependencies/issues/810)) ([c2b2c9a](https://togithub.com/googleapis/java-shared-dependencies/commit/c2b2c9a327fd588f69524bb93a17e5d4ae8f5a42))
- Update google.core.version to v2.8.17 ([#835](https://togithub.com/googleapis/java-shared-dependencies/issues/835)) ([3def21d](https://togithub.com/googleapis/java-shared-dependencies/commit/3def21df2e4253e3df0da064b6c4e472df079d2b))
- Update google.core.version to v2.8.18 ([#840](https://togithub.com/googleapis/java-shared-dependencies/issues/840)) ([46566dc](https://togithub.com/googleapis/java-shared-dependencies/commit/46566dc18c4b1ed41c482b4ce21b92651e2f9dc5))
- Update google.core.version to v2.8.19 ([#841](https://togithub.com/googleapis/java-shared-dependencies/issues/841)) ([99afde9](https://togithub.com/googleapis/java-shared-dependencies/commit/99afde97ea498f549eb75cc58c4ed88edf81b20d))
- Update google.core.version to v2.8.20 ([#848](https://togithub.com/googleapis/java-shared-dependencies/issues/848)) ([c980c4f](https://togithub.com/googleapis/java-shared-dependencies/commit/c980c4fdfc8890d812b4881ba5b87bfd21269a5f))
- Update iam.version to v1.6.1 ([#806](https://togithub.com/googleapis/java-shared-dependencies/issues/806)) ([a50158d](https://togithub.com/googleapis/java-shared-dependencies/commit/a50158d3b83cf8e02d8ee08c94e512b5669a927b))
- Update iam.version to v1.6.2 ([#849](https://togithub.com/googleapis/java-shared-dependencies/issues/849)) ([e43ac96](https://togithub.com/googleapis/java-shared-dependencies/commit/e43ac96bc189a096a9311c9b03e85c86bea07e99))
---
### 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/gapic-generator-java).
* fix: Get numeric value for Enum fields if it is configured as query param or path param (#1042)
Get numeric value for Enum fields if it is configured as query param or path param. Refactor HttpBinding to include Field info and use builder.
* refactor unit tests
* refactor composers
* chore(deps): update dependency com.google.auto.value:auto-value to v1.10 (#1058)
[![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.auto.value:auto-value](https://togithub.com/google/auto/tree/master/value) ([source](https://togithub.com/google/auto)) | `1.9` -> `1.10` | [![age](https://badges.renovateapi.com/packages/maven/com.google.auto.value:auto-value/1.10/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.auto.value:auto-value/1.10/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.auto.value:auto-value/1.10/compatibility-slim/1.9)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.auto.value:auto-value/1.10/confidence-slim/1.9)](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/gapic-generator-java).
* update comment
* fix lint
Co-authored-by: WhiteSource Renovate
Co-authored-by: Blake Li
---
.../generator/gapic/composer/Composer.java | 60 +++++++---
.../AbstractServiceClientClassComposer.java | 3 +-
.../AbstractServiceSettingsClassComposer.java | 3 +-
...tractServiceStubSettingsClassComposer.java | 3 +-
.../samplecode/SettingsSampleComposer.java | 1 +
.../api/generator/gapic/model/GapicClass.java | 14 ++-
.../api/generator/gapic/model/RegionTag.java | 1 +
.../gapic/composer/ComposerTest.java | 112 +++++++++++++-----
.../grpc/ServiceClientClassComposerTest.java | 33 ++++--
.../ServiceSettingsClassComposerTest.java | 12 +-
.../grpc/ServiceStubClassComposerTest.java | 8 +-
.../ServiceStubSettingsClassComposerTest.java | 26 +++-
.../AsyncAnalyzeIamPolicy.java | 4 +-
.../SyncAnalyzeIamPolicy.java | 4 +-
.../AsyncAnalyzeIamPolicyLongrunning.java | 4 +-
.../AsyncAnalyzeIamPolicyLongrunningLRO.java | 4 +-
.../SyncAnalyzeIamPolicyLongrunning.java | 4 +-
.../analyzemove/AsyncAnalyzeMove.java | 4 +-
.../analyzemove/SyncAnalyzeMove.java | 4 +-
.../AsyncBatchGetAssetsHistory.java | 4 +-
.../SyncBatchGetAssetsHistory.java | 4 +-
.../SyncCreateSetCredentialsProvider.java | 4 +-
.../create/SyncCreateSetEndpoint.java | 4 +-
.../createfeed/AsyncCreateFeed.java | 4 +-
.../createfeed/SyncCreateFeed.java | 4 +-
.../createfeed/SyncCreateFeedString.java | 4 +-
.../deletefeed/AsyncDeleteFeed.java | 4 +-
.../deletefeed/SyncDeleteFeed.java | 4 +-
.../deletefeed/SyncDeleteFeedFeedname.java | 4 +-
.../deletefeed/SyncDeleteFeedString.java | 4 +-
.../exportassets/AsyncExportAssets.java | 4 +-
.../exportassets/AsyncExportAssetsLRO.java | 4 +-
.../exportassets/SyncExportAssets.java | 4 +-
.../getfeed/AsyncGetFeed.java | 4 +-
.../getfeed/SyncGetFeed.java | 4 +-
.../getfeed/SyncGetFeedFeedname.java | 4 +-
.../getfeed/SyncGetFeedString.java | 4 +-
.../listassets/AsyncListAssets.java | 4 +-
.../listassets/AsyncListAssetsPaged.java | 4 +-
.../listassets/SyncListAssets.java | 4 +-
.../SyncListAssetsResourcename.java | 4 +-
.../listassets/SyncListAssetsString.java | 4 +-
.../listfeeds/AsyncListFeeds.java | 4 +-
.../listfeeds/SyncListFeeds.java | 4 +-
.../listfeeds/SyncListFeedsString.java | 4 +-
.../AsyncSearchAllIamPolicies.java | 4 +-
.../AsyncSearchAllIamPoliciesPaged.java | 4 +-
.../SyncSearchAllIamPolicies.java | 4 +-
.../SyncSearchAllIamPoliciesStringString.java | 4 +-
.../AsyncSearchAllResources.java | 4 +-
.../AsyncSearchAllResourcesPaged.java | 4 +-
.../SyncSearchAllResources.java | 4 +-
...rchAllResourcesStringStringListstring.java | 4 +-
.../updatefeed/AsyncUpdateFeed.java | 4 +-
.../updatefeed/SyncUpdateFeed.java | 4 +-
.../updatefeed/SyncUpdateFeedFeed.java | 4 +-
.../SyncBatchGetAssetsHistory.java | 4 +-
.../SyncBatchGetAssetsHistory.java | 4 +-
.../SyncCreateSetCredentialsProvider.java | 4 +-
.../create/SyncCreateSetEndpoint.java | 4 +-
.../AsyncGenerateAccessToken.java | 4 +-
.../SyncGenerateAccessToken.java | 4 +-
...countnameListstringListstringDuration.java | 4 +-
...kenStringListstringListstringDuration.java | 4 +-
.../generateidtoken/AsyncGenerateIdToken.java | 4 +-
.../generateidtoken/SyncGenerateIdToken.java | 4 +-
...iceaccountnameListstringStringBoolean.java | 4 +-
...eIdTokenStringListstringStringBoolean.java | 4 +-
.../signblob/AsyncSignBlob.java | 4 +-
.../signblob/SyncSignBlob.java | 4 +-
...erviceaccountnameListstringBytestring.java | 4 +-
...yncSignBlobStringListstringBytestring.java | 4 +-
.../signjwt/AsyncSignJwt.java | 4 +-
.../signjwt/SyncSignJwt.java | 4 +-
...JwtServiceaccountnameListstringString.java | 4 +-
.../SyncSignJwtStringListstringString.java | 4 +-
.../SyncGenerateAccessToken.java | 4 +-
.../SyncGenerateAccessToken.java | 4 +-
.../AsyncAsymmetricDecrypt.java | 4 +-
.../SyncAsymmetricDecrypt.java | 4 +-
...DecryptCryptokeyversionnameBytestring.java | 4 +-
...SyncAsymmetricDecryptStringBytestring.java | 4 +-
.../asymmetricsign/AsyncAsymmetricSign.java | 4 +-
.../asymmetricsign/SyncAsymmetricSign.java | 4 +-
...mmetricSignCryptokeyversionnameDigest.java | 4 +-
.../SyncAsymmetricSignStringDigest.java | 4 +-
.../SyncCreateSetCredentialsProvider.java | 4 +-
.../create/SyncCreateSetEndpoint.java | 4 +-
.../createcryptokey/AsyncCreateCryptoKey.java | 4 +-
.../createcryptokey/SyncCreateCryptoKey.java | 4 +-
...teCryptoKeyKeyringnameStringCryptokey.java | 4 +-
...cCreateCryptoKeyStringStringCryptokey.java | 4 +-
.../AsyncCreateCryptoKeyVersion.java | 4 +-
.../SyncCreateCryptoKeyVersion.java | 4 +-
...yVersionCryptokeynameCryptokeyversion.java | 4 +-
...ryptoKeyVersionStringCryptokeyversion.java | 4 +-
.../createimportjob/AsyncCreateImportJob.java | 4 +-
.../createimportjob/SyncCreateImportJob.java | 4 +-
...teImportJobKeyringnameStringImportjob.java | 4 +-
...cCreateImportJobStringStringImportjob.java | 4 +-
.../createkeyring/AsyncCreateKeyRing.java | 4 +-
.../createkeyring/SyncCreateKeyRing.java | 4 +-
...reateKeyRingLocationnameStringKeyring.java | 4 +-
.../SyncCreateKeyRingStringStringKeyring.java | 4 +-
.../decrypt/AsyncDecrypt.java | 4 +-
.../decrypt/SyncDecrypt.java | 4 +-
.../SyncDecryptCryptokeynameBytestring.java | 4 +-
.../decrypt/SyncDecryptStringBytestring.java | 4 +-
.../AsyncDestroyCryptoKeyVersion.java | 4 +-
.../SyncDestroyCryptoKeyVersion.java | 4 +-
...yCryptoKeyVersionCryptokeyversionname.java | 4 +-
.../SyncDestroyCryptoKeyVersionString.java | 4 +-
.../encrypt/AsyncEncrypt.java | 4 +-
.../encrypt/SyncEncrypt.java | 4 +-
.../SyncEncryptResourcenameBytestring.java | 4 +-
.../encrypt/SyncEncryptStringBytestring.java | 4 +-
.../getcryptokey/AsyncGetCryptoKey.java | 4 +-
.../getcryptokey/SyncGetCryptoKey.java | 4 +-
.../SyncGetCryptoKeyCryptokeyname.java | 4 +-
.../getcryptokey/SyncGetCryptoKeyString.java | 4 +-
.../AsyncGetCryptoKeyVersion.java | 4 +-
.../SyncGetCryptoKeyVersion.java | 4 +-
...tCryptoKeyVersionCryptokeyversionname.java | 4 +-
.../SyncGetCryptoKeyVersionString.java | 4 +-
.../getiampolicy/AsyncGetIamPolicy.java | 4 +-
.../getiampolicy/SyncGetIamPolicy.java | 4 +-
.../getimportjob/AsyncGetImportJob.java | 4 +-
.../getimportjob/SyncGetImportJob.java | 4 +-
.../SyncGetImportJobImportjobname.java | 4 +-
.../getimportjob/SyncGetImportJobString.java | 4 +-
.../getkeyring/AsyncGetKeyRing.java | 4 +-
.../getkeyring/SyncGetKeyRing.java | 4 +-
.../getkeyring/SyncGetKeyRingKeyringname.java | 4 +-
.../getkeyring/SyncGetKeyRingString.java | 4 +-
.../getlocation/AsyncGetLocation.java | 4 +-
.../getlocation/SyncGetLocation.java | 4 +-
.../getpublickey/AsyncGetPublicKey.java | 4 +-
.../getpublickey/SyncGetPublicKey.java | 4 +-
.../SyncGetPublicKeyCryptokeyversionname.java | 4 +-
.../getpublickey/SyncGetPublicKeyString.java | 4 +-
.../AsyncImportCryptoKeyVersion.java | 4 +-
.../SyncImportCryptoKeyVersion.java | 4 +-
.../listcryptokeys/AsyncListCryptoKeys.java | 4 +-
.../AsyncListCryptoKeysPaged.java | 4 +-
.../listcryptokeys/SyncListCryptoKeys.java | 4 +-
.../SyncListCryptoKeysKeyringname.java | 4 +-
.../SyncListCryptoKeysString.java | 4 +-
.../AsyncListCryptoKeyVersions.java | 4 +-
.../AsyncListCryptoKeyVersionsPaged.java | 4 +-
.../SyncListCryptoKeyVersions.java | 4 +-
...yncListCryptoKeyVersionsCryptokeyname.java | 4 +-
.../SyncListCryptoKeyVersionsString.java | 4 +-
.../listimportjobs/AsyncListImportJobs.java | 4 +-
.../AsyncListImportJobsPaged.java | 4 +-
.../listimportjobs/SyncListImportJobs.java | 4 +-
.../SyncListImportJobsKeyringname.java | 4 +-
.../SyncListImportJobsString.java | 4 +-
.../listkeyrings/AsyncListKeyRings.java | 4 +-
.../listkeyrings/AsyncListKeyRingsPaged.java | 4 +-
.../listkeyrings/SyncListKeyRings.java | 4 +-
.../SyncListKeyRingsLocationname.java | 4 +-
.../listkeyrings/SyncListKeyRingsString.java | 4 +-
.../listlocations/AsyncListLocations.java | 4 +-
.../AsyncListLocationsPaged.java | 4 +-
.../listlocations/SyncListLocations.java | 4 +-
.../AsyncRestoreCryptoKeyVersion.java | 4 +-
.../SyncRestoreCryptoKeyVersion.java | 4 +-
...eCryptoKeyVersionCryptokeyversionname.java | 4 +-
.../SyncRestoreCryptoKeyVersionString.java | 4 +-
.../AsyncTestIamPermissions.java | 4 +-
.../SyncTestIamPermissions.java | 4 +-
.../updatecryptokey/AsyncUpdateCryptoKey.java | 4 +-
.../updatecryptokey/SyncUpdateCryptoKey.java | 4 +-
...SyncUpdateCryptoKeyCryptokeyFieldmask.java | 4 +-
.../AsyncUpdateCryptoKeyPrimaryVersion.java | 4 +-
.../SyncUpdateCryptoKeyPrimaryVersion.java | 4 +-
...oKeyPrimaryVersionCryptokeynameString.java | 4 +-
...teCryptoKeyPrimaryVersionStringString.java | 4 +-
.../AsyncUpdateCryptoKeyVersion.java | 4 +-
.../SyncUpdateCryptoKeyVersion.java | 4 +-
...toKeyVersionCryptokeyversionFieldmask.java | 4 +-
.../getkeyring/SyncGetKeyRing.java | 4 +-
.../getkeyring/SyncGetKeyRing.java | 4 +-
.../SyncCreateSetCredentialsProvider.java | 4 +-
.../create/SyncCreateSetEndpoint.java | 4 +-
.../createbook/AsyncCreateBook.java | 4 +-
.../createbook/SyncCreateBook.java | 4 +-
.../SyncCreateBookShelfnameBook.java | 4 +-
.../createbook/SyncCreateBookStringBook.java | 4 +-
.../createshelf/AsyncCreateShelf.java | 4 +-
.../createshelf/SyncCreateShelf.java | 4 +-
.../createshelf/SyncCreateShelfShelf.java | 4 +-
.../deletebook/AsyncDeleteBook.java | 4 +-
.../deletebook/SyncDeleteBook.java | 4 +-
.../deletebook/SyncDeleteBookBookname.java | 4 +-
.../deletebook/SyncDeleteBookString.java | 4 +-
.../deleteshelf/AsyncDeleteShelf.java | 4 +-
.../deleteshelf/SyncDeleteShelf.java | 4 +-
.../deleteshelf/SyncDeleteShelfShelfname.java | 4 +-
.../deleteshelf/SyncDeleteShelfString.java | 4 +-
.../getbook/AsyncGetBook.java | 4 +-
.../getbook/SyncGetBook.java | 4 +-
.../getbook/SyncGetBookBookname.java | 4 +-
.../getbook/SyncGetBookString.java | 4 +-
.../getshelf/AsyncGetShelf.java | 4 +-
.../getshelf/SyncGetShelf.java | 4 +-
.../getshelf/SyncGetShelfShelfname.java | 4 +-
.../getshelf/SyncGetShelfString.java | 4 +-
.../listbooks/AsyncListBooks.java | 4 +-
.../listbooks/AsyncListBooksPaged.java | 4 +-
.../listbooks/SyncListBooks.java | 4 +-
.../listbooks/SyncListBooksShelfname.java | 4 +-
.../listbooks/SyncListBooksString.java | 4 +-
.../listshelves/AsyncListShelves.java | 4 +-
.../listshelves/AsyncListShelvesPaged.java | 4 +-
.../listshelves/SyncListShelves.java | 4 +-
.../mergeshelves/AsyncMergeShelves.java | 4 +-
.../mergeshelves/SyncMergeShelves.java | 4 +-
.../SyncMergeShelvesShelfnameShelfname.java | 4 +-
.../SyncMergeShelvesShelfnameString.java | 4 +-
.../SyncMergeShelvesStringShelfname.java | 4 +-
.../SyncMergeShelvesStringString.java | 4 +-
.../movebook/AsyncMoveBook.java | 4 +-
.../movebook/SyncMoveBook.java | 4 +-
.../SyncMoveBookBooknameShelfname.java | 4 +-
.../movebook/SyncMoveBookBooknameString.java | 4 +-
.../movebook/SyncMoveBookStringShelfname.java | 4 +-
.../movebook/SyncMoveBookStringString.java | 4 +-
.../updatebook/AsyncUpdateBook.java | 4 +-
.../updatebook/SyncUpdateBook.java | 4 +-
.../SyncUpdateBookBookFieldmask.java | 4 +-
.../createshelf/SyncCreateShelf.java | 4 +-
.../createshelf/SyncCreateShelf.java | 4 +-
233 files changed, 650 insertions(+), 510 deletions(-)
diff --git a/src/main/java/com/google/api/generator/gapic/composer/Composer.java b/src/main/java/com/google/api/generator/gapic/composer/Composer.java
index 8306930de1..60d4f5dde2 100644
--- a/src/main/java/com/google/api/generator/gapic/composer/Composer.java
+++ b/src/main/java/com/google/api/generator/gapic/composer/Composer.java
@@ -15,6 +15,7 @@
package com.google.api.generator.gapic.composer;
import com.google.api.generator.engine.ast.ClassDefinition;
+import com.google.api.generator.engine.ast.CommentStatement;
import com.google.api.generator.gapic.composer.comment.CommentComposer;
import com.google.api.generator.gapic.composer.grpc.GrpcServiceCallableFactoryClassComposer;
import com.google.api.generator.gapic.composer.grpc.GrpcServiceStubClassComposer;
@@ -36,6 +37,8 @@
import com.google.api.generator.gapic.model.Service;
import com.google.api.generator.gapic.model.Transport;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -191,36 +194,57 @@ public static List generateTestClasses(GapicContext context) {
@VisibleForTesting
static List prepareExecutableSamples(List clazzes, String protoPackage) {
- // parse protoPackage for apiVersion and apiShortName
+ // parse protoPackage for apiVersion
String[] pakkage = protoPackage.split("\\.");
String apiVersion;
- String apiShortName;
// e.g. v1, v2, v1beta1
if (pakkage[pakkage.length - 1].matches("v[0-9].*")) {
apiVersion = pakkage[pakkage.length - 1];
- apiShortName = pakkage[pakkage.length - 2];
} else {
apiVersion = "";
- apiShortName = pakkage[pakkage.length - 1];
}
- // Include license header, apiShortName, and apiVersion
- return clazzes.stream()
- .map(
- gapicClass -> {
- List samples =
- gapicClass.samples().stream()
- .map(
- sample -> addRegionTagAndHeaderToSample(sample, apiShortName, apiVersion))
- .collect(Collectors.toList());
- return gapicClass.withSamples(samples);
- })
- .collect(Collectors.toList());
+ // Include license header, apiShortName, and apiVersion
+ List clazzesWithSamples = new ArrayList<>();
+ clazzes.forEach(
+ gapicClass -> {
+ List samples = new ArrayList<>();
+ gapicClass
+ .samples()
+ .forEach(
+ sample ->
+ samples.add(
+ addRegionTagAndHeaderToSample(
+ sample, parseDefaultHost(gapicClass.defaultHost()), apiVersion)));
+ clazzesWithSamples.add(gapicClass.withSamples(samples));
+ });
+ return clazzesWithSamples;
}
- private static Sample addRegionTagAndHeaderToSample(
+ // Parse defaultHost for apiShortName for the RegionTag. Need to account for regional default
+ // endpoints like
+ // "us-east1-pubsub.googleapis.com".
+ @VisibleForTesting
+ protected static String parseDefaultHost(String defaultHost) {
+ // If the defaultHost is of the format "**.googleapis.com", take the name before the first
+ // period.
+ String apiShortName = Iterables.getFirst(Splitter.on(".").split(defaultHost), defaultHost);
+ // If the defaultHost is of the format "**-**-**.googleapis.com", take the section before the
+ // first period and after the last dash to follow CSharp's implementation here:
+ // https://github.com/googleapis/gapic-generator-csharp/blob/main/Google.Api.Generator/Generation/ServiceDetails.cs#L70
+ apiShortName = Iterables.getLast(Splitter.on("-").split(apiShortName), defaultHost);
+ // `iam-meta-api` service is an exceptional case and is handled as a one-off
+ if (defaultHost.contains("iam-meta-api")) {
+ apiShortName = "iam";
+ }
+ return apiShortName;
+ }
+
+ @VisibleForTesting
+ protected static Sample addRegionTagAndHeaderToSample(
Sample sample, String apiShortName, String apiVersion) {
+ final List header = Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT);
return sample
- .withHeader(Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT))
+ .withHeader(header)
.withRegionTag(
sample.regionTag().withApiVersion(apiVersion).withApiShortName(apiShortName));
}
diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java
index cf99df8d15..c76f25c9f6 100644
--- a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java
+++ b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java
@@ -163,7 +163,8 @@ public GapicClass generate(GapicContext context, Service service) {
.build();
updateGapicMetadata(context, service, className, grpcRpcsToJavaMethodNames);
- return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
+ return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
+ .withDefaultHost(service.defaultHost());
}
private static List createClassAnnotations(Service service, TypeStore typeStore) {
diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java
index 68780ed6bc..08186862ae 100644
--- a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java
+++ b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java
@@ -126,7 +126,8 @@ public GapicClass generate(GapicContext context, Service service) {
.setMethods(createClassMethods(service, typeStore))
.setNestedClasses(Arrays.asList(createNestedBuilderClass(service, typeStore)))
.build();
- return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
+ return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
+ .withDefaultHost(service.defaultHost());
}
private static List createClassHeaderComments(
diff --git a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java
index 1074173850..cea124e96d 100644
--- a/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java
+++ b/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java
@@ -201,7 +201,8 @@ public GapicClass generate(GapicContext context, Service service) {
Arrays.asList(createNestedBuilderClass(service, serviceConfig, typeStore)))
.build();
return GapicClass.create(
- GapicClass.Kind.STUB, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
+ GapicClass.Kind.STUB, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
+ .withDefaultHost(service.defaultHost());
}
protected MethodDefinition createDefaultCredentialsProviderBuilderMethod() {
diff --git a/src/main/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposer.java b/src/main/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposer.java
index 9027f50000..372399ee56 100644
--- a/src/main/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposer.java
+++ b/src/main/java/com/google/api/generator/gapic/composer/samplecode/SettingsSampleComposer.java
@@ -145,6 +145,7 @@ public static Optional composeSettingsSample(
.map(e -> ExprStatement.withExpr(e))
.collect(Collectors.toList());
+ // TODO: alicejli edit RegionTag to match other languages
RegionTag regionTag =
RegionTag.builder()
.setServiceName(classType.reference().name())
diff --git a/src/main/java/com/google/api/generator/gapic/model/GapicClass.java b/src/main/java/com/google/api/generator/gapic/model/GapicClass.java
index eee6349fa8..165cb4d94b 100644
--- a/src/main/java/com/google/api/generator/gapic/model/GapicClass.java
+++ b/src/main/java/com/google/api/generator/gapic/model/GapicClass.java
@@ -35,6 +35,10 @@ public enum Kind {
public abstract List samples();
+ // Represents the host URL for the service. May or may not contain a regional endpoint. Only used
+ // for generating the region tag for samples; therefore only used in select Composers.
+ public abstract String defaultHost();
+
public static GapicClass create(Kind kind, ClassDefinition classDefinition) {
return builder().setKind(kind).setClassDefinition(classDefinition).build();
}
@@ -45,7 +49,9 @@ public static GapicClass create(
}
static Builder builder() {
- return new AutoValue_GapicClass.Builder().setSamples(Collections.emptyList());
+ return new AutoValue_GapicClass.Builder()
+ .setSamples(Collections.emptyList())
+ .setDefaultHost("");
}
abstract Builder toBuilder();
@@ -54,6 +60,10 @@ public final GapicClass withSamples(List samples) {
return toBuilder().setSamples(samples).build();
}
+ public final GapicClass withDefaultHost(String defaultHost) {
+ return toBuilder().setDefaultHost(defaultHost).build();
+ }
+
@AutoValue.Builder
abstract static class Builder {
abstract Builder setKind(Kind kind);
@@ -62,6 +72,8 @@ abstract static class Builder {
abstract Builder setSamples(List samples);
+ abstract Builder setDefaultHost(String defaultHost);
+
abstract GapicClass build();
}
}
diff --git a/src/main/java/com/google/api/generator/gapic/model/RegionTag.java b/src/main/java/com/google/api/generator/gapic/model/RegionTag.java
index d98212ef6b..29bb98eeef 100644
--- a/src/main/java/com/google/api/generator/gapic/model/RegionTag.java
+++ b/src/main/java/com/google/api/generator/gapic/model/RegionTag.java
@@ -20,6 +20,7 @@
import com.google.auto.value.AutoValue;
import com.google.common.base.Preconditions;
+// TODO: alicejli edit RegionTag to match other languages
/**
* This model represents a code sample region tag. Matching region start and end region tag comments
* are used to determine the boundaries of code snippets to be used in documentation.
diff --git a/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java
index 4bbc779dcf..caf070682c 100644
--- a/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java
+++ b/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java
@@ -15,6 +15,7 @@
package com.google.api.generator.gapic.composer;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import com.google.api.generator.engine.ast.ClassDefinition;
import com.google.api.generator.engine.ast.ScopeNode;
@@ -25,11 +26,11 @@
import com.google.api.generator.gapic.model.GapicClass;
import com.google.api.generator.gapic.model.GapicClass.Kind;
import com.google.api.generator.gapic.model.GapicContext;
+import com.google.api.generator.gapic.model.RegionTag;
import com.google.api.generator.gapic.model.Sample;
import com.google.api.generator.gapic.model.Service;
import com.google.api.generator.test.framework.Assert;
import com.google.api.generator.test.framework.Utils;
-import com.google.common.collect.ImmutableList;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
@@ -42,8 +43,13 @@ public class ComposerTest {
private final List clazzes =
Arrays.asList(
GrpcServiceCallableFactoryClassComposer.instance().generate(context, echoProtoService));
- private final String protoPackage = context.gapicMetadata().getProtoPackage();
- private final List samples = clazzes.get(0).samples();
+ private final Sample sample =
+ Sample.builder()
+ .setRegionTag(
+ RegionTag.builder().setServiceName("serviceName").setRpcName("rpcName").build())
+ .build();
+ private List ListofSamples = Arrays.asList(new Sample[] {sample});
+ private final String protoPackage = echoProtoService.protoPakkage();
@Test
public void gapicClass_addApacheLicense() {
@@ -65,58 +71,102 @@ public void gapicClass_addApacheLicense() {
@Test
public void composeSamples_showcase() {
- for (Sample sample : samples) {
- assertEquals(
- "File header will be empty before composing samples",
- sample.fileHeader(),
- ImmutableList.of());
- assertEquals(
- "ApiShortName will be empty before composing samples",
- sample.regionTag().apiShortName(),
- "");
- assertEquals(
- "ApiVersion will be empty before composing samples", sample.regionTag().apiVersion(), "");
- }
+ GapicClass testClass = clazzes.get(0).withSamples(ListofSamples);
+ List testClassList = Arrays.asList(new GapicClass[] {testClass});
List composedSamples =
- Composer.prepareExecutableSamples(clazzes, protoPackage).get(0).samples();
+ Composer.prepareExecutableSamples(testClassList, protoPackage).get(0).samples();
+ assertFalse(composedSamples.isEmpty());
for (Sample sample : composedSamples) {
assertEquals(
- "File header should be apache",
- sample.fileHeader(),
- Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT));
- assertEquals(
- "ApiShortName should be showcase", sample.regionTag().apiShortName(), "showcase");
- assertEquals("ApiVersion should be v1beta1", sample.regionTag().apiVersion(), "v1beta1");
+ "File header should be APACHE",
+ Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT),
+ sample.fileHeader());
+ assertEquals("ApiShortName should be empty", "", sample.regionTag().apiShortName());
+ assertEquals("ApiVersion should be V1beta1", "V1Beta1", sample.regionTag().apiVersion());
}
}
+ @Test
+ public void parseDefaultHost_shouldReturnApiShortNameIfHostContainsRegionalEndpoint() {
+ String defaultHost = "us-east1-pubsub.googleapis.com";
+ String apiShortName = Composer.parseDefaultHost(defaultHost);
+ assertEquals("pubsub", apiShortName);
+ }
+
+ @Test
+ public void parseDefaultHost_shouldReturnApiShortName() {
+ String defaultHost = "logging.googleapis.com";
+ String apiShortName = Composer.parseDefaultHost(defaultHost);
+ assertEquals("logging", apiShortName);
+ }
+
+ @Test
+ public void parseDefaultHost_shouldReturnApiShortNameForIam() {
+ String defaultHost = "iam-meta-api.googleapis.com";
+ String apiShortName = Composer.parseDefaultHost(defaultHost);
+ assertEquals("iam", apiShortName);
+ }
+
+ @Test
+ public void parseDefaultHost_shouldReturnHostIfNoPeriods() {
+ String defaultHost = "logging:7469";
+ String apiShortName = Composer.parseDefaultHost(defaultHost);
+ assertEquals("logging:7469", apiShortName);
+ }
+
+ @Test
+ public void gapicClass_addRegionTagAndHeaderToSample() {
+ Sample testSample;
+ testSample = Composer.addRegionTagAndHeaderToSample(sample, "showcase", "v1");
+ assertEquals("Showcase", testSample.regionTag().apiShortName());
+ assertEquals("V1", testSample.regionTag().apiVersion());
+ assertEquals(Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT), testSample.fileHeader());
+ }
+
@Test
public void composeSamples_parseProtoPackage() {
+
+ String defaultHost = "accessapproval.googleapis.com:443";
+ GapicClass testClass = clazzes.get(0).withSamples(ListofSamples).withDefaultHost(defaultHost);
+ List testClassList = Arrays.asList(new GapicClass[] {testClass});
String protoPack = "google.cloud.accessapproval.v1";
+
List composedSamples =
- Composer.prepareExecutableSamples(clazzes, protoPack).get(0).samples();
+ Composer.prepareExecutableSamples(testClassList, protoPack).get(0).samples();
+
+ // If samples is empty, the test automatically passes without checking.
+ assertFalse(composedSamples.isEmpty());
for (Sample sample : composedSamples) {
assertEquals(
- "ApiShortName should be accessapproval",
+ "ApiShortName should be Accessapproval",
sample.regionTag().apiShortName(),
- "accessapproval");
- assertEquals("ApiVersion should be v1", sample.regionTag().apiVersion(), "v1");
+ "Accessapproval");
+ assertEquals("ApiVersion should be V1", sample.regionTag().apiVersion(), "V1");
}
protoPack = "google.cloud.vision.v1p1beta1";
- composedSamples = Composer.prepareExecutableSamples(clazzes, protoPack).get(0).samples();
+ defaultHost = "vision.googleapis.com";
+ testClass = clazzes.get(0).withSamples(ListofSamples).withDefaultHost(defaultHost);
+ testClassList = Arrays.asList(new GapicClass[] {testClass});
+ composedSamples = Composer.prepareExecutableSamples(testClassList, protoPack).get(0).samples();
+ // If samples is empty, the test automatically passes without checking.
+ assertFalse(composedSamples.isEmpty());
+
for (Sample sample : composedSamples) {
- assertEquals("ApiShortName should be vision", sample.regionTag().apiShortName(), "vision");
- assertEquals("ApiVersion should be v1p1beta1", sample.regionTag().apiVersion(), "v1p1beta1");
+ assertEquals("ApiShortName should be Vision", sample.regionTag().apiShortName(), "Vision");
+ assertEquals("ApiVersion should be V1P1Beta1", sample.regionTag().apiVersion(), "V1P1Beta1");
}
protoPack = "google.cloud.vision";
- composedSamples = Composer.prepareExecutableSamples(clazzes, protoPack).get(0).samples();
+ composedSamples = Composer.prepareExecutableSamples(testClassList, protoPack).get(0).samples();
+ // If samples is empty, the test automatically passes without checking.
+ assertFalse(composedSamples.isEmpty());
+
for (Sample sample : composedSamples) {
- assertEquals("ApiShortName should be vision", sample.regionTag().apiShortName(), "vision");
+ assertEquals("ApiShortName should be Vision", sample.regionTag().apiShortName(), "Vision");
assertEquals("ApiVersion should be empty", sample.regionTag().apiVersion(), "");
}
}
diff --git a/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java b/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java
index fe00c3ca04..18450c1ca8 100644
--- a/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java
+++ b/src/test/java/com/google/api/generator/gapic/composer/grpc/ServiceClientClassComposerTest.java
@@ -18,8 +18,7 @@
import com.google.api.generator.gapic.model.GapicContext;
import com.google.api.generator.gapic.model.Service;
import com.google.api.generator.test.framework.Assert;
-import java.util.Arrays;
-import java.util.Collection;
+import java.util.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -30,11 +29,27 @@ public class ServiceClientClassComposerTest {
public static Collection