Skip to content

Commit

Permalink
fix: update sample region tag to parse host instead of proto package (#…
Browse files Browse the repository at this point in the history
…1040)

* 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

<details>
<summary>googleapis/java-shared-dependencies</summary>

### [`v3.0.3`](https://togithub.com/googleapis/java-shared-dependencies/blob/HEAD/CHANGELOG.md#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;793](https://togithub.com/googleapis/java-shared-dependencies/issues/793)) ([63c1297](https://togithub.com/googleapis/java-shared-dependencies/commit/63c129722aa0b821031ff5b4c11004adf7b12044))

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTUuNSIsInVwZGF0ZWRJblZlciI6IjMyLjE5NS41In0=-->

* 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.

---

 - [ ] <!-- rebase-check -->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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTQuNSIsInVwZGF0ZWRJblZlciI6IjMyLjE5OC4xIn0=-->

* 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.

---

 - [ ] <!-- rebase-check -->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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDIuNCIsInVwZGF0ZWRJblZlciI6IjMyLjIwMi40In0=-->

* 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

<details>
<summary>googleapis/java-shared-dependencies</summary>

### [`v3.0.4`](https://togithub.com/googleapis/java-shared-dependencies/blob/HEAD/CHANGELOG.md#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;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 ([#&#8203;849](https://togithub.com/googleapis/java-shared-dependencies/issues/849)) ([e43ac96](https://togithub.com/googleapis/java-shared-dependencies/commit/e43ac96bc189a096a9311c9b03e85c86bea07e99))

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMTMuMCIsInVwZGF0ZWRJblZlciI6IjMyLjIxMy4wIn0=-->

* 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.

---

 - [ ] <!-- rebase-check -->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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMTkuMSIsInVwZGF0ZWRJblZlciI6IjMyLjIxOS4xIn0=-->

* update comment

* fix lint

Co-authored-by: WhiteSource Renovate <bot@renovateapp.com>
Co-authored-by: Blake Li <blakeli@google.com>
  • Loading branch information
3 people authored and emmileaf committed Nov 3, 2022
1 parent bd5599f commit eb94f30
Show file tree
Hide file tree
Showing 233 changed files with 650 additions and 510 deletions.
60 changes: 42 additions & 18 deletions src/main/java/com/google/api/generator/gapic/composer/Composer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -191,36 +194,57 @@ public static List<GapicClass> generateTestClasses(GapicContext context) {

@VisibleForTesting
static List<GapicClass> prepareExecutableSamples(List<GapicClass> 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<Sample> 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<GapicClass> clazzesWithSamples = new ArrayList<>();
clazzes.forEach(
gapicClass -> {
List<Sample> 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<CommentStatement> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnnotationNode> createClassAnnotations(Service service, TypeStore typeStore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommentStatement> createClassHeaderComments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public static Optional<Sample> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public enum Kind {

public abstract List<Sample> 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();
}
Expand All @@ -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();
Expand All @@ -54,6 +60,10 @@ public final GapicClass withSamples(List<Sample> 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);
Expand All @@ -62,6 +72,8 @@ abstract static class Builder {

abstract Builder setSamples(List<Sample> samples);

abstract Builder setDefaultHost(String defaultHost);

abstract GapicClass build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -42,8 +43,13 @@ public class ComposerTest {
private final List<GapicClass> clazzes =
Arrays.asList(
GrpcServiceCallableFactoryClassComposer.instance().generate(context, echoProtoService));
private final String protoPackage = context.gapicMetadata().getProtoPackage();
private final List<Sample> samples = clazzes.get(0).samples();
private final Sample sample =
Sample.builder()
.setRegionTag(
RegionTag.builder().setServiceName("serviceName").setRpcName("rpcName").build())
.build();
private List<Sample> ListofSamples = Arrays.asList(new Sample[] {sample});
private final String protoPackage = echoProtoService.protoPakkage();

@Test
public void gapicClass_addApacheLicense() {
Expand All @@ -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<GapicClass> testClassList = Arrays.asList(new GapicClass[] {testClass});

List<Sample> 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<GapicClass> testClassList = Arrays.asList(new GapicClass[] {testClass});
String protoPack = "google.cloud.accessapproval.v1";

List<Sample> 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(), "");
}
}
Expand Down
Loading

0 comments on commit eb94f30

Please sign in to comment.