diff --git a/gapic-libraries-bom/pom.xml b/gapic-libraries-bom/pom.xml index e5b2a5be507c..43349c7d492f 100644 --- a/gapic-libraries-bom/pom.xml +++ b/gapic-libraries-bom/pom.xml @@ -553,6 +553,13 @@ pom import + + com.google.cloud + google-iam-policy-bom + 1.7.1-SNAPSHOT + pom + import + com.google.cloud google-cloud-ids-bom diff --git a/generation/check_non_release_please_versions.sh b/generation/check_non_release_please_versions.sh index 206ba13d601f..5c45738ded2c 100755 --- a/generation/check_non_release_please_versions.sh +++ b/generation/check_non_release_please_versions.sh @@ -4,7 +4,10 @@ set -e violations=0 for pomFile in $(find . -mindepth 2 -name pom.xml | sort ); do - if [[ "${pomFile}" =~ .*google-cloud-jar-parent.* ]] || [[ "${pomFile}" =~ .*google-cloud-pom-parent.* ]] ||[[ "${pomFile}" =~ .*CoverageAggregator.* ]]; then + if [[ "${pomFile}" =~ .*google-cloud-jar-parent.* ]] || \ + [[ "${pomFile}" =~ .*google-cloud-pom-parent.* ]] || \ + [[ "${pomFile}" =~ .*CoverageAggregator.* ]] || \ + [[ "${pomFile}" =~ .*java-shared-dependencies*. ]]; then continue fi if [[ "${pomFile}" =~ .*owl-bot-postprocessor.* ]]; then diff --git a/generation/generate_gapic_bom.sh b/generation/generate_gapic_bom.sh index 00a6baf69c33..d008389883b0 100755 --- a/generation/generate_gapic_bom.sh +++ b/generation/generate_gapic_bom.sh @@ -7,7 +7,7 @@ set -e bom_lines="" # For modules that produce BOMs for bom_directory in $(find . -maxdepth 3 -name 'google-*-bom' | sort --dictionary-order); do - if [[ "${bom_directory}" = *gapic-libraries-bom ]]; then + if [[ "${bom_directory}" = *gapic-libraries-bom ]] || [[ "${bom_directory}" = *google-cloud-core* ]]; then continue fi repo_metadata="${bom_directory}/../.repo-metadata.json" diff --git a/generation/merge_repository.sh b/generation/merge_repository.sh index 8a74a97deabb..02b2f11d009e 100755 --- a/generation/merge_repository.sh +++ b/generation/merge_repository.sh @@ -1,6 +1,20 @@ #!/bin/bash +# Merging repository to google-cloud-java using git-filter-repo. # https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories +# +# Usage: +# cd google-cloud-java +# # edit the repository to merge. +# vim generation/repo.txt +# # use your account +# export USERNAME=XXX +# # Run the script +# ./generation/merge_repository.sh +# # Create a pull request. Ensure you MERGE the pull request. Not 'squash'. +# cd generation/monorepo/google-cloud-java-merged +# git checkout -b merge_repositories +# gh pr create --title 'chore: merge new repository into google-cloud-java' --body '' set -xe @@ -33,23 +47,25 @@ do git filter-repo --to-subdirectory-filter ${service} # setup owlbot files correctly to match monorepo configuration - cp ${service}/.github/.OwlBot.yaml ${service}/.OwlBot.yaml - rm ${service}/.github/.OwlBot.lock.yaml - rm ${service}/.github/.OwlBot.yaml - sed -i.bak '/docker/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak - sed -i.bak '/image/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak - - # In monorepo, the staging directory structure tells the destination module to - # which the OwlBot Java postprocessor copies the files. - sed -i.bak "s|owl-bot-staging|owl-bot-staging/${service}|" ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak - - text=$(grep '^.*api_shortname.*' ${service}/.repo-metadata.json) - text=$(echo "$text" | sed 's/\"//g; s/\,//g; s/^[[:space:]]*//' ) - text=${text/api_shortname/api-name} - echo -e "\n"$text>> ${service}/.OwlBot.yaml - git add . - git config --add secrets.allowed "dest.*src" - git commit -am "chore: setup owlbot configuration" + if [ -r "${service}/.github/.OwlBot.yaml" ]; then + cp ${service}/.github/.OwlBot.yaml ${service}/.OwlBot.yaml + rm ${service}/.github/.OwlBot.lock.yaml + rm ${service}/.github/.OwlBot.yaml + sed -i.bak '/docker/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak + sed -i.bak '/image/d' ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak + + # In monorepo, the staging directory structure tells the destination module to + # which the OwlBot Java postprocessor copies the files. + sed -i.bak "s|owl-bot-staging|owl-bot-staging/${service}|" ${service}/.OwlBot.yaml && rm ${service}/.OwlBot.yaml.bak + + text=$(grep '^.*api_shortname.*' ${service}/.repo-metadata.json) + text=$(echo "$text" | sed 's/\"//g; s/\,//g; s/^[[:space:]]*//' ) + text=${text/api_shortname/api-name} + echo -e "\n"$text>> ${service}/.OwlBot.yaml + git add . + git config --add secrets.allowed "dest.*src" + git commit -am "chore: setup owlbot configuration" + fi cd "../${merged_repository}" git remote add ${service} ../${service} @@ -158,4 +174,4 @@ git commit -m 'split repo - diff versions.txt' --allow-empty git add --all || true git commit -am 'split repo - diff everything else' --allow-empty -cd ../.. \ No newline at end of file +cd ../.. diff --git a/generation/set_parent_pom.sh b/generation/set_parent_pom.sh index 9396c7b6be7c..db187e575fd4 100755 --- a/generation/set_parent_pom.sh +++ b/generation/set_parent_pom.sh @@ -24,7 +24,10 @@ function replaceParent { # Then, apply the values as the parent pom of each module for module in $(find . -mindepth 2 -maxdepth 2 -name pom.xml | sort --dictionary-order | xargs dirname); do # example value of module is "./java-accessapproval" - if [[ "${module}" = *gapic-libraries-bom ]] || [[ "${module}" = *google-cloud-jar-parent ]] || [[ "${module}" = *google-cloud-pom-parent ]]; then + if [[ "${module}" = *gapic-libraries-bom ]] || \ + [[ "${module}" = *google-cloud-jar-parent ]] || \ + [[ "${module}" = *google-cloud-pom-parent ]] || \ + [[ "${module}" = *java-shared-dependencies ]]; then continue fi echo "Processing module $module" diff --git a/google-cloud-jar-parent/pom.xml b/google-cloud-jar-parent/pom.xml index af963cba13fb..e580ef987b0e 100644 --- a/google-cloud-jar-parent/pom.xml +++ b/google-cloud-jar-parent/pom.xml @@ -27,7 +27,7 @@ com.google.cloud google-cloud-shared-dependencies - 3.1.2 + 3.1.3-SNAPSHOT pom import diff --git a/java-core/CHANGELOG.md b/java-core/CHANGELOG.md new file mode 100644 index 000000000000..59ea2dd72f42 --- /dev/null +++ b/java-core/CHANGELOG.md @@ -0,0 +1,1277 @@ +# Changelog + +## [2.9.4](https://github.com/googleapis/java-core/compare/v2.9.3...v2.9.4) (2023-01-20) + + +### Bug Fixes + +* **java:** Skip fixing poms for special modules ([#1744](https://github.com/googleapis/java-core/issues/1744)) ([#1080](https://github.com/googleapis/java-core/issues/1080)) ([db2cc2f](https://github.com/googleapis/java-core/commit/db2cc2fcd03342948c6c4e753d012d08000e7733)) + +## [2.9.3](https://github.com/googleapis/java-core/compare/v2.9.2...v2.9.3) (2023-01-19) + + +### Dependencies + +* Update dependency com.google.api:api-common to v2.5.0 ([#1083](https://github.com/googleapis/java-core/issues/1083)) ([dc3e6c7](https://github.com/googleapis/java-core/commit/dc3e6c713f3b65b59a0d814cddd1509583db081c)) +* Update dependency com.google.api:gax-bom to v2.22.0 ([#1084](https://github.com/googleapis/java-core/issues/1084)) ([5b94330](https://github.com/googleapis/java-core/commit/5b94330a90920f106e70a0ec7823026c3c87d55e)) +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.13.0 ([#1081](https://github.com/googleapis/java-core/issues/1081)) ([d4bfd0e](https://github.com/googleapis/java-core/commit/d4bfd0efea78e3266f237fbb620ab5441abf0003)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.8.0 ([#1082](https://github.com/googleapis/java-core/issues/1082)) ([bbda002](https://github.com/googleapis/java-core/commit/bbda002fc193af2b6a52fae54f1238c5ce66dc6e)) + +## [2.9.2](https://github.com/googleapis/java-core/compare/v2.9.1...v2.9.2) (2023-01-18) + + +### Dependencies + +* Update dependency io.grpc:grpc-bom to v1.52.1 ([#1073](https://github.com/googleapis/java-core/issues/1073)) ([a45ec31](https://github.com/googleapis/java-core/commit/a45ec316782d2d2a1d3af149f338daf028d94206)) + +## [2.9.1](https://github.com/googleapis/java-core/compare/v2.9.0...v2.9.1) (2023-01-09) + + +### Bug Fixes + +* Make title and description of Condition Nullable ([#1063](https://github.com/googleapis/java-core/issues/1063)) ([1238462](https://github.com/googleapis/java-core/commit/12384628ab07b7edb04181c79ed07e742277e4c4)) + + +### Documentation + +* Update javadocs for ReadChannel to be more clear about the behavior ([#1050](https://github.com/googleapis/java-core/issues/1050)) ([8b574f6](https://github.com/googleapis/java-core/commit/8b574f66c6e77b31ec8d544319a116f5c19804b9)) + + +### Dependencies + +* Update dependency com.google.api-client:google-api-client-bom to v2.1.2 ([#1064](https://github.com/googleapis/java-core/issues/1064)) ([6bf1c24](https://github.com/googleapis/java-core/commit/6bf1c2414978340cb997acb18e98815e20028718)) +* Update dependency com.google.api:api-common to v2.3.1 ([#1053](https://github.com/googleapis/java-core/issues/1053)) ([43ce490](https://github.com/googleapis/java-core/commit/43ce49083ebdfada11732ff82aa407c69311f4c9)) +* Update dependency com.google.api:api-common to v2.4.0 ([#1069](https://github.com/googleapis/java-core/issues/1069)) ([083bc07](https://github.com/googleapis/java-core/commit/083bc071f4529cd2a827cd4586e5c02690f4ffcd)) +* Update dependency com.google.api:gax-bom to v2.21.0 ([#1070](https://github.com/googleapis/java-core/issues/1070)) ([e133832](https://github.com/googleapis/java-core/commit/e133832eb6e81089745e21d9b0188cb91af0a51b)) +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.12.0 ([#1067](https://github.com/googleapis/java-core/issues/1067)) ([bfab3ad](https://github.com/googleapis/java-core/commit/bfab3adbcefea538d50d567297eb491650ad19ba)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.23 ([#1060](https://github.com/googleapis/java-core/issues/1060)) ([a2e5c4e](https://github.com/googleapis/java-core/commit/a2e5c4eb35824ee019b0d0b8f984144f07d76c0a)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.7.0 ([#1068](https://github.com/googleapis/java-core/issues/1068)) ([404f222](https://github.com/googleapis/java-core/commit/404f2220ea85253945f470a6370870cce248c11e)) +* Update dependency com.google.auth:google-auth-library-bom to v1.14.0 ([#1056](https://github.com/googleapis/java-core/issues/1056)) ([328628d](https://github.com/googleapis/java-core/commit/328628da55cea6d27c4fe4ed2aaa14bf2bc59a58)) +* Update dependency com.google.code.gson:gson to v2.10.1 ([#1066](https://github.com/googleapis/java-core/issues/1066)) ([a4b941e](https://github.com/googleapis/java-core/commit/a4b941e8daed4650bd019a7c03602cd617bdcad2)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.17.0 ([#1061](https://github.com/googleapis/java-core/issues/1061)) ([e7159c2](https://github.com/googleapis/java-core/commit/e7159c28eb4882395cc351d3dbd29db74a75c271)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.18.0 ([#1071](https://github.com/googleapis/java-core/issues/1071)) ([b85690f](https://github.com/googleapis/java-core/commit/b85690fdcf0803502412bf5af418c17b43a718e7)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.12 ([#1054](https://github.com/googleapis/java-core/issues/1054)) ([3fc149e](https://github.com/googleapis/java-core/commit/3fc149e28a8724b100717c0ddfb138338401fea9)) +* Update dependency io.grpc:grpc-bom to v1.51.1 ([#1058](https://github.com/googleapis/java-core/issues/1058)) ([d8ca14c](https://github.com/googleapis/java-core/commit/d8ca14cdb10d5af41396b40702a4abd7c9b5b15c)) +* Update dependency org.easymock:easymock to v5.1.0 ([#1062](https://github.com/googleapis/java-core/issues/1062)) ([4c0095d](https://github.com/googleapis/java-core/commit/4c0095daa0a17564c972434e4824c03b2204e3e0)) +* Update dependency org.threeten:threetenbp to v1.6.5 ([#1052](https://github.com/googleapis/java-core/issues/1052)) ([7e12b5d](https://github.com/googleapis/java-core/commit/7e12b5d137db97d95320416cd80e467bb300c499)) + +## [2.9.0](https://github.com/googleapis/java-core/compare/v2.8.28...v2.9.0) (2022-12-05) + + +### Features + +* Next release from main branch is 2.9.0 ([#1018](https://github.com/googleapis/java-core/issues/1018)) ([e53bf16](https://github.com/googleapis/java-core/commit/e53bf165791149ae4bcbe8ab21f14d8c6331680c)) +* Support get CREDENTIAL_ENV_NAME from properties ([#782](https://github.com/googleapis/java-core/issues/782)) ([2bb7d57](https://github.com/googleapis/java-core/commit/2bb7d576a3da2185a9756c7b4f5386bf67824d1d)) + + +### Dependencies + +* Update dependency com.google.api-client:google-api-client-bom to v2.1.1 ([#1045](https://github.com/googleapis/java-core/issues/1045)) ([c957f18](https://github.com/googleapis/java-core/commit/c957f1882a93cadc19964912ab57eb8119ccf529)) +* Update dependency com.google.api:gax-bom to v2.20.1 ([#1049](https://github.com/googleapis/java-core/issues/1049)) ([46af789](https://github.com/googleapis/java-core/commit/46af7892e49c5967e2fcd82bca21332cad5b5458)) +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.11.0 ([#1046](https://github.com/googleapis/java-core/issues/1046)) ([b0d785a](https://github.com/googleapis/java-core/commit/b0d785a0c77c193a8fdc25f4b43ed26ac1b478bc)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.10 ([#1028](https://github.com/googleapis/java-core/issues/1028)) ([399899a](https://github.com/googleapis/java-core/commit/399899a4a1bcffb4bdbf5ee2898b5f6050ea00a6)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.11 ([#1029](https://github.com/googleapis/java-core/issues/1029)) ([0e33024](https://github.com/googleapis/java-core/commit/0e3302464ff613fa082d6f165155d6a825cf4294)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.12 ([#1031](https://github.com/googleapis/java-core/issues/1031)) ([3705e63](https://github.com/googleapis/java-core/commit/3705e63d3291f4d0d9c6346f32c43f209983e801)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.13 ([#1033](https://github.com/googleapis/java-core/issues/1033)) ([3256faa](https://github.com/googleapis/java-core/commit/3256faa6301939492a07d2c5d02d3a5eb3c75c5e)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.14 ([#1034](https://github.com/googleapis/java-core/issues/1034)) ([03d481b](https://github.com/googleapis/java-core/commit/03d481be4aa7e4885acc6fb204f92606a514db0f)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.15 ([#1035](https://github.com/googleapis/java-core/issues/1035)) ([a0f1915](https://github.com/googleapis/java-core/commit/a0f191579b61db1cfa984d9aba56a293c577f56e)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.16 ([#1036](https://github.com/googleapis/java-core/issues/1036)) ([d236920](https://github.com/googleapis/java-core/commit/d236920a6ddbbac523db19534f5944d38a5feed2)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.17 ([#1037](https://github.com/googleapis/java-core/issues/1037)) ([c06c8e1](https://github.com/googleapis/java-core/commit/c06c8e19cbf7f8e2e4fe387a685cc36fc8be674d)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.18 ([#1040](https://github.com/googleapis/java-core/issues/1040)) ([2baec55](https://github.com/googleapis/java-core/commit/2baec55331fa1e74a9199adcb7eb44b7ac886a6e)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.20 ([#1041](https://github.com/googleapis/java-core/issues/1041)) ([ee64ef7](https://github.com/googleapis/java-core/commit/ee64ef76995061a238957705405b56f4bd4870f9)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.21 ([#1042](https://github.com/googleapis/java-core/issues/1042)) ([df6f385](https://github.com/googleapis/java-core/commit/df6f3857871604663626dbbe6b262fc8b3db1dc3)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.22 ([#1043](https://github.com/googleapis/java-core/issues/1043)) ([84c3820](https://github.com/googleapis/java-core/commit/84c382042cedc934cc571b32de7aa058ac025e9e)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.9 ([#1024](https://github.com/googleapis/java-core/issues/1024)) ([3bb2fae](https://github.com/googleapis/java-core/commit/3bb2fae3c4c96301985f2e4c51d0a6bc9d737341)) +* Update dependency com.google.auth:google-auth-library-bom to v1.13.0 ([#1030](https://github.com/googleapis/java-core/issues/1030)) ([799e584](https://github.com/googleapis/java-core/commit/799e584645fb03c96f7e93156770c9afa631eff6)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.10 ([#1048](https://github.com/googleapis/java-core/issues/1048)) ([ea0d8d4](https://github.com/googleapis/java-core/commit/ea0d8d4ce7732353506d70c9c16ee6c2d9f01b23)) +* Update dependency io.grpc:grpc-bom to v1.51.0 ([#1032](https://github.com/googleapis/java-core/issues/1032)) ([2572bcc](https://github.com/googleapis/java-core/commit/2572bcc6f62e713009ebcb4c41a2e5ec4ba57707)) + +## [2.8.28](https://github.com/googleapis/java-core/compare/v2.8.27...v2.8.28) (2022-11-09) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.8 ([#1020](https://github.com/googleapis/java-core/issues/1020)) ([e8b3608](https://github.com/googleapis/java-core/commit/e8b360836633345db0a8010590cf9a9753e1a1f9)) + +## [2.8.27](https://github.com/googleapis/java-core/compare/v2.8.26...v2.8.27) (2022-11-07) + + +### Dependencies + +* Update dependency com.google.api:gax-bom to v2.19.5 ([#1014](https://github.com/googleapis/java-core/issues/1014)) ([00753f8](https://github.com/googleapis/java-core/commit/00753f88745ad0232658b634aadf5250c6daad01)) + +## [2.8.26](https://github.com/googleapis/java-core/compare/v2.8.25...v2.8.26) (2022-11-07) + + +### Dependencies + +* Update dependency com.google.api-client:google-api-client-bom to v2.0.1 ([#1011](https://github.com/googleapis/java-core/issues/1011)) ([e52b05c](https://github.com/googleapis/java-core/commit/e52b05c0b4973258d7d783af725182d5ba834c25)) +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.10.0 ([#1010](https://github.com/googleapis/java-core/issues/1010)) ([db9d19e](https://github.com/googleapis/java-core/commit/db9d19e9e760bef0c543f7e5da6af172a7ceca06)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.7 ([#1005](https://github.com/googleapis/java-core/issues/1005)) ([45513e6](https://github.com/googleapis/java-core/commit/45513e639543ca2025d4c4c4cd84f5735c067443)) + +## [2.8.25](https://github.com/googleapis/java-core/compare/v2.8.24...v2.8.25) (2022-10-31) + + +### Dependencies + +* Update dependency com.google.api:api-common to v2.2.2 ([#999](https://github.com/googleapis/java-core/issues/999)) ([e639a64](https://github.com/googleapis/java-core/commit/e639a641c3041c829b8e58eeed79df6352e1c7eb)) +* Update dependency com.google.http-client:google-http-client-bom to v1.42.3 ([#1001](https://github.com/googleapis/java-core/issues/1001)) ([8e35c4f](https://github.com/googleapis/java-core/commit/8e35c4ffe5c12f0e4e570b04d0563640c688eb91)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.9 ([#998](https://github.com/googleapis/java-core/issues/998)) ([ce2d265](https://github.com/googleapis/java-core/commit/ce2d265669cd8fb43d1de43f02c53384c1d73a0d)) +* Update dependency org.threeten:threetenbp to v1.6.4 ([#1003](https://github.com/googleapis/java-core/issues/1003)) ([a69f122](https://github.com/googleapis/java-core/commit/a69f122b6bd84f6a3ddb496f77a1aa1fba072d13)) + +## [2.8.24](https://github.com/googleapis/java-core/compare/v2.8.23...v2.8.24) (2022-10-26) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.6 ([#994](https://github.com/googleapis/java-core/issues/994)) ([8a7b330](https://github.com/googleapis/java-core/commit/8a7b3304f714261501c64180abfc94edaa86d9d4)) +* Update dependency com.google.code.gson:gson to v2.10 ([#995](https://github.com/googleapis/java-core/issues/995)) ([5b947a2](https://github.com/googleapis/java-core/commit/5b947a2486979ba26175753fcf054ba3d4904b35)) + +## [2.8.23](https://github.com/googleapis/java-core/compare/v2.8.22...v2.8.23) (2022-10-24) + + +### Dependencies + +* Update dependency io.grpc:grpc-bom to v1.50.2 ([#990](https://github.com/googleapis/java-core/issues/990)) ([42b1081](https://github.com/googleapis/java-core/commit/42b108100173041925cc705f596f388bab26d954)) +* Update dependency org.easymock:easymock to v5 ([#980](https://github.com/googleapis/java-core/issues/980)) ([64be350](https://github.com/googleapis/java-core/commit/64be350d3713af1a95ca51997194a15c7292f7ae)) + +## [2.8.22](https://github.com/googleapis/java-core/compare/v2.8.21...v2.8.22) (2022-10-19) + + +### Dependencies + +* Update dependency com.google.api:gax-bom to v2.19.4 ([#987](https://github.com/googleapis/java-core/issues/987)) ([70a959b](https://github.com/googleapis/java-core/commit/70a959bd01884ec4e9ec4705a25442bf06e9bb73)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.4 ([#976](https://github.com/googleapis/java-core/issues/976)) ([ddf887f](https://github.com/googleapis/java-core/commit/ddf887fa35872299c1b65cd03934595a89c2ab4c)) +* Update dependency com.google.auth:google-auth-library-bom to v1.12.0 ([#981](https://github.com/googleapis/java-core/issues/981)) ([87c5616](https://github.com/googleapis/java-core/commit/87c5616ff8a5c4e96ff761b25cf1423505bdc4e2)) +* Update dependency com.google.auth:google-auth-library-bom to v1.12.1 ([#983](https://github.com/googleapis/java-core/issues/983)) ([ddf787a](https://github.com/googleapis/java-core/commit/ddf787a470a8f4b8416b09bf3bb656f249b1caf5)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.16 ([#977](https://github.com/googleapis/java-core/issues/977)) ([6f9f78e](https://github.com/googleapis/java-core/commit/6f9f78ef38d586e1cded056451658b77c5a093b7)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.8 ([#984](https://github.com/googleapis/java-core/issues/984)) ([234c9a7](https://github.com/googleapis/java-core/commit/234c9a7788c32692b1e7f9686a6b7329d758acb9)) +* Update dependency io.grpc:grpc-bom to v1.50.0 ([#978](https://github.com/googleapis/java-core/issues/978)) ([024fb77](https://github.com/googleapis/java-core/commit/024fb77b67b4a0f9d8dfcd8315376a0b4937a0da)) +* Update dependency io.grpc:grpc-bom to v1.50.1 ([#985](https://github.com/googleapis/java-core/issues/985)) ([8b71163](https://github.com/googleapis/java-core/commit/8b71163725178ffcbbaae21c6d1fc530be77b9b4)) +* Update dependency org.threeten:threetenbp to v1.6.3 ([#979](https://github.com/googleapis/java-core/issues/979)) ([f51ea92](https://github.com/googleapis/java-core/commit/f51ea92c8bd1ebe0c7a2796d435cceafd037ce06)) + +## [2.8.21](https://github.com/googleapis/java-core/compare/v2.8.20...v2.8.21) (2022-10-10) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.2 ([#971](https://github.com/googleapis/java-core/issues/971)) ([5d778fc](https://github.com/googleapis/java-core/commit/5d778fc0d78e67cbcc4eb061da3b66dd3cab440e)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.3 ([#974](https://github.com/googleapis/java-core/issues/974)) ([1b7fcb9](https://github.com/googleapis/java-core/commit/1b7fcb978da55f8d30cf66941bc8208853fef116)) + +## [2.8.20](https://github.com/googleapis/java-core/compare/v2.8.19...v2.8.20) (2022-10-02) + + +### Dependencies + +* Update dependency com.google.api:gax-bom to v2.19.2 ([#969](https://github.com/googleapis/java-core/issues/969)) ([1151449](https://github.com/googleapis/java-core/commit/1151449c061ab51c45982444db5f9da9d2ce4fb7)) +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.9.6 ([#967](https://github.com/googleapis/java-core/issues/967)) ([4a7b524](https://github.com/googleapis/java-core/commit/4a7b524fa366484825bedbc0a4f86d4551a6a0e8)) +* Update dependency io.grpc:grpc-bom to v1.49.2 ([#966](https://github.com/googleapis/java-core/issues/966)) ([b7738aa](https://github.com/googleapis/java-core/commit/b7738aa71fb9cf0994e4ad1dae4bae433754cda0)) + +## [2.8.19](https://github.com/googleapis/java-core/compare/v2.8.18...v2.8.19) (2022-09-30) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.9.5 ([#963](https://github.com/googleapis/java-core/issues/963)) ([1ee2f9a](https://github.com/googleapis/java-core/commit/1ee2f9acd3968b21974a550b6732fe68b18085f4)) + +## [2.8.18](https://github.com/googleapis/java-core/compare/v2.8.17...v2.8.18) (2022-09-30) + + +### Dependencies + +* Update dependency com.google.protobuf:protobuf-bom to v3.21.7 ([#960](https://github.com/googleapis/java-core/issues/960)) ([1fcd95f](https://github.com/googleapis/java-core/commit/1fcd95f2401b66a79383bd79729595334493b0e4)) + +## [2.8.17](https://github.com/googleapis/java-core/compare/v2.8.16...v2.8.17) (2022-09-28) + + +### Dependencies + +* Update dependency cachetools to v5 ([#943](https://github.com/googleapis/java-core/issues/943)) ([c6c511d](https://github.com/googleapis/java-core/commit/c6c511d82534e96fe5b42ad9e4886aaa18efaef3)) +* Update dependency certifi to v2022.9.24 ([#934](https://github.com/googleapis/java-core/issues/934)) ([c756885](https://github.com/googleapis/java-core/commit/c75688575c3c19d0d8a1a2b25c6fe3eb99c229cb)) +* Update dependency charset-normalizer to v2.1.1 ([#938](https://github.com/googleapis/java-core/issues/938)) ([1520f65](https://github.com/googleapis/java-core/commit/1520f65cf6655aed9767d9470e3729a0fc270b9e)) +* Update dependency click to v8.1.3 ([#946](https://github.com/googleapis/java-core/issues/946)) ([6f7a7f5](https://github.com/googleapis/java-core/commit/6f7a7f5f318a7c3586fa79a7a0013bca562b059e)) +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.9.4 ([#945](https://github.com/googleapis/java-core/issues/945)) ([307e406](https://github.com/googleapis/java-core/commit/307e40688d55af3cb96e38972af6035cf846c595)) +* Update dependency gcp-releasetool to v1.8.8 ([#935](https://github.com/googleapis/java-core/issues/935)) ([a5ba3b8](https://github.com/googleapis/java-core/commit/a5ba3b8d6bc43734bb01b0ba04e11b5262db526b)) +* Update dependency google-api-core to v2.10.1 ([#947](https://github.com/googleapis/java-core/issues/947)) ([1f3da64](https://github.com/googleapis/java-core/commit/1f3da6450b1a5093aadaa9f299fc797773cc8480)) +* Update dependency google-auth to v2.12.0 ([#948](https://github.com/googleapis/java-core/issues/948)) ([361da3d](https://github.com/googleapis/java-core/commit/361da3dcaecadd708546447737c5a7c1d9799834)) +* Update dependency google-cloud-core to v2.3.2 ([#936](https://github.com/googleapis/java-core/issues/936)) ([99c0013](https://github.com/googleapis/java-core/commit/99c001309e1f72b84c41b7df55ff26c9f182863a)) +* Update dependency google-cloud-storage to v2.5.0 ([#949](https://github.com/googleapis/java-core/issues/949)) ([cd6cbfb](https://github.com/googleapis/java-core/commit/cd6cbfb3b1c45e2f55d51edee74621a7dbe06401)) +* Update dependency google-crc32c to v1.5.0 ([#950](https://github.com/googleapis/java-core/issues/950)) ([abd5ff9](https://github.com/googleapis/java-core/commit/abd5ff9321304b1238f4dd6fa0b4dd57665b46cc)) +* Update dependency googleapis-common-protos to v1.56.4 ([#937](https://github.com/googleapis/java-core/issues/937)) ([bd7d676](https://github.com/googleapis/java-core/commit/bd7d676c3f221b59768815ccca000c7763aeb7f9)) +* Update dependency importlib-metadata to v4.12.0 ([#951](https://github.com/googleapis/java-core/issues/951)) ([f0d1fe8](https://github.com/googleapis/java-core/commit/f0d1fe8cc2079216b95d8fd24a46de5161801b35)) +* Update dependency jeepney to v0.8.0 ([#952](https://github.com/googleapis/java-core/issues/952)) ([342614b](https://github.com/googleapis/java-core/commit/342614b1275877fb41e8241f0c6061286989df13)) +* Update dependency jinja2 to v3.1.2 ([#953](https://github.com/googleapis/java-core/issues/953)) ([a1542bf](https://github.com/googleapis/java-core/commit/a1542bf8938a72c85b20f97e642dde3666ea0b04)) +* Update dependency keyring to v23.9.3 ([#954](https://github.com/googleapis/java-core/issues/954)) ([34bbdae](https://github.com/googleapis/java-core/commit/34bbdaeb312cce804d92d6b041e3098b8a6c04bc)) +* Update dependency markupsafe to v2.1.1 ([#955](https://github.com/googleapis/java-core/issues/955)) ([cb444b0](https://github.com/googleapis/java-core/commit/cb444b0d274af29ffa3076bd89c42acedf514749)) +* Update dependency protobuf to v3.20.2 ([#956](https://github.com/googleapis/java-core/issues/956)) ([949b4fe](https://github.com/googleapis/java-core/commit/949b4feab38e8b0f0b32ae80067dc07da5a2a383)) +* Update dependency protobuf to v4 ([#944](https://github.com/googleapis/java-core/issues/944)) ([9d379e2](https://github.com/googleapis/java-core/commit/9d379e202dd8bedf0c3bbaab3d3ba593813285d9)) +* Update dependency pyjwt to v2.5.0 ([#939](https://github.com/googleapis/java-core/issues/939)) ([bd4896e](https://github.com/googleapis/java-core/commit/bd4896ed5d0413472ae100b60e5f632506214a97)) +* Update dependency requests to v2.28.1 ([#940](https://github.com/googleapis/java-core/issues/940)) ([f64fef9](https://github.com/googleapis/java-core/commit/f64fef9ef365b43e1ec195db312862000db18627)) +* Update dependency typing-extensions to v4.3.0 ([#941](https://github.com/googleapis/java-core/issues/941)) ([3b8f163](https://github.com/googleapis/java-core/commit/3b8f163789f5cb11a4b461411cb7c1e132439449)) +* Update dependency zipp to v3.8.1 ([#942](https://github.com/googleapis/java-core/issues/942)) ([96ccc51](https://github.com/googleapis/java-core/commit/96ccc51c7107fbbcea6564cdf71fcedb05364761)) + +## [2.8.16](https://github.com/googleapis/java-core/compare/v2.8.15...v2.8.16) (2022-09-26) + + +### Dependencies + +* Update dependency org.threeten:threetenbp to v1.6.2 ([#929](https://github.com/googleapis/java-core/issues/929)) ([2f797f9](https://github.com/googleapis/java-core/commit/2f797f990eacc112dd982e7a8f9155bc229b7bf3)) + +## [2.8.15](https://github.com/googleapis/java-core/compare/v2.8.14...v2.8.15) (2022-09-23) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.0 ([#925](https://github.com/googleapis/java-core/issues/925)) ([a5475c5](https://github.com/googleapis/java-core/commit/a5475c5333ca97392c9e64a883826ea1bd976a01)) +* Update dependency com.google.api.grpc:proto-google-iam-v1 to v1.6.1 ([#926](https://github.com/googleapis/java-core/issues/926)) ([3bc96fb](https://github.com/googleapis/java-core/commit/3bc96fbba4907d4ac3d24915870132fed596c0d3)) + +## [2.8.14](https://github.com/googleapis/java-core/compare/v2.8.13...v2.8.14) (2022-09-20) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-common-protos to v2.9.3 ([#922](https://github.com/googleapis/java-core/issues/922)) ([96b5b4e](https://github.com/googleapis/java-core/commit/96b5b4e00004c28cd2d726c2161e94778f6a1c01)) + +## [2.8.13](https://github.com/googleapis/java-core/compare/v2.8.12...v2.8.13) (2022-09-20) + + +### Dependencies + +* Update dependency io.grpc:grpc-bom to v1.49.1 ([#919](https://github.com/googleapis/java-core/issues/919)) ([2d481ba](https://github.com/googleapis/java-core/commit/2d481ba500e247d8fee49abe30a9eb84bdcc8d07)) + +## [2.8.12](https://github.com/googleapis/java-core/compare/v2.8.11...v2.8.12) (2022-09-14) + + +### Dependencies + +* Update dependency com.google.api:gax-bom to v2.19.1 ([#915](https://github.com/googleapis/java-core/issues/915)) ([2647fde](https://github.com/googleapis/java-core/commit/2647fdee8e2b168f3364af8e76abfe2903578b29)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.6 ([#916](https://github.com/googleapis/java-core/issues/916)) ([a7db234](https://github.com/googleapis/java-core/commit/a7db234800481ffba71d3222542971dbcd212d8e)) + +## [2.8.11](https://github.com/googleapis/java-core/compare/v2.8.10...v2.8.11) (2022-09-08) + + +### Dependencies + +* Update dependency com.google.auth:google-auth-library-bom to v1.11.0 ([#911](https://github.com/googleapis/java-core/issues/911)) ([4656905](https://github.com/googleapis/java-core/commit/4656905956504e4bc4fe224d1f8cd70bbab614d8)) + +## [2.8.10](https://github.com/googleapis/java-core/compare/v2.8.9...v2.8.10) (2022-08-24) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.19.0 ([#907](https://github.com/googleapis/java-core/issues/907)) ([51b824c](https://github.com/googleapis/java-core/commit/51b824c225fd7095138e1ec2b6d47af4e2a34352)) +* update dependency io.grpc:grpc-bom to v1.49.0 ([#908](https://github.com/googleapis/java-core/issues/908)) ([fbccd2d](https://github.com/googleapis/java-core/commit/fbccd2daceb0984c7cb95f84f89a116e54bf4ddc)) + +## [2.8.9](https://github.com/googleapis/java-core/compare/v2.8.8...v2.8.9) (2022-08-16) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v1.10.0 ([#900](https://github.com/googleapis/java-core/issues/900)) ([c01b47a](https://github.com/googleapis/java-core/commit/c01b47a122a9036f8c594cb583dab3512a257597)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.5 ([#901](https://github.com/googleapis/java-core/issues/901)) ([13e2fd6](https://github.com/googleapis/java-core/commit/13e2fd6fbae1d34385ec500aaf4a2b38e19dd6de)) +* update dependency org.threeten:threetenbp to v1.6.1 ([#902](https://github.com/googleapis/java-core/issues/902)) ([02dac62](https://github.com/googleapis/java-core/commit/02dac62784a6614291836917b022a32745312157)) + +## [2.8.8](https://github.com/googleapis/java-core/compare/v2.8.7...v2.8.8) (2022-08-04) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_annotations to v2.15.0 ([#897](https://github.com/googleapis/java-core/issues/897)) ([29e4fc9](https://github.com/googleapis/java-core/commit/29e4fc93d5d4d50f7de85eae7a8150314cca6f43)) + +## [2.8.7](https://github.com/googleapis/java-core/compare/v2.8.6...v2.8.7) (2022-08-03) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v1.9.0 ([#894](https://github.com/googleapis/java-core/issues/894)) ([82aaa16](https://github.com/googleapis/java-core/commit/82aaa16cd9813984a0c92d944eb1ad956759a8e5)) +* update dependency io.grpc:grpc-bom to v1.48.1 ([#891](https://github.com/googleapis/java-core/issues/891)) ([0b0f9b8](https://github.com/googleapis/java-core/commit/0b0f9b89757b801e8334c764644d7b66032d36d1)) + +## [2.8.6](https://github.com/googleapis/java-core/compare/v2.8.5...v2.8.6) (2022-08-02) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.18.7 ([#890](https://github.com/googleapis/java-core/issues/890)) ([c67bed5](https://github.com/googleapis/java-core/commit/c67bed5281b458e78780cdd918235b5d073917c7)) +* update dependency com.google.code.gson:gson to v2.9.1 ([#888](https://github.com/googleapis/java-core/issues/888)) ([7b799c6](https://github.com/googleapis/java-core/commit/7b799c66f4aaf057242e9a231b920e49a7c964e9)) + +## [2.8.5](https://github.com/googleapis/java-core/compare/v2.8.4...v2.8.5) (2022-07-29) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.18.6 ([#885](https://github.com/googleapis/java-core/issues/885)) ([7fa028c](https://github.com/googleapis/java-core/commit/7fa028c0e78bd21583c8687582da24834bd54449)) + +## [2.8.4](https://github.com/googleapis/java-core/compare/v2.8.3...v2.8.4) (2022-07-27) + + +### Documentation + +* update javadocs for ReadChannel#limit to be more clear ([#880](https://github.com/googleapis/java-core/issues/880)) ([c7de4e2](https://github.com/googleapis/java-core/commit/c7de4e2871d6a32cacc7aab69d826f3afd6301ef)) + + +### Dependencies + +* Update google-cloud-shared-config to v1.5.3 ([#882](https://github.com/googleapis/java-core/issues/882)) ([aabb0b4](https://github.com/googleapis/java-core/commit/aabb0b42076f8a02e7b31d604add567fa909df6c)) + +## [2.8.3](https://github.com/googleapis/java-core/compare/v2.8.2...v2.8.3) (2022-07-26) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v2 ([#868](https://github.com/googleapis/java-core/issues/868)) ([e117c40](https://github.com/googleapis/java-core/commit/e117c40f31acf16a45bdbeeb727ba26d80eb6a51)) +* update dependency com.google.api:gax-bom to v2.18.4 ([#864](https://github.com/googleapis/java-core/issues/864)) ([bd40b1d](https://github.com/googleapis/java-core/commit/bd40b1d1b36cdcfa833047609e2488594b112be1)) +* update dependency com.google.api:gax-bom to v2.18.5 ([#876](https://github.com/googleapis/java-core/issues/876)) ([d8dc7fb](https://github.com/googleapis/java-core/commit/d8dc7fbdb0d65e493ca4154658c63e80d89ab600)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.9.2 ([#870](https://github.com/googleapis/java-core/issues/870)) ([7e961e9](https://github.com/googleapis/java-core/commit/7e961e945d5e049a1a1bb2592e9c155b5937e33b)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.5.2 ([#865](https://github.com/googleapis/java-core/issues/865)) ([fe7b974](https://github.com/googleapis/java-core/commit/fe7b974a0eae82711ca96edf412944309d5d6202)) +* update dependency com.google.auth:google-auth-library-bom to v1.8.1 ([#856](https://github.com/googleapis/java-core/issues/856)) ([92df5d3](https://github.com/googleapis/java-core/commit/92df5d3c248214970d38432e8c264d151298d1e6)) +* update dependency com.google.http-client:google-http-client-bom to v1.42.2 ([#871](https://github.com/googleapis/java-core/issues/871)) ([1972e8e](https://github.com/googleapis/java-core/commit/1972e8e45e11597e56609aa5fcd44e61958d5857)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.3 ([#874](https://github.com/googleapis/java-core/issues/874)) ([1e18977](https://github.com/googleapis/java-core/commit/1e18977820ac766157156fb6246bd318d207971c)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.4 ([#877](https://github.com/googleapis/java-core/issues/877)) ([d12fb5e](https://github.com/googleapis/java-core/commit/d12fb5e4eb8aa42015df84abf31f56408c8b64d8)) +* update dependency io.grpc:grpc-bom to v1.48.0 ([#873](https://github.com/googleapis/java-core/issues/873)) ([a45b075](https://github.com/googleapis/java-core/commit/a45b075e414049550c51ff0097337e45128fc499)) + +## [2.8.2](https://github.com/googleapis/java-core/compare/v2.8.1...v2.8.2) (2022-07-13) + + +### Bug Fixes + +* enable longpaths support for windows test ([#1485](https://github.com/googleapis/java-core/issues/1485)) ([#866](https://github.com/googleapis/java-core/issues/866)) ([3add981](https://github.com/googleapis/java-core/commit/3add98191ecfc00f324ef214b98d02cfb143d08e)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.35.2 ([#859](https://github.com/googleapis/java-core/issues/859)) ([c26a33d](https://github.com/googleapis/java-core/commit/c26a33d44df2405653ee5161f5335b423d334c93)) +* update dependency com.google.api:gax-bom to v2.18.3 ([#860](https://github.com/googleapis/java-core/issues/860)) ([f16395e](https://github.com/googleapis/java-core/commit/f16395e005b253a1cccadcd77b6403617cf72467)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.9.1 ([#855](https://github.com/googleapis/java-core/issues/855)) ([f7fc1cc](https://github.com/googleapis/java-core/commit/f7fc1cca6e79a17313c1d9c522dc93ea6df44645)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.5.0 ([#862](https://github.com/googleapis/java-core/issues/862)) ([fc82590](https://github.com/googleapis/java-core/commit/fc82590ca3022449300f18bb6d0109521aa73cbc)) +* update dependency com.google.http-client:google-http-client-bom to v1.42.1 ([#861](https://github.com/googleapis/java-core/issues/861)) ([3849fdf](https://github.com/googleapis/java-core/commit/3849fdf14e863d23b097b0d625e3a11b47f5d99b)) + +## [2.8.1](https://github.com/googleapis/java-core/compare/v2.8.0...v2.8.1) (2022-06-27) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.21.2 ([#851](https://github.com/googleapis/java-core/issues/851)) ([c0f09f0](https://github.com/googleapis/java-core/commit/c0f09f0fcd57a2d90e0a99b17c9e346df8651d65)) + +## [2.8.0](https://github.com/googleapis/java-core/compare/v2.7.1...v2.8.0) (2022-06-21) + + +### Features + +* add build scripts for native image testing in Java 17 ([#1440](https://github.com/googleapis/java-core/issues/1440)) ([#836](https://github.com/googleapis/java-core/issues/836)) ([8826d9b](https://github.com/googleapis/java-core/commit/8826d9bc05eb9e4a54c40e8578de85ed79c50e99)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.35.1 ([#843](https://github.com/googleapis/java-core/issues/843)) ([9ffe0c5](https://github.com/googleapis/java-core/commit/9ffe0c5b25761abf7ff1bea091aa1db057dff2d0)) +* update dependency com.google.api:api-common to v2.2.1 ([#844](https://github.com/googleapis/java-core/issues/844)) ([69dde56](https://github.com/googleapis/java-core/commit/69dde5641546b678a385b1ed3a2c7a020f81d285)) +* update dependency com.google.api:gax-bom to v2.18.2 ([#849](https://github.com/googleapis/java-core/issues/849)) ([11764b0](https://github.com/googleapis/java-core/commit/11764b04629c5bfbc9b0d68174782cc126dc1646)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.9.0 ([#846](https://github.com/googleapis/java-core/issues/846)) ([5dced6d](https://github.com/googleapis/java-core/commit/5dced6d25ce0f3e7587d7ac1f6f3713f3b2a18c2)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.4.0 ([#838](https://github.com/googleapis/java-core/issues/838)) ([b0a7afe](https://github.com/googleapis/java-core/commit/b0a7afe342a5e15436d439b9cc1e3c58f894ab66)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.4.1 ([#848](https://github.com/googleapis/java-core/issues/848)) ([8260997](https://github.com/googleapis/java-core/commit/826099767b0aabe0db26eff2f612f0847b451366)) +* update dependency com.google.errorprone:error_prone_annotations to v2.14.0 ([#839](https://github.com/googleapis/java-core/issues/839)) ([3459fb6](https://github.com/googleapis/java-core/commit/3459fb668557b982cef5682ce47d3c978b83d69c)) +* update dependency com.google.http-client:google-http-client-bom to v1.42.0 ([#845](https://github.com/googleapis/java-core/issues/845)) ([2d2c873](https://github.com/googleapis/java-core/commit/2d2c873e274b26f4687d569cc3b8ae58c3c5ed54)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.0 ([#840](https://github.com/googleapis/java-core/issues/840)) ([037da15](https://github.com/googleapis/java-core/commit/037da15b2aed1719e768ba5b4e001caf25952adc)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.1 ([#841](https://github.com/googleapis/java-core/issues/841)) ([04b8862](https://github.com/googleapis/java-core/commit/04b886224128f1525ad8398815dc62dac87680af)) +* update dependency io.grpc:grpc-bom to v1.47.0 ([#842](https://github.com/googleapis/java-core/issues/842)) ([40984e2](https://github.com/googleapis/java-core/commit/40984e23242ba954b6ca741ca3f02ec89e92ae57)) + +### [2.7.1](https://github.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://github.com/googleapis/java-core/issues/833)) ([7541115](https://github.com/googleapis/java-core/commit/7541115095e0ae28d938a4c9621fd0f82892fe55)) + +## [2.7.0](https://github.com/googleapis/java-core/compare/v2.6.1...v2.7.0) (2022-05-18) + + +### Features + +* **java:** remove native-image-support module ([#820](https://github.com/googleapis/java-core/issues/820)) ([a53ef6d](https://github.com/googleapis/java-core/commit/a53ef6d7ba05eeba82998378455f0aea58f24381)) +* next release from main branch is 2.7.0 ([#807](https://github.com/googleapis/java-core/issues/807)) ([5a2c608](https://github.com/googleapis/java-core/commit/5a2c608e375d15ec83ca71232627bce1f167e750)) + + +### Bug Fixes + +* remove native-image-support module from version.txt ([#822](https://github.com/googleapis/java-core/issues/822)) ([92e7efc](https://github.com/googleapis/java-core/commit/92e7efc4974911f7ce30021a280c9002a44dab47)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.34.1 ([#823](https://github.com/googleapis/java-core/issues/823)) ([71105c6](https://github.com/googleapis/java-core/commit/71105c64918d6444e321fa3de5fc402e577ebc7d)) +* update dependency com.google.api:api-common to v2.2.0 ([#827](https://github.com/googleapis/java-core/issues/827)) ([05a02d6](https://github.com/googleapis/java-core/commit/05a02d6b16cb06b9f1dea0814912e5a32913fca8)) +* update dependency com.google.api:gax-bom to v2.17.0 ([#826](https://github.com/googleapis/java-core/issues/826)) ([c90188e](https://github.com/googleapis/java-core/commit/c90188e9a94ae71d71105d908173f1bd7e77c1cb)) +* update dependency com.google.api:gax-bom to v2.18.0 ([#829](https://github.com/googleapis/java-core/issues/829)) ([5537e7f](https://github.com/googleapis/java-core/commit/5537e7f80d5db94038b24a393e310120fab62e8c)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.2 ([#805](https://github.com/googleapis/java-core/issues/805)) ([493ac03](https://github.com/googleapis/java-core/commit/493ac038d3ca9f603cd47969fde0da68a1f9bfd0)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.3 ([#814](https://github.com/googleapis/java-core/issues/814)) ([e809baa](https://github.com/googleapis/java-core/commit/e809baa69672d3eca2dc348f55615dc072a8fbe3)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.4 ([#825](https://github.com/googleapis/java-core/issues/825)) ([5ce12ee](https://github.com/googleapis/java-core/commit/5ce12ee0c10e2bdb5981e6ca02966d7eb802ca6c)) +* update dependency com.google.auth:google-auth-library-bom to v1.7.0 ([#828](https://github.com/googleapis/java-core/issues/828)) ([2abca2c](https://github.com/googleapis/java-core/commit/2abca2c135ba2337d546d5c97bcdd5901e91301a)) +* update dependency com.google.cloud:native-image-support to v0.14.0 ([#824](https://github.com/googleapis/java-core/issues/824)) ([997a34a](https://github.com/googleapis/java-core/commit/997a34a15a59bb1818fff3d1fbce195a05d12da3)) +* update dependency com.google.errorprone:error_prone_annotations to v2.13.1 ([#806](https://github.com/googleapis/java-core/issues/806)) ([9fc5811](https://github.com/googleapis/java-core/commit/9fc5811eae52288acd9fb0b967e5737848fe7c5e)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.8 ([#821](https://github.com/googleapis/java-core/issues/821)) ([c7e3d6e](https://github.com/googleapis/java-core/commit/c7e3d6ef437d9f85dab450b54d63f7218b89788b)) +* update dependency com.google.protobuf:protobuf-bom to v3.20.1 ([#813](https://github.com/googleapis/java-core/issues/813)) ([a9c8c92](https://github.com/googleapis/java-core/commit/a9c8c92086c0266e14f86a957944c0cc4ab26ee6)) +* update dependency io.grpc:grpc-bom to v1.46.0 ([#815](https://github.com/googleapis/java-core/issues/815)) ([03c9bfe](https://github.com/googleapis/java-core/commit/03c9bfe4210a6c3995adf89be28b7c8aab402fb3)) +* update opencensus.version to v0.31.1 ([#819](https://github.com/googleapis/java-core/issues/819)) ([1800d3a](https://github.com/googleapis/java-core/commit/1800d3aa3ff7315947681b648f822f2cf9656a3b)) + +### [2.6.1](https://github.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://github.com/googleapis/java-core/issues/802)) ([042b08e](https://github.com/googleapis/java-core/commit/042b08e3cf05dba7e006f802dbc60f95b6da99ef)) + +## [2.6.0](https://github.com/googleapis/java-core/compare/v2.5.11...v2.6.0) (2022-04-14) + + +### Features + +* **java:** remove GoogleJsonClentFeature and OpenCensusFeature after relocation ([#793](https://github.com/googleapis/java-core/issues/793)) ([2880112](https://github.com/googleapis/java-core/commit/28801121a50583118286419ac91332a201285c4c)) +* **java:** remove Netty Native Image configuration after relocation to gax ([#771](https://github.com/googleapis/java-core/issues/771)) ([9ba04f9](https://github.com/googleapis/java-core/commit/9ba04f9f135e1ff7344bb45eeb5796154616ef20)) +* **java:** remove protobuf Native Image configuration ([#784](https://github.com/googleapis/java-core/issues/784)) ([0bc8549](https://github.com/googleapis/java-core/commit/0bc8549d3364ac169f21cc00c00497cd59998106)) +* remove native-image.properties settings after relocation ([#794](https://github.com/googleapis/java-core/issues/794)) ([e24bfdd](https://github.com/googleapis/java-core/commit/e24bfddbb9f588fbf69cdc0022cdf67f2c628278)) +* remove resource-config after relocation ([#795](https://github.com/googleapis/java-core/issues/795)) ([87e2973](https://github.com/googleapis/java-core/commit/87e29733c3714b39000e5fa3d232c35ce69955a2)) +* remove substitutions after relocation to gax ([#789](https://github.com/googleapis/java-core/issues/789)) ([29291e9](https://github.com/googleapis/java-core/commit/29291e9f50e4500ef5d5c1fe30098d025b216f9a)) + + +### Bug Fixes + +* **java:** register test class for reflection to fix native image test ([#766](https://github.com/googleapis/java-core/issues/766)) ([6fe52c3](https://github.com/googleapis/java-core/commit/6fe52c3424546cad7b8158668d3f8a655b56af41)) + + +### Dependencies + +* revert protobuf to 3.19 and common-protos 2.8.3 ([#798](https://github.com/googleapis/java-core/issues/798)) ([0f36a84](https://github.com/googleapis/java-core/commit/0f36a848a03c50d5d0187241bccd66fdb0cea862)) +* update dependency com.google.api-client:google-api-client-bom to v1.34.0 ([#800](https://github.com/googleapis/java-core/issues/800)) ([8430aee](https://github.com/googleapis/java-core/commit/8430aee231100ef13296f22f09265589b2aa0252)) +* update dependency com.google.api:gax-bom to v2.16.0 ([#785](https://github.com/googleapis/java-core/issues/785)) ([fd435b0](https://github.com/googleapis/java-core/commit/fd435b00f01fac1dc96b5f401b403d67809fa1eb)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.8.1 ([#792](https://github.com/googleapis/java-core/issues/792)) ([4d201ac](https://github.com/googleapis/java-core/commit/4d201ac5dc694c9e4a4f06c5580a0c707ea68b87)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.8.2 ([#796](https://github.com/googleapis/java-core/issues/796)) ([dc28a0f](https://github.com/googleapis/java-core/commit/dc28a0f2d58bcf4eb3c9b9f129ce8d88470e94e6)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.0 ([#783](https://github.com/googleapis/java-core/issues/783)) ([4ed5ba4](https://github.com/googleapis/java-core/commit/4ed5ba4d096cb19f60186cbcfc789f5b058b07f8)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.3.1 ([#799](https://github.com/googleapis/java-core/issues/799)) ([fce5315](https://github.com/googleapis/java-core/commit/fce531519184225e103a8faad54e81ae9232210a)) +* update dependency com.google.errorprone:error_prone_annotations to v2.12.1 ([#788](https://github.com/googleapis/java-core/issues/788)) ([4e71f68](https://github.com/googleapis/java-core/commit/4e71f680142bf8cffaa519dcb0fd2916458674e2)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.6 ([#791](https://github.com/googleapis/java-core/issues/791)) ([fe006c6](https://github.com/googleapis/java-core/commit/fe006c60e6cbaff8127a9f6f6792c6a6ce9ff26b)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.7 ([#797](https://github.com/googleapis/java-core/issues/797)) ([570f8d5](https://github.com/googleapis/java-core/commit/570f8d5870044d1f3026b4aec49a6800d904f1be)) +* update dependency com.google.protobuf:protobuf-bom to v3.20.0 ([#787](https://github.com/googleapis/java-core/issues/787)) ([19202bc](https://github.com/googleapis/java-core/commit/19202bcb76e28977e0f2c9b02c75c83644bfb438)) +* update dependency io.grpc:grpc-bom to v1.45.1 ([#780](https://github.com/googleapis/java-core/issues/780)) ([6e3bf35](https://github.com/googleapis/java-core/commit/6e3bf35c501028ac293a401f55c14f1d97fa3953)) + +### [2.5.11](https://github.com/googleapis/java-core/compare/v2.5.10...v2.5.11) (2022-03-28) + + +### Bug Fixes + +* **java:** Register Spanner classes for reflection to fix Native Image tests ([#760](https://github.com/googleapis/java-core/issues/760)) ([257de0f](https://github.com/googleapis/java-core/commit/257de0f71963550ce11aca608fdf9a99672ff19a)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.33.4 ([#776](https://github.com/googleapis/java-core/issues/776)) ([1b6fb2a](https://github.com/googleapis/java-core/commit/1b6fb2a5b9602f5ff8375deb15f5121851b09bd1)) +* update dependency com.google.api:api-common to v2.1.5 ([#768](https://github.com/googleapis/java-core/issues/768)) ([c76c332](https://github.com/googleapis/java-core/commit/c76c332b5676bffad2a1e75b094790c9b0488447)) +* update dependency com.google.api:gax-bom to v2.13.0 ([#774](https://github.com/googleapis/java-core/issues/774)) ([8075c54](https://github.com/googleapis/java-core/commit/8075c54a127496a5330671652678b03f5abdd5c9)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.8.0 ([#770](https://github.com/googleapis/java-core/issues/770)) ([6809477](https://github.com/googleapis/java-core/commit/680947779ac9bc58f60c6c18750aac6b756e73b2)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.10 ([#763](https://github.com/googleapis/java-core/issues/763)) ([9f2eb5f](https://github.com/googleapis/java-core/commit/9f2eb5fed5d9dc91ee01068a2c4eec9acef38c86)) +* update dependency com.google.auth:google-auth-library-bom to v1.6.0 ([#765](https://github.com/googleapis/java-core/issues/765)) ([2eb1924](https://github.com/googleapis/java-core/commit/2eb19241f119f39de7d07ee863c9c78a3e7f11a4)) +* update dependency com.google.guava:guava to 31.1-jre ([#772](https://github.com/googleapis/java-core/issues/772)) ([060adf3](https://github.com/googleapis/java-core/commit/060adf35bf6afdd4b31d790e5484f63eac777a11)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.5 ([#769](https://github.com/googleapis/java-core/issues/769)) ([999be7a](https://github.com/googleapis/java-core/commit/999be7ab10459b33ab001b5bd84d650aeb13313f)) +* update dependency org.threeten:threetenbp to v1.6.0 ([#767](https://github.com/googleapis/java-core/issues/767)) ([9a4a438](https://github.com/googleapis/java-core/commit/9a4a438e04acfd0ec15cdfac5da3610223fe0071)) + +### [2.5.10](https://github.com/googleapis/java-core/compare/v2.5.9...v2.5.10) (2022-03-10) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.9 ([#759](https://github.com/googleapis/java-core/issues/759)) ([9585d4e](https://github.com/googleapis/java-core/commit/9585d4ea8377c087b33e63e46672a79d52e04a4b)) + +### [2.5.9](https://github.com/googleapis/java-core/compare/v2.5.8...v2.5.9) (2022-03-09) + + +### Dependencies + +* update dependency io.grpc:grpc-bom to v1.45.0 ([#756](https://github.com/googleapis/java-core/issues/756)) ([403b10a](https://github.com/googleapis/java-core/commit/403b10accfe2694dc2a5fac63a374d00585df5bb)) + +### [2.5.8](https://github.com/googleapis/java-core/compare/v2.5.7...v2.5.8) (2022-03-08) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.8 ([#753](https://github.com/googleapis/java-core/issues/753)) ([6866b84](https://github.com/googleapis/java-core/commit/6866b8407162ecbff7ed5a6eec5e3e4d130fcfa7)) + +### [2.5.7](https://github.com/googleapis/java-core/compare/v2.5.6...v2.5.7) (2022-03-08) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.7 ([#748](https://github.com/googleapis/java-core/issues/748)) ([91cc595](https://github.com/googleapis/java-core/commit/91cc595c7df73af8e71e4feeb663c973e6bcc8e5)) + +### [2.5.6](https://github.com/googleapis/java-core/compare/v2.5.5...v2.5.6) (2022-03-01) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.6 ([#742](https://github.com/googleapis/java-core/issues/742)) ([474e56c](https://github.com/googleapis/java-core/commit/474e56cca19f9d7b61f62585ee06f1fbdba0ae46)) + +### [2.5.5](https://github.com/googleapis/java-core/compare/v2.5.4...v2.5.5) (2022-02-28) + + +### Bug Fixes + +* **java:** initialize spanner test environment class at build-time ([#734](https://github.com/googleapis/java-core/issues/734)) ([684934e](https://github.com/googleapis/java-core/commit/684934efb28e4ed5f5f975aab91adad25bf1ab52)) +* **java:** initialize TestTag at build time ([#732](https://github.com/googleapis/java-core/issues/732)) ([a5f1dc2](https://github.com/googleapis/java-core/commit/a5f1dc2ed3d71404d699830ba4bea8824e67d0e8)) + + +### Dependencies + +* update actions/setup-java action to v3 ([#739](https://github.com/googleapis/java-core/issues/739)) ([46322e3](https://github.com/googleapis/java-core/commit/46322e3a9929195c223fc6399860c1cab4d81eb5)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.7.4 ([#728](https://github.com/googleapis/java-core/issues/728)) ([3b83bd7](https://github.com/googleapis/java-core/commit/3b83bd7dce6a369c6668f0967572ae08df1b77d8)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.4 ([#729](https://github.com/googleapis/java-core/issues/729)) ([0759c2b](https://github.com/googleapis/java-core/commit/0759c2b8163d45bf87692e2f131df76dac5f178e)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.5 ([#735](https://github.com/googleapis/java-core/issues/735)) ([cefbf97](https://github.com/googleapis/java-core/commit/cefbf978ac21f00b3c4558ebc40ef1f6355ea156)) +* update dependency com.google.auth:google-auth-library-bom to v1.5.3 ([#737](https://github.com/googleapis/java-core/issues/737)) ([a1cb8d8](https://github.com/googleapis/java-core/commit/a1cb8d81db34142937c85be5c4502036a4b7939d)) +* update dependency com.google.code.gson:gson to v2.9.0 ([#727](https://github.com/googleapis/java-core/issues/727)) ([faf8a44](https://github.com/googleapis/java-core/commit/faf8a44e8823ecae44d543e6f5c2a9d8598f04fe)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.4 ([#730](https://github.com/googleapis/java-core/issues/730)) ([1975b61](https://github.com/googleapis/java-core/commit/1975b617e23f7dd0b263e9acb4010b3126e5d7e7)) +* update dependency io.grpc:grpc-bom to v1.44.1 ([#736](https://github.com/googleapis/java-core/issues/736)) ([4ca315c](https://github.com/googleapis/java-core/commit/4ca315ca400e020badbdf27bb92d1b67680a2e73)) + +### [2.5.4](https://github.com/googleapis/java-core/compare/v2.5.3...v2.5.4) (2022-02-11) + + +### Dependencies + +* update actions/github-script action to v6 ([#724](https://github.com/googleapis/java-core/issues/724)) ([b8673d3](https://github.com/googleapis/java-core/commit/b8673d3b3ae08cbfed135cd7ff9d891c04e90611)) + +### [2.5.3](https://github.com/googleapis/java-core/compare/v2.5.2...v2.5.3) (2022-02-10) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.12.2 ([#719](https://github.com/googleapis/java-core/issues/719)) ([4de90d0](https://github.com/googleapis/java-core/commit/4de90d05c152c21a1ebb98f6cbff0f9b9c39e5d2)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.3 ([#720](https://github.com/googleapis/java-core/issues/720)) ([d2a5b4f](https://github.com/googleapis/java-core/commit/d2a5b4ffa598f232b84655a7ac146bfa2e1f24c9)) + +### [2.5.2](https://github.com/googleapis/java-core/compare/v2.5.1...v2.5.2) (2022-02-09) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.3 ([#716](https://github.com/googleapis/java-core/issues/716)) ([100e41e](https://github.com/googleapis/java-core/commit/100e41e092f35f6e6d187de45bb6dc3e4e760052)) + +### [2.5.1](https://github.com/googleapis/java-core/compare/v2.5.0...v2.5.1) (2022-02-08) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.33.2 ([#709](https://github.com/googleapis/java-core/issues/709)) ([de08f4e](https://github.com/googleapis/java-core/commit/de08f4eea6cf4e7813c8da1f6adb28e1e56fd1cd)) +* update dependency com.google.api:api-common to v2.1.4 ([#712](https://github.com/googleapis/java-core/issues/712)) ([9cc49de](https://github.com/googleapis/java-core/commit/9cc49de654d57e8efdb97c8e3c7f9d8723e79eb9)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.7.3 ([#710](https://github.com/googleapis/java-core/issues/710)) ([a5f1991](https://github.com/googleapis/java-core/commit/a5f199157319dfb82cbb24d1b4249d924118de84)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.2 ([#705](https://github.com/googleapis/java-core/issues/705)) ([b8722b9](https://github.com/googleapis/java-core/commit/b8722b998966b21cd2d9e6208627c34ff046accf)) + +## [2.5.0](https://github.com/googleapis/java-core/compare/v2.4.0...v2.5.0) (2022-02-02) + + +### Features + +* add limit support to ReadChannel ([#688](https://github.com/googleapis/java-core/issues/688)) ([476109e](https://github.com/googleapis/java-core/commit/476109e1943c1a9561cc636ffc64ab8cdd1888f9)) + + +### Bug Fixes + +* **java:** Initialize AsyncSSLPrivateKeyMethod (a grpc netty class) at run-time ([#702](https://github.com/googleapis/java-core/issues/702)) ([24146a3](https://github.com/googleapis/java-core/commit/24146a35a10ae06238de9556c24dab5dbd3bcaff)) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.12.0 ([#698](https://github.com/googleapis/java-core/issues/698)) ([c10aab8](https://github.com/googleapis/java-core/commit/c10aab8a57ff0aad07a700540085e2ed7521b1a1)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.4 ([#699](https://github.com/googleapis/java-core/issues/699)) ([5d163f5](https://github.com/googleapis/java-core/commit/5d163f591547cd8e0e508b9c824a17da2074b264)) + +## [2.4.0](https://github.com/googleapis/java-core/compare/v2.3.5...v2.4.0) (2022-01-28) + + +### Features + +* **java:** Add native-image support classes to java-core module ([#637](https://github.com/googleapis/java-core/issues/637)) ([154bc18](https://github.com/googleapis/java-core/commit/154bc18ba86328d29665c502db1d35e265c92bbf)) + + +### Bug Fixes + +* **java:** initialize LoggerFactory at build time ([#685](https://github.com/googleapis/java-core/issues/685)) ([eb3aba2](https://github.com/googleapis/java-core/commit/eb3aba2455a0ab6ffec2c6beb3f3cbb4bcb6008d)) + + +### Dependencies + +* **java:** update actions/github-script action to v5 ([#1339](https://github.com/googleapis/java-core/issues/1339)) ([#689](https://github.com/googleapis/java-core/issues/689)) ([eb462c7](https://github.com/googleapis/java-core/commit/eb462c7b1a005ce37d1be58900a244f6b807e5d5)) +* update dependency com.google.api-client:google-api-client-bom to v1.33.1 ([#684](https://github.com/googleapis/java-core/issues/684)) ([9ff47e6](https://github.com/googleapis/java-core/commit/9ff47e68d0c435d7636d89b03369aabbdfe3663b)) +* update dependency com.google.api:api-common to v2.1.3 ([#694](https://github.com/googleapis/java-core/issues/694)) ([684ae80](https://github.com/googleapis/java-core/commit/684ae805b8d25747830ce9266fd51a287c018cc9)) +* update dependency com.google.api:gax-bom to v2.11.0 ([#677](https://github.com/googleapis/java-core/issues/677)) ([1a578bd](https://github.com/googleapis/java-core/commit/1a578bdee2fa229ffbdd8fdde3d66d7e29dedf98)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.7.2 ([#695](https://github.com/googleapis/java-core/issues/695)) ([1085d2c](https://github.com/googleapis/java-core/commit/1085d2cb1d7e8391f981d1f4b97c7724b0107e94)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.1 ([#667](https://github.com/googleapis/java-core/issues/667)) ([b57ec04](https://github.com/googleapis/java-core/commit/b57ec047234a1a044458980a8cf7de6a3156bf41)) +* update dependency com.google.auth:google-auth-library-bom to v1.4.0 ([#681](https://github.com/googleapis/java-core/issues/681)) ([3273b1e](https://github.com/googleapis/java-core/commit/3273b1ed0b1db610790e7832a6c92797a341cc7d)) +* update dependency com.google.errorprone:error_prone_annotations to v2.11.0 ([#687](https://github.com/googleapis/java-core/issues/687)) ([dc4d18d](https://github.com/googleapis/java-core/commit/dc4d18de86695fddbcb9d221cc53fdca3faf09f5)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.1 ([#683](https://github.com/googleapis/java-core/issues/683)) ([45cb753](https://github.com/googleapis/java-core/commit/45cb7535151cfcffa282b4c8d9cd56265cca2ece)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.2 ([#696](https://github.com/googleapis/java-core/issues/696)) ([f4875c0](https://github.com/googleapis/java-core/commit/f4875c0deecfea3728925e5ee0ef95ee90852301)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.3 ([#674](https://github.com/googleapis/java-core/issues/674)) ([c54f997](https://github.com/googleapis/java-core/commit/c54f9973b71c91c1fde0a1d128957cd022a27902)) +* update dependency io.grpc:grpc-bom to v1.43.2 ([#665](https://github.com/googleapis/java-core/issues/665)) ([752ba6e](https://github.com/googleapis/java-core/commit/752ba6e384c382d0e39d8335640eaaea2beee9e1)) +* update dependency io.grpc:grpc-bom to v1.44.0 ([#693](https://github.com/googleapis/java-core/issues/693)) ([ed85045](https://github.com/googleapis/java-core/commit/ed850455995fc5b5c2dae3595116721316f63698)) +* update dependency org.easymock:easymock to v4 ([#668](https://github.com/googleapis/java-core/issues/668)) ([c36e976](https://github.com/googleapis/java-core/commit/c36e976c0379c1119dfe643dc3131f2e52130c5c)) +* update dependency org.graalvm.sdk:graal-sdk to v22 ([#680](https://github.com/googleapis/java-core/issues/680)) ([0f535f8](https://github.com/googleapis/java-core/commit/0f535f869f7ce68192f821d0f3361634676dddf7)) +* update graalvm.version to v21.3.1 ([#679](https://github.com/googleapis/java-core/issues/679)) ([dfb305a](https://github.com/googleapis/java-core/commit/dfb305acaf9d6db91727e42509fc6b043f07a5ce)) +* update graalvm.version to v22.0.0.2 ([#691](https://github.com/googleapis/java-core/issues/691)) ([780b734](https://github.com/googleapis/java-core/commit/780b734bb4f26fab49065f303d102033b2c3a3d0)) +* update opencensus.version to v0.30.0 ([#646](https://github.com/googleapis/java-core/issues/646)) ([c2caaa7](https://github.com/googleapis/java-core/commit/c2caaa7cb2c094318e611ba2c082a8a31fee21ea)) +* update opencensus.version to v0.31.0 ([#692](https://github.com/googleapis/java-core/issues/692)) ([bdf7d4e](https://github.com/googleapis/java-core/commit/bdf7d4ec05c5314e5f2667287ed3e7cb83667c35)) + +### [2.3.5](https://www.github.com/googleapis/java-core/compare/v2.3.4...v2.3.5) (2022-01-06) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.2 ([#661](https://www.github.com/googleapis/java-core/issues/661)) ([0a136d8](https://www.github.com/googleapis/java-core/commit/0a136d8122f6c5042808cbfee9e58dc53e368da6)) +* update gax.version to v2.8.1 ([#663](https://www.github.com/googleapis/java-core/issues/663)) ([7c09aa5](https://www.github.com/googleapis/java-core/commit/7c09aa5729408a395f1a8fae94744f9d33638b1a)) + +### [2.3.4](https://www.github.com/googleapis/java-core/compare/v2.3.3...v2.3.4) (2022-01-06) + + +### Bug Fixes + +* fixed compilation warnings from error prone ([e6e7040](https://www.github.com/googleapis/java-core/commit/e6e7040305b19ec9d5468f4cd44d7a29d0d5e470)) +* **java:** add -ntp flag to native image testing command ([#1299](https://www.github.com/googleapis/java-core/issues/1299)) ([#643](https://www.github.com/googleapis/java-core/issues/643)) ([0f4c1db](https://www.github.com/googleapis/java-core/commit/0f4c1dbbd89d82f5cc86c2b684d6645699b835b3)) +* **java:** run Maven in plain console-friendly mode ([#1301](https://www.github.com/googleapis/java-core/issues/1301)) ([#652](https://www.github.com/googleapis/java-core/issues/652)) ([ab2fa93](https://www.github.com/googleapis/java-core/commit/ab2fa93ba0434f593abb063afad44dc923bf462a)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.33.0 ([#658](https://www.github.com/googleapis/java-core/issues/658)) ([d417ebd](https://www.github.com/googleapis/java-core/commit/d417ebd7bedc9d4e983f32c87a8d61163502cf1d)) +* update dependency com.google.api:gax-bom to v2.8.0 ([#659](https://www.github.com/googleapis/java-core/issues/659)) ([91717ab](https://www.github.com/googleapis/java-core/commit/91717ab9361a31976727b26d08837e8b3838bdb4)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.7.1 ([#656](https://www.github.com/googleapis/java-core/issues/656)) ([ecfbdc1](https://www.github.com/googleapis/java-core/commit/ecfbdc181087d37d38f7911b9962953f5d246434)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.2.0 ([#645](https://www.github.com/googleapis/java-core/issues/645)) ([3926b54](https://www.github.com/googleapis/java-core/commit/3926b5423893635dd709b8fc6037fb896396ff13)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.0 ([#657](https://www.github.com/googleapis/java-core/issues/657)) ([41a5120](https://www.github.com/googleapis/java-core/commit/41a51201a3712f71f6cf3be3c29db68360b2405f)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.2 ([#655](https://www.github.com/googleapis/java-core/issues/655)) ([eb6c037](https://www.github.com/googleapis/java-core/commit/eb6c03729af41e6d7bd9db80644b8ddfd22e78ec)) +* update dependency io.grpc:grpc-bom to v1.43.1 ([#647](https://www.github.com/googleapis/java-core/issues/647)) ([275b882](https://www.github.com/googleapis/java-core/commit/275b882918f7625daeb3e98ab26b7b0a2f2cdb7b)) + +### [2.3.3](https://www.github.com/googleapis/java-core/compare/v2.3.2...v2.3.3) (2021-12-02) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.7.1 ([#640](https://www.github.com/googleapis/java-core/issues/640)) ([18e033b](https://www.github.com/googleapis/java-core/commit/18e033bdafe536a42ada9f93b0a2b502caea0bcf)) + +### [2.3.2](https://www.github.com/googleapis/java-core/compare/v2.3.1...v2.3.2) (2021-12-02) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.1 ([#632](https://www.github.com/googleapis/java-core/issues/632)) ([b9bb47a](https://www.github.com/googleapis/java-core/commit/b9bb47a0b0a6b132c516361d23750a92a32e53be)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.7.0 ([#638](https://www.github.com/googleapis/java-core/issues/638)) ([74862a8](https://www.github.com/googleapis/java-core/commit/74862a8864eb7bffe6659d1e2a261dd5b934d6ff)) + +### [2.3.1](https://www.github.com/googleapis/java-core/compare/v2.3.0...v2.3.1) (2021-11-15) + + +### Dependencies + +* update dependency io.grpc:grpc-bom to v1.42.1 ([#629](https://www.github.com/googleapis/java-core/issues/629)) ([85fcd99](https://www.github.com/googleapis/java-core/commit/85fcd99237d7526b1b373d07204c4114c49b08b8)) + +## [2.3.0](https://www.github.com/googleapis/java-core/compare/v2.2.0...v2.3.0) (2021-11-11) + + +### Features + +* next release from main branch is 2.3.0 ([#602](https://www.github.com/googleapis/java-core/issues/602)) ([34fa5f1](https://www.github.com/googleapis/java-core/commit/34fa5f1e750629d4431d5f97eb8b09ee65ebc016)) + + +### Bug Fixes + +* **java:** java 17 dependency arguments ([#1266](https://www.github.com/googleapis/java-core/issues/1266)) ([#612](https://www.github.com/googleapis/java-core/issues/612)) ([5be3eff](https://www.github.com/googleapis/java-core/commit/5be3eff4041ca39d513979b948afe99f27bb1d20)) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.0 ([#613](https://www.github.com/googleapis/java-core/issues/613)) ([62d6ab8](https://www.github.com/googleapis/java-core/commit/62d6ab8b5a7c5edb4482d7afda5b87f4832226ca)) +* update dependency com.google.api:gax-bom to v2.7.0 ([#626](https://www.github.com/googleapis/java-core/issues/626)) ([4a1e965](https://www.github.com/googleapis/java-core/commit/4a1e96551e16a5abc5d8f71f9e096a284fc59528)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.7 ([#604](https://www.github.com/googleapis/java-core/issues/604)) ([0d36d59](https://www.github.com/googleapis/java-core/commit/0d36d59e4ff8817ba5984579188bfc6d7745348d)) +* update dependency com.google.auth:google-auth-library-bom to v1.2.2 ([#610](https://www.github.com/googleapis/java-core/issues/610)) ([c5e33d8](https://www.github.com/googleapis/java-core/commit/c5e33d87d211c22a93ea2e0de1776e7f2fbf6ef7)) +* update dependency com.google.auth:google-auth-library-bom to v1.3.0 ([#627](https://www.github.com/googleapis/java-core/issues/627)) ([f4403b2](https://www.github.com/googleapis/java-core/commit/f4403b2af856cc6ce45e2aab277d7e78baa6ecfe)) +* update dependency com.google.code.gson:gson to v2.8.9 ([#615](https://www.github.com/googleapis/java-core/issues/615)) ([ec0e387](https://www.github.com/googleapis/java-core/commit/ec0e387d3c96467218406ef4c5da5e59a11e8b7a)) +* update dependency com.google.errorprone:error_prone_annotations to v2.10.0 ([#618](https://www.github.com/googleapis/java-core/issues/618)) ([21139a8](https://www.github.com/googleapis/java-core/commit/21139a83821b12b5312e470c61b45ca76a0b921a)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.1 ([#609](https://www.github.com/googleapis/java-core/issues/609)) ([28e6333](https://www.github.com/googleapis/java-core/commit/28e6333080fbe10ad8ecdfeef12d80af204f71fd)) +* update dependency io.grpc:grpc-bom to v1.42.0 ([#619](https://www.github.com/googleapis/java-core/issues/619)) ([da4cbd5](https://www.github.com/googleapis/java-core/commit/da4cbd5ccc54a81f89635435a2045cfa0de8d722)) +* update dependency org.threeten:threetenbp to v1.5.2 ([#624](https://www.github.com/googleapis/java-core/issues/624)) ([91eec9d](https://www.github.com/googleapis/java-core/commit/91eec9d83285e10cd9ecf3e75cb99b9a9d40cb89)) + +## [2.2.0](https://www.github.com/googleapis/java-core/compare/v2.1.8...v2.2.0) (2021-10-18) + + +### Features + +* next release from main branch is 2.2.0 ([#596](https://www.github.com/googleapis/java-core/issues/596)) ([cca72b8](https://www.github.com/googleapis/java-core/commit/cca72b82b45e01207bd45c6a2b988981c213c6fd)) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.6.1 ([#600](https://www.github.com/googleapis/java-core/issues/600)) ([a0cff6a](https://www.github.com/googleapis/java-core/commit/a0cff6a83506d1da3a8aacd6eafc39ff1ab11583)) + +### [2.1.8](https://www.github.com/googleapis/java-core/compare/v2.1.7...v2.1.8) (2021-10-15) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.32.2 ([#593](https://www.github.com/googleapis/java-core/issues/593)) ([644fc6f](https://www.github.com/googleapis/java-core/commit/644fc6f728b0791c61d85f34c535c09dff862c1d)) +* update dependency com.google.api:api-common to v2.0.4 ([#585](https://www.github.com/googleapis/java-core/issues/585)) ([ad4e4b7](https://www.github.com/googleapis/java-core/commit/ad4e4b7e076d8bd52bf621615301ec810917db43)) +* update dependency com.google.api:api-common to v2.0.5 ([#589](https://www.github.com/googleapis/java-core/issues/589)) ([c30cc40](https://www.github.com/googleapis/java-core/commit/c30cc40cd8687f79c7154503ee1f602089d62f2d)) +* update dependency com.google.api:gax-bom to v2.6.0 ([#594](https://www.github.com/googleapis/java-core/issues/594)) ([710cbe6](https://www.github.com/googleapis/java-core/commit/710cbe6e5121f118a5f4be327e8eeeceddfa04fb)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.6.0 ([#578](https://www.github.com/googleapis/java-core/issues/578)) ([113b686](https://www.github.com/googleapis/java-core/commit/113b6868f98caa64d713f02729c3f16d878252ff)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.3 ([#574](https://www.github.com/googleapis/java-core/issues/574)) ([338444b](https://www.github.com/googleapis/java-core/commit/338444bd4d169bb7fd41242e790c74596948178b)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.4 ([#584](https://www.github.com/googleapis/java-core/issues/584)) ([57211ce](https://www.github.com/googleapis/java-core/commit/57211ce15e9b1a4c1b7468fed217e4ab46ec0a5d)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.5 ([#587](https://www.github.com/googleapis/java-core/issues/587)) ([55f9f4e](https://www.github.com/googleapis/java-core/commit/55f9f4e084defaf8a243bf21afd67302be802b25)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.6 ([#590](https://www.github.com/googleapis/java-core/issues/590)) ([f534c46](https://www.github.com/googleapis/java-core/commit/f534c462fadb479c6fd934c24ac8cd24e06e2698)) +* update dependency com.google.auth:google-auth-library-bom to v1.2.0 ([#581](https://www.github.com/googleapis/java-core/issues/581)) ([c32d2c5](https://www.github.com/googleapis/java-core/commit/c32d2c552dfa04b8e5eab27a115ac10832898473)) +* update dependency com.google.auth:google-auth-library-bom to v1.2.1 ([#591](https://www.github.com/googleapis/java-core/issues/591)) ([046f95d](https://www.github.com/googleapis/java-core/commit/046f95d8ed0811dd278c40fcfeb2c042e6535996)) +* update dependency com.google.guava:guava-bom to v31 ([#577](https://www.github.com/googleapis/java-core/issues/577)) ([4a987fb](https://www.github.com/googleapis/java-core/commit/4a987fbd3f1bd69b0b923fc9a691fc60908ad1cc)) +* update dependency com.google.http-client:google-http-client-bom to v1.40.1 ([#588](https://www.github.com/googleapis/java-core/issues/588)) ([3d36d77](https://www.github.com/googleapis/java-core/commit/3d36d77e6db9856c276d6263036764c60f32b7b3)) +* update dependency com.google.protobuf:protobuf-bom to v3.18.1 ([#583](https://www.github.com/googleapis/java-core/issues/583)) ([47da21c](https://www.github.com/googleapis/java-core/commit/47da21c793be9477323a234f7e3beaf6b705cd7d)) + +### [2.1.7](https://www.github.com/googleapis/java-core/compare/v2.1.6...v2.1.7) (2021-09-23) + + +### Dependencies + +* update dependency io.grpc:grpc-bom to v1.41.0 ([#569](https://www.github.com/googleapis/java-core/issues/569)) ([36703e9](https://www.github.com/googleapis/java-core/commit/36703e9a1f2d97d465a13220027a27f813da14a8)) + +### [2.1.6](https://www.github.com/googleapis/java-core/compare/v2.1.5...v2.1.6) (2021-09-21) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.5.0 ([#565](https://www.github.com/googleapis/java-core/issues/565)) ([3ce8e28](https://www.github.com/googleapis/java-core/commit/3ce8e28813858ea932dc5c54324441f2f0c52d46)) + +### [2.1.5](https://www.github.com/googleapis/java-core/compare/v2.1.4...v2.1.5) (2021-09-21) + + +### Dependencies + +* downgrading protobuf to 3.17.3 ([#562](https://www.github.com/googleapis/java-core/issues/562)) ([5711b83](https://www.github.com/googleapis/java-core/commit/5711b835a19238df1bfa1f2e4dfc115495a55c9b)) + +### [2.1.4](https://www.github.com/googleapis/java-core/compare/v2.1.3...v2.1.4) (2021-09-15) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.1 ([#556](https://www.github.com/googleapis/java-core/issues/556)) ([095efa1](https://www.github.com/googleapis/java-core/commit/095efa1fc1fffde34c6c38a88fee8f91bd495bfc)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.2 ([#559](https://www.github.com/googleapis/java-core/issues/559)) ([3cda672](https://www.github.com/googleapis/java-core/commit/3cda672059727642d1b90f8bcc6bb34546f6893d)) +* update dependency com.google.protobuf:protobuf-bom to v3.18.0 ([#558](https://www.github.com/googleapis/java-core/issues/558)) ([85766e6](https://www.github.com/googleapis/java-core/commit/85766e67f0a9f381593ea2d6e9c8f30fc0ba2993)) + +### [2.1.3](https://www.github.com/googleapis/java-core/compare/v2.1.2...v2.1.3) (2021-09-10) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.4.1 ([#549](https://www.github.com/googleapis/java-core/issues/549)) ([0b4be35](https://www.github.com/googleapis/java-core/commit/0b4be350d47cab58f3bb4e53d34e913e736a522b)) + +### [2.1.2](https://www.github.com/googleapis/java-core/compare/v2.1.1...v2.1.2) (2021-08-31) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.0.2 ([#534](https://www.github.com/googleapis/java-core/issues/534)) ([1883c81](https://www.github.com/googleapis/java-core/commit/1883c81cb0fdf2f4b34a3a3a17987206d8c452aa)) +* update dependency com.google.api:gax-bom to v2.4.0 ([#540](https://www.github.com/googleapis/java-core/issues/540)) ([06b0d6e](https://www.github.com/googleapis/java-core/commit/06b0d6e3ff3c3b6e2aa440a9f893f9b27e0d66d1)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.5.0 ([#539](https://www.github.com/googleapis/java-core/issues/539)) ([9d5a0b0](https://www.github.com/googleapis/java-core/commit/9d5a0b0918f6a1ab264f1ba272dcd8f22b670a7f)) +* update dependency com.google.http-client:google-http-client-bom to v1.40.0 ([#538](https://www.github.com/googleapis/java-core/issues/538)) ([150e07d](https://www.github.com/googleapis/java-core/commit/150e07ddb884d163d0efbcf786f04a713d29ed81)) +* update dependency io.grpc:grpc-bom to v1.40.1 ([#535](https://www.github.com/googleapis/java-core/issues/535)) ([3cd48a9](https://www.github.com/googleapis/java-core/commit/3cd48a902691ddddb9df9f74517648ca35b5bfd7)) + +### [2.1.1](https://www.github.com/googleapis/java-core/compare/v2.1.0...v2.1.1) (2021-08-24) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.1.0 ([#531](https://www.github.com/googleapis/java-core/issues/531)) ([1b27f8c](https://www.github.com/googleapis/java-core/commit/1b27f8cbfaffcc9b19103b471db237f2448d7cb8)) + +## [2.1.0](https://www.github.com/googleapis/java-core/compare/v2.0.5...v2.1.0) (2021-08-23) + + +### Features + +* support downloading an emulator from an access controlled URL ([#513](https://www.github.com/googleapis/java-core/issues/513)) ([f42a707](https://www.github.com/googleapis/java-core/commit/f42a7078522461018da96196a67657809d28b15b)) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.3.0 ([#523](https://www.github.com/googleapis/java-core/issues/523)) ([6fa1d96](https://www.github.com/googleapis/java-core/commit/6fa1d96d07a7d255e7564407364216436cad6ca3)) +* update dependency com.google.auth:google-auth-library-bom to v1.1.0 ([#526](https://www.github.com/googleapis/java-core/issues/526)) ([0fc1532](https://www.github.com/googleapis/java-core/commit/0fc1532183148d09c3005a68e528c6c438cb6ddd)) +* update dependency com.google.code.gson:gson to v2.8.8 ([#529](https://www.github.com/googleapis/java-core/issues/529)) ([92b7f97](https://www.github.com/googleapis/java-core/commit/92b7f9715eeab0a07b64437a62dd47e5eed006de)) +* update dependency com.google.errorprone:error_prone_annotations to v2.9.0 ([#528](https://www.github.com/googleapis/java-core/issues/528)) ([5ecba07](https://www.github.com/googleapis/java-core/commit/5ecba07336499fc6fddae4cfdc2bc12105ec9b66)) +* update dependency io.grpc:grpc-bom to v1.40.0 ([#525](https://www.github.com/googleapis/java-core/issues/525)) ([a1e81f7](https://www.github.com/googleapis/java-core/commit/a1e81f73a4cc29e7186adf37f1cb718c1a88f41e)) + +### [2.0.5](https://www.github.com/googleapis/java-core/compare/v2.0.4...v2.0.5) (2021-08-11) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2.1.0 ([#519](https://www.github.com/googleapis/java-core/issues/519)) ([266e2f7](https://www.github.com/googleapis/java-core/commit/266e2f75e83fe1fd635a1528deb38131b8bfc742)) + +### [2.0.4](https://www.github.com/googleapis/java-core/compare/v2.0.3...v2.0.4) (2021-08-11) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.0.1 ([#516](https://www.github.com/googleapis/java-core/issues/516)) ([aa6abf3](https://www.github.com/googleapis/java-core/commit/aa6abf3cc458ca117ec009fb29a14fd4f5409ef3)) + +### [2.0.3](https://www.github.com/googleapis/java-core/compare/v2.0.2...v2.0.3) (2021-08-10) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_annotations to v2.8.1 ([#512](https://www.github.com/googleapis/java-core/issues/512)) ([6127b8f](https://www.github.com/googleapis/java-core/commit/6127b8f23ec267a4cf8daa794b88a5cd97f054e3)) + +### [2.0.2](https://www.github.com/googleapis/java-core/compare/v2.0.1...v2.0.2) (2021-08-03) + + +### Features + +* release 2.0.2 ([#509](https://www.github.com/googleapis/java-core/issues/509)) ([afbb532](https://www.github.com/googleapis/java-core/commit/afbb532965a9ab6f9e3eafbf9d5d8502dd29d1bb)) + +### [2.0.1](https://www.github.com/googleapis/java-core/compare/v2.0.0...v2.0.1) (2021-08-03) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v2 ([#506](https://www.github.com/googleapis/java-core/issues/506)) ([a0c49a2](https://www.github.com/googleapis/java-core/commit/a0c49a2eb2579df78afccc6db021e78c3bd58493)) + +## [2.0.0](https://www.github.com/googleapis/java-core/compare/v1.95.4...v2.0.0) (2021-07-29) + + +### Features + +* promote to 2.0.0 ([#504](https://www.github.com/googleapis/java-core/issues/504)) ([48076ba](https://www.github.com/googleapis/java-core/commit/48076bafa2a89dc6b3ad88a698166da8ebb144f4)) + + +### Bug Fixes + +* Add shopt -s nullglob to dependencies script ([1fa147c](https://www.github.com/googleapis/java-core/commit/1fa147c9cded08f9eea4a717c622c0b33ad239d0)) +* Update dependencies.sh to not break on mac ([#484](https://www.github.com/googleapis/java-core/issues/484)) ([1fa147c](https://www.github.com/googleapis/java-core/commit/1fa147c9cded08f9eea4a717c622c0b33ad239d0)) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.10.6 ([#494](https://www.github.com/googleapis/java-core/issues/494)) ([1353d7b](https://www.github.com/googleapis/java-core/commit/1353d7b42dc98110733d279404f9295067f632cf)) +* update dependency com.google.api:api-common to v2 ([#497](https://www.github.com/googleapis/java-core/issues/497)) ([05edb6e](https://www.github.com/googleapis/java-core/commit/05edb6ec2156978b49e72f16de35a935acd43ca8)) +* update dependency com.google.api:gax-bom to v1.66.0 ([#483](https://www.github.com/googleapis/java-core/issues/483)) ([0698c66](https://www.github.com/googleapis/java-core/commit/0698c6679877e0666c684ea5c5daaf8ebae7c15c)) +* update dependency com.google.api:gax-bom to v1.67.0 ([#491](https://www.github.com/googleapis/java-core/issues/491)) ([65f4a1e](https://www.github.com/googleapis/java-core/commit/65f4a1e4ace1ec70cd2a151233c626d80874beb4)) +* update dependency com.google.auth:google-auth-library-bom to v0.27.0 ([#489](https://www.github.com/googleapis/java-core/issues/489)) ([21b0afe](https://www.github.com/googleapis/java-core/commit/21b0afea717805dfd5c93929d2a72de86f048781)) +* update dependency com.google.auth:google-auth-library-bom to v1 ([#496](https://www.github.com/googleapis/java-core/issues/496)) ([9cddefc](https://www.github.com/googleapis/java-core/commit/9cddefc0fdb0eb400121db0faf18bf1bdfdfc7f5)) +* update dependency com.google.errorprone:error_prone_annotations to v2.8.0 ([#492](https://www.github.com/googleapis/java-core/issues/492)) ([acd03c0](https://www.github.com/googleapis/java-core/commit/acd03c00896a1e8f6ab948823e5a5ebd5b741115)) +* update dependency io.grpc:grpc-bom to v1.39.0 ([#482](https://www.github.com/googleapis/java-core/issues/482)) ([02e69d4](https://www.github.com/googleapis/java-core/commit/02e69d46d3b8a71b6286915e08e987a5fc9ce8a6)) +* update guava 30.1.1-jre ([#503](https://www.github.com/googleapis/java-core/issues/503)) ([cac0c63](https://www.github.com/googleapis/java-core/commit/cac0c6367d42afb8af2dec56b9eec4de2e95978e)) + +### [1.95.4](https://www.github.com/googleapis/java-core/compare/v1.95.3...v1.95.4) (2021-06-25) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.32.1 ([#479](https://www.github.com/googleapis/java-core/issues/479)) ([5f9f732](https://www.github.com/googleapis/java-core/commit/5f9f73212c8073c3b590206f69a2446c8bce2c75)) + +### [1.95.3](https://www.github.com/googleapis/java-core/compare/v1.95.2...v1.95.3) (2021-06-23) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.10.4 ([#475](https://www.github.com/googleapis/java-core/issues/475)) ([5c8223d](https://www.github.com/googleapis/java-core/commit/5c8223df9d4e30b6f2fadd4985c3bcfc5b0ff4ec)) +* update dependency io.grpc:grpc-bom to v1.38.1 ([#476](https://www.github.com/googleapis/java-core/issues/476)) ([b6a7923](https://www.github.com/googleapis/java-core/commit/b6a7923e255f0146e126bad2296e12e9d591c04d)) + +### [1.95.2](https://www.github.com/googleapis/java-core/compare/v1.95.1...v1.95.2) (2021-06-09) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v1.65.1 ([#471](https://www.github.com/googleapis/java-core/issues/471)) ([3814364](https://www.github.com/googleapis/java-core/commit/381436415073b728b4deb3f82fd129c887205c19)) + +### [1.95.1](https://www.github.com/googleapis/java-core/compare/v1.95.0...v1.95.1) (2021-06-09) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.17.3 ([#468](https://www.github.com/googleapis/java-core/issues/468)) ([d456df2](https://www.github.com/googleapis/java-core/commit/d456df20269cfb531adf7bcc7694d0ffff7b1962)) + +## [1.95.0](https://www.github.com/googleapis/java-core/compare/v1.94.8...v1.95.0) (2021-06-03) + + +### Features + +* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#453](https://www.github.com/googleapis/java-core/issues/453)) ([33d8edf](https://www.github.com/googleapis/java-core/commit/33d8edf12d20f2bbdaedb1f1cd5a9194357934f1)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.31.5 ([#446](https://www.github.com/googleapis/java-core/issues/446)) ([fa83a61](https://www.github.com/googleapis/java-core/commit/fa83a618050cdac519eadda5e8a72c2f9cbfeac0)) +* update dependency com.google.api:gax-bom to v1.64.0-sp.1 ([#443](https://www.github.com/googleapis/java-core/issues/443)) ([19efb61](https://www.github.com/googleapis/java-core/commit/19efb61af60bb5867ebc4c603ac528f277ef6ed0)) +* update dependency com.google.api:gax-bom to v1.65.0 ([#464](https://www.github.com/googleapis/java-core/issues/464)) ([bb15bf9](https://www.github.com/googleapis/java-core/commit/bb15bf9fb9cf571afc5050e4eaf055e556cb534b)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.2.2 ([#449](https://www.github.com/googleapis/java-core/issues/449)) ([42bf8ea](https://www.github.com/googleapis/java-core/commit/42bf8eae15854e01566bac7e094f9b08f273c24e)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.3.0 ([#458](https://www.github.com/googleapis/java-core/issues/458)) ([eb930c2](https://www.github.com/googleapis/java-core/commit/eb930c2c690e58d0e1c00abe16ee5671a0bb5144)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.3.1 ([#463](https://www.github.com/googleapis/java-core/issues/463)) ([c2b2907](https://www.github.com/googleapis/java-core/commit/c2b29070e5d07b8c7e1d4c76d297d349f6c4d7a3)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.3.2 ([#466](https://www.github.com/googleapis/java-core/issues/466)) ([fd68350](https://www.github.com/googleapis/java-core/commit/fd683505e85dd92f77d4a9723015f610716283f7)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.14 ([#439](https://www.github.com/googleapis/java-core/issues/439)) ([c32bd33](https://www.github.com/googleapis/java-core/commit/c32bd33a9d79bc4388b75842a629c582e1c91526)) +* update dependency com.google.auth:google-auth-library-bom to v0.26.0 ([#456](https://www.github.com/googleapis/java-core/issues/456)) ([97bb7a9](https://www.github.com/googleapis/java-core/commit/97bb7a9c2beb17169de17e2a2d0aa37c051933ee)) +* update dependency com.google.code.gson:gson to v2.8.7 ([#461](https://www.github.com/googleapis/java-core/issues/461)) ([4381e02](https://www.github.com/googleapis/java-core/commit/4381e02d9147440822b2639e59c4d5ca60b4b3c5)) +* update dependency com.google.errorprone:error_prone_annotations to v2.7.1 ([#451](https://www.github.com/googleapis/java-core/issues/451)) ([8bf562f](https://www.github.com/googleapis/java-core/commit/8bf562f42fca37b8d0b14a498f47a2bf8c49277d)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.0 ([#445](https://www.github.com/googleapis/java-core/issues/445)) ([aa9d87c](https://www.github.com/googleapis/java-core/commit/aa9d87ca138714a47c2d4b3e0bca33037a861959)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.1 ([#460](https://www.github.com/googleapis/java-core/issues/460)) ([4edf784](https://www.github.com/googleapis/java-core/commit/4edf7849261c3b427719a434db2c5dc251facc26)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.2 ([#465](https://www.github.com/googleapis/java-core/issues/465)) ([f9b847a](https://www.github.com/googleapis/java-core/commit/f9b847af7d3660de79a2b68abee33842daabddf8)) +* update dependency io.grpc:grpc-bom to v1.38.0 ([#450](https://www.github.com/googleapis/java-core/issues/450)) ([bde03c1](https://www.github.com/googleapis/java-core/commit/bde03c10c2921f8b2bdf47fdaa0a46c277af382a)) + +### [1.94.8](https://www.github.com/googleapis/java-core/compare/v1.94.7...v1.94.8) (2021-04-23) + + +### Bug Fixes + +* release scripts from issuing overlapping phases ([#432](https://www.github.com/googleapis/java-core/issues/432)) ([289bcab](https://www.github.com/googleapis/java-core/commit/289bcab7d8eeffc1671c3cb4c3e8cc4843d90e1a)) +* typo ([#429](https://www.github.com/googleapis/java-core/issues/429)) ([f1ea2f8](https://www.github.com/googleapis/java-core/commit/f1ea2f8568bc7c5ed9b1d495bdd88446aa3c4135)) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.10.3 ([#437](https://www.github.com/googleapis/java-core/issues/437)) ([e853d98](https://www.github.com/googleapis/java-core/commit/e853d98caca3d5f0312a0fb9bbab0ffe4a0ce6e2)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.4 ([#428](https://www.github.com/googleapis/java-core/issues/428)) ([7cc490d](https://www.github.com/googleapis/java-core/commit/7cc490df5e3d24986e7032f5a93a1f844aaa66d5)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.5 ([#435](https://www.github.com/googleapis/java-core/issues/435)) ([7f7f362](https://www.github.com/googleapis/java-core/commit/7f7f3624a3c436c61a366e5e172592838a4078e0)) +* update dependency org.threeten:threetenbp to v1.5.1 ([#433](https://www.github.com/googleapis/java-core/issues/433)) ([af08225](https://www.github.com/googleapis/java-core/commit/af08225277fb436a53a1a65d60a7be80b786da4b)) + +### [1.94.7](https://www.github.com/googleapis/java-core/compare/v1.94.6...v1.94.7) (2021-04-12) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.31.4 ([#424](https://www.github.com/googleapis/java-core/issues/424)) ([6773b81](https://www.github.com/googleapis/java-core/commit/6773b81893ce9f69ce457e3243bd89b49de6e553)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.12 ([#425](https://www.github.com/googleapis/java-core/issues/425)) ([df2ba7a](https://www.github.com/googleapis/java-core/commit/df2ba7a6aa73d2755382d19a4dfd86bdd6fd927a)) + +### [1.94.6](https://www.github.com/googleapis/java-core/compare/v1.94.5...v1.94.6) (2021-04-09) + + +### Dependencies + +* update dependency com.google.http-client:google-http-client-bom to v1.39.2 ([#420](https://www.github.com/googleapis/java-core/issues/420)) ([541355d](https://www.github.com/googleapis/java-core/commit/541355db1e1652bac87ed7ab4f57c3bf2ba5d469)) + +### [1.94.5](https://www.github.com/googleapis/java-core/compare/v1.94.4...v1.94.5) (2021-04-08) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v1.63.0 ([#415](https://www.github.com/googleapis/java-core/issues/415)) ([31d41f3](https://www.github.com/googleapis/java-core/commit/31d41f310db803c5f84e122256850cf3f6722481)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.2 ([#408](https://www.github.com/googleapis/java-core/issues/408)) ([bfb3cae](https://www.github.com/googleapis/java-core/commit/bfb3caee3d056b6fcbc54a83c1eca36cf58ef72a)) +* update dependency com.google.errorprone:error_prone_annotations to v2.6.0 ([#412](https://www.github.com/googleapis/java-core/issues/412)) ([e78e5d9](https://www.github.com/googleapis/java-core/commit/e78e5d9676ebf8bc44af7f81a282c7436878730f)) +* update dependency com.google.http-client:google-http-client-bom to v1.39.1 ([#407](https://www.github.com/googleapis/java-core/issues/407)) ([9ac757f](https://www.github.com/googleapis/java-core/commit/9ac757fa7e121b0db0f66577ed974d6dc24a803a)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.6 ([#405](https://www.github.com/googleapis/java-core/issues/405)) ([a20bce4](https://www.github.com/googleapis/java-core/commit/a20bce416bfa6556bb7c3518afeca5259fdf23f4)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.7 ([#413](https://www.github.com/googleapis/java-core/issues/413)) ([16d2bf5](https://www.github.com/googleapis/java-core/commit/16d2bf54340e78e8ba9765b531d9cd64089d723e)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.8 ([#418](https://www.github.com/googleapis/java-core/issues/418)) ([101910c](https://www.github.com/googleapis/java-core/commit/101910c3edf25ece32fff2408ee09074c2593d18)) +* update dependency io.grpc:grpc-bom to v1.36.1 ([#410](https://www.github.com/googleapis/java-core/issues/410)) ([e31620a](https://www.github.com/googleapis/java-core/commit/e31620a2f7a15853a1acec8c09416953cc4dce09)) +* update dependency io.grpc:grpc-bom to v1.37.0 ([#416](https://www.github.com/googleapis/java-core/issues/416)) ([690fe8f](https://www.github.com/googleapis/java-core/commit/690fe8fe44b99b6b81175cef4797174ee28b7dac)) +* update guava ([#417](https://www.github.com/googleapis/java-core/issues/417)) ([acaa804](https://www.github.com/googleapis/java-core/commit/acaa804a740c1dbf95498db92e0627339f91dc6f)) + +### [1.94.4](https://www.github.com/googleapis/java-core/compare/v1.94.3...v1.94.4) (2021-03-11) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.11 ([#402](https://www.github.com/googleapis/java-core/issues/402)) ([73d893c](https://www.github.com/googleapis/java-core/commit/73d893c76ab1bef3b69bd55040d9f6c5942b36c5)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.5 ([#399](https://www.github.com/googleapis/java-core/issues/399)) ([a9c2e43](https://www.github.com/googleapis/java-core/commit/a9c2e43e06fcf2f15918359db765fb44d5e28a55)) + +### [1.94.3](https://www.github.com/googleapis/java-core/compare/v1.94.2...v1.94.3) (2021-03-02) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.31.3 ([#394](https://www.github.com/googleapis/java-core/issues/394)) ([278cb03](https://www.github.com/googleapis/java-core/commit/278cb032dd201a9729ef6a6e6e3c177bf9b3cd7e)) +* update dependency com.google.auth:google-auth-library-bom to v0.24.1 ([#390](https://www.github.com/googleapis/java-core/issues/390)) ([9948791](https://www.github.com/googleapis/java-core/commit/99487914834709cd97b283c59ac14fb7b945c9e7)) + +### [1.94.2](https://www.github.com/googleapis/java-core/compare/v1.94.1...v1.94.2) (2021-03-01) + + +### Bug Fixes + +* fix gcloud SDK detection on Windows ([#384](https://www.github.com/googleapis/java-core/issues/384)) ([9545442](https://www.github.com/googleapis/java-core/commit/9545442906b21897c5227fecf8efd264d7c2d84c)), closes [#383](https://www.github.com/googleapis/java-core/issues/383) + + +### Dependencies + +* switch from Jackson to GSON ([#368](https://www.github.com/googleapis/java-core/issues/368)) ([220df17](https://www.github.com/googleapis/java-core/commit/220df176826fe154e36dadd19702c307cc232c16)) +* update dependency com.google.api-client:google-api-client-bom to v1.31.2 ([#359](https://www.github.com/googleapis/java-core/issues/359)) ([107a32a](https://www.github.com/googleapis/java-core/commit/107a32aa170eca0f61e14183af1e795a61291d49)) +* update dependency com.google.api:gax-bom to v1.62.0 ([2374ca7](https://www.github.com/googleapis/java-core/commit/2374ca77df96976c3920963e0e97e9fabd07b625)) +* update dependency com.google.api.grpc:proto-google-common-protos to v2.1.0 ([#387](https://www.github.com/googleapis/java-core/issues/387)) ([c55f950](https://www.github.com/googleapis/java-core/commit/c55f95038865d262b58f5b5c9847df75160876d2)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.10 ([#392](https://www.github.com/googleapis/java-core/issues/392)) ([45b5abf](https://www.github.com/googleapis/java-core/commit/45b5abf7692cc0d7f2c03170b7ec47a6408ccfad)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.5 ([#345](https://www.github.com/googleapis/java-core/issues/345)) ([0a5596d](https://www.github.com/googleapis/java-core/commit/0a5596d8fb5a398b56c7dce07e13d534e3b6c208)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.7 ([#357](https://www.github.com/googleapis/java-core/issues/357)) ([3c2b7b4](https://www.github.com/googleapis/java-core/commit/3c2b7b490c64625ecf9846b097aebcc577511696)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.9 ([#372](https://www.github.com/googleapis/java-core/issues/372)) ([82840da](https://www.github.com/googleapis/java-core/commit/82840da9e99f49471c30f2a95f0d06ae17a76507)) +* update dependency com.google.auth:google-auth-library-bom to v0.22.2 ([#343](https://www.github.com/googleapis/java-core/issues/343)) ([3b418f7](https://www.github.com/googleapis/java-core/commit/3b418f7ae6677e9e44546e7108d985dfbbedbfa4)) +* update dependency com.google.auth:google-auth-library-bom to v0.23.0 ([#364](https://www.github.com/googleapis/java-core/issues/364)) ([7d52e06](https://www.github.com/googleapis/java-core/commit/7d52e06e2df4a0c69f018e3f7dadfc166a5754be)) +* update dependency com.google.auth:google-auth-library-bom to v0.24.0 ([#382](https://www.github.com/googleapis/java-core/issues/382)) ([44d8d02](https://www.github.com/googleapis/java-core/commit/44d8d029e7f15efa3dfbf3df49f48f14a8375a6b)) +* update dependency com.google.errorprone:error_prone_annotations to v2.5.1 ([#354](https://www.github.com/googleapis/java-core/issues/354)) ([e7a688c](https://www.github.com/googleapis/java-core/commit/e7a688c3a20f0c17806ab25c528d69bcafd287c8)) +* update dependency com.google.guava:guava-bom to v30.1-android ([#348](https://www.github.com/googleapis/java-core/issues/348)) ([0f2eadd](https://www.github.com/googleapis/java-core/commit/0f2eadd32020b546e71332bf4009e4c9195ee72a)) +* update dependency com.google.http-client:google-http-client-bom to v1.38.1 ([#358](https://www.github.com/googleapis/java-core/issues/358)) ([8fdc254](https://www.github.com/googleapis/java-core/commit/8fdc2549c9ed15e347e282077b9e36159bd32a2e)) +* update dependency com.google.http-client:google-http-client-bom to v1.39.0 ([2374ca7](https://www.github.com/googleapis/java-core/commit/2374ca77df96976c3920963e0e97e9fabd07b625)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.0 ([#378](https://www.github.com/googleapis/java-core/issues/378)) ([4314da9](https://www.github.com/googleapis/java-core/commit/4314da9fc62eb6e57b0265a6ff4663c450e0ad9f)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.1 ([#381](https://www.github.com/googleapis/java-core/issues/381)) ([09fac9d](https://www.github.com/googleapis/java-core/commit/09fac9d078d8d00716500deabfdecfcecab891ea)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.2 ([#385](https://www.github.com/googleapis/java-core/issues/385)) ([8c2c179](https://www.github.com/googleapis/java-core/commit/8c2c1792df60b9e077534328fc5351c63a745b09)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.3 ([#391](https://www.github.com/googleapis/java-core/issues/391)) ([6e03ce5](https://www.github.com/googleapis/java-core/commit/6e03ce5b571464f8f62a4b4665f21efb527b112a)) +* update dependency io.grpc:grpc-bom to v1.34.1 ([#342](https://www.github.com/googleapis/java-core/issues/342)) ([b80c3da](https://www.github.com/googleapis/java-core/commit/b80c3da61e5b158c78358566289800bea0f8997b)) +* update dependency opencensus to v0.28.0 ([2374ca7](https://www.github.com/googleapis/java-core/commit/2374ca77df96976c3920963e0e97e9fabd07b625)) +* update io.grpc:grpc-bom to v1.36.0 ([#389](https://www.github.com/googleapis/java-core/issues/389)) ([2374ca7](https://www.github.com/googleapis/java-core/commit/2374ca77df96976c3920963e0e97e9fabd07b625)) + +### [1.94.1](https://www.github.com/googleapis/java-core/compare/v1.94.0...v1.94.1) (2020-12-11) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.31.1 ([#331](https://www.github.com/googleapis/java-core/issues/331)) ([e01ec17](https://www.github.com/googleapis/java-core/commit/e01ec179163dfc0069ae34680abaef30b00e05e1)) +* update dependency com.google.api:gax-bom to v1.60.1 ([#340](https://www.github.com/googleapis/java-core/issues/340)) ([e3219b4](https://www.github.com/googleapis/java-core/commit/e3219b46a6a83a95795b77516426859959406d3a)) +* update dependency com.google.protobuf:protobuf-bom to v3.14.0 ([#335](https://www.github.com/googleapis/java-core/issues/335)) ([0fc6971](https://www.github.com/googleapis/java-core/commit/0fc6971a23f720102156de3bbcfe38eeff15fd94)) + +## [1.94.0](https://www.github.com/googleapis/java-core/compare/v1.93.10...v1.94.0) (2020-11-10) + + +### Features + +* **test:** add new MultipleAttemptRule, StdOutCaptureRule & StdErrCaptureRule JUnit 4 rules ([#327](https://www.github.com/googleapis/java-core/issues/327)) ([60f4a66](https://www.github.com/googleapis/java-core/commit/60f4a66ad907f4a838536e405326869487468f35)) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-common-protos to v2.0.1 ([#323](https://www.github.com/googleapis/java-core/issues/323)) ([4b989e8](https://www.github.com/googleapis/java-core/commit/4b989e802f773794babd2403253c81d528c6f661)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.3 ([#324](https://www.github.com/googleapis/java-core/issues/324)) ([a40c71a](https://www.github.com/googleapis/java-core/commit/a40c71ab678c3ec267d43b5cb434b7cb302d1b7e)) +* update dependency com.google.http-client:google-http-client-bom to v1.38.0 ([#325](https://www.github.com/googleapis/java-core/issues/325)) ([48f1da7](https://www.github.com/googleapis/java-core/commit/48f1da709dbfbcffd8faad1f2342c85475ec4e93)) +* update dependency io.grpc:grpc-bom to v1.33.1 ([#319](https://www.github.com/googleapis/java-core/issues/319)) ([8a788a6](https://www.github.com/googleapis/java-core/commit/8a788a606c8a397121a4177e1004ddf582e112ae)) + +### [1.93.10](https://www.github.com/googleapis/java-core/compare/v1.93.9...v1.93.10) (2020-10-30) + + +### Dependencies + +* update core dependencies ([#294](https://www.github.com/googleapis/java-core/issues/294)) ([dcb6a67](https://www.github.com/googleapis/java-core/commit/dcb6a6767d245ac134a1985c450c7ce5a2f2ee29)) +* update core transport dependencies ([#295](https://www.github.com/googleapis/java-core/issues/295)) ([341c032](https://www.github.com/googleapis/java-core/commit/341c032e98c8aac1b6f82a2d026374eaa5cc4c3e)) +* update dependency com.google.api:api-common to v1.10.1 ([#302](https://www.github.com/googleapis/java-core/issues/302)) ([34260c0](https://www.github.com/googleapis/java-core/commit/34260c0befd0ff858c075cfd58da022a3d083ea9)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.2 ([#312](https://www.github.com/googleapis/java-core/issues/312)) ([16e375a](https://www.github.com/googleapis/java-core/commit/16e375abfb6d0bd41c42a785a3b7c19a2e71c483)) +* update dependency com.google.guava:guava-bom to v30 ([#310](https://www.github.com/googleapis/java-core/issues/310)) ([17962f8](https://www.github.com/googleapis/java-core/commit/17962f84301f6d630bc6cc85dcb5ebeb24d94561)) +* update dependency io.grpc:grpc-bom to v1.33.0 ([#309](https://www.github.com/googleapis/java-core/issues/309)) ([e9ac780](https://www.github.com/googleapis/java-core/commit/e9ac780d218928d78ba1fc225576dfe47d85bb8d)) +* update dependency org.threeten:threetenbp to v1.4.5 ([#297](https://www.github.com/googleapis/java-core/issues/297)) ([a0b878f](https://www.github.com/googleapis/java-core/commit/a0b878f8eeebb7e06efb6f8fc8e887d3ddb3e467)) +* update dependency org.threeten:threetenbp to v1.5.0 ([#314](https://www.github.com/googleapis/java-core/issues/314)) ([485b30f](https://www.github.com/googleapis/java-core/commit/485b30f47db8e18d153e6b27db9d39080aee285c)) + +### [1.93.9](https://www.github.com/googleapis/java-core/compare/v1.93.8...v1.93.9) (2020-09-23) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.1 ([#282](https://www.github.com/googleapis/java-core/issues/282)) ([933172c](https://www.github.com/googleapis/java-core/commit/933172c835593ad13c4ae85c0c467b2823ca44da)) +* update dependency com.google.protobuf:protobuf-bom to v3.13.0 ([#273](https://www.github.com/googleapis/java-core/issues/273)) ([4476f33](https://www.github.com/googleapis/java-core/commit/4476f33cab440ff2dcc12597f968d9d719d46e5b)) +* update dependency io.grpc:grpc-bom to v1.32.1 ([#270](https://www.github.com/googleapis/java-core/issues/270)) ([df518d3](https://www.github.com/googleapis/java-core/commit/df518d3445df07811d9be9770f120315af0100b1)) + +### [1.93.8](https://www.github.com/googleapis/java-core/compare/v1.93.7...v1.93.8) (2020-08-12) + + +### Bug Fixes + +* docs of com.google.cloud.Timestamp.parseTimestamp ([#258](https://www.github.com/googleapis/java-core/issues/258)) ([964dd14](https://www.github.com/googleapis/java-core/commit/964dd142609ae8923a285e20746ce9ee8c302bd5)) + + +### Dependencies + +* update core dependencies ([#263](https://www.github.com/googleapis/java-core/issues/263)) ([44023c3](https://www.github.com/googleapis/java-core/commit/44023c34d0b5d1990c5028f6e04479b8d7539e77)) +* update dependency com.google.api-client:google-api-client-bom to v1.30.10 ([#253](https://www.github.com/googleapis/java-core/issues/253)) ([0fd53fe](https://www.github.com/googleapis/java-core/commit/0fd53fe522e35fdd09783bb618ff7dcf01d82a95)) +* update dependency com.google.api:api-common to v1.10.0 ([#261](https://www.github.com/googleapis/java-core/issues/261)) ([1414e01](https://www.github.com/googleapis/java-core/commit/1414e01a8154533d53911933eb86fc785760af6c)) +* update dependency com.google.api.grpc:proto-google-common-protos to v1.18.1 ([#268](https://www.github.com/googleapis/java-core/issues/268)) ([b59a83c](https://www.github.com/googleapis/java-core/commit/b59a83c212f862043de0f5f8fa6ae7bb5d2baba4)) +* update dependency com.google.api.grpc:proto-google-iam-v1 to v1 ([#269](https://www.github.com/googleapis/java-core/issues/269)) ([fe3987e](https://www.github.com/googleapis/java-core/commit/fe3987e2dffb2fe7b7bdd0d48266eba7aad7929b)) +* update dependency com.google.protobuf:protobuf-bom to v3.12.4 ([#262](https://www.github.com/googleapis/java-core/issues/262)) ([2ffca65](https://www.github.com/googleapis/java-core/commit/2ffca65399a716a0b929ae3f1ae388481b187ae2)) + +### [1.93.7](https://www.github.com/googleapis/java-core/compare/v1.93.6...v1.93.7) (2020-07-08) + + +### Dependencies + +* update core dependencies ([#241](https://www.github.com/googleapis/java-core/issues/241)) ([60a4a05](https://www.github.com/googleapis/java-core/commit/60a4a054d54119807aa8d0342f76d2925c35f2a6)) +* update dependency com.google.api:api-common to v1.9.3 ([#250](https://www.github.com/googleapis/java-core/issues/250)) ([792cb60](https://www.github.com/googleapis/java-core/commit/792cb6016cf3d509667e3b03b5f25847c0430af8)) +* update dependency com.google.api:gax-bom to v1.57.1 ([#251](https://www.github.com/googleapis/java-core/issues/251)) ([dd1a8a9](https://www.github.com/googleapis/java-core/commit/dd1a8a9814f244b2516283d23938f8f49a92f190)) +* update dependency com.google.auth:google-auth-library-bom to v0.21.1 ([#252](https://www.github.com/googleapis/java-core/issues/252)) ([4844b26](https://www.github.com/googleapis/java-core/commit/4844b268e81b69e409f887272f3bed30709ec33d)) +* update dependency com.google.errorprone:error_prone_annotations to v2.4.0 ([#226](https://www.github.com/googleapis/java-core/issues/226)) ([b2fd33c](https://www.github.com/googleapis/java-core/commit/b2fd33c3a1dfa8269f67986211af5f93bacdfad9)) +* update dependency com.google.http-client:google-http-client-bom to v1.36.0 ([#248](https://www.github.com/googleapis/java-core/issues/248)) ([34deaf9](https://www.github.com/googleapis/java-core/commit/34deaf94190cfa2aa9dee5edabbe6bf5dccb0a90)) + +### [1.93.6](https://www.github.com/googleapis/java-core/compare/v1.93.5...v1.93.6) (2020-06-12) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.9.1 ([#221](https://www.github.com/googleapis/java-core/issues/221)) ([4df33f0](https://www.github.com/googleapis/java-core/commit/4df33f0da02855161562e80a9d50e52dc21f4693)) +* update dependency com.google.api:api-common to v1.9.2 ([#229](https://www.github.com/googleapis/java-core/issues/229)) ([e8c1aa2](https://www.github.com/googleapis/java-core/commit/e8c1aa2ff9c1eaa4030faa86b403a77fc6602bdb)) +* update dependency com.google.api:gax-bom to v1.57.0 ([#236](https://www.github.com/googleapis/java-core/issues/236)) ([3d7d2a6](https://www.github.com/googleapis/java-core/commit/3d7d2a69ea95d7cd93f1175e0cc7f051fd591ad8)) +* update dependency com.google.protobuf:protobuf-bom to v3.12.2 ([#220](https://www.github.com/googleapis/java-core/issues/220)) ([815569d](https://www.github.com/googleapis/java-core/commit/815569d7274cccd12110062e72dc8774f3b1d3de)) +* update dependency io.grpc:grpc-bom to v1.30.0 ([#233](https://www.github.com/googleapis/java-core/issues/233)) ([b41c34f](https://www.github.com/googleapis/java-core/commit/b41c34f28a2cddddafbb872bbd0100a934972042)) + +### [1.93.5](https://www.github.com/googleapis/java-core/compare/v1.93.4...v1.93.5) (2020-05-26) + + +### Dependencies + +* rely on shared-config for auto-value configuration ([#222](https://www.github.com/googleapis/java-core/issues/222)) ([22adbcf](https://www.github.com/googleapis/java-core/commit/22adbcf307cf5ef4819bad9afa91c4c83a9f31bb)) +* update dependency com.google.api.grpc:proto-google-common-protos to v1.18.0 ([#215](https://www.github.com/googleapis/java-core/issues/215)) ([488a351](https://www.github.com/googleapis/java-core/commit/488a351ab41adafb1d969740bfbd3a6d2ddfd36d)) +* update dependency com.google.guava:guava-bom to v29 ([#205](https://www.github.com/googleapis/java-core/issues/205)) ([48d3f97](https://www.github.com/googleapis/java-core/commit/48d3f970bd931ee5f04205ab939c318c69cbcf3f)) +* update dependency com.google.http-client:google-http-client-bom to v1.35.0 ([#211](https://www.github.com/googleapis/java-core/issues/211)) ([e56b3ef](https://www.github.com/googleapis/java-core/commit/e56b3ef0e2ea5c96b36f8aae851fd26efe1337c1)) +* update dependency com.google.protobuf:protobuf-bom to v3.12.0 ([#218](https://www.github.com/googleapis/java-core/issues/218)) ([b2c6f15](https://www.github.com/googleapis/java-core/commit/b2c6f15ae63302dbeea16ecb7d7b89404907516f)) +* update dependency io.grpc:grpc-bom to v1.29.0 ([#209](https://www.github.com/googleapis/java-core/issues/209)) ([e63cb7c](https://www.github.com/googleapis/java-core/commit/e63cb7ca69e49afae50af1f2cf4fe3601984be49)) +* update dependency org.threeten:threetenbp to v1.4.4 ([#210](https://www.github.com/googleapis/java-core/issues/210)) ([a837fa4](https://www.github.com/googleapis/java-core/commit/a837fa441fbbf83494709b1779e0ef35ef13b345)) + +### [1.93.4](https://www.github.com/googleapis/java-core/compare/v1.93.3...v1.93.4) (2020-04-06) + + +### Dependencies + +* update core dependencies ([#198](https://www.github.com/googleapis/java-core/issues/198)) ([129b3f8](https://www.github.com/googleapis/java-core/commit/129b3f8b03e6809bcae9545a6c2484aa8acc2447)) +* update dependency com.google.api:api-common to v1.9.0 ([#195](https://www.github.com/googleapis/java-core/issues/195)) ([ac19258](https://www.github.com/googleapis/java-core/commit/ac192586f086b91f479e85e4677ac2d10f10968a)) +* update dependency com.google.api:gax-bom to v1.56.0 ([#201](https://www.github.com/googleapis/java-core/issues/201)) ([875c4ed](https://www.github.com/googleapis/java-core/commit/875c4ed001193dfe2c301ad7f163395a568bcb10)) +* update dependency org.threeten:threetenbp to v1.4.3 ([#192](https://www.github.com/googleapis/java-core/issues/192)) ([ce6ec17](https://www.github.com/googleapis/java-core/commit/ce6ec179e4024264c0aee09f85f6f60218d46138)) + +### [1.93.3](https://www.github.com/googleapis/java-core/compare/v1.93.2...v1.93.3) (2020-03-16) + + +### Bug Fixes + +* fix Timestamp.of(java.sql.Timestamp) pre-epoch on exact second ([#179](https://www.github.com/googleapis/java-core/issues/179)) ([9bfb54c](https://www.github.com/googleapis/java-core/commit/9bfb54c5a88c906bebcf90f81ed19aeece09befd)) +* retry SSLException ([#183](https://www.github.com/googleapis/java-core/issues/183)) ([775a848](https://www.github.com/googleapis/java-core/commit/775a84877ef69d22ca7a4392edd0d3680df2256e)) + + +### Dependencies + +* revert gRPC updates ([#181](https://www.github.com/googleapis/java-core/issues/181)) ([f5ba782](https://www.github.com/googleapis/java-core/commit/f5ba782fe7078bd2e02d27d8770ad20a459c73f3)) +* update dependency io.grpc:grpc-bom to v1.28.0 ([#178](https://www.github.com/googleapis/java-core/issues/178)) ([6d5632c](https://www.github.com/googleapis/java-core/commit/6d5632c22507d1d3d36a90778291a6fa25b4788b)) + +### [1.93.2](https://www.github.com/googleapis/java-core/compare/v1.93.1...v1.93.2) (2020-03-10) + + +### Bug Fixes + +* verify correctness of map -> list equality ([#174](https://www.github.com/googleapis/java-core/issues/174)) ([f45d913](https://www.github.com/googleapis/java-core/commit/f45d9131d5d2bbb2cc4cec67ebe82054fda58f55)) + +### [1.93.1](https://www.github.com/googleapis/java-core/compare/v1.93.0...v1.93.1) (2020-02-28) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.30.9 ([#171](https://www.github.com/googleapis/java-core/issues/171)) ([1fdcd5e](https://www.github.com/googleapis/java-core/commit/1fdcd5e839049f650ba7ebb003dea62511c8667f)) + +## [1.93.0](https://www.github.com/googleapis/java-core/compare/v1.92.6...v1.93.0) (2020-02-27) + + +### Features + +* support conditional policies ([#110](https://www.github.com/googleapis/java-core/issues/110)) ([61e2d19](https://www.github.com/googleapis/java-core/commit/61e2d19bb4400978681aa018a8dc200214203830)) + + +### Bug Fixes + +* fix conversion for pre-epoch timestamps ([#160](https://www.github.com/googleapis/java-core/issues/160)) ([1f8b6b4](https://www.github.com/googleapis/java-core/commit/1f8b6b4835aaa702ec94bbbde89ed90f519c935a)) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v1.54.0 ([#168](https://www.github.com/googleapis/java-core/issues/168)) ([5b52f9e](https://www.github.com/googleapis/java-core/commit/5b52f9e8d8cdc82b56114d3d1e857d137ae7ca98)) +* update dependency io.grpc:grpc-bom to v1.27.2 ([#166](https://www.github.com/googleapis/java-core/issues/166)) ([28c9859](https://www.github.com/googleapis/java-core/commit/28c98595c9ee96760a063085bd85024177bd6dd2)) + +### [1.92.5](https://www.github.com/googleapis/java-core/compare/v1.92.4...v1.92.5) (2020-02-10) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.30.8 ([#146](https://www.github.com/googleapis/java-core/issues/146)) ([1d9c7db](https://www.github.com/googleapis/java-core/commit/1d9c7db40502eff9723f27c24be31ecc2fac9c5d)) +* update dependency com.google.protobuf:protobuf-bom to v3.11.3 ([#148](https://www.github.com/googleapis/java-core/issues/148)) ([092c69b](https://www.github.com/googleapis/java-core/commit/092c69bef5b10cf27ef6770e90ae8e50ea205dcd)) + +### [1.92.4](https://www.github.com/googleapis/java-core/compare/v1.92.3...v1.92.4) (2020-01-31) + + +### Dependencies + +* update core dependencies ([#143](https://www.github.com/googleapis/java-core/issues/143)) ([454ce1d](https://www.github.com/googleapis/java-core/commit/454ce1dc5a6a41f3333a2a5303315cd9eb66f442)) + +### [1.92.3](https://www.github.com/googleapis/java-core/compare/v1.92.2...v1.92.3) (2020-01-28) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v1.53.0 ([#126](https://www.github.com/googleapis/java-core/issues/126)) ([bdb1bce](https://www.github.com/googleapis/java-core/commit/bdb1bceb63502c828a37dd50fdb3e0e2204fc0aa)) +* update dependency com.google.auth:google-auth-library-bom to v0.20.0 ([#135](https://www.github.com/googleapis/java-core/issues/135)) ([f40c636](https://www.github.com/googleapis/java-core/commit/f40c6365b1b19bc3360b0094599311bc3271f0e5)) +* update dependency com.google.http-client:google-http-client-bom to v1.34.1 ([#137](https://www.github.com/googleapis/java-core/issues/137)) ([9216702](https://www.github.com/googleapis/java-core/commit/92167026d8e4178ebb952490a3322bd685441a60)) +* update dependency org.threeten:threetenbp to v1.4.1 ([82cac64](https://www.github.com/googleapis/java-core/commit/82cac64486352e46ddc6044a72fff6141d9b10ce)) + +### [1.92.2](https://www.github.com/googleapis/java-core/compare/v1.92.1...v1.92.2) (2020-01-09) + + +### Bug Fixes + +* cast to proper interface ([#124](https://www.github.com/googleapis/java-core/issues/124)) ([cd6eabf](https://www.github.com/googleapis/java-core/commit/cd6eabffcdeed485aba088336fa473a6b85c752d)), closes [#123](https://www.github.com/googleapis/java-core/issues/123) + +### [1.92.1](https://www.github.com/googleapis/java-core/compare/v1.92.0...v1.92.1) (2020-01-02) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_annotations to v2.3.4 ([#105](https://www.github.com/googleapis/java-core/issues/105)) ([52f47c5](https://www.github.com/googleapis/java-core/commit/52f47c5ed84742b4b41417c486bfbb3c817b4a23)) +* update dependency com.google.guava:guava-bom to v28.2-android ([#113](https://www.github.com/googleapis/java-core/issues/113)) ([8b11b1a](https://www.github.com/googleapis/java-core/commit/8b11b1a8d452ab823f35509ae42263c4a69f2a5a)) +* update dependency com.google.http-client:google-http-client-bom to v1.34.0 ([#98](https://www.github.com/googleapis/java-core/issues/98)) ([d8e946d](https://www.github.com/googleapis/java-core/commit/d8e946dfd3866380406b02ad908925c4250cc34a)) +* update dependency com.google.protobuf:protobuf-bom to v3.11.1 ([#106](https://www.github.com/googleapis/java-core/issues/106)) ([6d36434](https://www.github.com/googleapis/java-core/commit/6d364341bc5552e98590f9344b0e2d8cf4e68f0c)) +* update dependency io.grpc:grpc-bom to v1.26.0 ([#107](https://www.github.com/googleapis/java-core/issues/107)) ([fca41a7](https://www.github.com/googleapis/java-core/commit/fca41a73fb6ca42eb4014d3cec6b32cc8e97ded9)) + +## [1.92.0](https://www.github.com/googleapis/java-core/compare/v1.91.3...v1.92.0) (2019-12-13) + + +### Features + +* increase DEFAULT_CHUNK_SIZE to reduce transfer overhead ([#87](https://www.github.com/googleapis/java-core/issues/87)) ([09b327d](https://www.github.com/googleapis/java-core/commit/09b327daf764403b7800180cab79ae3e38815075)) +* support setting ServiceOption for quota project ([#92](https://www.github.com/googleapis/java-core/issues/92)) ([6aa4476](https://www.github.com/googleapis/java-core/commit/6aa4476441fd7636dd116516d3bf4b738cf8a8a9)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.30.5 ([#68](https://www.github.com/googleapis/java-core/issues/68)) ([e1a4047](https://www.github.com/googleapis/java-core/commit/e1a4047fb470ea4f80459ca0bb399f4ab2c7decf)) +* update dependency com.google.api:gax-bom to v1.50.1 ([#73](https://www.github.com/googleapis/java-core/issues/73)) ([f493b5b](https://www.github.com/googleapis/java-core/commit/f493b5bbe5945202af6a94fe01407f795014b4a1)) +* update dependency com.google.api:gax-bom to v1.51.0 ([#85](https://www.github.com/googleapis/java-core/issues/85)) ([71d0de7](https://www.github.com/googleapis/java-core/commit/71d0de782432814971facb7cbb67acdec5e45f00)) +* update dependency com.google.auth:google-auth-library-bom to v0.19.0 ([#93](https://www.github.com/googleapis/java-core/issues/93)) ([b465630](https://www.github.com/googleapis/java-core/commit/b465630023dc87537a02a34fb957be340aeb6078)) +* update dependency com.google.http-client:google-http-client-bom to v1.33.0 ([#71](https://www.github.com/googleapis/java-core/issues/71)) ([8f1e690](https://www.github.com/googleapis/java-core/commit/8f1e690611e98855d0eed26d7ef75120bccc862e)) +* update dependency io.grpc:grpc-bom to v1.25.0 ([#72](https://www.github.com/googleapis/java-core/issues/72)) ([3a09fc7](https://www.github.com/googleapis/java-core/commit/3a09fc7c4ce73a3c4f144d0cd4da6d29a1664b75)) +* update to threetenbp 1.4.0 ([#89](https://www.github.com/googleapis/java-core/issues/89)) ([5128bd4](https://www.github.com/googleapis/java-core/commit/5128bd45bae8cbb8540eccd683f5bba52783feef)) + +### [1.91.3](https://www.github.com/googleapis/java-core/compare/v1.91.2...v1.91.3) (2019-10-23) + + +### Bug Fixes + +* try to keep autovalue out of the runtime time classpath ([#48](https://www.github.com/googleapis/java-core/issues/48)) ([0988c27](https://www.github.com/googleapis/java-core/commit/0988c27b01461a0b8c02ac0f9def5b409c56980c)) + + +### Dependencies + +* update dependency com.google.api:gax-bom to v1.49.1 ([#65](https://www.github.com/googleapis/java-core/issues/65)) ([131a0fd](https://www.github.com/googleapis/java-core/commit/131a0fd52bebdd217bdcb288374127cef7889692)) +* update dependency com.google.api.grpc:proto-google-common-protos to v1.17.0 ([#50](https://www.github.com/googleapis/java-core/issues/50)) ([3ba5512](https://www.github.com/googleapis/java-core/commit/3ba55124247b82061781c4ae0acb08cec239afe4)) +* update dependency com.google.auth:google-auth-library-bom to v0.18.0 ([#56](https://www.github.com/googleapis/java-core/issues/56)) ([ab25f15](https://www.github.com/googleapis/java-core/commit/ab25f153021f73b5f0ce5cc2cf0b53d42a1871c7)) +* update dependency io.grpc:grpc-bom to v1.24.1 ([07fefbb](https://www.github.com/googleapis/java-core/commit/07fefbb38de93c2b3b5095bc5432bc5161bb7094)) + +### [1.91.2](https://www.github.com/googleapis/java-core/compare/v1.91.1...v1.91.2) (2019-09-30) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-iam-v1 to v0.13.0 ([#40](https://www.github.com/googleapis/java-core/issues/40)) ([4f500cc](https://www.github.com/googleapis/java-core/commit/4f500cc)) +* update dependency io.grpc:grpc-bom to v1.24.0 ([#39](https://www.github.com/googleapis/java-core/issues/39)) ([7f6f780](https://www.github.com/googleapis/java-core/commit/7f6f780)) +* update errorprone to 2.3.3 ([#43](https://www.github.com/googleapis/java-core/issues/43)) ([232694c](https://www.github.com/googleapis/java-core/commit/232694c)) + +### [1.91.1](https://www.github.com/googleapis/java-core/compare/v1.91.0...v1.91.1) (2019-09-25) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.30.4 ([#34](https://www.github.com/googleapis/java-core/issues/34)) ([886eda3](https://www.github.com/googleapis/java-core/commit/886eda3)) +* update dependency com.google.auth:google-auth-library-bom to v0.17.2 ([#35](https://www.github.com/googleapis/java-core/issues/35)) ([ae44c72](https://www.github.com/googleapis/java-core/commit/ae44c72)) +* update dependency com.google.http-client:google-http-client-bom to v1.32.1 ([#31](https://www.github.com/googleapis/java-core/issues/31)) ([4bdf09b](https://www.github.com/googleapis/java-core/commit/4bdf09b)) +* update dependency com.google.protobuf:protobuf-bom to v3.10.0 ([#27](https://www.github.com/googleapis/java-core/issues/27)) ([23e4c26](https://www.github.com/googleapis/java-core/commit/23e4c26)) +* update guava to 28.1-android ([#32](https://www.github.com/googleapis/java-core/issues/32)) ([0279479](https://www.github.com/googleapis/java-core/commit/0279479)) + +## [1.91.0](https://www.github.com/googleapis/java-core/compare/v1.90.0...v1.91.0) (2019-09-18) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.30.3 ([#21](https://www.github.com/googleapis/java-core/issues/21)) ([fcd67f8](https://www.github.com/googleapis/java-core/commit/fcd67f8)) +* update opencensus packages to v0.24.0 ([#22](https://www.github.com/googleapis/java-core/issues/22)) ([4b21afa](https://www.github.com/googleapis/java-core/commit/4b21afa)) + + +### Documentation + +* fix Kokoro badge link ([19d79d6](https://www.github.com/googleapis/java-core/commit/19d79d6)) +* fix README versions and CI Status table ([6e3ccf3](https://www.github.com/googleapis/java-core/commit/6e3ccf3)) +* update README with a better project description ([#17](https://www.github.com/googleapis/java-core/issues/17)) ([018d4d5](https://www.github.com/googleapis/java-core/commit/018d4d5)) + + +### Features + +* add google-cloud-core-bom artifact ([#13](https://www.github.com/googleapis/java-core/issues/13)) ([3cb19a0](https://www.github.com/googleapis/java-core/commit/3cb19a0)) diff --git a/java-core/README.md b/java-core/README.md new file mode 100644 index 000000000000..d38313884e0f --- /dev/null +++ b/java-core/README.md @@ -0,0 +1,52 @@ +# Google Cloud Java Client -- Core + +A set of classes and utilities used in Google Cloud Java libraries. + +*Note*: This library is only meant to be consumed by other Google Libraries. + +[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-core.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-core.svg) + +- [API Documentation][api-docs] + +## Java Versions + +Java 7 or above is required for using this client. + +## Contributing + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING][contributing] documentation for more information on how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + +## Versioning + +This library follows [Semantic Versioning][semver]. + +It is currently in major version one (``1.y.z``), which means that the public API should be +considered stable. + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +## CI Status + +Java Version | Status +------------ | ------ +Java 7 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java7.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java7.html) +Java 8 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java8.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java8.html) +Java 8 OSX | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java8-osx.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java8-osx.html) +Java 8 Windows | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java8-win.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java8-win.html) +Java 11 | [![Kokoro CI](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java11.svg)](https://storage.googleapis.com/cloud-devrel-public/java/badges/java-core/java11.html) + + +[contributing]: https://github.com/googleapis/java-core/blob/main/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/java-core/blob/main/CODE_OF_CONDUCT.md +[license]: https://github.com/googleapis/java-core/blob/main/LICENSE +[semver]: http://semver.org/ +[cloud-platform]: https://cloud.google.com/ +[api-docs]: https://googleapis.dev/java/google-cloud-core/latest diff --git a/java-core/google-cloud-core-bom/pom.xml b/java-core/google-cloud-core-bom/pom.xml new file mode 100644 index 000000000000..66b16c7773f6 --- /dev/null +++ b/java-core/google-cloud-core-bom/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + com.google.cloud + google-cloud-core-bom + 2.9.5-SNAPSHOT + pom + + + com.google.cloud + google-cloud-pom-parent + 1.4.0-SNAPSHOT + ../../google-cloud-pom-parent/pom.xml + + + Google Cloud Core + + BOM for Google Cloud Core + + + + + + com.google.cloud + google-cloud-core + 2.9.5-SNAPSHOT + + + com.google.cloud + google-cloud-core-grpc + 2.9.5-SNAPSHOT + + + com.google.cloud + google-cloud-core-http + 2.9.5-SNAPSHOT + + + + diff --git a/java-core/google-cloud-core-grpc/pom.xml b/java-core/google-cloud-core-grpc/pom.xml new file mode 100644 index 000000000000..f60066a72970 --- /dev/null +++ b/java-core/google-cloud-core-grpc/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + com.google.cloud + google-cloud-core-grpc + 2.9.5-SNAPSHOT + jar + Google Cloud Core gRPC + + Core gRPC module for the google-cloud. + + + com.google.cloud + google-cloud-core-parent + 2.9.5-SNAPSHOT + + + google-cloud-core-grpc + + + + com.google.auth + google-auth-library-credentials + + + com.google.cloud + google-cloud-core + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax-grpc + + + com.google.api + api-common + + + io.grpc + grpc-api + + + com.google.http-client + google-http-client + + + junit + junit + test + + + org.easymock + easymock + test + + + diff --git a/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java new file mode 100644 index 000000000000..dffa4d37ee63 --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/BaseGrpcServiceException.java @@ -0,0 +1,85 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import com.google.api.client.http.HttpResponseException; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.rpc.ApiException; +import com.google.cloud.BaseServiceException; +import com.google.common.base.MoreObjects; +import java.io.IOException; +import java.util.Collections; + +/** Base class for all exceptions from grpc-based services. */ +public class BaseGrpcServiceException extends BaseServiceException { + + private static final long serialVersionUID = -2685197215731335549L; + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseGrpcServiceException(String message, Throwable cause, int code, boolean retryable) { + super( + ExceptionData.newBuilder() + .setMessage(message) + .setCause(cause) + .setCode(code) + .setRetryable(retryable) + .build()); + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseGrpcServiceException(IOException exception, boolean idempotent) { + super(makeExceptionData(exception, idempotent)); + } + + private static ExceptionData makeExceptionData(IOException exception, boolean idempotent) { + int code = UNKNOWN_CODE; + Boolean retryable = null; + if (exception instanceof HttpResponseException) { + // In cases where an exception is an instance of HttpResponseException, + // check the status code to determine whether it's retryable + code = ((HttpResponseException) exception).getStatusCode(); + retryable = + BaseServiceException.isRetryable(code, null, idempotent, Collections.emptySet()); + } + return ExceptionData.newBuilder() + .setMessage(exception.getMessage()) + .setCause(exception) + .setRetryable( + MoreObjects.firstNonNull( + retryable, BaseServiceException.isRetryable(idempotent, exception))) + .setCode(code) + .setReason(null) + .setLocation(null) + .setDebugInfo(null) + .build(); + } + + @BetaApi + public BaseGrpcServiceException(ApiException apiException) { + super( + ExceptionData.newBuilder() + .setMessage(apiException.getMessage()) + .setCause(apiException) + .setRetryable(apiException.isRetryable()) + .setCode(apiException.getStatusCode().getCode().getHttpStatusCode()) + .setReason(apiException.getStatusCode().getCode().name()) + .setLocation(null) + .setDebugInfo(null) + .build()); + } +} diff --git a/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java new file mode 100644 index 000000000000..4db83253a3a1 --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/GrpcTransportOptions.java @@ -0,0 +1,206 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import static com.google.common.base.MoreObjects.firstNonNull; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.auth.Credentials; +import com.google.cloud.NoCredentials; +import com.google.cloud.ServiceOptions; +import com.google.cloud.TransportOptions; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.Objects; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** Class representing service options for those services that use gRPC as the transport layer. */ +public class GrpcTransportOptions implements TransportOptions { + + private static final long serialVersionUID = -9049538465533951165L; + private final String executorFactoryClassName; + + private transient ExecutorFactory executorFactory; + + /** Shared thread pool executor. */ + private static final SharedResourceHolder.Resource EXECUTOR = + new SharedResourceHolder.Resource() { + @Override + public ScheduledExecutorService create() { + ScheduledThreadPoolExecutor service = + new ScheduledThreadPoolExecutor( + 8, + new ThreadFactoryBuilder() + .setDaemon(true) + .setNameFormat("grpc-transport-%d") + .build()); + service.setKeepAliveTime(5, TimeUnit.SECONDS); + service.allowCoreThreadTimeOut(true); + service.setRemoveOnCancelPolicy(true); + return service; + } + + @Override + public void close(ScheduledExecutorService instance) { + instance.shutdown(); + } + }; + + /** + * An interface for {@link ExecutorService} factories. Implementations of this interface can be + * used to provide an user-defined executor to execute requests. Any implementation of this + * interface must override the {@code get()} method to return the desired executor. The {@code + * release(executor)} method should be overriden to free resources used by the executor (if + * needed) according to application's logic. + * + *

Implementation must provide a public no-arg constructor. Loading of a factory implementation + * is done via {@link java.util.ServiceLoader}. + * + * @param the {@link ExecutorService} subclass created by this factory + */ + public interface ExecutorFactory { + + /** Gets an executor service instance. */ + T get(); + + /** Releases resources used by the executor and possibly shuts it down. */ + void release(T executor); + } + + @InternalApi + public static class DefaultExecutorFactory implements ExecutorFactory { + + private static final DefaultExecutorFactory INSTANCE = new DefaultExecutorFactory(); + + @Override + public ScheduledExecutorService get() { + return SharedResourceHolder.get(EXECUTOR); + } + + @Override + public synchronized void release(ScheduledExecutorService executor) { + SharedResourceHolder.release(EXECUTOR, executor); + } + } + + /** Builder for {@code GrpcTransportOptions}. */ + public static class Builder { + + private ExecutorFactory executorFactory; + + private Builder() {} + + private Builder(GrpcTransportOptions options) { + executorFactory = options.executorFactory; + } + + public GrpcTransportOptions build() { + return new GrpcTransportOptions(this); + } + + /** + * Sets the scheduled executor factory. This method can be used to provide an user-defined + * scheduled executor to execute requests. + * + * @return the builder + */ + public Builder setExecutorFactory(ExecutorFactory executorFactory) { + this.executorFactory = executorFactory; + return this; + } + } + + @SuppressWarnings("unchecked") + private GrpcTransportOptions(Builder builder) { + executorFactory = + firstNonNull( + builder.executorFactory, + ServiceOptions.getFromServiceLoader( + ExecutorFactory.class, DefaultExecutorFactory.INSTANCE)); + executorFactoryClassName = executorFactory.getClass().getName(); + } + + /** Returns a scheduled executor service provider. */ + public ExecutorFactory getExecutorFactory() { + return executorFactory; + } + + /** Returns a builder for API call settings. */ + @Deprecated + public UnaryCallSettings.Builder getApiCallSettings(RetrySettings retrySettings) { + return UnaryCallSettings.newUnaryCallSettingsBuilder().setRetrySettings(retrySettings); + } + + /** Returns a channel provider from the given default provider. */ + @BetaApi + public static TransportChannelProvider setUpChannelProvider( + InstantiatingGrpcChannelProvider.Builder providerBuilder, + ServiceOptions serviceOptions) { + providerBuilder.setEndpoint(serviceOptions.getHost()); + return providerBuilder.build(); + } + + public static CredentialsProvider setUpCredentialsProvider(ServiceOptions serviceOptions) { + Credentials scopedCredentials = serviceOptions.getScopedCredentials(); + if (scopedCredentials != null && scopedCredentials != NoCredentials.getInstance()) { + return FixedCredentialsProvider.create(scopedCredentials); + } + return NoCredentialsProvider.create(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + @Override + public int hashCode() { + return Objects.hash(executorFactoryClassName); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + GrpcTransportOptions other = (GrpcTransportOptions) obj; + return Objects.equals(executorFactoryClassName, other.executorFactoryClassName); + } + + private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { + input.defaultReadObject(); + executorFactory = ServiceOptions.newInstance(executorFactoryClassName); + } + + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/LogExceptionRunnable.java b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/LogExceptionRunnable.java new file mode 100644 index 000000000000..40fd6884c10a --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/LogExceptionRunnable.java @@ -0,0 +1,58 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Throwables; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * This class was copied from grpc-core to prevent dependence on an unstable API that may be subject + * to changes + * (https://github.com/grpc/grpc-java/blob/d07ecbe037d2705a1c9f4b6345581f860e505b56/core/src/main/java/io/grpc/internal/LogExceptionRunnable.java) + * + *

A simple wrapper for a {@link Runnable} that logs any exception thrown by it, before + * re-throwing it. + */ +final class LogExceptionRunnable implements Runnable { + + private static final Logger log = Logger.getLogger(LogExceptionRunnable.class.getName()); + + private final Runnable task; + + public LogExceptionRunnable(Runnable task) { + this.task = checkNotNull(task, "task"); + } + + @Override + public void run() { + try { + task.run(); + } catch (Throwable t) { + log.log(Level.SEVERE, "Exception while executing runnable " + task, t); + Throwables.throwIfUnchecked(t); + throw new AssertionError(t); + } + } + + @Override + public String toString() { + return "LogExceptionRunnable(" + task + ")"; + } +} diff --git a/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/SharedResourceHolder.java b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/SharedResourceHolder.java new file mode 100644 index 000000000000..c8fc6a886bac --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/main/java/com/google/cloud/grpc/SharedResourceHolder.java @@ -0,0 +1,184 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import java.util.IdentityHashMap; +import java.util.concurrent.*; + +/** + * This class was copied from grpc-core to prevent dependence on an unstable API that may be subject + * to changes + * (https://github.com/grpc/grpc-java/blob/d07ecbe037d2705a1c9f4b6345581f860e505b56/core/src/main/java/io/grpc/internal/SharedResourceHolder.java) + * + *

A holder for shared resource singletons. + * + *

Components like client channels and servers need certain resources, e.g. a thread pool, to + * run. If the user has not provided such resources, these components will use a default one, which + * is shared as a static resource. This class holds these default resources and manages their + * life-cycles. + * + *

A resource is identified by the reference of a {@link Resource} object, which is typically a + * singleton, provided to the get() and release() methods. Each Resource object (not its class) maps + * to an object cached in the holder. + * + *

Resources are ref-counted and shut down after a delay when the ref-count reaches zero. + */ +final class SharedResourceHolder { + static final long DESTROY_DELAY_SECONDS = 1; + + // The sole holder instance. + private static final SharedResourceHolder holder = + new SharedResourceHolder( + new ScheduledExecutorFactory() { + @Override + public ScheduledExecutorService createScheduledExecutor() { + return Executors.newSingleThreadScheduledExecutor( + getThreadFactory("grpc-shared-destroyer-%d", true)); + } + }); + + private final IdentityHashMap, Instance> instances = new IdentityHashMap<>(); + + private final ScheduledExecutorFactory destroyerFactory; + + private ScheduledExecutorService destroyer; + + // Visible to tests that would need to create instances of the holder. + SharedResourceHolder(ScheduledExecutorFactory destroyerFactory) { + this.destroyerFactory = destroyerFactory; + } + + private static ThreadFactory getThreadFactory(String nameFormat, boolean daemon) { + return new ThreadFactoryBuilder().setDaemon(daemon).setNameFormat(nameFormat).build(); + } + + /** + * Try to get an existing instance of the given resource. If an instance does not exist, create a + * new one with the given factory. + * + * @param resource the singleton object that identifies the requested static resource + */ + public static T get(Resource resource) { + return holder.getInternal(resource); + } + + /** + * Releases an instance of the given resource. + * + *

The instance must have been obtained from {@link #get(Resource)}. Otherwise will throw + * IllegalArgumentException. + * + *

Caller must not release a reference more than once. It's advisory that you clear the + * reference to the instance with the null returned by this method. + * + * @param resource the singleton Resource object that identifies the released static resource + * @param instance the released static resource + * @return a null which the caller can use to clear the reference to that instance. + */ + public static T release(final Resource resource, final T instance) { + return holder.releaseInternal(resource, instance); + } + + /** + * Visible to unit tests. + * + * @see #get(Resource) + */ + @SuppressWarnings("unchecked") + synchronized T getInternal(Resource resource) { + Instance instance = instances.get(resource); + if (instance == null) { + instance = new Instance(resource.create()); + instances.put(resource, instance); + } + if (instance.destroyTask != null) { + instance.destroyTask.cancel(false); + instance.destroyTask = null; + } + instance.refcount++; + return (T) instance.payload; + } + + /** Visible to unit tests. */ + synchronized T releaseInternal(final Resource resource, final T instance) { + final Instance cached = instances.get(resource); + if (cached == null) { + throw new IllegalArgumentException("No cached instance found for " + resource); + } + Preconditions.checkArgument(instance == cached.payload, "Releasing the wrong instance"); + Preconditions.checkState(cached.refcount > 0, "Refcount has already reached zero"); + cached.refcount--; + if (cached.refcount == 0) { + Preconditions.checkState(cached.destroyTask == null, "Destroy task already scheduled"); + // Schedule a delayed task to destroy the resource. + if (destroyer == null) { + destroyer = destroyerFactory.createScheduledExecutor(); + } + cached.destroyTask = + destroyer.schedule( + new LogExceptionRunnable( + new Runnable() { + @Override + public void run() { + synchronized (SharedResourceHolder.this) { + // Refcount may have gone up since the task was scheduled. Re-check it. + if (cached.refcount == 0) { + try { + resource.close(instance); + } finally { + instances.remove(resource); + if (instances.isEmpty()) { + destroyer.shutdown(); + destroyer = null; + } + } + } + } + } + }), + DESTROY_DELAY_SECONDS, + TimeUnit.SECONDS); + } + // Always returning null + return null; + } + + /** Defines a resource, and the way to create and destroy instances of it. */ + public interface Resource { + /** Create a new instance of the resource. */ + T create(); + + /** Destroy the given instance. */ + void close(T instance); + } + + interface ScheduledExecutorFactory { + ScheduledExecutorService createScheduledExecutor(); + } + + private static class Instance { + final Object payload; + int refcount; + ScheduledFuture destroyTask; + + Instance(Object payload) { + this.payload = payload; + } + } +} diff --git a/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java b/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java new file mode 100644 index 000000000000..696de60c550c --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/BaseGrpcServiceExceptionTest.java @@ -0,0 +1,106 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.rpc.InternalException; +import com.google.cloud.BaseServiceException; +import com.google.cloud.RetryHelper; +import io.grpc.Status.Code; +import java.io.IOException; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import org.junit.Test; + +public class BaseGrpcServiceExceptionTest { + + private static final String MESSAGE = "some message"; + private static final boolean NOT_RETRYABLE = false; + private static final boolean IDEMPOTENT = true; + + @Test + public void testBaseServiceException() { + BaseGrpcServiceException serviceException = null; + + IOException exception = new SocketTimeoutException(); + serviceException = new BaseGrpcServiceException(exception, IDEMPOTENT); + assertTrue(serviceException.isRetryable()); + assertNull(serviceException.getMessage()); + assertEquals(exception, serviceException.getCause()); + assertNull(serviceException.getReason()); + assertNull(serviceException.getLocation()); + assertNull(serviceException.getDebugInfo()); + + exception = new SocketException(); + serviceException = new BaseGrpcServiceException(exception, IDEMPOTENT); + assertTrue(serviceException.isRetryable()); + assertNull(serviceException.getMessage()); + assertEquals(exception, serviceException.getCause()); + assertNull(serviceException.getReason()); + assertNull(serviceException.getLocation()); + assertNull(serviceException.getDebugInfo()); + + exception = new IOException("insufficient data written"); + serviceException = new BaseGrpcServiceException(exception, IDEMPOTENT); + assertTrue(serviceException.isRetryable()); + assertEquals("insufficient data written", serviceException.getMessage()); + assertEquals(exception, serviceException.getCause()); + assertNull(serviceException.getReason()); + assertNull(serviceException.getLocation()); + assertNull(serviceException.getDebugInfo()); + + Exception cause = new IllegalArgumentException("bad arg"); + InternalException apiException = + new InternalException(MESSAGE, cause, GrpcStatusCode.of(Code.INTERNAL), NOT_RETRYABLE); + serviceException = new BaseGrpcServiceException(apiException); + assertFalse(serviceException.isRetryable()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(apiException, serviceException.getCause()); + assertEquals(500, serviceException.getCode()); + assertEquals(Code.INTERNAL.name(), serviceException.getReason()); + assertNull(serviceException.getLocation()); + assertNull(serviceException.getDebugInfo()); + } + + @Test + public void testTranslateAndThrow() throws Exception { + IOException exception = new SocketTimeoutException(); + BaseGrpcServiceException cause = new BaseGrpcServiceException(exception, IDEMPOTENT); + RetryHelper.RetryHelperException exceptionMock = + createMock(RetryHelper.RetryHelperException.class); + expect(exceptionMock.getCause()).andReturn(cause).times(2); + replay(exceptionMock); + try { + BaseServiceException.translate(exceptionMock); + } catch (BaseServiceException ex) { + assertEquals(0, ex.getCode()); + assertNull(ex.getMessage()); + assertTrue(ex.isRetryable()); + } finally { + verify(exceptionMock); + } + } +} diff --git a/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java b/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java new file mode 100644 index 000000000000..b51eab96ce89 --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/GrpcTransportOptionsTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.grpc.GrpcTransportOptions.DefaultExecutorFactory; +import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory; +import java.util.concurrent.ScheduledExecutorService; +import org.easymock.EasyMock; +import org.junit.Test; + +public class GrpcTransportOptionsTest { + + private static final ExecutorFactory MOCK_EXECUTOR_FACTORY = + EasyMock.createMock(ExecutorFactory.class); + private static final GrpcTransportOptions OPTIONS = + GrpcTransportOptions.newBuilder().setExecutorFactory(MOCK_EXECUTOR_FACTORY).build(); + private static final GrpcTransportOptions DEFAULT_OPTIONS = + GrpcTransportOptions.newBuilder().build(); + private static final GrpcTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build(); + + @Test + public void testBuilder() { + assertSame(MOCK_EXECUTOR_FACTORY, OPTIONS.getExecutorFactory()); + assertTrue(DEFAULT_OPTIONS.getExecutorFactory() instanceof DefaultExecutorFactory); + } + + @Test + public void testBaseEquals() { + assertEquals(OPTIONS, OPTIONS_COPY); + assertNotEquals(DEFAULT_OPTIONS, OPTIONS); + GrpcTransportOptions options = + OPTIONS.toBuilder().setExecutorFactory(new DefaultExecutorFactory()).build(); + assertNotEquals(OPTIONS, options); + } + + @Test + public void testBaseHashCode() { + assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode()); + assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode()); + GrpcTransportOptions options = + OPTIONS.toBuilder().setExecutorFactory(new DefaultExecutorFactory()).build(); + assertNotEquals(OPTIONS.hashCode(), options.hashCode()); + } + + @Test + public void testDefaultExecutorFactory() { + ExecutorFactory executorFactory = new DefaultExecutorFactory(); + ScheduledExecutorService executorService = executorFactory.get(); + assertSame(executorService, executorFactory.get()); + } +} diff --git a/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/SharedResourceHolderTest.java b/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/SharedResourceHolderTest.java new file mode 100644 index 000000000000..ba70a0de55ed --- /dev/null +++ b/java-core/google-cloud-core-grpc/src/test/java/com/google/cloud/grpc/SharedResourceHolderTest.java @@ -0,0 +1,292 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.grpc; + +import static org.easymock.EasyMock.*; +import static org.junit.Assert.*; + +import java.util.LinkedList; +import java.util.concurrent.Delayed; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import org.easymock.EasyMock; +import org.easymock.IAnswer; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * This class was copied from grpc-core to prevent dependence on an unstable API that may be subject + * to changes + * (https://github.com/grpc/grpc-java/blob/d07ecbe037d2705a1c9f4b6345581f860e505b56/core/src/test/java/io/grpc/internal/SharedResourceHolderTest.java) + * + *

Unit tests for {@link SharedResourceHolder}. + */ +@RunWith(JUnit4.class) +public class SharedResourceHolderTest { + + private final LinkedList> scheduledDestroyTasks = new LinkedList<>(); + + private SharedResourceHolder holder; + + private static class ResourceInstance { + volatile boolean closed; + } + + private static class ResourceFactory implements SharedResourceHolder.Resource { + @Override + public ResourceInstance create() { + return new ResourceInstance(); + } + + @Override + public void close(ResourceInstance instance) { + instance.closed = true; + } + } + + // Defines two kinds of resources + private static final SharedResourceHolder.Resource SHARED_FOO = + new ResourceFactory(); + private static final SharedResourceHolder.Resource SHARED_BAR = + new ResourceFactory(); + + @Before + public void setUp() { + holder = new SharedResourceHolder(new MockExecutorFactory()); + } + + @Test + public void destroyResourceWhenRefCountReachesZero() { + ResourceInstance foo1 = holder.getInternal(SHARED_FOO); + ResourceInstance sharedFoo = foo1; + ResourceInstance foo2 = holder.getInternal(SHARED_FOO); + assertSame(sharedFoo, foo2); + + ResourceInstance bar1 = holder.getInternal(SHARED_BAR); + ResourceInstance sharedBar = bar1; + + foo2 = holder.releaseInternal(SHARED_FOO, foo2); + // foo refcount not reached 0, thus shared foo is not closed + assertTrue(scheduledDestroyTasks.isEmpty()); + assertFalse(sharedFoo.closed); + assertNull(foo2); + + foo1 = holder.releaseInternal(SHARED_FOO, foo1); + assertNull(foo1); + + // foo refcount has reached 0, a destroying task is scheduled + assertEquals(1, scheduledDestroyTasks.size()); + MockScheduledFuture scheduledDestroyTask = scheduledDestroyTasks.poll(); + assertEquals( + SharedResourceHolder.DESTROY_DELAY_SECONDS, + scheduledDestroyTask.getDelay(TimeUnit.SECONDS)); + + // Simluate that the destroyer executes the foo destroying task + scheduledDestroyTask.runTask(); + assertTrue(sharedFoo.closed); + + // After the destroying, obtaining a foo will get a different instance + ResourceInstance foo3 = holder.getInternal(SHARED_FOO); + assertNotSame(sharedFoo, foo3); + + holder.releaseInternal(SHARED_BAR, bar1); + + // bar refcount has reached 0, a destroying task is scheduled + assertEquals(1, scheduledDestroyTasks.size()); + scheduledDestroyTask = scheduledDestroyTasks.poll(); + assertEquals( + SharedResourceHolder.DESTROY_DELAY_SECONDS, + scheduledDestroyTask.getDelay(TimeUnit.SECONDS)); + + // Simulate that the destroyer executes the bar destroying task + scheduledDestroyTask.runTask(); + assertTrue(sharedBar.closed); + } + + @Test + public void cancelDestroyTask() { + ResourceInstance foo1 = holder.getInternal(SHARED_FOO); + ResourceInstance sharedFoo = foo1; + holder.releaseInternal(SHARED_FOO, foo1); + // A destroying task for foo is scheduled + MockScheduledFuture scheduledDestroyTask = scheduledDestroyTasks.poll(); + assertFalse(scheduledDestroyTask.cancelled); + + // obtaining a foo before the destroying task is executed will cancel the destroy + ResourceInstance foo2 = holder.getInternal(SHARED_FOO); + assertTrue(scheduledDestroyTask.cancelled); + assertTrue(scheduledDestroyTasks.isEmpty()); + assertFalse(sharedFoo.closed); + + // And it will be the same foo instance + assertSame(sharedFoo, foo2); + + // Release it and the destroying task is scheduled again + holder.releaseInternal(SHARED_FOO, foo2); + scheduledDestroyTask = scheduledDestroyTasks.poll(); + assertNotNull(scheduledDestroyTask); + assertFalse(scheduledDestroyTask.cancelled); + scheduledDestroyTask.runTask(); + assertTrue(sharedFoo.closed); + } + + @Test + public void releaseWrongInstance() { + ResourceInstance uncached = new ResourceInstance(); + try { + holder.releaseInternal(SHARED_FOO, uncached); + fail("Should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // expected + } + ResourceInstance cached = holder.getInternal(SHARED_FOO); + try { + holder.releaseInternal(SHARED_FOO, uncached); + fail("Should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // expected + } + holder.releaseInternal(SHARED_FOO, cached); + } + + @Test + public void overreleaseInstance() { + ResourceInstance foo1 = holder.getInternal(SHARED_FOO); + holder.releaseInternal(SHARED_FOO, foo1); + try { + holder.releaseInternal(SHARED_FOO, foo1); + fail("Should throw IllegalStateException"); + } catch (IllegalStateException e) { + // expected + } + } + + @Test + public void handleInstanceCloseError() { + class ExceptionOnCloseResource implements SharedResourceHolder.Resource { + @Override + public ResourceInstance create() { + return new ResourceInstance(); + } + + @Override + public void close(ResourceInstance instance) { + throw new RuntimeException(); + } + } + + SharedResourceHolder.Resource resource = new ExceptionOnCloseResource(); + ResourceInstance instance = holder.getInternal(resource); + holder.releaseInternal(resource, instance); + MockScheduledFuture scheduledDestroyTask = scheduledDestroyTasks.poll(); + try { + scheduledDestroyTask.runTask(); + fail("Should throw RuntimeException"); + } catch (RuntimeException e) { + // expected + } + + // Future resource fetches should not get the partially-closed one. + assertNotSame(instance, holder.getInternal(resource)); + } + + private class MockExecutorFactory implements SharedResourceHolder.ScheduledExecutorFactory { + @Override + public ScheduledExecutorService createScheduledExecutor() { + ScheduledExecutorService mockExecutor = createNiceMock(ScheduledExecutorService.class); + expect(mockExecutor.schedule(anyObject(Runnable.class), anyLong(), anyObject(TimeUnit.class))) + .andAnswer( + new IAnswer() { + @Override + public ScheduledFuture answer() throws Throwable { + Object[] args = EasyMock.getCurrentArguments(); + Runnable command = (Runnable) args[0]; + long delay = (Long) args[1]; + TimeUnit unit = (TimeUnit) args[2]; + MockScheduledFuture future = + new MockScheduledFuture<>(command, delay, unit); + scheduledDestroyTasks.add(future); + return future; + } + }) + .anyTimes(); + replay(mockExecutor); + return mockExecutor; + } + } + + protected static class MockScheduledFuture implements java.util.concurrent.ScheduledFuture { + private boolean cancelled; + private boolean finished; + final Runnable command; + final long delay; + final TimeUnit unit; + + MockScheduledFuture(Runnable command, long delay, TimeUnit unit) { + this.command = command; + this.delay = delay; + this.unit = unit; + } + + void runTask() { + command.run(); + finished = true; + } + + @Override + public boolean cancel(boolean interrupt) { + if (cancelled || finished) { + return false; + } + cancelled = true; + return true; + } + + @Override + public boolean isCancelled() { + return cancelled; + } + + @Override + public long getDelay(TimeUnit targetUnit) { + return targetUnit.convert(this.delay, this.unit); + } + + @Override + public int compareTo(Delayed o) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isDone() { + return cancelled || finished; + } + + @Override + public V get() { + throw new UnsupportedOperationException(); + } + + @Override + public V get(long timeout, TimeUnit unit) { + throw new UnsupportedOperationException(); + } + } +} diff --git a/java-core/google-cloud-core-http/pom.xml b/java-core/google-cloud-core-http/pom.xml new file mode 100644 index 000000000000..978b35bf8aae --- /dev/null +++ b/java-core/google-cloud-core-http/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + com.google.cloud + google-cloud-core-http + 2.9.5-SNAPSHOT + jar + Google Cloud Core HTTP + + Core http module for the google-cloud. + + + com.google.cloud + google-cloud-core-parent + 2.9.5-SNAPSHOT + + + google-cloud-core-http + + + + com.google.cloud + google-cloud-core + + + com.google.auth + google-auth-library-credentials + + + com.google.auth + google-auth-library-oauth2-http + + + com.google.http-client + google-http-client + + + com.google.guava + guava + + + com.google.api-client + google-api-client + + + com.google.http-client + google-http-client-appengine + + + com.google.api + gax + + + com.google.api + gax-httpjson + + + com.google.code.findbugs + jsr305 + + + io.opencensus + opencensus-api + + + io.opencensus + opencensus-contrib-http-util + + + com.google.api + api-common + + + + + junit + junit + test + + + org.easymock + easymock + test + + + com.google.truth + truth + test + + + diff --git a/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/BaseHttpServiceException.java b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/BaseHttpServiceException.java new file mode 100644 index 000000000000..26f43b276f03 --- /dev/null +++ b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/BaseHttpServiceException.java @@ -0,0 +1,166 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.http; + +import com.google.api.client.googleapis.json.GoogleJsonError; +import com.google.api.client.googleapis.json.GoogleJsonResponseException; +import com.google.api.client.http.HttpResponseException; +import com.google.api.core.InternalApi; +import com.google.cloud.BaseServiceException; +import com.google.common.base.MoreObjects; +import java.io.IOException; +import java.util.Set; + +/** Base class for all exceptions from http-based services. */ +public class BaseHttpServiceException extends BaseServiceException { + + private static final long serialVersionUID = -5793034110344127954L; + public static final int UNKNOWN_CODE = 0; + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseHttpServiceException( + IOException exception, boolean idempotent, Set retryableErrors) { + super(makeExceptionData(exception, idempotent, retryableErrors)); + } + + private static ExceptionData makeExceptionData( + IOException exception, boolean idempotent, Set retryableErrors) { + int code = UNKNOWN_CODE; + String reason = null; + String location = null; + String debugInfo = null; + Boolean retryable = null; + if (exception instanceof HttpResponseException) { + if (exception instanceof GoogleJsonResponseException) { + GoogleJsonError jsonError = ((GoogleJsonResponseException) exception).getDetails(); + if (jsonError != null) { + BaseServiceException.Error error = + new BaseServiceException.Error(jsonError.getCode(), reason(jsonError)); + code = error.getCode(); + reason = error.getReason(); + retryable = error.isRetryable(idempotent, retryableErrors); + if (reason != null) { + GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0); + location = errorInfo.getLocation(); + debugInfo = (String) errorInfo.get("debugInfo"); + } + } else { + code = ((GoogleJsonResponseException) exception).getStatusCode(); + retryable = BaseServiceException.isRetryable(code, null, idempotent, retryableErrors); + } + } else { + // In cases where an exception is an instance of HttpResponseException but not + // an instance of GoogleJsonResponseException, check the status code to determine whether + // it's retryable + code = ((HttpResponseException) exception).getStatusCode(); + retryable = BaseServiceException.isRetryable(code, null, idempotent, retryableErrors); + } + } + return ExceptionData.newBuilder() + .setMessage(message(exception)) + .setCause(exception) + .setRetryable( + MoreObjects.firstNonNull( + retryable, BaseServiceException.isRetryable(idempotent, exception))) + .setCode(code) + .setReason(reason) + .setLocation(location) + .setDebugInfo(debugInfo) + .build(); + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseHttpServiceException( + GoogleJsonError googleJsonError, + boolean idempotent, + Set retryableErrors) { + super(makeExceptionData(googleJsonError, idempotent, retryableErrors)); + } + + private static ExceptionData makeExceptionData( + GoogleJsonError googleJsonError, + boolean idempotent, + Set retryableErrors) { + int code = googleJsonError.getCode(); + String reason = reason(googleJsonError); + + ExceptionData.Builder exceptionData = ExceptionData.newBuilder(); + exceptionData + .setMessage(googleJsonError.getMessage()) + .setCause(null) + .setRetryable(BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors)) + .setCode(code) + .setReason(reason); + if (reason != null) { + GoogleJsonError.ErrorInfo errorInfo = googleJsonError.getErrors().get(0); + exceptionData.setLocation(errorInfo.getLocation()); + exceptionData.setDebugInfo((String) errorInfo.get("debugInfo")); + } else { + exceptionData.setLocation(null); + exceptionData.setDebugInfo(null); + } + return exceptionData.build(); + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseHttpServiceException( + int code, + String message, + String reason, + boolean idempotent, + Set retryableErrors) { + this(code, message, reason, idempotent, retryableErrors, null); + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseHttpServiceException( + int code, + String message, + String reason, + boolean idempotent, + Set retryableErrors, + Throwable cause) { + super( + ExceptionData.newBuilder() + .setMessage(message) + .setCause(cause) + .setRetryable( + BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors)) + .setCode(code) + .setReason(reason) + .setLocation(null) + .setDebugInfo(null) + .build()); + } + + private static String reason(GoogleJsonError error) { + if (error.getErrors() != null && !error.getErrors().isEmpty()) { + return error.getErrors().get(0).getReason(); + } + return null; + } + + private static String message(IOException exception) { + if (exception instanceof GoogleJsonResponseException) { + GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails(); + if (details != null) { + return details.getMessage(); + } + } + return exception.getMessage(); + } +} diff --git a/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java new file mode 100644 index 000000000000..d141507cc09b --- /dev/null +++ b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/CensusHttpModule.java @@ -0,0 +1,156 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.http; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.client.http.HttpExecuteInterceptor; +import com.google.api.client.http.HttpHeaders; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.common.annotations.VisibleForTesting; +import io.opencensus.contrib.http.util.HttpPropagationUtil; +import io.opencensus.trace.SpanContext; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.propagation.TextFormat; +import java.io.IOException; +import javax.annotation.Nullable; + +/** + * Provides utilities for Open Census to record http stats/trace information and propagate tracing + * context. + */ +public final class CensusHttpModule { + + /** + * OpenCensus tracing component. When no OpenCensus implementation is provided, it will return a + * no-op tracer. + */ + private final Tracer tracer; + + /** {@link TextFormat} used in tracing context propagation. */ + @Nullable private final TextFormat propagationTextFormat; + + /** {@link TextFormat.Setter} for {@link #propagationTextFormat}. */ + @Nullable private final TextFormat.Setter propagationTextFormatSetter; + + /** Whether spans are stored locally. */ + private final boolean isRecordEvents; + + /** Default HTTP propagation text formatter. */ + @VisibleForTesting + static final class DefaultPropagationTextFormatSetter extends TextFormat.Setter { + static final TextFormat.Setter INSTANCE = new DefaultPropagationTextFormatSetter(); + + @Override + public void put(HttpHeaders carrier, String key, String value) { + carrier.set(key, value); + } + } + + /** + * An {@link HttpExecuteInterceptor} implementation to inject HTTP request and add getContext + * information before it is executed. + */ + @VisibleForTesting + final class CensusHttpExecuteInterceptor implements HttpExecuteInterceptor { + @Nullable HttpExecuteInterceptor interceptor; + + CensusHttpExecuteInterceptor(HttpExecuteInterceptor interceptor) { + this.interceptor = interceptor; + } + + @Override + public void intercept(HttpRequest request) throws IOException { + checkNotNull(request); + if (this.interceptor != null) { + this.interceptor.intercept(request); + } + if (propagationTextFormat != null && propagationTextFormatSetter != null) { + SpanContext spanContext = tracer.getCurrentSpan().getContext(); + if (!SpanContext.INVALID.equals(spanContext)) { + propagationTextFormat.inject( + spanContext, request.getHeaders(), propagationTextFormatSetter); + } + } + } + } + + /** + * An {@link HttpRequestInitializer} implementation to set {@link CensusHttpExecuteInterceptor} as + * interceptor. + */ + @VisibleForTesting + final class CensusHttpRequestInitializer implements HttpRequestInitializer { + @Nullable HttpRequestInitializer initializer; + + CensusHttpRequestInitializer(HttpRequestInitializer initializer) { + this.initializer = initializer; + } + + @Override + public void initialize(HttpRequest request) throws IOException { + checkNotNull(request); + if (this.initializer != null) { + this.initializer.initialize(request); + } + request.setInterceptor(new CensusHttpExecuteInterceptor(request.getInterceptor())); + } + } + + /** + * Creates a {@link CensusHttpModule} with given parameters. + * + * @param tracer the OpenCensus {@code Tracer}. + * @param isRecordEvents whether spans are stored locally. + */ + public CensusHttpModule(Tracer tracer, boolean isRecordEvents) { + checkNotNull(tracer, "tracer"); + this.tracer = tracer; + this.isRecordEvents = isRecordEvents; + this.propagationTextFormat = HttpPropagationUtil.getCloudTraceFormat(); + this.propagationTextFormatSetter = DefaultPropagationTextFormatSetter.INSTANCE; + } + + /** + * Returns the tracing component of OpenCensus. + * + * @return the tracing component of OpenCensus. + */ + public Tracer getTracer() { + return tracer; + } + + /** + * Returns whether spans are stored locally. + * + * @return whether spans are stored locally. + */ + public boolean isRecordEvents() { + return isRecordEvents; + } + + /** + * Returns the {@link HttpExecuteInterceptor} used when initializing the {@link HttpRequest}. + * + * @param initializer the original initializer which will be executed before this initializer. + * @return the {@code HttpExecuteInterceptor}. + */ + public HttpRequestInitializer getHttpRequestInitializer(HttpRequestInitializer initializer) { + return new CensusHttpRequestInitializer(initializer); + } +} diff --git a/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java new file mode 100644 index 000000000000..4bdfee3cca9f --- /dev/null +++ b/java-core/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java @@ -0,0 +1,230 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.http; + +import static com.google.common.base.MoreObjects.firstNonNull; + +import com.google.api.client.extensions.appengine.http.UrlFetchTransport; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.httpjson.HttpHeadersUtils; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.auth.Credentials; +import com.google.auth.http.HttpCredentialsAdapter; +import com.google.auth.http.HttpTransportFactory; +import com.google.cloud.NoCredentials; +import com.google.cloud.PlatformInformation; +import com.google.cloud.ServiceOptions; +import com.google.cloud.TransportOptions; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.Objects; + +/** Class representing service options for those services that use HTTP as the transport layer. */ +public class HttpTransportOptions implements TransportOptions { + + private static final long serialVersionUID = 7890117765045419810L; + private final int connectTimeout; + private final int readTimeout; + private final String httpTransportFactoryClassName; + + private transient HttpTransportFactory httpTransportFactory; + + public static class DefaultHttpTransportFactory implements HttpTransportFactory { + + private static final HttpTransportFactory INSTANCE = new DefaultHttpTransportFactory(); + + @Override + public HttpTransport create() { + // Consider App Engine Standard + if (PlatformInformation.isOnGAEStandard7()) { + try { + return new UrlFetchTransport(); + } catch (Exception ignore) { + // Maybe not on App Engine + } + } + return new NetHttpTransport(); + } + } + + /** Builder for {@code HttpTransportOptions}. */ + public static class Builder { + + private HttpTransportFactory httpTransportFactory; + private int connectTimeout = -1; + private int readTimeout = -1; + + private Builder() {} + + private Builder(HttpTransportOptions options) { + httpTransportFactory = options.httpTransportFactory; + connectTimeout = options.connectTimeout; + readTimeout = options.readTimeout; + } + + public HttpTransportOptions build() { + return new HttpTransportOptions(this); + } + + /** + * Sets the HTTP transport factory. + * + * @return the builder + */ + public Builder setHttpTransportFactory(HttpTransportFactory httpTransportFactory) { + this.httpTransportFactory = httpTransportFactory; + return this; + } + + /** + * Sets the timeout in milliseconds to establish a connection. + * + * @param connectTimeout connection timeout in milliseconds. 0 for an infinite timeout, a + * negative number for the default value (20000). + * @return the builder + */ + public Builder setConnectTimeout(int connectTimeout) { + this.connectTimeout = connectTimeout; + return this; + } + + /** + * Sets the timeout in milliseconds to read data from an established connection. + * + * @param readTimeout read timeout in milliseconds. 0 for an infinite timeout, a negative number + * for the default value (20000). + * @return the builder + */ + public Builder setReadTimeout(int readTimeout) { + this.readTimeout = readTimeout; + return this; + } + } + + public HttpTransportOptions(Builder builder) { + httpTransportFactory = + firstNonNull( + builder.httpTransportFactory, + ServiceOptions.getFromServiceLoader( + HttpTransportFactory.class, DefaultHttpTransportFactory.INSTANCE)); + httpTransportFactoryClassName = httpTransportFactory.getClass().getName(); + connectTimeout = builder.connectTimeout; + readTimeout = builder.readTimeout; + } + + /** Returns the HTTP transport factory. */ + public HttpTransportFactory getHttpTransportFactory() { + return httpTransportFactory; + } + + /** + * Returns a request initializer responsible for initializing requests according to service + * options. + */ + public HttpRequestInitializer getHttpRequestInitializer( + final ServiceOptions serviceOptions) { + Credentials scopedCredentials = serviceOptions.getScopedCredentials(); + final HttpRequestInitializer delegate = + scopedCredentials != null && scopedCredentials != NoCredentials.getInstance() + ? new HttpCredentialsAdapter(scopedCredentials) + : null; + HeaderProvider internalHeaderProvider = + getInternalHeaderProviderBuilder(serviceOptions).build(); + final HeaderProvider headerProvider = + serviceOptions.getMergedHeaderProvider(internalHeaderProvider); + + return new HttpRequestInitializer() { + @Override + public void initialize(HttpRequest httpRequest) throws IOException { + if (delegate != null) { + delegate.initialize(httpRequest); + } + if (connectTimeout >= 0) { + httpRequest.setConnectTimeout(connectTimeout); + } + if (readTimeout >= 0) { + httpRequest.setReadTimeout(readTimeout); + } + + HttpHeadersUtils.setHeaders(httpRequest.getHeaders(), headerProvider.getHeaders()); + } + }; + } + + ApiClientHeaderProvider.Builder getInternalHeaderProviderBuilder( + ServiceOptions serviceOptions) { + ApiClientHeaderProvider.Builder builder = ApiClientHeaderProvider.newBuilder(); + builder.setClientLibToken( + ServiceOptions.getGoogApiClientLibName(), + GaxProperties.getLibraryVersion(serviceOptions.getClass())); + builder.setQuotaProjectIdToken(serviceOptions.getQuotaProjectId()); + return builder; + } + + /** + * Returns the timeout in milliseconds to establish a connection. 0 is an infinite timeout, a + * negative number is the default value (20000). + */ + public int getConnectTimeout() { + return connectTimeout; + } + + /** + * Returns the timeout in milliseconds to read from an established connection. 0 is an infinite + * timeout, a negative number is the default value (20000). + */ + public int getReadTimeout() { + return readTimeout; + } + + public Builder toBuilder() { + return new Builder(this); + } + + @Override + public int hashCode() { + return Objects.hash(httpTransportFactoryClassName, connectTimeout, readTimeout); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + HttpTransportOptions other = (HttpTransportOptions) obj; + return Objects.equals(httpTransportFactoryClassName, other.httpTransportFactoryClassName) + && Objects.equals(connectTimeout, other.connectTimeout) + && Objects.equals(readTimeout, other.readTimeout); + } + + private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { + input.defaultReadObject(); + httpTransportFactory = ServiceOptions.newInstance(httpTransportFactoryClassName); + } + + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/BaseHttpServiceExceptionTest.java b/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/BaseHttpServiceExceptionTest.java new file mode 100644 index 000000000000..e88a32a9afda --- /dev/null +++ b/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/BaseHttpServiceExceptionTest.java @@ -0,0 +1,165 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.http; + +import static com.google.cloud.BaseServiceException.UNKNOWN_CODE; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.api.client.googleapis.json.GoogleJsonError; +import com.google.cloud.BaseServiceException; +import com.google.cloud.RetryHelper; +import com.google.common.collect.ImmutableSet; +import java.io.IOException; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import java.util.Collections; +import java.util.Set; +import org.junit.Test; + +public class BaseHttpServiceExceptionTest { + + private static final int CODE = 1; + private static final int CODE_NO_REASON = 2; + private static final String MESSAGE = "some message"; + private static final String REASON = "some reason"; + private static final boolean RETRYABLE = true; + private static final boolean IDEMPOTENT = true; + private static final boolean NOT_IDEMPOTENT = false; + private static final Set EMPTY_RETRYABLE_ERRORS = + Collections.emptySet(); + + private static class CustomServiceException extends BaseHttpServiceException { + + private static final long serialVersionUID = -195251309124875103L; + + public CustomServiceException(int code, String message, String reason, boolean idempotent) { + super(code, message, reason, idempotent, RETRYABLE_ERRORS); + } + + private static final Set RETRYABLE_ERRORS = + ImmutableSet.of( + new Error(CODE, REASON), new Error(null, REASON), new Error(CODE_NO_REASON, null)); + } + + @Test + public void testBaseServiceException() { + BaseServiceException serviceException = + new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertFalse(serviceException.isRetryable()); + assertNull(serviceException.getCause()); + + serviceException = + new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertFalse(serviceException.isRetryable()); + assertNull(serviceException.getCause()); + + Exception cause = new RuntimeException(); + serviceException = + new BaseHttpServiceException( + CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS, cause); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertFalse(serviceException.isRetryable()); + assertEquals(cause, serviceException.getCause()); + + serviceException = + new BaseHttpServiceException( + CODE, MESSAGE, REASON, NOT_IDEMPOTENT, EMPTY_RETRYABLE_ERRORS, cause); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertFalse(serviceException.isRetryable()); + assertEquals(cause, serviceException.getCause()); + + IOException exception = new SocketTimeoutException(); + serviceException = new BaseHttpServiceException(exception, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + assertTrue(serviceException.isRetryable()); + assertNull(serviceException.getMessage()); + assertEquals(exception, serviceException.getCause()); + + exception = new SocketException(); + serviceException = new BaseHttpServiceException(exception, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + assertTrue(serviceException.isRetryable()); + assertNull(serviceException.getMessage()); + assertEquals(exception, serviceException.getCause()); + + exception = new IOException("insufficient data written"); + serviceException = new BaseHttpServiceException(exception, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + assertTrue(serviceException.isRetryable()); + assertEquals("insufficient data written", serviceException.getMessage()); + assertEquals(exception, serviceException.getCause()); + + GoogleJsonError error = new GoogleJsonError(); + error.setCode(CODE); + error.setMessage(MESSAGE); + serviceException = new BaseHttpServiceException(error, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertFalse(serviceException.isRetryable()); + + serviceException = new CustomServiceException(CODE, MESSAGE, REASON, IDEMPOTENT); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertEquals(RETRYABLE, serviceException.isRetryable()); + + serviceException = new CustomServiceException(CODE_NO_REASON, MESSAGE, null, IDEMPOTENT); + assertEquals(CODE_NO_REASON, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertNull(serviceException.getReason()); + assertEquals(RETRYABLE, serviceException.isRetryable()); + + serviceException = new CustomServiceException(UNKNOWN_CODE, MESSAGE, REASON, IDEMPOTENT); + assertEquals(UNKNOWN_CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertEquals(RETRYABLE, serviceException.isRetryable()); + } + + @Test + public void testTranslateAndThrow() throws Exception { + BaseServiceException cause = + new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); + RetryHelper.RetryHelperException exceptionMock = + createMock(RetryHelper.RetryHelperException.class); + expect(exceptionMock.getCause()).andReturn(cause).times(2); + replay(exceptionMock); + try { + BaseServiceException.translate(exceptionMock); + } catch (BaseServiceException ex) { + assertEquals(CODE, ex.getCode()); + assertEquals(MESSAGE, ex.getMessage()); + assertFalse(ex.isRetryable()); + } finally { + verify(exceptionMock); + } + } +} diff --git a/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/CensusHttpModuleTest.java b/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/CensusHttpModuleTest.java new file mode 100644 index 000000000000..c04d0647fb47 --- /dev/null +++ b/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/CensusHttpModuleTest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.http; + +import static com.google.common.truth.Truth.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.createMockBuilder; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpExecuteInterceptor; +import com.google.api.client.http.HttpHeaders; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.javanet.NetHttpTransport; +import io.opencensus.common.Scope; +import io.opencensus.trace.Span; +import io.opencensus.trace.SpanContext; +import io.opencensus.trace.SpanId; +import io.opencensus.trace.TraceId; +import io.opencensus.trace.TraceOptions; +import io.opencensus.trace.Tracer; +import io.opencensus.trace.Tracestate; +import io.opencensus.trace.Tracing; +import io.opencensus.trace.propagation.TextFormat; +import java.io.IOException; +import java.util.EnumSet; +import java.util.Random; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link CensusHttpModule}. */ +@RunWith(JUnit4.class) +public class CensusHttpModuleTest { + + @Rule public final ExpectedException thrown = ExpectedException.none(); + + private final Tracer tracer = Tracing.getTracer(); + private final CensusHttpModule censusHttpModule = new CensusHttpModule(tracer, false); + private HttpRequest httpRequest; + + @Before + public void setUp() throws IOException { + httpRequest = + new NetHttpTransport() + .createRequestFactory() + .buildRequest("GET", new GenericUrl("https://www.google.com"), null); + } + + @Test + public void tracerShouldNotBeNull() { + assertThat(censusHttpModule.getTracer()).isNotNull(); + } + + @Test + public void isRecordEventsShouldBeSet() { + assertThat(censusHttpModule.isRecordEvents()).isEqualTo(false); + } + + @Test + public void getHttpRequestInitializerShouldReturnCorrectClass() { + HttpRequestInitializer initializer = censusHttpModule.getHttpRequestInitializer(null); + assertThat(initializer).isInstanceOf(CensusHttpModule.CensusHttpRequestInitializer.class); + } + + @Test + public void implementationOfDefaultTextFormatSetter() { + String testKey = "testKey"; + String testValue = "testValue"; + TextFormat.Setter setter = + CensusHttpModule.DefaultPropagationTextFormatSetter.INSTANCE; + setter.put(httpRequest.getHeaders(), testKey, testValue); + assertThat(httpRequest.getHeaders().get(testKey)).isEqualTo(testValue); + } + + @Test + public void censusHttpExecuteInterceptorDisallowNullRequest() throws IOException { + HttpExecuteInterceptor interceptor = censusHttpModule.new CensusHttpExecuteInterceptor(null); + thrown.expect(NullPointerException.class); + interceptor.intercept(null); + } + + @Test + public void censusHttpExecuteInterceptorShouldExecuteOriginal() throws IOException { + HttpExecuteInterceptor mockInterceptor = createMock(HttpExecuteInterceptor.class); + HttpExecuteInterceptor censusInterceptor = + censusHttpModule.new CensusHttpExecuteInterceptor(mockInterceptor); + mockInterceptor.intercept(httpRequest); + replay(mockInterceptor); + censusInterceptor.intercept(httpRequest); + verify(mockInterceptor); + } + + @Test + public void censusHttpExecuteInterceptorShouldInjectHeader() throws IOException { + Random random = new Random(); + SpanContext spanContext = + SpanContext.create( + TraceId.generateRandomId(random), + SpanId.generateRandomId(random), + TraceOptions.DEFAULT, + Tracestate.builder().build()); + Span mockSpan = + createMockBuilder(Span.class) + .withConstructor(SpanContext.class, EnumSet.class) + .withArgs(spanContext, null) + .createMock(); + Scope scope = tracer.withSpan(mockSpan); + try { + HttpExecuteInterceptor interceptor = censusHttpModule.new CensusHttpExecuteInterceptor(null); + interceptor.intercept(httpRequest); + assertThat(httpRequest.getHeaders().get("X-Cloud-Trace-Context")).isNotNull(); + } finally { + scope.close(); + } + } + + @Test + public void censusHttpRequestInitializerDisallowNullRequest() throws IOException { + HttpRequestInitializer initializer = censusHttpModule.getHttpRequestInitializer(null); + thrown.expect(NullPointerException.class); + initializer.initialize(null); + } + + @Test + public void censusHttpRequestInitializerShouldExecuteOriginal() throws IOException { + HttpRequestInitializer mockOriginalInitializer = createMock(HttpRequestInitializer.class); + HttpRequestInitializer censusInitializer = + censusHttpModule.getHttpRequestInitializer(mockOriginalInitializer); + mockOriginalInitializer.initialize(httpRequest); + replay(mockOriginalInitializer); + censusInitializer.initialize(httpRequest); + verify(mockOriginalInitializer); + } + + @Test + public void censusHttpRequestInitializerShouldSetInterceptor() throws IOException { + censusHttpModule.getHttpRequestInitializer(null).initialize(httpRequest); + assertThat(httpRequest.getInterceptor()) + .isInstanceOf(CensusHttpModule.CensusHttpExecuteInterceptor.class); + } +} diff --git a/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/HttpTransportOptionsTest.java b/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/HttpTransportOptionsTest.java new file mode 100644 index 000000000000..1ff7871aec4e --- /dev/null +++ b/java-core/google-cloud-core-http/src/test/java/com/google/cloud/http/HttpTransportOptionsTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.http; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import com.google.api.gax.rpc.HeaderProvider; +import com.google.auth.http.HttpTransportFactory; +import com.google.cloud.ServiceOptions; +import com.google.cloud.http.HttpTransportOptions.DefaultHttpTransportFactory; +import java.util.regex.Pattern; +import org.easymock.EasyMock; +import org.junit.Test; + +public class HttpTransportOptionsTest { + + private static final HttpTransportFactory MOCK_HTTP_TRANSPORT_FACTORY = + EasyMock.createMock(HttpTransportFactory.class); + private static final HttpTransportOptions OPTIONS = + HttpTransportOptions.newBuilder() + .setConnectTimeout(1234) + .setHttpTransportFactory(MOCK_HTTP_TRANSPORT_FACTORY) + .setReadTimeout(5678) + .build(); + private static final HttpTransportOptions DEFAULT_OPTIONS = + HttpTransportOptions.newBuilder().build(); + private static final HttpTransportOptions OPTIONS_COPY = OPTIONS.toBuilder().build(); + + @Test + public void testBuilder() { + assertEquals(1234, OPTIONS.getConnectTimeout()); + assertSame(MOCK_HTTP_TRANSPORT_FACTORY, OPTIONS.getHttpTransportFactory()); + assertEquals(5678, OPTIONS.getReadTimeout()); + assertEquals(-1, DEFAULT_OPTIONS.getConnectTimeout()); + assertTrue(DEFAULT_OPTIONS.getHttpTransportFactory() instanceof DefaultHttpTransportFactory); + assertEquals(-1, DEFAULT_OPTIONS.getReadTimeout()); + } + + @Test + public void testBaseEquals() { + assertEquals(OPTIONS, OPTIONS_COPY); + assertNotEquals(DEFAULT_OPTIONS, OPTIONS); + } + + @Test + public void testBaseHashCode() { + assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode()); + assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode()); + } + + @Test + public void testHeader() { + String expectedHeaderPattern = "^gl-java/.+ gccl/.* gax/.+"; + ServiceOptions serviceOptions = EasyMock.createMock(ServiceOptions.class); + HeaderProvider headerProvider = + OPTIONS.getInternalHeaderProviderBuilder(serviceOptions).build(); + + assertEquals(1, headerProvider.getHeaders().size()); + assertTrue( + Pattern.compile(expectedHeaderPattern) + .matcher(headerProvider.getHeaders().values().iterator().next()) + .find()); + } +} diff --git a/java-core/google-cloud-core/EnableAutoValue.txt b/java-core/google-cloud-core/EnableAutoValue.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/java-core/google-cloud-core/clirr-ignored-differences.xml b/java-core/google-cloud-core/clirr-ignored-differences.xml new file mode 100644 index 000000000000..0f7f80a7b4d5 --- /dev/null +++ b/java-core/google-cloud-core/clirr-ignored-differences.xml @@ -0,0 +1,15 @@ + + + + + + 7012 + com/google/cloud/ReadChannel + * limit(long) + + + 7012 + com/google/cloud/ReadChannel + long limit() + + diff --git a/java-core/google-cloud-core/pom.xml b/java-core/google-cloud-core/pom.xml new file mode 100644 index 000000000000..5044212b1ecb --- /dev/null +++ b/java-core/google-cloud-core/pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + com.google.cloud + google-cloud-core + 2.9.5-SNAPSHOT + jar + Google Cloud Core + + Core module for the google-cloud. + + + com.google.cloud + google-cloud-core-parent + 2.9.5-SNAPSHOT + + + google-cloud-core + + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.auto.value + auto-value-annotations + + + com.google.protobuf + protobuf-java-util + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-iam-v1 + + + org.threeten + threetenbp + + + com.google.api + api-common + + + com.google.auth + google-auth-library-credentials + + + com.google.auth + google-auth-library-oauth2-http + + + com.google.http-client + google-http-client + + + com.google.http-client + google-http-client-gson + + + com.google.protobuf + protobuf-java + + + + junit + junit + test + + + org.easymock + easymock + test + + + com.google.code.findbugs + jsr305 + + + com.google.truth + truth + test + + + com.google.guava + guava-testlib + test + + + diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java new file mode 100644 index 000000000000..25cae6f7c8d4 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java @@ -0,0 +1,87 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.InternalApi; +import com.google.api.gax.paging.AsyncPage; +import com.google.api.gax.paging.Page; +import com.google.common.base.Throwables; +import com.google.common.util.concurrent.Uninterruptibles; +import java.io.Serializable; +import java.util.concurrent.ExecutionException; + +/** + * Base implementation for asynchronously consuming Google Cloud paginated results. + * + * @param the value type that the page holds + */ +@InternalApi +public class AsyncPageImpl extends PageImpl implements AsyncPage { + + private static final long serialVersionUID = -6009473188630364906L; + + private final NextPageFetcher asyncPageFetcher; + + /** + * Interface for asynchronously fetching the next page of results from the service. + * + * @param the value type that the page holds + */ + public interface NextPageFetcher extends Serializable { + + ApiFuture> getNextPage(); + } + + private static class SyncNextPageFetcher implements PageImpl.NextPageFetcher { + + private static final long serialVersionUID = -4124568632363525351L; + + private final NextPageFetcher asyncPageFetcher; + + private SyncNextPageFetcher(NextPageFetcher asyncPageFetcher) { + this.asyncPageFetcher = asyncPageFetcher; + } + + @Override + public Page getNextPage() { + try { + return asyncPageFetcher != null + ? Uninterruptibles.getUninterruptibly(asyncPageFetcher.getNextPage()) + : null; + } catch (ExecutionException ex) { + Throwables.throwIfUnchecked(ex.getCause()); + throw new RuntimeException(ex); + } + } + } + + /** Creates an {@code AsyncPageImpl} object. */ + public AsyncPageImpl(NextPageFetcher asyncPageFetcher, String cursor, Iterable results) { + super(new SyncNextPageFetcher(asyncPageFetcher), cursor, results); + this.asyncPageFetcher = asyncPageFetcher; + } + + @Override + public ApiFuture> getNextPageAsync() { + if (getNextPageToken() == null || asyncPageFetcher == null) { + return ApiFutures.immediateFuture(null); + } + return asyncPageFetcher.getNextPage(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseService.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseService.java new file mode 100644 index 000000000000..781f29b421a8 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseService.java @@ -0,0 +1,68 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.InternalApi; +import com.google.cloud.ExceptionHandler.Interceptor; + +/** + * Base class for service objects. + * + * @param the {@code ServiceOptions} subclass corresponding to the service + */ +public abstract class BaseService> + implements Service { + + public static final Interceptor EXCEPTION_HANDLER_INTERCEPTOR = + new Interceptor() { + + private static final long serialVersionUID = -8429573486870467828L; + + @Override + public RetryResult afterEval(Exception exception, RetryResult retryResult) { + return Interceptor.RetryResult.CONTINUE_EVALUATION; + } + + @Override + public RetryResult beforeEval(Exception exception) { + if (exception instanceof BaseServiceException) { + boolean retriable = ((BaseServiceException) exception).isRetryable(); + return retriable + ? Interceptor.RetryResult.RETRY + : Interceptor.RetryResult.CONTINUE_EVALUATION; + } + return Interceptor.RetryResult.CONTINUE_EVALUATION; + } + }; + public static final ExceptionHandler EXCEPTION_HANDLER = + ExceptionHandler.newBuilder() + .abortOn(RuntimeException.class) + .addInterceptors(EXCEPTION_HANDLER_INTERCEPTOR) + .build(); + + private final OptionsT options; + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseService(OptionsT options) { + this.options = options; + } + + @Override + public OptionsT getOptions() { + return options; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java new file mode 100644 index 000000000000..29396d6d5897 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseServiceException.java @@ -0,0 +1,343 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.InternalApi; +import com.google.common.base.MoreObjects; +import java.io.IOException; +import java.io.Serializable; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import java.security.cert.CertificateException; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; + +/** Base class for all service exceptions. */ +public class BaseServiceException extends RuntimeException { + + private static final long serialVersionUID = 759921776378760835L; + public static final int UNKNOWN_CODE = 0; + + private final int code; + private final boolean retryable; + private final String reason; + private final String location; + private final String debugInfo; + + @InternalApi + public static final class ExceptionData implements Serializable { + private static final long serialVersionUID = 2222230861338426753L; + + private final String message; + private final Throwable cause; + private final int code; + private final boolean retryable; + private final String reason; + private final String location; + private final String debugInfo; + + private ExceptionData( + String message, + Throwable cause, + int code, + boolean retryable, + String reason, + String location, + String debugInfo) { + this.message = message; + this.cause = cause; + this.code = code; + this.retryable = retryable; + this.reason = reason; + this.location = location; + this.debugInfo = debugInfo; + } + + public String getMessage() { + return message; + } + + public Throwable getCause() { + return cause; + } + + public int getCode() { + return code; + } + + public boolean isRetryable() { + return retryable; + } + + public String getReason() { + return reason; + } + + public String getLocation() { + return location; + } + + public String getDebugInfo() { + return debugInfo; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public static ExceptionData from(int code, String message, String reason, boolean retryable) { + return from(code, message, reason, retryable, null); + } + + public static ExceptionData from( + int code, String message, String reason, boolean retryable, Throwable cause) { + return newBuilder() + .setCode(code) + .setMessage(message) + .setReason(reason) + .setRetryable(retryable) + .setCause(cause) + .build(); + } + + @InternalApi + public static final class Builder { + + private String message; + private Throwable cause; + private int code; + private boolean retryable; + private String reason; + private String location; + private String debugInfo; + + private Builder() {} + + public Builder setMessage(String message) { + this.message = message; + return this; + } + + public Builder setCause(Throwable cause) { + this.cause = cause; + return this; + } + + public Builder setCode(int code) { + this.code = code; + return this; + } + + public Builder setRetryable(boolean retryable) { + this.retryable = retryable; + return this; + } + + public Builder setReason(String reason) { + this.reason = reason; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setDebugInfo(String debugInfo) { + this.debugInfo = debugInfo; + return this; + } + + public ExceptionData build() { + return new ExceptionData(message, cause, code, retryable, reason, location, debugInfo); + } + } + } + + @InternalApi + public static final class Error implements Serializable { + + private static final long serialVersionUID = -4019600198652965721L; + + private final Integer code; + private final String reason; + private final boolean rejected; + + public Error(Integer code, String reason) { + this(code, reason, false); + } + + public Error(Integer code, String reason, boolean rejected) { + this.code = code; + this.reason = reason; + this.rejected = rejected; + } + + /** Returns the code associated with this exception. */ + public Integer getCode() { + return code; + } + + /** + * Returns true if the error indicates that the API call was certainly not accepted by the + * server. For instance, if the server returns a rate limit exceeded error, it certainly did not + * process the request and this method will return {@code true}. + */ + public boolean isRejected() { + return rejected; + } + + /** Returns the reason that caused the exception. */ + public String getReason() { + return reason; + } + + @InternalApi + public boolean isRetryable(boolean idempotent, Set retryableErrors) { + return BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("code", code) + .add("reason", reason) + .add("rejected", rejected) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(code, reason, rejected); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Error)) { + return false; + } + Error o = (Error) obj; + return Objects.equals(code, o.code) + && Objects.equals(reason, o.reason) + && Objects.equals(rejected, o.rejected); + } + } + + @InternalApi + public static boolean isRetryable( + Integer code, String reason, boolean idempotent, Set retryableErrors) { + for (Error retryableError : retryableErrors) { + if ((retryableError.getCode() == null || retryableError.getCode().equals(code)) + && (retryableError.getReason() == null || retryableError.getReason().equals(reason))) { + return idempotent || retryableError.isRejected(); + } + } + return false; + } + + @InternalApi + public static boolean isRetryable(boolean idempotent, IOException exception) { + boolean exceptionIsRetryable = + exception instanceof SocketTimeoutException + || exception instanceof SocketException + || (exception instanceof SSLException + && exception.getMessage().contains("Connection has been shutdown: ")) + || (exception instanceof SSLHandshakeException + && !(exception.getCause() instanceof CertificateException)) + || "insufficient data written".equals(exception.getMessage()) + || "Error writing request body to server".equals(exception.getMessage()); + return idempotent && exceptionIsRetryable; + } + + @InternalApi + public static void translate(RetryHelper.RetryHelperException ex) { + if (ex.getCause() instanceof BaseServiceException) { + throw (BaseServiceException) ex.getCause(); + } + } + + @InternalApi + public static void translate(ExecutionException ex) { + if (ex.getCause() instanceof BaseServiceException) { + throw (BaseServiceException) ex.getCause(); + } + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseServiceException(ExceptionData exceptionData) { + super(exceptionData.getMessage(), exceptionData.getCause()); + this.code = exceptionData.getCode(); + this.reason = exceptionData.getReason(); + this.retryable = exceptionData.isRetryable(); + this.location = exceptionData.getLocation(); + this.debugInfo = exceptionData.getDebugInfo(); + } + + /** Returns the code associated with this exception. */ + public int getCode() { + return code; + } + + /** Returns the reason that caused the exception. */ + public String getReason() { + return reason; + } + + /** Returns {@code true} when it is safe to retry the operation that caused this exception. */ + public boolean isRetryable() { + return retryable; + } + + /** + * Returns the service location where the error causing the exception occurred. Returns {@code + * null} if not available. + */ + public String getLocation() { + return location; + } + + @InternalApi + public String getDebugInfo() { + return debugInfo; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BaseServiceException)) { + return false; + } + BaseServiceException other = (BaseServiceException) obj; + return Objects.equals(getCause(), other.getCause()) + && Objects.equals(getMessage(), other.getMessage()) + && code == other.code + && retryable == other.retryable + && Objects.equals(reason, other.reason) + && Objects.equals(location, other.location) + && Objects.equals(debugInfo, other.debugInfo); + } + + @Override + public int hashCode() { + return Objects.hash(getCause(), getMessage(), code, retryable, reason, location, debugInfo); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java new file mode 100644 index 000000000000..e45a5aead157 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java @@ -0,0 +1,332 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.InternalApi; +import java.io.IOException; +import java.io.Serializable; +import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * Base implementation for a {@link WriteChannel}. + * + * @param the service options used by the channel to issue RPC requests + * @param the entity this channel writes data to. Possibly with additional configuration + */ +public abstract class BaseWriteChannel< + ServiceOptionsT extends ServiceOptions, EntityT extends Serializable> + implements WriteChannel { + + private static final int MIN_CHUNK_SIZE = 256 * 1024; // 256 KiB + private static final int DEFAULT_CHUNK_SIZE = 60 * MIN_CHUNK_SIZE; // 15MiB + + private final ServiceOptionsT options; + private final EntityT entity; + private final String uploadId; + private long position; + private byte[] buffer = new byte[0]; + private int limit; + private boolean isOpen = true; + private int chunkSize = getDefaultChunkSize(); + + protected int getMinChunkSize() { + return MIN_CHUNK_SIZE; + } + + protected int getDefaultChunkSize() { + return DEFAULT_CHUNK_SIZE; + } + + /** + * Writes {@code length} bytes of {@link #getBuffer()} to the {@link #getUploadId()} URL. + * + * @param length the number of bytes to write from {@link #getBuffer()} + * @param last if {@code true} the resumable session is closed + */ + protected abstract void flushBuffer(int length, boolean last); + + protected ServiceOptionsT getOptions() { + return options; + } + + protected EntityT getEntity() { + return entity; + } + + protected String getUploadId() { + return uploadId; + } + + protected long getPosition() { + return position; + } + + protected byte[] getBuffer() { + return buffer; + } + + protected int getLimit() { + return limit; + } + + protected int getChunkSize() { + return chunkSize; + } + + @Override + public final void setChunkSize(int chunkSize) { + int minSize = getMinChunkSize(); + + this.chunkSize = Math.max(minSize, (chunkSize + minSize - 1) / minSize * minSize); + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseWriteChannel(ServiceOptionsT options, EntityT entity, String uploadId) { + this.options = options; + this.entity = entity; + this.uploadId = uploadId; + } + + private void flush() { + if (limit >= chunkSize) { + final int length = limit - limit % getMinChunkSize(); + flushBuffer(length, false); + position += length; + limit -= length; + byte[] temp = new byte[chunkSize]; + System.arraycopy(buffer, length, temp, 0, limit); + buffer = temp; + } + } + + private void validateOpen() throws ClosedChannelException { + if (!isOpen) { + throw new ClosedChannelException(); + } + } + + @Override + public final int write(ByteBuffer byteBuffer) throws IOException { + validateOpen(); + int toWrite = byteBuffer.remaining(); + int spaceInBuffer = buffer.length - limit; + if (spaceInBuffer >= toWrite) { + byteBuffer.get(buffer, limit, toWrite); + } else { + buffer = Arrays.copyOf(buffer, Math.max(chunkSize, buffer.length + toWrite - spaceInBuffer)); + byteBuffer.get(buffer, limit, toWrite); + } + limit += toWrite; + flush(); + return toWrite; + } + + @Override + public boolean isOpen() { + return isOpen; + } + + @Override + public final void close() throws IOException { + if (isOpen) { + flushBuffer(limit, true); + position += buffer.length; + isOpen = false; + buffer = null; + } + } + + /** Creates a {@link BaseState.Builder} for the current write channel. */ + protected abstract BaseState.Builder stateBuilder(); + + @Override + public RestorableState capture() { + byte[] bufferToSave = null; + if (isOpen) { + bufferToSave = Arrays.copyOf(buffer, limit); + } + return stateBuilder() + .setPosition(position) + .setBuffer(bufferToSave) + .setIsOpen(isOpen) + .setChunkSize(chunkSize) + .build(); + } + + /** Restores the state of the current write channel given a {@link BaseState} object. */ + protected void restore(BaseState state) { + if (state.buffer != null) { + this.buffer = state.buffer.clone(); + this.limit = state.buffer.length; + } + this.position = state.position; + this.isOpen = state.isOpen; + this.chunkSize = state.chunkSize; + } + + protected abstract static class BaseState< + ServiceOptionsT extends ServiceOptions, EntityT extends Serializable> + implements RestorableState, Serializable { + + private static final long serialVersionUID = 8541062465055125619L; + + protected final ServiceOptionsT serviceOptions; + protected final EntityT entity; + protected final String uploadId; + protected final long position; + protected final byte[] buffer; + protected final boolean isOpen; + protected final int chunkSize; + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseState(Builder builder) { + this.serviceOptions = builder.serviceOptions; + this.entity = builder.entity; + this.uploadId = builder.uploadId; + this.position = builder.position; + this.buffer = builder.buffer; + this.isOpen = builder.isOpen; + this.chunkSize = builder.chunkSize; + } + + /** + * Base builder for a write channel's state. Users are not supposed to access this class + * directly. + * + * @param the service options used by the channel to issue RPC requests + * @param the entity this channel writes data to. Possibly with additional + * configuration + */ + public abstract static class Builder< + ServiceOptionsT extends ServiceOptions, EntityT extends Serializable> { + private final ServiceOptionsT serviceOptions; + private final EntityT entity; + private final String uploadId; + private long position; + private byte[] buffer; + private boolean isOpen; + private int chunkSize; + + @InternalApi("This class should only be extended within google-cloud-java") + protected Builder(ServiceOptionsT options, EntityT entity, String uploadId) { + this.serviceOptions = options; + this.entity = entity; + this.uploadId = uploadId; + } + + public Builder setPosition(long position) { + this.position = position; + return this; + } + + public Builder setBuffer(byte[] buffer) { + this.buffer = buffer; + return this; + } + + public Builder setIsOpen(boolean isOpen) { + this.isOpen = isOpen; + return this; + } + + public Builder setChunkSize(int chunkSize) { + this.chunkSize = chunkSize; + return this; + } + + public abstract RestorableState build(); + } + + @Override + public int hashCode() { + return Objects.hash( + serviceOptions, entity, uploadId, position, isOpen, chunkSize, Arrays.hashCode(buffer)); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof BaseState)) { + return false; + } + final BaseState other = (BaseState) obj; + return Objects.equals(this.serviceOptions, other.serviceOptions) + && Objects.equals(this.entity, other.entity) + && Objects.equals(this.uploadId, other.uploadId) + && Objects.deepEquals(this.buffer, other.buffer) + && this.position == other.position + && this.isOpen == other.isOpen + && this.chunkSize == other.chunkSize; + } + + protected static final class ValueHolder { + final String name; + final Object value; + + private ValueHolder(String name, Object value) { + this.name = name; + this.value = value; + } + + public static ValueHolder create(String name, Object value) { + return new ValueHolder(name, value); + } + + @Override + public String toString() { + String result = name + "="; + if (value != null && value.getClass().isArray()) { + Object[] objectArray = new Object[] {value}; + String arrayString = Arrays.deepToString(objectArray); + result += arrayString.substring(1, arrayString.length() - 1); + } else { + result += value; + } + return result; + } + } + + protected List toStringHelper() { + List valueList = new ArrayList<>(); + valueList.add(ValueHolder.create("entity", entity)); + valueList.add(ValueHolder.create("uploadId", uploadId)); + valueList.add(ValueHolder.create("position", String.valueOf(position))); + valueList.add(ValueHolder.create("isOpen", String.valueOf(isOpen))); + return valueList; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append(getClass().getSimpleName()).append('{'); + String nextSeparator = ""; + for (ValueHolder valueHolder : toStringHelper()) { + builder.append(nextSeparator).append(valueHolder); + nextSeparator = ", "; + } + builder.append('}'); + return builder.toString(); + } + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/BatchResult.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/BatchResult.java new file mode 100644 index 000000000000..7281571f916b --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/BatchResult.java @@ -0,0 +1,103 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import com.google.api.core.InternalApi; +import java.util.LinkedList; +import java.util.List; + +/** + * This class holds a single result of a batch call. The class is not thread-safe. + * + * @param the type of the result + * @param the type of the service-dependent exception thrown when a processing error occurs + */ +public abstract class BatchResult { + + private T result; + private boolean completed = false; + private E error; + private final List> toBeNotified = new LinkedList<>(); + + @InternalApi("This class should only be extended within google-cloud-java") + protected BatchResult() {} + + /** + * Returns {@code true} if the batch has been completed and the result is available; {@code false} + * otherwise. + */ + public boolean completed() { + return completed; + } + + /** + * Returns the result of this call. + * + * @throws IllegalStateException if the batch has not been completed yet + * @throws E if an error occurred when processing the batch request + */ + public T get() throws E { + checkState(completed(), "Batch has not been completed yet"); + if (error != null) { + throw error; + } + return result; + } + + /** + * Adds a callback for the batch operation. + * + * @throws IllegalStateException if the batch has been completed already + */ + public void notify(Callback callback) { + checkState( + !completed, + "The batch has been completed. All the calls to the notify()" + + " method should be done prior to submitting the batch."); + toBeNotified.add(callback); + } + + /** Sets an error and status as completed. Notifies all callbacks. */ + protected void error(E error) { + this.error = checkNotNull(error); + this.completed = true; + for (Callback callback : toBeNotified) { + callback.error(error); + } + } + + /** Sets a result and status as completed. Notifies all callbacks. */ + protected void success(T result) { + this.result = result; + this.completed = true; + for (Callback callback : toBeNotified) { + callback.success(result); + } + } + + /** An interface for the batch callbacks. */ + public interface Callback { + /** The method to be called when the batched operation succeeds. */ + void success(T result); + + /** The method to be called when the batched operation fails. */ + void error(E exception); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java new file mode 100644 index 000000000000..be16f8742138 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Binding.java @@ -0,0 +1,112 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Predicates.in; +import static com.google.common.base.Predicates.not; + +import com.google.api.core.BetaApi; +import com.google.auto.value.AutoValue; +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import javax.annotation.Nullable; + +/** + * Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access + * settings for Cloud Platform resources. A policy is a list of bindings. A binding assigns a set of + * identities to a role, where the identities can be user accounts, Google groups, Google domains, + * and service accounts. A role is a named list of permissions defined by IAM. + * + * @see Policy + */ +@BetaApi("This is a Beta API is not stable yet and may change in the future.") +@AutoValue +public abstract class Binding { + /** Get IAM Policy Binding Role */ + public abstract String getRole(); + + /** Get IAM Policy Binding Members */ + public abstract ImmutableList getMembers(); + + /** Get IAM Policy Binding Condition */ + @Nullable + public abstract Condition getCondition(); + + /** Create a Binding.Builder from an existing Binding */ + public abstract Builder toBuilder(); + + /** Create a new Binding.Builder */ + public static Builder newBuilder() { + List emptyMembers = ImmutableList.of(); + return new AutoValue_Binding.Builder().setMembers(emptyMembers); + } + + @AutoValue.Builder + public abstract static class Builder { + /** + * Set IAM Role for Policy Binding + * + * @throws NullPointerException if the role is null. + */ + public abstract Builder setRole(String role); + + /** + * Set IAM Members for Policy Binding + * + * @throws NullPointerException if a member is null. + */ + public abstract Builder setMembers(Iterable members); + + /** Set IAM Condition for Policy Binding */ + public abstract Builder setCondition(Condition condition); + + /** Internal use to getMembers() in addMembers() and removeMembers() */ + abstract ImmutableList getMembers(); + + /** + * Add members to Policy Binding. + * + * @throws NullPointerException if a member is null. + */ + public Builder addMembers(String member, String... moreMembers) { + ImmutableList.Builder membersBuilder = ImmutableList.builder(); + membersBuilder.addAll(getMembers()); + membersBuilder.addAll(Lists.asList(member, moreMembers)); + setMembers(membersBuilder.build()); + return this; + } + + /** + * Remove members to Policy Binding. + * + * @throws NullPointerException if a member is null. + */ + public Builder removeMembers(String... members) { + Predicate selectMembersNotInList = not(in(Arrays.asList(members))); + Collection filter = Collections2.filter(getMembers(), selectMembersNotInList); + setMembers(filter); + return this; + } + + public abstract Binding build(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ByteArray.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ByteArray.java new file mode 100644 index 000000000000..5841c541c46d --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ByteArray.java @@ -0,0 +1,153 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.BetaApi; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.io.BaseEncoding; +import com.google.protobuf.ByteString; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Iterator; + +/** An immutable byte array holder. */ +@BetaApi +public class ByteArray implements Iterable, Serializable { + + private static final long serialVersionUID = -1908809133893782840L; + private static final BaseEncoding encoder = BaseEncoding.base64(); + + private final ByteString byteString; + + ByteArray(ByteString byteString) { + this.byteString = byteString; + } + + @Override + public final Iterator iterator() { + return byteString.iterator(); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + StringBuilder stBuilder = new StringBuilder(); + for (int i = 0; i < Math.min(256, byteString.size()); i++) { + stBuilder.append(String.format("%02x", byteString.byteAt(i))); + } + if (byteString.size() > 256) { + stBuilder.append("..."); + } + return toStringHelper.add("bytes", stBuilder.toString()).toString(); + } + + @Override + public final int hashCode() { + return byteString.hashCode(); + } + + @Override + public final boolean equals(Object obj) { + return obj == this + || obj instanceof ByteArray && byteString.equals(((ByteArray) obj).byteString); + } + + /** Returns the number of bytes in this {@code ByteArray}. */ + public final int length() { + return byteString.size(); + } + + /** Returns a copy of this {@code ByteArray} as an array of bytes. */ + public final byte[] toByteArray() { + return byteString.toByteArray(); + } + + /** Returns a copy of this {@code ByteArray} as an {@code UTF-8} string. */ + public final String toStringUtf8() { + return byteString.toStringUtf8(); + } + + /** Converts this byte array to its base64 representation. */ + public final String toBase64() { + return encoder.encode(toByteArray()); + } + + /** Returns the content of this {@code ByteArray} as a read-only {@link ByteBuffer}. */ + public final ByteBuffer asReadOnlyByteBuffer() { + return byteString.asReadOnlyByteBuffer(); + } + + /** Returns an {@link InputStream} for this {@code ByteArray} content. */ + public final InputStream asInputStream() { + return byteString.newInput(); + } + + /** + * Copies the content of this {@code ByteArray} into an existing {@code ByteBuffer}. + * + * @throws java.nio.ReadOnlyBufferException if the target is read-only + * @throws java.nio.BufferOverflowException if the target's {@link ByteBuffer#remaining()} space + * is not large enough to hold the data + */ + public final void copyTo(ByteBuffer target) { + byteString.copyTo(target); + } + + /** + * Copies the content of this {@code ByteArray} into an array of bytes. + * + * @throws IndexOutOfBoundsException if the target is not large enough to hold the data + */ + public final void copyTo(byte[] target) { + byteString.copyTo(target, 0); + } + + /** Creates a {@code ByteArray} object given an array of bytes. The bytes are copied. */ + public static final ByteArray copyFrom(byte[] bytes) { + return new ByteArray(ByteString.copyFrom(bytes)); + } + + /** + * Creates a {@code ByteArray} object given a string. The string is encoded in {@code UTF-8}. The + * bytes are copied. + */ + public static final ByteArray copyFrom(String string) { + return new ByteArray(ByteString.copyFrom(string, StandardCharsets.UTF_8)); + } + + /** Creates a {@code ByteArray} object given a {@link ByteBuffer}. The bytes are copied. */ + public static final ByteArray copyFrom(ByteBuffer bytes) { + return new ByteArray(ByteString.copyFrom(bytes)); + } + + /** + * Creates a {@code ByteArray} object given an {@link InputStream}. The stream is read into the + * created object. + */ + public static final ByteArray copyFrom(InputStream input) throws IOException { + return new ByteArray(ByteString.readFrom(input)); + } + + /** Creates a {@code ByteArray} from a base64 representation. */ + public static ByteArray fromBase64(String data) { + return ByteArray.copyFrom(encoder.decode(data)); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java new file mode 100644 index 000000000000..c3c4c83fb986 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Condition.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.BetaApi; +import com.google.auto.value.AutoValue; +import javax.annotation.Nullable; + +/** + * Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access + * settings for Cloud Platform resources. A policy is a list of bindings. A binding assigns a set of + * identities to a role, where the identities can be user accounts, Google groups, Google domains, + * and service accounts. A role is a named list of permissions defined by IAM. + * + * @see Policy + * @see IAM Conditions + */ +@BetaApi("This is a Beta API is not stable yet and may change in the future.") +@AutoValue +public abstract class Condition { + /** Get IAM Policy Binding Condition Title */ + @Nullable + public abstract String getTitle(); + + /** Get IAM Policy Binding Condition Description */ + @Nullable + public abstract String getDescription(); + + /** Get IAM Policy Binding Condition Expression */ + public abstract String getExpression(); + + /** Create a new Condition.Builder from an existing Condition */ + public abstract Builder toBuilder(); + + /** Create a new Condition.Builder */ + public static Builder newBuilder() { + return new AutoValue_Condition.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + /** Set IAM Policy Binding Condition Title */ + public abstract Builder setTitle(@Nullable String title); + + /** Set IAM Policy Binding Condition Description */ + public abstract Builder setDescription(@Nullable String description); + + /** Set IAM Policy Binding Condition Expression */ + public abstract Builder setExpression(String expression); + + /** Build Builder which creates a Condition instance */ + public abstract Condition build(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Date.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Date.java new file mode 100644 index 000000000000..d7f3b71275e7 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Date.java @@ -0,0 +1,159 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.BetaApi; +import com.google.common.base.Preconditions; +import java.io.Serializable; +import java.util.Calendar; +import java.util.Objects; + +/** Represents a Date without time, such as 2017-03-17. Date is timezone independent. */ +@BetaApi("This is going to be replaced with LocalDate from threetenbp") +public final class Date implements Comparable, Serializable { + + // Date format "yyyy-mm-dd" + private static final long serialVersionUID = 8067099123096783929L; + private final int year; + private final int month; + private final int dayOfMonth; + + private Date(int year, int month, int dayOfMonth) { + Preconditions.checkArgument(year > 0, "Invalid year: " + year); + Preconditions.checkArgument(month > 0 && month <= 12, "Invalid month: " + month); + Preconditions.checkArgument(dayOfMonth > 0 && dayOfMonth <= 31, "Invalid day: " + dayOfMonth); + this.year = year; + this.month = month; + this.dayOfMonth = dayOfMonth; + } + + /** + * Constructs a new Date instance. + * + * @param year must be greater than 0 + * @param month must be between [1,12] + * @param dayOfMonth must be between [1,31] + */ + public static Date fromYearMonthDay(int year, int month, int dayOfMonth) { + return new Date(year, month, dayOfMonth); + } + + /** @param date Data in RFC 3339 date format (yyyy-mm-dd). */ + public static Date parseDate(String date) { + Preconditions.checkNotNull(date); + final String invalidDate = "Invalid date: " + date; + Preconditions.checkArgument(date.length() == 10, invalidDate); + Preconditions.checkArgument(date.charAt(4) == '-', invalidDate); + Preconditions.checkArgument(date.charAt(7) == '-', invalidDate); + try { + int year = Integer.parseInt(date.substring(0, 4)); + int month = Integer.parseInt(date.substring(5, 7)); + int dayOfMonth = Integer.parseInt(date.substring(8, 10)); + return new Date(year, month, dayOfMonth); + } catch (NumberFormatException e) { + throw new IllegalArgumentException(invalidDate, e); + } + } + + /** + * Convert a Google Date to a Java Util Date. + * + * @param date the date of the Google Date. + * @return java.util.Date + */ + public static java.util.Date toJavaUtilDate(Date date) { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + // Calender.MONTH starts from 0 while G C date starts from 1 + cal.set(date.year, date.month - 1, date.dayOfMonth); + return cal.getTime(); + } + + /** + * Convert a Java Util Date to a Google Date. + * + * @param date the date of the java.util.Date + * @return Google Java Date + */ + public static Date fromJavaUtilDate(java.util.Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + // Calender.MONTH starts from 0 while G C date starts from 1 + return new Date( + cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH)); + } + + /** Returns the year. */ + public int getYear() { + return year; + } + + /** Returns the month between 1 and 12 inclusive. */ + public int getMonth() { + return month; + } + + /** Returns day of month between 1 and 31 inclusive. */ + public int getDayOfMonth() { + return dayOfMonth; + } + + @Override + public String toString() { + return String.format("%04d-%02d-%02d", year, month, dayOfMonth); + } + + StringBuilder toString(StringBuilder b) { + return b.append(toString()); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Date that = (Date) o; + return year == that.year && month == that.month && dayOfMonth == that.dayOfMonth; + } + + @Override + public int hashCode() { + return Objects.hash(year, month, dayOfMonth); + } + + @Override + public int compareTo(Date other) { + int r = Integer.compare(year, other.year); + if (r == 0) { + r = Integer.compare(month, other.month); + if (r == 0) { + r = Integer.compare(dayOfMonth, other.dayOfMonth); + } + } + return r; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java new file mode 100644 index 000000000000..d243de180771 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ExceptionHandler.java @@ -0,0 +1,296 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.BetaApi; +import com.google.api.gax.retrying.ResultRetryAlgorithm; +import com.google.api.gax.retrying.TimedAttemptSettings; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.Callable; + +/** Exception retry algorithm implementation used by {@link RetryHelper}. */ +@BetaApi +public final class ExceptionHandler implements ResultRetryAlgorithm, Serializable { + + private static final long serialVersionUID = -2460707015779532919L; + + private static final ExceptionHandler DEFAULT_INSTANCE = + newBuilder().retryOn(Exception.class).abortOn(RuntimeException.class).build(); + + private final ImmutableList interceptors; + private final ImmutableSet> retriableExceptions; + private final ImmutableSet> nonRetriableExceptions; + private final Set retryInfo = Sets.newHashSet(); + + public interface Interceptor extends Serializable { + + enum RetryResult { + NO_RETRY, + RETRY, + CONTINUE_EVALUATION; + } + + /** + * This method is called before exception evaluation and could short-circuit the process. + * + * @param exception the exception that is being evaluated + * @return {@link RetryResult} to indicate if the exception should be ignored ( {@link + * RetryResult#RETRY}), propagated ({@link RetryResult#NO_RETRY}), or evaluation should + * proceed ({@link RetryResult#CONTINUE_EVALUATION}). + */ + RetryResult beforeEval(Exception exception); + + /** + * This method is called after the evaluation and could alter its result. + * + * @param exception the exception that is being evaluated + * @param retryResult the result of the evaluation so far + * @return {@link RetryResult} to indicate if the exception should be ignored ( {@link + * RetryResult#RETRY}), propagated ({@link RetryResult#NO_RETRY}), or evaluation should + * proceed ({@link RetryResult#CONTINUE_EVALUATION}). + */ + RetryResult afterEval(Exception exception, RetryResult retryResult); + } + + /** ExceptionHandler builder. */ + public static class Builder { + + private final ImmutableList.Builder interceptors = ImmutableList.builder(); + private final ImmutableSet.Builder> retriableExceptions = + ImmutableSet.builder(); + private final ImmutableSet.Builder> nonRetriableExceptions = + ImmutableSet.builder(); + + private Builder() {} + + /** + * Adds the exception handler interceptors. Call order will be maintained. + * + * @param interceptors the interceptors for this exception handler + * @return the Builder for chaining + */ + public Builder addInterceptors(Interceptor... interceptors) { + for (Interceptor interceptor : interceptors) { + this.interceptors.add(interceptor); + } + return this; + } + + /** + * Add the exceptions to ignore/retry-on. + * + * @param exceptions retry should continue when such exceptions are thrown + * @return the Builder for chaining + */ + @SafeVarargs + public final Builder retryOn(Class... exceptions) { + for (Class exception : exceptions) { + retriableExceptions.add(checkNotNull(exception)); + } + return this; + } + + /** + * Adds the exceptions to abort on. + * + * @param exceptions retry should abort when such exceptions are thrown + * @return the Builder for chaining + */ + @SafeVarargs + public final Builder abortOn(Class... exceptions) { + for (Class exception : exceptions) { + nonRetriableExceptions.add(checkNotNull(exception)); + } + return this; + } + + /** Returns a new ExceptionHandler instance. */ + public ExceptionHandler build() { + return new ExceptionHandler(this); + } + } + + @VisibleForTesting + static final class RetryInfo implements Serializable { + + private static final long serialVersionUID = -4264634837841455974L; + private final Class exception; + private final Interceptor.RetryResult retry; + private final Set children = Sets.newHashSet(); + + RetryInfo(Class exception, Interceptor.RetryResult retry) { + this.exception = checkNotNull(exception); + this.retry = checkNotNull(retry); + } + + @Override + public int hashCode() { + return exception.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RetryInfo)) { + return false; + } + // We only care about exception in equality as we allow only one instance per exception + return ((RetryInfo) obj).exception.equals(exception); + } + } + + private ExceptionHandler(Builder builder) { + interceptors = builder.interceptors.build(); + retriableExceptions = builder.retriableExceptions.build(); + nonRetriableExceptions = builder.nonRetriableExceptions.build(); + Preconditions.checkArgument( + Sets.intersection(retriableExceptions, nonRetriableExceptions).isEmpty(), + "Same exception was found in both retryable and non-retryable sets"); + for (Class exception : retriableExceptions) { + addRetryInfo(new RetryInfo(exception, Interceptor.RetryResult.RETRY), retryInfo); + } + for (Class exception : nonRetriableExceptions) { + addRetryInfo(new RetryInfo(exception, Interceptor.RetryResult.NO_RETRY), retryInfo); + } + } + + private static void addRetryInfo(RetryInfo retryInfo, Set dest) { + for (RetryInfo current : dest) { + if (current.exception.isAssignableFrom(retryInfo.exception)) { + addRetryInfo(retryInfo, current.children); + return; + } + if (retryInfo.exception.isAssignableFrom(current.exception)) { + retryInfo.children.add(current); + } + } + dest.removeAll(retryInfo.children); + dest.add(retryInfo); + } + + private static RetryInfo findMostSpecificRetryInfo( + Set retryInfo, Class exception) { + for (RetryInfo current : retryInfo) { + if (current.exception.isAssignableFrom(exception)) { + RetryInfo match = findMostSpecificRetryInfo(current.children, exception); + return match == null ? current : match; + } + } + return null; + } + + // called for Class, therefore a "call" method must be found. + private static Method getCallableMethod(Class clazz) { + try { + return clazz.getDeclaredMethod("call"); + } catch (NoSuchMethodException e) { + // check parent + return getCallableMethod(clazz.getSuperclass()); + } catch (SecurityException e) { + // This should never happen + throw new IllegalStateException("Unexpected exception", e); + } + } + + void verifyCaller(Callable callable) { + Method callMethod = getCallableMethod(callable.getClass()); + for (Class exceptionOrError : callMethod.getExceptionTypes()) { + Preconditions.checkArgument( + Exception.class.isAssignableFrom(exceptionOrError), + "Callable method exceptions must be derived from Exception"); + @SuppressWarnings("unchecked") + Class exception = (Class) exceptionOrError; + Preconditions.checkArgument( + findMostSpecificRetryInfo(retryInfo, exception) != null, + "Declared exception '" + exception + "' is not covered by exception handler"); + } + } + + @Override + public boolean shouldRetry(Throwable prevThrowable, Object prevResponse) { + if (!(prevThrowable instanceof Exception)) { + return false; + } + Exception ex = (Exception) prevThrowable; + for (Interceptor interceptor : interceptors) { + Interceptor.RetryResult retryResult = checkNotNull(interceptor.beforeEval(ex)); + if (retryResult != Interceptor.RetryResult.CONTINUE_EVALUATION) { + return retryResult == Interceptor.RetryResult.RETRY; + } + } + RetryInfo retryInfo = findMostSpecificRetryInfo(this.retryInfo, ex.getClass()); + Interceptor.RetryResult retryResult = + retryInfo == null ? Interceptor.RetryResult.NO_RETRY : retryInfo.retry; + for (Interceptor interceptor : interceptors) { + Interceptor.RetryResult interceptorRetry = + checkNotNull(interceptor.afterEval(ex, retryResult)); + if (interceptorRetry != Interceptor.RetryResult.CONTINUE_EVALUATION) { + retryResult = interceptorRetry; + } + } + return retryResult == Interceptor.RetryResult.RETRY; + } + + @Override + public TimedAttemptSettings createNextAttempt( + Throwable prevThrowable, Object prevResponse, TimedAttemptSettings prevSettings) { + // Return null to indicate that this implementation does not provide any specific attempt + // settings, so by default the TimedRetryAlgorithm options can be used instead. + return null; + } + + @Override + public int hashCode() { + return Objects.hash(interceptors, retriableExceptions, nonRetriableExceptions, retryInfo); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ExceptionHandler)) { + return false; + } + ExceptionHandler other = (ExceptionHandler) obj; + return Objects.equals(interceptors, other.interceptors) + && Objects.equals(retriableExceptions, other.retriableExceptions) + && Objects.equals(nonRetriableExceptions, other.nonRetriableExceptions) + && Objects.equals(retryInfo, other.retryInfo); + } + + /** Returns an instance which retry any checked exception and abort on any runtime exception. */ + public static ExceptionHandler getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/FieldSelector.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/FieldSelector.java new file mode 100644 index 000000000000..aad60f7a4dd8 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/FieldSelector.java @@ -0,0 +1,127 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.InternalApi; +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +/** + * Interface for Google Cloud resource's fields. Implementations of this interface can be used to + * select only desired fields from a returned Google Cloud resource. + */ +public interface FieldSelector { + + /** + * Returns a string selector. This selector is passed to a Google Cloud service (possibly with + * other field selectors) to specify which resource fields should be returned by an API call. + */ + String getSelector(); + + /** + * A helper class used to build composite selectors given a number of fields. This class is not + * supposed to be used directly by users. + */ + @InternalApi + class Helper { + + private static final String[] EMPTY_FIELDS = {}; + + private Helper() {} + + private static final Function FIELD_TO_STRING_FUNCTION = + new Function() { + @Override + public String apply(FieldSelector fieldSelector) { + return fieldSelector.getSelector(); + } + }; + + private static String selector( + List required, + FieldSelector[] others, + String... extraResourceFields) { + Set fieldStrings = Sets.newHashSetWithExpectedSize(required.size() + others.length); + fieldStrings.addAll(Lists.transform(required, FIELD_TO_STRING_FUNCTION)); + fieldStrings.addAll(Lists.transform(Arrays.asList(others), FIELD_TO_STRING_FUNCTION)); + fieldStrings.addAll(Arrays.asList(extraResourceFields)); + return Joiner.on(',').join(fieldStrings); + } + + /** + * Returns a composite selector given a number of resource fields. The string selector returned + * by this method can be used for field selection in API calls that return a single resource. + * This method is not supposed to be used directly by users. + */ + public static String selector(List required, FieldSelector... others) { + return selector(required, others, new String[] {}); + } + + /** + * Returns a composite selector given a number of resource fields and a container name. The + * string selector returned by this method can be used for field selection in API calls that + * return a list of resources. This method is not supposed to be used directly by users. + */ + public static String listSelector( + String containerName, List required, FieldSelector... others) { + return "nextPageToken," + containerName + '(' + selector(required, others) + ')'; + } + + /** + * Returns a composite selector given a number of resource fields and a container name. This + * method also takes an {@code extraResourceFields} parameter to specify some extra resource + * fields as strings. The string selector returned by this method can be used for field + * selection in API calls that return a list of resources. This method is not supposed to be + * used directly by users. + */ + public static String listSelector( + String containerName, + List required, + FieldSelector[] others, + String... extraResourceFields) { + return listSelector(EMPTY_FIELDS, containerName, required, others, extraResourceFields); + } + + /** + * Returns a composite selector given a number of top level fields as strings, a number of + * resource fields and a container name. This method also takes an {@code extraResourceFields} + * parameter to specify some extra resource fields as strings. The string selector returned by + * this method can be used for field selection in API calls that return a list of resources. + * This method is not supposed to be used directly by users. + */ + public static String listSelector( + String[] topLevelFields, + String containerName, + List required, + FieldSelector[] others, + String... extraResourceFields) { + Set topLevelStrings = Sets.newHashSetWithExpectedSize(topLevelFields.length + 1); + topLevelStrings.addAll(Lists.asList("nextPageToken", topLevelFields)); + return Joiner.on(',').join(topLevelStrings) + + "," + + containerName + + '(' + + selector(required, others, extraResourceFields) + + ')'; + } + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/GcpLaunchStage.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/GcpLaunchStage.java new file mode 100644 index 000000000000..e83f773c9d4d --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/GcpLaunchStage.java @@ -0,0 +1,75 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * A qualifier indicating what level of access and support can be expected of a particular Google + * Cloud Platform feature. The "GeneralAvailability" qualifier is not provided since the vast + * majority of features are in this category. Note that features may be in a later launch stage than + * the client library annotation indicates. + * + *

See more at the Launch Stages + * Documentation. + */ +public class GcpLaunchStage { + + /** + * Early Access features are limited to a closed group of testers. To use these features, you must + * sign up in advance and sign a Trusted Tester agreement (which includes confidentiality + * provisions). These features may be unstable, changed in backward-incompatible ways, and are not + * guaranteed to be released. + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface EarlyAccess {} + + /** + * Alpha is a limited availability test for releases before they are cleared for widespread use. + * By Alpha, all significant design issues are resolved and we are in the process of verifying + * functionality. Alpha customers need to apply for access, agree to applicable terms, and have + * their projects whitelisted. Alpha releases don’t have to be feature complete, no SLAs are + * provided, and there are no technical support obligations, but they will be far enough along + * that customers can actually use them in test environments or for limited-use tests -- just like + * they would in normal production cases. + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface Alpha {} + + /** + * Beta is the point at which we are ready to open a release for any customer to use. There are no + * SLA or technical support obligations in a Beta release, and charges may be waived in some + * cases. Products will be complete from a feature perspective, but may have some open outstanding + * issues. Beta releases are suitable for limited production use cases. + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface Beta {} + + /** + * Deprecated features are scheduled to be shut down and removed. For more information, see the + * “Deprecation Policy” section of our Terms of + * Service and the Google Cloud Platform + * Subject to the Deprecation Policy documentation. + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface Deprecated {} + + private GcpLaunchStage() { + // Intentionally left blank. + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Identity.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Identity.java new file mode 100644 index 000000000000..a3aff1ade722 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Identity.java @@ -0,0 +1,268 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.ApiFunction; +import com.google.common.base.CaseFormat; +import java.io.Serializable; +import java.util.Objects; + +/** + * An identity in a {@link Policy}. The following types of identities are permitted in IAM policies: + * + *

    + *
  • Google account + *
  • Service account + *
  • Google group + *
  • Google Apps domain + *
+ * + *

There are also two special identities that represent all users and all Google-authenticated + * accounts. + * + * @see Concepts + * related to identity + */ +public final class Identity implements Serializable { + + private static final long serialVersionUID = -8181841964597657446L; + + private final Type type; + private final String value; + + /** The types of IAM identities. */ + public static final class Type extends StringEnumValue { + private static final long serialVersionUID = 3809891273596003916L; + + private Type(String constant) { + super(constant); + } + + private static final ApiFunction CONSTRUCTOR = + new ApiFunction() { + @Override + public Type apply(String constant) { + return new Type(constant); + } + }; + + private static final StringEnumType type = new StringEnumType(Type.class, CONSTRUCTOR); + + /** Represents anyone who is on the internet; with or without a Google account. */ + public static final Type ALL_USERS = type.createAndRegister("ALL_USERS"); + + /** Represents anyone who is authenticated with a Google account or a service account. */ + public static final Type ALL_AUTHENTICATED_USERS = + type.createAndRegister("ALL_AUTHENTICATED_USERS"); + + /** Represents a specific Google account. */ + public static final Type USER = type.createAndRegister("USER"); + + /** Represents a service account. */ + public static final Type SERVICE_ACCOUNT = type.createAndRegister("SERVICE_ACCOUNT"); + + /** Represents a Google group. */ + public static final Type GROUP = type.createAndRegister("GROUP"); + + /** Represents all the users of a Google Apps domain name. */ + public static final Type DOMAIN = type.createAndRegister("DOMAIN"); + + /** Represents owners of a Google Cloud Platform project. */ + public static final Type PROJECT_OWNER = type.createAndRegister("PROJECT_OWNER"); + + /** Represents editors of a Google Cloud Platform project. */ + public static final Type PROJECT_EDITOR = type.createAndRegister("PROJECT_EDITOR"); + + /** Represents viewers of a Google Cloud Platform project. */ + public static final Type PROJECT_VIEWER = type.createAndRegister("PROJECT_VIEWER"); + + /** + * Get the Type for the given String constant, and throw an exception if the constant is not + * recognized. + */ + public static Type valueOfStrict(String constant) { + return type.valueOfStrict(constant); + } + + /** Get the Type for the given String constant, and allow unrecognized values. */ + public static Type valueOf(String constant) { + return type.valueOf(constant); + } + + /** Return the known values for Type. */ + public static Type[] values() { + return type.values(); + } + } + + private Identity(Type type, String value) { + this.type = type; + this.value = value; + } + + public Type getType() { + return type; + } + + /** + * Returns the string identifier for this identity. The value corresponds to: + * + *

    + *
  • email address (for identities of type {@code USER}, {@code SERVICE_ACCOUNT}, and {@code + * GROUP}) + *
  • domain (for identities of type {@code DOMAIN}) + *
  • {@code null} (for identities of type {@code ALL_USERS} and {@code + * ALL_AUTHENTICATED_USERS}) + *
+ */ + public String getValue() { + return value; + } + + /** + * Returns a new identity representing anyone who is on the internet; with or without a Google + * account. + */ + public static Identity allUsers() { + return new Identity(Type.ALL_USERS, null); + } + + /** + * Returns a new identity representing anyone who is authenticated with a Google account or a + * service account. + */ + public static Identity allAuthenticatedUsers() { + return new Identity(Type.ALL_AUTHENTICATED_USERS, null); + } + + /** + * Returns a new user identity. + * + * @param email An email address that represents a specific Google account. For example, + * alice@gmail.com or joe@example.com. + */ + public static Identity user(String email) { + return new Identity(Type.USER, checkNotNull(email)); + } + + /** + * Returns a new service account identity. + * + * @param email An email address that represents a service account. For example, + * my-other-app@appspot.gserviceaccount.com. + */ + public static Identity serviceAccount(String email) { + return new Identity(Type.SERVICE_ACCOUNT, checkNotNull(email)); + } + + /** + * Returns a new group identity. + * + * @param email An email address that represents a Google group. For example, + * admins@example.com. + */ + public static Identity group(String email) { + return new Identity(Type.GROUP, checkNotNull(email)); + } + + /** + * Returns a new domain identity. + * + * @param domain A Google Apps domain name that represents all the users of that domain. For + * example, google.com or example.com. + */ + public static Identity domain(String domain) { + return new Identity(Type.DOMAIN, checkNotNull(domain)); + } + + /** + * Returns a new project owner identity. + * + * @param projectId A Google Cloud Platform project ID. For example, my-sample-project. + */ + public static Identity projectOwner(String projectId) { + return new Identity(Type.PROJECT_OWNER, checkNotNull(projectId)); + } + + /** + * Returns a new project editor identity. + * + * @param projectId A Google Cloud Platform project ID. For example, my-sample-project. + */ + public static Identity projectEditor(String projectId) { + return new Identity(Type.PROJECT_EDITOR, checkNotNull(projectId)); + } + + /** + * Returns a new project viewer identity. + * + * @param projectId A Google Cloud Platform project ID. For example, my-sample-project. + */ + public static Identity projectViewer(String projectId) { + return new Identity(Type.PROJECT_VIEWER, checkNotNull(projectId)); + } + + @Override + public String toString() { + return strValue(); + } + + @Override + public int hashCode() { + return Objects.hash(value, type); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Identity)) { + return false; + } + Identity other = (Identity) obj; + return Objects.equals(value, other.getValue()) && Objects.equals(type, other.getType()); + } + + /** + * Returns the string value associated with the identity. Used primarily for converting from + * {@code Identity} objects to strings for protobuf-generated policies. + */ + public String strValue() { + String protobufString = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, type.toString()); + if (value == null) { + return protobufString; + } else { + return protobufString + ":" + value; + } + } + + /** + * Converts a string to an {@code Identity}. Used primarily for converting protobuf-generated + * policy identities to {@code Identity} objects. + */ + public static Identity valueOf(String identityStr) { + String[] info = identityStr.split(":", 2); + Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0])); + if (info.length == 1) { + return new Identity(type, null); + } else if (info.length == 2) { + return new Identity(type, info[1]); + } else { + throw new IllegalArgumentException("Illegal identity string: \"" + identityStr + "\""); + } + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/MetadataConfig.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/MetadataConfig.java new file mode 100644 index 000000000000..8f1bac04ca69 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/MetadataConfig.java @@ -0,0 +1,88 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * Retrieves Google Cloud project-id and a limited set of instance attributes from Metadata server. + * + * @see + * https://cloud.google.com/compute/docs/storing-retrieving-metadata + */ +public class MetadataConfig { + + private static final String METADATA_URL = "http://metadata.google.internal/computeMetadata/v1/"; + private static final int TIMEOUT_MS = 5000; + + private MetadataConfig() {} + + public static String getProjectId() { + return getAttribute("project/project-id"); + } + + public static String getZone() { + String zoneId = getAttribute("instance/zone"); + if (zoneId != null && zoneId.contains("/")) { + return zoneId.substring(zoneId.lastIndexOf('/') + 1); + } + return zoneId; + } + + public static String getInstanceId() { + return getAttribute("instance/id"); + } + + public static String getClusterName() { + return getAttribute("instance/attributes/cluster-name"); + } + + public static String getContainerName() { + return getAttribute("instance/attributes/container-name"); + } + + public static String getNamespaceId() { + return getAttribute("instance/attributes/namespace-id"); + } + + public static String getAttribute(String attributeName) { + try { + URL url = new URL(METADATA_URL + attributeName); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setConnectTimeout(TIMEOUT_MS); + connection.setReadTimeout(TIMEOUT_MS); + connection.setRequestProperty("Metadata-Flavor", "Google"); + try (InputStream input = connection.getInputStream()) { + if (connection.getResponseCode() == 200) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, UTF_8))) { + return reader.readLine(); + } + } + } + } catch (IOException ignore) { + // ignore + } + return null; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/MonitoredResource.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/MonitoredResource.java new file mode 100644 index 000000000000..a1fbe44b92dd --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/MonitoredResource.java @@ -0,0 +1,165 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableMap; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Objects of this class represent a resource that can be used for monitoring, logging, billing, or + * other purposes. Examples include virtual machine instances, databases, and storage devices such + * as disks. The type field identifies a {@link MonitoredResourceDescriptor} object that describes + * the resource's schema. Information in the labels field identifies the actual resource and its + * attributes according to the schema. + * + *

For example, the monitored resource for Google Compute Engine VM instances has {@code + * gce_instance} type and specifies values for the labels {@code instance_id} and {@code zone} to + * identify particular VM instances. + */ +public final class MonitoredResource implements Serializable { + + private static final long serialVersionUID = -4393604148752640581L; + + private final String type; + private final Map labels; + + /** A builder for {@code MonitoredResource} objects. */ + public static class Builder { + + private String type; + private Map labels = new HashMap<>(); + + Builder(String type) { + this.type = type; + } + + Builder(MonitoredResource monitoredResource) { + this.type = monitoredResource.type; + this.labels = new HashMap<>(monitoredResource.labels); + } + + /** + * Sets the monitored resource type. This value must match the one of {@link + * MonitoredResourceDescriptor#getType()} of a {@code MonitoredResourceDescriptor} object. For + * example, the type {@code cloudsql_database} represent databases in Google Cloud SQL. + */ + public Builder setType(String type) { + this.type = type; + return this; + } + + /** + * Sets the values for all the labels required by the corresponding monitored resource + * descriptor (see {@link MonitoredResourceDescriptor#getLabels()}. For example, Google Compute + * Engine VM instances use the labels {@code instance_id} and {@code zone}. + */ + public Builder setLabels(Map labels) { + this.labels = new HashMap<>(checkNotNull(labels)); + return this; + } + + /** Adds a label to the labels of the monitored resource. */ + public Builder addLabel(String key, String value) { + this.labels.put(key, value); + return this; + } + + /** Clears all the labels of the monitored resource. */ + public Builder clearLabels() { + this.labels.clear(); + return this; + } + + public MonitoredResource build() { + return new MonitoredResource(this); + } + } + + MonitoredResource(Builder builder) { + this.type = checkNotNull(builder.type); + this.labels = ImmutableMap.copyOf(builder.labels); + } + + /** + * Returns the monitored resource type. This value must match the one of {@link + * MonitoredResourceDescriptor#getType()} of a {@code MonitoredResourceDescriptor} object. For + * example, the type {@code cloudsql_database} represent databases in Google Cloud SQL. + */ + public String getType() { + return type; + } + + /** + * Returns the values for all the labels required by the corresponding monitored resource + * descriptor (see {@link MonitoredResourceDescriptor#getLabels()}. For example, Google Compute + * Engine VM instances use the labels {@code instance_id} and {@code zone}. + */ + public Map getLabels() { + return labels; + } + + @Override + public int hashCode() { + return Objects.hash(type, labels); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MonitoredResource)) { + return false; + } + MonitoredResource other = (MonitoredResource) obj; + return Objects.equals(type, other.type) && Objects.equals(labels, other.labels); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("type", type).add("labels", labels).toString(); + } + + public com.google.api.MonitoredResource toPb() { + return com.google.api.MonitoredResource.newBuilder().setType(type).putAllLabels(labels).build(); + } + + /** Returns a builder for this {@code MonitoredResource} object. */ + public Builder toBuilder() { + return new Builder(this); + } + + /** Returns a builder for {@code MonitoredResource} objects given the resource's type. */ + public static Builder newBuilder(String type) { + return new Builder(type); + } + + /** Creates a {@code MonitoredResource} object given the resource's type and labels. */ + public static MonitoredResource of(String type, Map labels) { + return newBuilder(type).setLabels(labels).build(); + } + + public static MonitoredResource fromPb(com.google.api.MonitoredResource descriptorPb) { + return new Builder(descriptorPb.getType()).setLabels(descriptorPb.getLabelsMap()).build(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/MonitoredResourceDescriptor.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/MonitoredResourceDescriptor.java new file mode 100644 index 000000000000..cfc24590d4c8 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/MonitoredResourceDescriptor.java @@ -0,0 +1,342 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.ApiFunction; +import com.google.common.base.Function; +import com.google.common.base.MoreObjects; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * This class describes the schema of Cloud monitored resources. Monitored resource descriptors + * contain a type name and a set of labels. For example, the monitored resource descriptor for + * Google Compute Engine VM instances has a type of {@code gce_instance} and specifies the use of + * the labels {@code instance_id} and {@code zone} to identify particular VM instances. + */ +public class MonitoredResourceDescriptor implements Serializable { + + private static final long serialVersionUID = -3702077512777687441L; + public static final ApiFunction< + com.google.api.MonitoredResourceDescriptor, MonitoredResourceDescriptor> + FROM_PB_FUNCTION = + new ApiFunction< + com.google.api.MonitoredResourceDescriptor, MonitoredResourceDescriptor>() { + @Override + public MonitoredResourceDescriptor apply( + com.google.api.MonitoredResourceDescriptor pb) { + return fromPb(pb); + } + }; + + private final String type; + private final String name; + private final String displayName; + private final String description; + private final List labels; + + /** + * This class describes a label for a monitored resource. Label descriptors contain the key for + * the label, the type of data that the label can hold and an optional description. + */ + public static class LabelDescriptor implements Serializable { + + private static final long serialVersionUID = -2811608103754481777L; + private static final Function + FROM_PB_FUNCTION = + new Function() { + @Override + public LabelDescriptor apply(com.google.api.LabelDescriptor descriptorPb) { + return fromPb(descriptorPb); + } + }; + private static final Function TO_PB_FUNCTION = + new Function() { + @Override + public com.google.api.LabelDescriptor apply(LabelDescriptor descriptor) { + return descriptor.toPb(); + } + }; + + private final String key; + private final ValueType valueType; + private final String description; + + /** Value types that can be used as label values. */ + public enum ValueType { + STRING(com.google.api.LabelDescriptor.ValueType.STRING), + BOOL(com.google.api.LabelDescriptor.ValueType.BOOL), + INT64(com.google.api.LabelDescriptor.ValueType.INT64); + + private com.google.api.LabelDescriptor.ValueType typePb; + + ValueType(com.google.api.LabelDescriptor.ValueType typePb) { + this.typePb = typePb; + } + + com.google.api.LabelDescriptor.ValueType toPb() { + return typePb; + } + + static ValueType fromPb(com.google.api.LabelDescriptor.ValueType typePb) { + switch (typePb) { + case STRING: + return ValueType.STRING; + case BOOL: + return ValueType.BOOL; + case INT64: + return ValueType.INT64; + default: + throw new IllegalArgumentException("Unrecognized label type"); + } + } + } + + LabelDescriptor(String key, ValueType valueType, String description) { + this.key = checkNotNull(key); + this.valueType = checkNotNull(valueType); + this.description = description; + } + + /** Returns the key associated to this label. */ + public String getKey() { + return key; + } + + /** Returns the type of data that can be assigned to this label. */ + public ValueType getValueType() { + return valueType; + } + + /** + * Returns the optional human-readable description for this label. If not set, this method + * returns {@code null}. + */ + public String getDescription() { + return description; + } + + @Override + public final int hashCode() { + return Objects.hash(key, valueType, description); + } + + @Override + public final boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj == null || !obj.getClass().equals(LabelDescriptor.class)) { + return false; + } + LabelDescriptor other = (LabelDescriptor) obj; + return Objects.equals(key, other.key) + && Objects.equals(valueType, other.valueType) + && Objects.equals(description, other.description); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("key", key) + .add("valueType", valueType) + .add("description", description) + .toString(); + } + + com.google.api.LabelDescriptor toPb() { + com.google.api.LabelDescriptor.Builder builder = + com.google.api.LabelDescriptor.newBuilder().setKey(key).setValueType(valueType.toPb()); + if (description != null) { + builder.setDescription(description); + } + return builder.build(); + } + + static LabelDescriptor fromPb(com.google.api.LabelDescriptor descriptorPb) { + String description = null; + if (descriptorPb.getDescription() != null && !descriptorPb.getDescription().equals("")) { + description = descriptorPb.getDescription(); + } + return new LabelDescriptor( + descriptorPb.getKey(), ValueType.fromPb(descriptorPb.getValueType()), description); + } + } + + static class Builder { + + private final String type; + private String name; + private String displayName; + private String description; + private List labels = new ArrayList<>(); + + Builder(String type) { + this.type = type; + } + + Builder setName(String name) { + this.name = name; + return this; + } + + Builder setDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + Builder setDescription(String description) { + this.description = description; + return this; + } + + Builder setLabels(List labels) { + this.labels = labels; + return this; + } + + MonitoredResourceDescriptor build() { + return new MonitoredResourceDescriptor(this); + } + } + + MonitoredResourceDescriptor(Builder builder) { + this.type = checkNotNull(builder.type); + this.name = builder.name; + this.displayName = builder.displayName; + this.description = builder.description; + this.labels = checkNotNull(builder.labels); + } + + /** + * Returns the monitored resource type. For example, the type {@code cloudsql_database} represents + * databases in Google Cloud SQL. + */ + public String getType() { + return type; + } + + /** + * Returns an optional name for the monitored resource descriptor. If not set, this method returns + * {@code null}. + */ + public String getName() { + return name; + } + + /** + * Returns an optional concise name for the monitored resource type. This value might be displayed + * in user interfaces. For example, {@code Google Cloud SQL Database}. If not set, this method + * returns {@code null}. + */ + public String getDisplayName() { + return displayName; + } + + /** + * Returns an optional detailed description of the monitored resource type. This value might be + * used in documentation. If not set, this method returns {@code null}. + */ + public String getDescription() { + return description; + } + + /** + * Returns a list of labels used to describe instances of this monitored resource type. For + * example, an individual Google Cloud SQL database is identified by values for the labels {@code + * database_id} and {@code region}. + */ + public List getLabels() { + return labels; + } + + @Override + public final int hashCode() { + return Objects.hash(type, name, displayName, description, labels); + } + + @Override + public final boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj == null || !obj.getClass().equals(MonitoredResourceDescriptor.class)) { + return false; + } + MonitoredResourceDescriptor other = (MonitoredResourceDescriptor) obj; + return Objects.equals(type, other.type) + && Objects.equals(name, other.name) + && Objects.equals(displayName, other.displayName) + && Objects.equals(description, other.description) + && Objects.equals(labels, other.labels); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("type", type) + .add("name", name) + .add("displayName", displayName) + .add("description", description) + .add("labels", labels) + .toString(); + } + + public com.google.api.MonitoredResourceDescriptor toPb() { + com.google.api.MonitoredResourceDescriptor.Builder builder = + com.google.api.MonitoredResourceDescriptor.newBuilder() + .setType(type) + .addAllLabels(Iterables.transform(labels, LabelDescriptor.TO_PB_FUNCTION)); + if (name != null) { + builder.setName(name); + } + if (displayName != null) { + builder.setDisplayName(displayName); + } + if (description != null) { + builder.setDescription(description); + } + return builder.build(); + } + + static Builder newBuilder(String type) { + return new Builder(type); + } + + public static MonitoredResourceDescriptor fromPb( + com.google.api.MonitoredResourceDescriptor descriptorPb) { + Builder builder = newBuilder(descriptorPb.getType()); + if (descriptorPb.getName() != null && !descriptorPb.getName().equals("")) { + builder.setName(descriptorPb.getName()); + } + if (descriptorPb.getDisplayName() != null && !descriptorPb.getDisplayName().equals("")) { + builder.setDisplayName(descriptorPb.getDisplayName()); + } + if (descriptorPb.getDescription() != null && !descriptorPb.getDescription().equals("")) { + builder.setDescription(descriptorPb.getDescription()); + } + builder.setLabels( + Lists.transform(descriptorPb.getLabelsList(), LabelDescriptor.FROM_PB_FUNCTION)); + return builder.build(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/NoCredentials.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/NoCredentials.java new file mode 100644 index 000000000000..4726c4d0c633 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/NoCredentials.java @@ -0,0 +1,50 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.auth.oauth2.OAuth2Credentials; +import java.io.ObjectStreamException; + +/** + * A placeholder for credentials to signify that requests sent to the server should not be + * authenticated. This is typically useful when using local service emulators. + */ +public class NoCredentials extends OAuth2Credentials { + + private static final long serialVersionUID = -6263971603971044288L; + private static final NoCredentials INSTANCE = new NoCredentials(); + + private NoCredentials() {} + + private Object readResolve() throws ObjectStreamException { + return INSTANCE; + } + + public static NoCredentials getInstance() { + return INSTANCE; + } + + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Override + public int hashCode() { + return System.identityHashCode(this); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/PageImpl.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/PageImpl.java new file mode 100644 index 000000000000..72e0e858b433 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/PageImpl.java @@ -0,0 +1,156 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.InternalApi; +import com.google.api.gax.paging.Page; +import com.google.common.collect.AbstractIterator; +import com.google.common.collect.ImmutableMap; +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; + +/** + * Base implementation for Google Cloud paginated results. + * + * @param the value type that the page holds + */ +@InternalApi +public class PageImpl implements Page, Serializable { + + private static final long serialVersionUID = 3914827379823557934L; + + private final String cursor; + private final Iterable results; + private final NextPageFetcher pageFetcher; + + /** + * Interface for fetching the next page of results from the service. + * + * @param the value type that the page holds + */ + public interface NextPageFetcher extends Serializable { + + Page getNextPage(); + } + + static class PageIterator extends AbstractIterator { + + private Iterator currentPageIterator; + private Page currentPage; + + PageIterator(Page currentPage) { + this.currentPageIterator = currentPage.getValues().iterator(); + this.currentPage = currentPage; + } + + @Override + protected T computeNext() { + while (!currentPageIterator.hasNext()) { + currentPage = currentPage.getNextPage(); + if (currentPage == null) { + return endOfData(); + } + currentPageIterator = currentPage.getValues().iterator(); + } + return currentPageIterator.next(); + } + } + + /** + * Creates a {@code PageImpl} object. In order for the object to be serializable the {@code + * results} parameter must be serializable. + */ + public PageImpl(NextPageFetcher pageFetcher, String cursor, Iterable results) { + this.pageFetcher = pageFetcher; + this.cursor = cursor; + this.results = results; + } + + @Override + public Iterable getValues() { + return results == null ? Collections.emptyList() : results; + } + + @Override + public Iterable iterateAll() { + return new Iterable() { + @Override + public Iterator iterator() { + return new PageIterator<>(PageImpl.this); + } + }; + } + + @Override + public boolean hasNextPage() { + return getNextPageToken() != null && !getNextPageToken().equals(""); + } + + @Override + public String getNextPageToken() { + return cursor; + } + + @Override + public Page getNextPage() { + if (cursor == null || pageFetcher == null) { + return null; + } + return pageFetcher.getNextPage(); + } + + @Override + public int hashCode() { + return Objects.hash(cursor, results); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PageImpl)) { + return false; + } + PageImpl other = (PageImpl) obj; + return Objects.equals(cursor, other.cursor) && Objects.equals(results, other.results); + } + + /** + * Utility method to construct the options map for the next page request. + * + * @param the value type that the page holds. Instances of {@code T} should be {@code + * Serializable} + * @param pageTokenOption the key for the next page cursor option in the options map + * @param cursor the cursor for the next page + * @param optionMap the previous options map + * @return the options map for the next page request + */ + public static Map nextRequestOptions( + T pageTokenOption, String cursor, Map optionMap) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + if (cursor != null) { + builder.put(pageTokenOption, cursor); + } + for (Map.Entry option : optionMap.entrySet()) { + if (!Objects.equals(option.getKey(), pageTokenOption)) { + builder.put(option.getKey(), option.getValue()); + } + } + return builder.build(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/PlatformInformation.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/PlatformInformation.java new file mode 100644 index 000000000000..8c77bb9e911f --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/PlatformInformation.java @@ -0,0 +1,34 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.InternalApi; + +@InternalApi("This class should only be used within google-cloud-java") +public final class PlatformInformation { + public static final String GAE_RUNTIME = System.getenv("GAE_RUNTIME"); + + private PlatformInformation() {} + + public static boolean isOnGAEStandard7() { + return "java7".equals(GAE_RUNTIME); + } + + public static boolean isOnGAEStandard8() { + return "java8".equals(GAE_RUNTIME); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Policy.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Policy.java new file mode 100644 index 000000000000..1c5b78c9ea04 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Policy.java @@ -0,0 +1,455 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.ApiFunction; +import com.google.api.core.InternalApi; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.io.BaseEncoding; +import com.google.protobuf.ByteString; +import com.google.type.Expr; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * Class for Identity and Access Management (IAM) policies. IAM policies are used to specify access + * settings for Cloud Platform resources. A policy is a list of bindings. A binding assigns a set of + * identities to a role, where the identities can be user accounts, Google groups, Google domains, + * and service accounts. A role is a named list of permissions defined by IAM. + * + * @see Policy + */ +public final class Policy implements Serializable { + + private static final long serialVersionUID = -3348914530232544290L; + private final ImmutableList bindingsList; + private final String etag; + private final int version; + + /* + * Return true if Policy is version 3 OR bindings has a conditional binding. + * Return false if Policy is version 1 AND bindings does not have a conditional binding. + */ + private static boolean isConditional(int version, List bindingsList) { + for (Binding binding : bindingsList) { + if (binding.getCondition() != null) { + return true; + } + } + if (version == 3) { + return true; + } + return false; + } + + public abstract static class Marshaller { + + @InternalApi("This class should only be extended within google-cloud-java") + protected Marshaller() {} + + protected static final ApiFunction IDENTITY_VALUE_OF_FUNCTION = + new ApiFunction() { + @Override + public Identity apply(String identityPb) { + return Identity.valueOf(identityPb); + } + }; + protected static final ApiFunction IDENTITY_STR_VALUE_FUNCTION = + new ApiFunction() { + @Override + public String apply(Identity identity) { + return identity.strValue(); + } + }; + + protected abstract Policy fromPb(T policyPb); + + protected abstract T toPb(Policy policy); + } + + public static class DefaultMarshaller extends Marshaller { + + @Override + protected Policy fromPb(com.google.iam.v1.Policy policyPb) { + ImmutableList.Builder bindingsListBuilder = ImmutableList.builder(); + for (com.google.iam.v1.Binding bindingPb : policyPb.getBindingsList()) { + Binding.Builder convertedBinding = + Binding.newBuilder() + .setRole(bindingPb.getRole()) + .setMembers(bindingPb.getMembersList()); + if (bindingPb.hasCondition()) { + Expr expr = bindingPb.getCondition(); + convertedBinding.setCondition( + Condition.newBuilder() + .setTitle(expr.getTitle()) + .setDescription(expr.getDescription()) + .setExpression(expr.getExpression()) + .build()); + } + bindingsListBuilder.add(convertedBinding.build()); + } + return newBuilder() + .setBindings(bindingsListBuilder.build()) + .setEtag( + policyPb.getEtag().isEmpty() + ? null + : BaseEncoding.base64().encode(policyPb.getEtag().toByteArray())) + .setVersion(policyPb.getVersion()) + .build(); + } + + @Override + protected com.google.iam.v1.Policy toPb(Policy policy) { + com.google.iam.v1.Policy.Builder policyBuilder = com.google.iam.v1.Policy.newBuilder(); + List bindingPbList = new LinkedList<>(); + for (Binding binding : policy.getBindingsList()) { + com.google.iam.v1.Binding.Builder bindingBuilder = com.google.iam.v1.Binding.newBuilder(); + bindingBuilder.setRole(binding.getRole()); + bindingBuilder.addAllMembers(binding.getMembers()); + if (binding.getCondition() != null) { + Condition condition = binding.getCondition(); + bindingBuilder.setCondition( + Expr.newBuilder() + .setTitle(condition.getTitle()) + .setDescription(condition.getDescription()) + .setExpression(condition.getExpression()) + .build()); + } + bindingPbList.add(bindingBuilder.build()); + } + policyBuilder.addAllBindings(bindingPbList); + if (policy.etag != null) { + policyBuilder.setEtag(ByteString.copyFrom(BaseEncoding.base64().decode(policy.etag))); + } + policyBuilder.setVersion(policy.version); + return policyBuilder.build(); + } + } + + /** A builder for {@code Policy} objects. */ + public static class Builder { + private final List bindingsList = new ArrayList(); + private String etag; + private int version; + + @InternalApi("This class should only be extended within google-cloud-java") + protected Builder() {} + + @InternalApi("This class should only be extended within google-cloud-java") + protected Builder(Policy policy) { + bindingsList.addAll(policy.bindingsList); + setEtag(policy.etag); + setVersion(policy.version); + } + + /** + * Replaces the builder's map of bindings with the given map of bindings. + * + * @throws NullPointerException if the given map is null or contains any null keys or values + * @throws IllegalArgumentException if any identities in the given map are null or if policy + * version is equal to 3 or has conditional bindings because conditional policies are not + * supported + */ + public final Builder setBindings(Map> bindings) { + checkNotNull(bindings, "The provided map of bindings cannot be null."); + checkArgument( + !isConditional(this.version, this.bindingsList), + "setBindings() is only supported with version 1 policies and non-conditional policies"); + for (Map.Entry> binding : bindings.entrySet()) { + checkNotNull(binding.getKey(), "The role cannot be null."); + Set identities = binding.getValue(); + checkNotNull(identities, "A role cannot be assigned to a null set of identities."); + checkArgument(!identities.contains(null), "Null identities are not permitted."); + } + // convert into List format + this.bindingsList.clear(); + for (Map.Entry> binding : bindings.entrySet()) { + Binding.Builder bindingBuilder = Binding.newBuilder(); + bindingBuilder.setRole(binding.getKey().getValue()); + ImmutableList.Builder membersBuilder = ImmutableList.builder(); + for (Identity identity : binding.getValue()) { + membersBuilder.add(identity.strValue()); + } + bindingBuilder.setMembers(membersBuilder.build()); + this.bindingsList.add(bindingBuilder.build()); + } + return this; + } + + /** + * Replaces the builder's List of bindings with the given List of Bindings. + * + * @throws NullPointerException if the given list is null, role is null, or contains any null + * members in bindings + */ + public final Builder setBindings(List bindings) { + this.bindingsList.clear(); + for (Binding binding : bindings) { + Binding.Builder bindingBuilder = Binding.newBuilder(); + bindingBuilder.setMembers(ImmutableList.copyOf(binding.getMembers())); + bindingBuilder.setRole(binding.getRole()); + bindingBuilder.setCondition(binding.getCondition()); + this.bindingsList.add(bindingBuilder.build()); + } + return this; + } + + /** + * Removes the role (and all identities associated with that role) from the policy. + * + * @throws IllegalArgumentException if policy version is equal to 3 or has conditional bindings + * because conditional policies are not supported + */ + public final Builder removeRole(Role role) { + checkArgument( + !isConditional(this.version, this.bindingsList), + "removeRole() is only supported with version 1 policies and non-conditional policies"); + Iterator iterator = bindingsList.iterator(); + + while (iterator.hasNext()) { + Binding binding = (Binding) iterator.next(); + if (binding.getRole().equals(role.getValue())) { + iterator.remove(); + return this; + } + } + return this; + } + + /** + * Adds one or more identities to the policy under the role specified. + * + * @throws NullPointerException if the role or any of the identities is null. + * @throws IllegalArgumentException if policy version is equal to 3 or has conditional bindings. + */ + public final Builder addIdentity(Role role, Identity first, Identity... others) { + checkArgument( + !isConditional(this.version, this.bindingsList), + "addIdentity() is only supported with version 1 policies and non-conditional policies"); + String nullIdentityMessage = "Null identities are not permitted."; + checkNotNull(first, nullIdentityMessage); + checkNotNull(others, nullIdentityMessage); + checkNotNull(role, "The role cannot be null."); + for (int i = 0; i < bindingsList.size(); i++) { + Binding binding = bindingsList.get(i); + if (binding.getRole().equals(role.getValue())) { + Binding.Builder bindingBuilder = binding.toBuilder(); + ImmutableSet.Builder membersBuilder = ImmutableSet.builder(); + membersBuilder.addAll(binding.getMembers()); + membersBuilder.add(first.strValue()); + for (Identity identity : others) { + membersBuilder.add(identity.strValue()); + } + bindingBuilder.setMembers(membersBuilder.build()); + bindingsList.set(i, bindingBuilder.build()); + return this; + } + } + // Binding does not yet exist. + Binding.Builder bindingBuilder = Binding.newBuilder().setRole(role.getValue()); + ImmutableSet.Builder membersBuilder = ImmutableSet.builder(); + membersBuilder.add(first.strValue()); + for (Identity identity : others) { + membersBuilder.add(identity.strValue()); + } + bindingBuilder.setMembers(membersBuilder.build()); + bindingsList.add(bindingBuilder.build()); + return this; + } + + /** + * Removes one or more identities from an existing binding. Does nothing if the binding + * associated with the provided role doesn't exist. + * + * @throws IllegalArgumentException if policy version is equal to 3 or has conditional bindings + */ + public final Builder removeIdentity(Role role, Identity first, Identity... others) { + checkArgument( + !isConditional(this.version, this.bindingsList), + "removeIdentity() is only supported with version 1 policies and non-conditional policies"); + String nullIdentityMessage = "Null identities are not permitted."; + checkNotNull(first, nullIdentityMessage); + checkNotNull(others, nullIdentityMessage); + checkNotNull(role, "The role cannot be null."); + for (int i = 0; i < bindingsList.size(); i++) { + Binding binding = bindingsList.get(i); + if (binding.getRole().equals(role.getValue())) { + Binding.Builder bindingBuilder = binding.toBuilder().removeMembers(first.strValue()); + for (Identity identity : others) { + bindingBuilder.removeMembers(identity.strValue()); + } + Binding updatedBindings = bindingBuilder.build(); + bindingsList.set(i, updatedBindings); + break; + } + } + + Iterator iterator = bindingsList.iterator(); + while (iterator.hasNext()) { + Binding binding = (Binding) iterator.next(); + if (binding.getRole().equals(role.getValue()) && binding.getMembers().size() == 0) { + iterator.remove(); + break; + } + } + + return this; + } + + /** + * Sets the policy's etag. + * + *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous + * updates of a policy from overwriting each other. It is strongly suggested that systems make + * use of the etag in the read-modify-write cycle to perform policy updates in order to avoid + * race conditions. An etag is returned in the response to getIamPolicy, and systems are + * expected to put that etag in the request to setIamPolicy to ensure that their change will be + * applied to the same version of the policy. If no etag is provided in the call to + * setIamPolicy, then the existing policy is overwritten blindly. + */ + public final Builder setEtag(String etag) { + this.etag = etag; + return this; + } + + /** Sets the version of the policy. */ + public final Builder setVersion(int version) { + this.version = version; + return this; + } + + /** Creates a {@code Policy} object. */ + public final Policy build() { + return new Policy(this); + } + } + + private Policy(Builder builder) { + this.bindingsList = ImmutableList.copyOf(builder.bindingsList); + this.etag = builder.etag; + this.version = builder.version; + } + + /** Returns a builder containing the properties of this IAM Policy. */ + public Builder toBuilder() { + return new Builder(this); + } + + /** + * Returns the map of bindings that comprises the policy. + * + * @throws IllegalArgumentException if policy version is equal to 3 or has conditional bindings + */ + public Map> getBindings() { + checkArgument( + !isConditional(this.version, this.bindingsList), + "getBindings() is only supported with version 1 policies and non-conditional policies"); + ImmutableMap.Builder> bindingsV1Builder = ImmutableMap.builder(); + for (Binding binding : bindingsList) { + ImmutableSet.Builder identities = ImmutableSet.builder(); + for (String member : binding.getMembers()) { + identities.add(Identity.valueOf(member)); + } + bindingsV1Builder.put(Role.of(binding.getRole()), identities.build()); + } + return bindingsV1Builder.build(); + } + + /** Returns the list of bindings that comprises the policy for version 3. */ + public ImmutableList getBindingsList() { + return bindingsList; + } + + /** + * Returns the policy's etag. + * + *

Etags are used for optimistic concurrency control as a way to help prevent simultaneous + * updates of a policy from overwriting each other. It is strongly suggested that systems make use + * of the etag in the read-modify-write cycle to perform policy updates in order to avoid race + * conditions. An etag is returned in the response to getIamPolicy, and systems are expected to + * put that etag in the request to setIamPolicy to ensure that their change will be applied to the + * same version of the policy. If no etag is provided in the call to setIamPolicy, then the + * existing policy is overwritten blindly. + */ + public String getEtag() { + return etag; + } + + /** + * Returns the version of the policy. The default version is 0, meaning only the "owner", + * "editor", and "viewer" roles are permitted. If the version is 1, you may also use other roles. + */ + public int getVersion() { + return version; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("bindings", bindingsList) + .add("etag", etag) + .add("version", version) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(getClass(), bindingsList, etag, version); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Policy)) { + return false; + } + Policy other = (Policy) obj; + if (bindingsList == null && other.getBindingsList() == null) { + return true; + } + if ((bindingsList == null && other.getBindingsList() != null) + || bindingsList != null && other.getBindingsList() == null + || bindingsList.size() != other.getBindingsList().size()) { + return false; + } + for (Binding binding : bindingsList) { + if (!other.getBindingsList().contains(binding)) { + return false; + } + } + return Objects.equals(etag, other.getEtag()) && version == other.getVersion(); + } + + /** Returns a builder for {@code Policy} objects. */ + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ReadChannel.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ReadChannel.java new file mode 100644 index 000000000000..effc33ee8e43 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ReadChannel.java @@ -0,0 +1,108 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import java.io.Closeable; +import java.io.IOException; +import java.nio.channels.ReadableByteChannel; + +/** + * A channel for reading data from a Google Cloud object. + * + *

Implementations of this class may buffer data internally to reduce remote calls. This + * interface implements {@link Restorable} to allow saving the reader's state to continue reading + * afterwards. + */ +public interface ReadChannel extends ReadableByteChannel, Closeable, Restorable { + + /** + * Overridden to remove IOException. + * + * @see java.nio.channels.Channel#close() + */ + @Override + void close(); + + /** Set the offset to read from. */ + void seek(long position) throws IOException; + + /** + * Sets the minimum size that will be read by a single RPC. Read data will be locally buffered + * until consumed. + */ + void setChunkSize(int chunkSize); + + /** + * Captures the read channel state so that it can be saved and restored afterwards. + * + * @return a {@link RestorableState} object that contains the read channel state and can restore + * it afterwards. + */ + @Override + RestorableState capture(); + + /** + * Limit the maximum number of bytes to be read from the objects content, counting from the + * beginning of the object, which will be available to read from this channel. If the limit is + * larger than the actual size of the content this will have no material impact. + * + *

If used in conjunction with {@link #seek(long)} the total number of returned bytes from this + * channel will be reduced by the number of bytes specified to seek. + * + *

The value provided as {@code limit} will define a left-closed, + * right-open interval along with either {@code 0} or any value provided to {@link + * #seek(long)}, i.e. {@code [}{@link #seek(long)}{@code , }{@link #limit(long)}{@code )}. + * + *

An example to help illustrate the relationship

+ * + * Imagine some data {@code [A, B, C, D, E, F, G, H, I, J]}, 10 bytes total. + * + *
    + *
  1. {@code limit(5)} would produce {@code [A, B, C, D, E]} + *
  2. {@code seek(8)} would produce {@code [I, J]} + *
  3. {@code seek(2)} {@code limit(5)} would produce {@code [C, D, E]} + *
  4. {@code seek(3)} {@code limit(3)} would produce {@code []} + *
+ * + *

NOTE:Implementers are not required to return a new instance from this method, however + * they are allowed to. Users of this method should always use the instance returned from this + * method. + * + *

Default Implementation:By default, this method will simply return {@code this}. + * + * @param limit the maximum number of bytes to limit this channel to + * @return The instance of channel which will respect the limit. + * @throws UnsupportedOperationException If the {@code this} instances does not support limiting + * @since 2.4.0 + */ + default ReadChannel limit(long limit) { + return this; + } + + /** + * The currently defined limit for this channel. Initial value is {@link Long#MAX_VALUE} + * + * @return the current limit for this channel + * @throws UnsupportedOperationException If the {@code this} instances does not support limiting + * @since 2.4.0 + */ + default long limit() { + return Long.MAX_VALUE; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Restorable.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Restorable.java new file mode 100644 index 000000000000..7feedf0c6e4c --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Restorable.java @@ -0,0 +1,49 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +/** + * Implementation of this interface can persist their state and restore from it. + * + *

A typical capture usage: + * + *

{@code
+ * X restorableObj; // X instanceof Restorable
+ * RestorableState state = restorableObj.capture();
+ * .. persist state
+ * }
+ * + *

A typical restore usage: + * + *

{@code
+ * RestorableState state = ... // read from persistence
+ * X restorableObj = state.restore();
+ * ...
+ * }
+ * + * @param the restorable object's type + */ +public interface Restorable> { + + /** + * Captures the state of this object. + * + * @return a {@link RestorableState} instance that contains the state for this object and can + * restore it afterwards. + */ + RestorableState capture(); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/RestorableState.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/RestorableState.java new file mode 100644 index 000000000000..53a6458f1fd0 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/RestorableState.java @@ -0,0 +1,32 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +/** + * A common interface for restorable states. Implementations of {@code RestorableState} are capable + * of saving the state of an object to restore it for later use. + * + *

Implementations of this class must implement {@link java.io.Serializable} to ensure that the + * state of a the object can be correctly serialized. + * + * @param the restored object's type + */ +public interface RestorableState> { + + /** Returns an object whose internal state reflects the one saved in the invocation object. */ + T restore(); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/RetryHelper.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/RetryHelper.java new file mode 100644 index 000000000000..986fd355879c --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/RetryHelper.java @@ -0,0 +1,88 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.core.ApiClock; +import com.google.api.core.BetaApi; +import com.google.api.gax.retrying.DirectRetryingExecutor; +import com.google.api.gax.retrying.ExponentialPollAlgorithm; +import com.google.api.gax.retrying.ExponentialRetryAlgorithm; +import com.google.api.gax.retrying.ResultRetryAlgorithm; +import com.google.api.gax.retrying.RetryAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.retrying.RetryingExecutor; +import com.google.api.gax.retrying.RetryingFuture; +import com.google.api.gax.retrying.TimedRetryAlgorithm; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; + +/** + * Utility class for retrying operations. For more details about the parameters, see {@link + * RetrySettings}. In case if retrying is unsuccessful, {@link RetryHelperException} will be thrown. + */ +@BetaApi +public class RetryHelper { + public static V runWithRetries( + Callable callable, + RetrySettings retrySettings, + ResultRetryAlgorithm resultRetryAlgorithm, + ApiClock clock) + throws RetryHelperException { + try { + // Suppressing should be ok as a workaraund. Current and only ResultRetryAlgorithm + // implementation does not use response at all, so ignoring its type is ok. + @SuppressWarnings("unchecked") + ResultRetryAlgorithm algorithm = (ResultRetryAlgorithm) resultRetryAlgorithm; + return run(callable, new ExponentialRetryAlgorithm(retrySettings, clock), algorithm); + } catch (Exception e) { + // TODO: remove RetryHelperException, throw InterruptedException or + // ExecutionException#getCause() explicitly + throw new RetryHelperException(e.getCause()); + } + } + + public static V poll( + Callable callable, + RetrySettings pollSettings, + ResultRetryAlgorithm resultPollAlgorithm, + ApiClock clock) + throws ExecutionException, InterruptedException { + return run(callable, new ExponentialPollAlgorithm(pollSettings, clock), resultPollAlgorithm); + } + + private static V run( + Callable callable, + TimedRetryAlgorithm timedAlgorithm, + ResultRetryAlgorithm resultAlgorithm) + throws ExecutionException, InterruptedException { + RetryAlgorithm retryAlgorithm = new RetryAlgorithm<>(resultAlgorithm, timedAlgorithm); + RetryingExecutor executor = new DirectRetryingExecutor<>(retryAlgorithm); + + RetryingFuture retryingFuture = executor.createFuture(callable); + executor.submit(retryingFuture); + return retryingFuture.get(); + } + + public static class RetryHelperException extends RuntimeException { + + private static final long serialVersionUID = -8519852520090965314L; + + RetryHelperException(Throwable cause) { + super(cause); + } + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/RetryOption.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/RetryOption.java new file mode 100644 index 000000000000..a1069b48a265 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/RetryOption.java @@ -0,0 +1,150 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.BetaApi; +import com.google.api.gax.retrying.RetrySettings; +import java.io.Serializable; +import org.threeten.bp.Duration; + +/** + * This class represents an options wrapper around the {@link RetrySettings} class and is an + * alternative way of initializing it. The retry options are usually provided in a form of varargs + * for methods that wait for changes in the status of a resource, do poll operations or retry on + * failures. + */ +@BetaApi +public class RetryOption implements Serializable { + + private static final long serialVersionUID = 3622837212525370224L; + + private enum OptionType { + TOTAL_TIMEOUT, + INITIAL_RETRY_DELAY, + RETRY_DELAY_MULTIPLIER, + MAX_RETRY_DELAY, + MAX_ATTEMPTS, + JITTERED + } + + private final OptionType type; + private final Object value; + + private RetryOption(OptionType type, Object value) { + this.type = checkNotNull(type); + this.value = checkNotNull(value); + } + + /** See {@link RetrySettings#getTotalTimeout()}. */ + public static RetryOption totalTimeout(Duration totalTimeout) { + return new RetryOption(OptionType.TOTAL_TIMEOUT, totalTimeout); + } + + /** See {@link RetrySettings#getInitialRetryDelay()}. */ + public static RetryOption initialRetryDelay(Duration initialRetryDelay) { + return new RetryOption(OptionType.INITIAL_RETRY_DELAY, initialRetryDelay); + } + + /** See {@link RetrySettings#getRetryDelayMultiplier()}. */ + public static RetryOption retryDelayMultiplier(double retryDelayMultiplier) { + return new RetryOption(OptionType.RETRY_DELAY_MULTIPLIER, retryDelayMultiplier); + } + + /** See {@link RetrySettings#getMaxRetryDelay()}. */ + public static RetryOption maxRetryDelay(Duration maxRetryDelay) { + return new RetryOption(OptionType.MAX_RETRY_DELAY, maxRetryDelay); + } + + /** See {@link RetrySettings#getMaxAttempts()}. */ + public static RetryOption maxAttempts(int maxAttempts) { + return new RetryOption(OptionType.MAX_ATTEMPTS, maxAttempts); + } + + /** See {@link RetrySettings#isJittered()} ()}. */ + public static RetryOption jittered(boolean jittered) { + return new RetryOption(OptionType.JITTERED, jittered); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + RetryOption that = (RetryOption) o; + + if (type != that.type) { + return false; + } + return value.equals(that.value); + } + + @Override + public int hashCode() { + int result = type.hashCode(); + result = 31 * result + value.hashCode(); + return result; + } + + /** + * Creates a new {@code RetrySettings} instance, merging provided settings and multiple {@code + * RetryOptions}, each of which represents a single property in {@code RetrySettings}. It is an + * alternative way of initializing {@link RetrySettings} instances. + * + * @param settings retry settings + * @param options zero or more Retry + * @return new {@code RetrySettings} instance, which is a result of merging {@code options} into + * {@code settings}, i.e. each element in {@code options}, if present, overrides corresponding + * property in {@code settings} + */ + public static RetrySettings mergeToSettings(RetrySettings settings, RetryOption... options) { + if (options.length <= 0) { + return settings; + } + RetrySettings.Builder builder = settings.toBuilder(); + for (RetryOption option : options) { + switch (option.type) { + case TOTAL_TIMEOUT: + builder.setTotalTimeout((Duration) option.value); + break; + case INITIAL_RETRY_DELAY: + builder.setInitialRetryDelay((Duration) option.value); + break; + case RETRY_DELAY_MULTIPLIER: + builder.setRetryDelayMultiplier((Double) option.value); + break; + case MAX_RETRY_DELAY: + builder.setMaxRetryDelay((Duration) option.value); + break; + case MAX_ATTEMPTS: + builder.setMaxAttempts((Integer) option.value); + break; + case JITTERED: + builder.setJittered((Boolean) option.value); + break; + default: + throw new IllegalArgumentException("Unknown option type: " + option.type); + } + } + return builder.build(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Role.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Role.java new file mode 100644 index 000000000000..e75dd5f8f284 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Role.java @@ -0,0 +1,116 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A role in a IAM {@link Policy}. Project owners can grant access to team members to access + * project's resources and APIs by granting IAM roles to team members. + * + * @see Viewing the Grantable + * Roles on Resources + * @see Understanding Roles + */ +public final class Role implements Serializable { + + private static final long serialVersionUID = -7779252712160972508L; + private static final String ROLE_PREFIX = "roles/"; + + private final String value; + + private Role(String value) { + this.value = value; + } + + /** + * Returns the string identifier for this role. For example, {@code "roles/viewer"}, {@code + * "roles/editor"}, or {@code "roles/owner"}. + */ + public String getValue() { + return value; + } + + /** + * Returns the viewer role. Encapsulates the permission for read-only actions that preserve state + * of a resource. + * + * @see Understanding Roles + */ + public static Role viewer() { + return of("viewer"); + } + + /** + * Returns the editor role. Encapsulates all viewer's permissions and permissions for actions that + * modify the state of a resource. + * + * @see Understanding Roles + */ + public static Role editor() { + return of("editor"); + } + + /** + * Returns the owner role. Encapsulates all editor's permissions and permissions to manage access + * control for a resource or manage the billing options for a project. + * + * @see Understanding Roles + */ + public static Role owner() { + return of("owner"); + } + + /** + * Returns a new role given its string value. + * + *

If the value contains no slash character ({@code '/'}), the prefix {@code "roles/""} is + * prepended. This slightly simplifies usage for predefined roles. For custom roles, call this + * method with the fully-qualified name, eg {@code "projects/XXX/roles/YYY"}. + * + * @param value the string value for the role + * @see Viewing the Grantable + * Roles on Resources + */ + public static Role of(String value) { + checkNotNull(value); + if (!value.contains("/")) { + value = ROLE_PREFIX + value; + } + return new Role(value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof Role && Objects.equals(value, ((Role) obj).getValue()); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Service.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Service.java new file mode 100644 index 000000000000..bfacabdf7f80 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Service.java @@ -0,0 +1,27 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +/** + * Interface for service objects. + * + * @param the {@code ServiceOptions} subclass corresponding to the service + */ +public interface Service> { + + OptionsT getOptions(); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceDefaults.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceDefaults.java new file mode 100644 index 000000000000..7151740d9956 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceDefaults.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.cloud.spi.ServiceRpcFactory; +import java.io.Serializable; + +public interface ServiceDefaults< + ServiceT extends Service, OptionsT extends ServiceOptions> + extends Serializable { + ServiceFactory getDefaultServiceFactory(); + + ServiceRpcFactory getDefaultRpcFactory(); + + TransportOptions getDefaultTransportOptions(); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceFactory.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceFactory.java new file mode 100644 index 000000000000..3b8fefe52dda --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +/** + * A base interface for all service factories. + * + *

Implementation must provide a public no-arg constructor. Loading of a factory implementation + * is done via {@link java.util.ServiceLoader}. + * + * @param the service subclass + * @param the {@code ServiceOptions} subclass corresponding to the service + */ +@SuppressWarnings("rawtypes") +public interface ServiceFactory { + + ServiceT create(ServiceOptionsT serviceOptions); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java new file mode 100644 index 000000000000..231b9040c949 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java @@ -0,0 +1,770 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.MoreObjects.firstNonNull; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpHeaders; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.HttpResponse; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.api.client.json.GenericJson; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.JsonObjectParser; +import com.google.api.client.json.gson.GsonFactory; +import com.google.api.core.ApiClock; +import com.google.api.core.BetaApi; +import com.google.api.core.CurrentMillisClock; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.FixedHeaderProvider; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.NoHeaderProvider; +import com.google.auth.Credentials; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.auth.oauth2.QuotaProjectIdProvider; +import com.google.auth.oauth2.ServiceAccountCredentials; +import com.google.cloud.spi.ServiceRpcFactory; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.io.Files; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.threeten.bp.Duration; + +/** + * Abstract class representing service options. + * + * @param the service subclass + * @param the {@code ServiceOptions} subclass corresponding to the service + */ +public abstract class ServiceOptions< + ServiceT extends Service, OptionsT extends ServiceOptions> + implements Serializable { + + public static final String CREDENTIAL_ENV_NAME = "GOOGLE_APPLICATION_CREDENTIALS"; + + private static final String DEFAULT_HOST = "https://www.googleapis.com"; + private static final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT"; + private static final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT"; + + private static final RetrySettings DEFAULT_RETRY_SETTINGS = + getDefaultRetrySettingsBuilder().build(); + private static final RetrySettings NO_RETRY_SETTINGS = + getDefaultRetrySettingsBuilder().setMaxAttempts(1).build(); + + private static final long serialVersionUID = 9198896031667942014L; + protected final String clientLibToken; + + private final String projectId; + private final String host; + private final RetrySettings retrySettings; + private final String serviceRpcFactoryClassName; + private final String serviceFactoryClassName; + private final ApiClock clock; + protected Credentials credentials; + private final TransportOptions transportOptions; + private final HeaderProvider headerProvider; + private final String quotaProjectId; + + private transient ServiceRpcFactory serviceRpcFactory; + private transient ServiceFactory serviceFactory; + private transient ServiceT service; + private transient ServiceRpc rpc; + + /** + * Builder for {@code ServiceOptions}. + * + * @param the service subclass + * @param the {@code ServiceOptions} subclass corresponding to the service + * @param the {@code ServiceOptions} builder + */ + public abstract static class Builder< + ServiceT extends Service, + OptionsT extends ServiceOptions, + B extends Builder> { + + private final ImmutableSet allowedClientLibTokens = + ImmutableSet.of(ServiceOptions.getGoogApiClientLibName()); + private String projectId; + private String host; + protected Credentials credentials; + private RetrySettings retrySettings; + private ServiceFactory serviceFactory; + private ServiceRpcFactory serviceRpcFactory; + private ApiClock clock; + private TransportOptions transportOptions; + private HeaderProvider headerProvider; + private String clientLibToken = ServiceOptions.getGoogApiClientLibName(); + private String quotaProjectId; + + @InternalApi("This class should only be extended within google-cloud-java") + protected Builder() {} + + @InternalApi("This class should only be extended within google-cloud-java") + protected Builder(ServiceOptions options) { + projectId = options.projectId; + host = options.host; + credentials = options.credentials; + retrySettings = options.retrySettings; + serviceFactory = options.serviceFactory; + serviceRpcFactory = options.serviceRpcFactory; + clock = options.clock; + transportOptions = options.transportOptions; + clientLibToken = options.clientLibToken; + quotaProjectId = options.quotaProjectId; + } + + protected abstract ServiceOptions build(); + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + /** Sets the service factory. */ + public B setServiceFactory(ServiceFactory serviceFactory) { + this.serviceFactory = serviceFactory; + return self(); + } + + /** + * Sets the service's clock. The clock is mainly used for testing purpose. {@link ApiClock} will + * be replaced by Java8's {@code java.time.Clock}. + * + * @param clock the clock to set + * @return the builder + */ + public B setClock(ApiClock clock) { + this.clock = clock; + return self(); + } + + /** + * Sets the project ID. If no project ID is set, {@link #getDefaultProjectId()} will be used to + * attempt getting the project ID from the environment. + * + * @return the builder + */ + public B setProjectId(String projectId) { + this.projectId = projectId; + return self(); + } + + /** + * Sets service host. + * + * @return the builder + */ + public B setHost(String host) { + this.host = host; + return self(); + } + + /** + * Sets the service authentication credentials. If no credentials are set, {@link + * GoogleCredentials#getApplicationDefault()} will be used to attempt getting credentials from + * the environment. Use {@link NoCredentials#getInstance()} to skip authentication, this is + * typically useful when using local service emulators. + * + * @param credentials authentication credentials, should not be {@code null} + * @return the builder + * @throws NullPointerException if {@code credentials} is {@code null}. To disable + * authentication use {@link NoCredentials#getInstance()} + */ + public B setCredentials(Credentials credentials) { + this.credentials = checkNotNull(credentials); + // set project id if available + if (this.projectId == null && credentials instanceof ServiceAccountCredentials) { + this.projectId = ((ServiceAccountCredentials) credentials).getProjectId(); + } + + if (this.quotaProjectId == null && credentials instanceof QuotaProjectIdProvider) { + this.quotaProjectId = ((QuotaProjectIdProvider) credentials).getQuotaProjectId(); + } + return self(); + } + + /** + * Sets configuration parameters for request retries. + * + * @return the builder + */ + public B setRetrySettings(RetrySettings retrySettings) { + this.retrySettings = retrySettings; + return self(); + } + + /** + * Sets the factory for rpc services. + * + * @return the builder + */ + public B setServiceRpcFactory(ServiceRpcFactory serviceRpcFactory) { + this.serviceRpcFactory = serviceRpcFactory; + return self(); + } + + /** + * Sets the transport options. + * + * @return the builder + */ + public B setTransportOptions(TransportOptions transportOptions) { + this.transportOptions = transportOptions; + return self(); + } + + /** + * Sets the static header provider. The header provider will be called during client + * construction only once. The headers returned by the provider will be cached and supplied as + * is for each request issued by the constructed client. Some reserved headers can be overridden + * (e.g. Content-Type) or merged with the default value (e.g. User-Agent) by the underlying + * transport layer. + * + * @param headerProvider the header provider + * @return the builder + */ + @BetaApi + public B setHeaderProvider(HeaderProvider headerProvider) { + this.headerProvider = headerProvider; + return self(); + } + + @InternalApi + public B setClientLibToken(String clientLibToken) { + Preconditions.checkArgument( + getAllowedClientLibTokens().contains(clientLibToken), "Illegal client lib token"); + this.clientLibToken = clientLibToken; + return self(); + } + + /** + * Sets the quotaProjectId that specifies the project used for quota and billing purposes. + * + * @see See system parameter + * $userProject + */ + public B setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + return self(); + } + + protected Set getAllowedClientLibTokens() { + return allowedClientLibTokens; + } + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected ServiceOptions( + Class> serviceFactoryClass, + Class> rpcFactoryClass, + Builder builder, + ServiceDefaults serviceDefaults) { + projectId = builder.projectId != null ? builder.projectId : getDefaultProject(); + if (projectIdRequired()) { + checkArgument( + projectId != null, + "A project ID is required for this service but could not be determined from the builder " + + "or the environment. Please set a project ID using the builder."); + } + host = firstNonNull(builder.host, getDefaultHost()); + credentials = builder.credentials != null ? builder.credentials : defaultCredentials(); + retrySettings = firstNonNull(builder.retrySettings, getDefaultRetrySettings()); + serviceFactory = + firstNonNull( + builder.serviceFactory, + getFromServiceLoader(serviceFactoryClass, serviceDefaults.getDefaultServiceFactory())); + serviceFactoryClassName = serviceFactory.getClass().getName(); + serviceRpcFactory = + firstNonNull( + builder.serviceRpcFactory, + getFromServiceLoader(rpcFactoryClass, serviceDefaults.getDefaultRpcFactory())); + serviceRpcFactoryClassName = serviceRpcFactory.getClass().getName(); + clock = firstNonNull(builder.clock, CurrentMillisClock.getDefaultClock()); + transportOptions = + firstNonNull(builder.transportOptions, serviceDefaults.getDefaultTransportOptions()); + headerProvider = firstNonNull(builder.headerProvider, new NoHeaderProvider()); + clientLibToken = builder.clientLibToken; + quotaProjectId = + builder.quotaProjectId != null + ? builder.quotaProjectId + : getValueFromCredentialsFile(getCredentialsPath(), "quota_project_id"); + } + + private static String getCredentialsPath() { + return System.getProperty(CREDENTIAL_ENV_NAME, System.getenv(CREDENTIAL_ENV_NAME)); + } + + /** + * Returns whether a service requires a project ID. This method may be overridden in + * service-specific Options objects. + * + * @return true if a project ID is required to use the service, false if not + */ + protected boolean projectIdRequired() { + return true; + } + + private static GoogleCredentials defaultCredentials() { + try { + return GoogleCredentials.getApplicationDefault(); + } catch (Exception ex) { + return null; + } + } + + protected String getDefaultHost() { + return DEFAULT_HOST; + } + + protected String getDefaultProject() { + return getDefaultProjectId(); + } + + /** + * Returns the default project ID, or {@code null} if no default project ID could be found. This + * method returns the first available project ID among the following sources: + * + *

    + *
  1. The project ID specified by the GOOGLE_CLOUD_PROJECT environment variable + *
  2. The App Engine project ID + *
  3. The project ID specified in the JSON credentials file pointed by the {@code + * GOOGLE_APPLICATION_CREDENTIALS} environment variable + *
  4. The Google Cloud SDK project ID + *
  5. The Compute Engine project ID + *
+ */ + public static String getDefaultProjectId() { + String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME)); + if (projectId == null) { + projectId = + System.getProperty(LEGACY_PROJECT_ENV_NAME, System.getenv(LEGACY_PROJECT_ENV_NAME)); + } + if (projectId == null) { + projectId = getAppEngineProjectId(); + } + if (projectId == null) { + projectId = getServiceAccountProjectId(); + } + return projectId != null ? projectId : getGoogleCloudProjectId(); + } + + public static String getAppEngineAppId() { + return System.getProperty("com.google.appengine.application.id"); + } + + private static String getActiveGoogleCloudConfig(File configDir) { + String activeGoogleCloudConfig = null; + try { + activeGoogleCloudConfig = + Files.asCharSource(new File(configDir, "active_config"), Charset.defaultCharset()) + .readFirstLine(); + } catch (IOException ex) { + // ignore + } + // if reading active_config failed or the file is empty we try default + return firstNonNull(activeGoogleCloudConfig, "default"); + } + + protected static String getGoogleCloudProjectId() { + File configDir; + if (System.getenv().containsKey("CLOUDSDK_CONFIG")) { + configDir = new File(System.getenv("CLOUDSDK_CONFIG")); + } else if (isWindows() && System.getenv().containsKey("APPDATA")) { + configDir = new File(System.getenv("APPDATA"), "gcloud"); + } else { + configDir = new File(System.getProperty("user.home"), ".config/gcloud"); + } + String activeConfig = getActiveGoogleCloudConfig(configDir); + FileReader fileReader = null; + try { + fileReader = new FileReader(new File(configDir, "configurations/config_" + activeConfig)); + } catch (FileNotFoundException newConfigFileNotFoundEx) { + try { + fileReader = new FileReader(new File(configDir, "properties")); + } catch (FileNotFoundException oldConfigFileNotFoundEx) { + // ignore + } + } + if (fileReader != null) { + try (BufferedReader reader = new BufferedReader(fileReader)) { + String line; + String section = null; + Pattern projectPattern = Pattern.compile("^project\\s*=\\s*(.*)$"); + Pattern sectionPattern = Pattern.compile("^\\[(.*)\\]$"); + while ((line = reader.readLine()) != null) { + if (line.isEmpty() || line.startsWith(";")) { + continue; + } + line = line.trim(); + Matcher matcher = sectionPattern.matcher(line); + if (matcher.matches()) { + section = matcher.group(1); + } else if (section == null || section.equals("core")) { + matcher = projectPattern.matcher(line); + if (matcher.matches()) { + return matcher.group(1); + } + } + } + } catch (IOException ex) { + // ignore + } + } + // return project id from metadata config + return MetadataConfig.getProjectId(); + } + + private static boolean isWindows() { + return System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows"); + } + + protected static String getAppEngineProjectId() { + String projectId = null; + if (PlatformInformation.isOnGAEStandard7()) { + projectId = getAppEngineProjectIdFromAppId(); + } else { + // for GAE flex and standard Java 8 environment + projectId = System.getenv("GOOGLE_CLOUD_PROJECT"); + if (projectId == null) { + projectId = System.getenv("GCLOUD_PROJECT"); + } + if (projectId == null) { + projectId = getAppEngineProjectIdFromAppId(); + } + if (projectId == null) { + try { + projectId = getAppEngineProjectIdFromMetadataServer(); + } catch (IOException ignore) { + projectId = null; + } + } + } + return projectId; + } + + protected static String getAppEngineProjectIdFromAppId() { + String projectId = getAppEngineAppId(); + if (projectId != null && projectId.contains(":")) { + int colonIndex = projectId.indexOf(":"); + projectId = projectId.substring(colonIndex + 1); + } + return projectId; + } + + private static String getAppEngineProjectIdFromMetadataServer() throws IOException { + String metadata = "http://metadata.google.internal"; + String projectIdURL = "/computeMetadata/v1/project/project-id"; + GenericUrl url = new GenericUrl(metadata + projectIdURL); + + HttpTransport netHttpTransport = new NetHttpTransport(); + HttpRequestFactory requestFactory = netHttpTransport.createRequestFactory(); + HttpRequest request = + requestFactory + .buildGetRequest(url) + .setConnectTimeout(500) + .setReadTimeout(500) + .setHeaders(new HttpHeaders().set("Metadata-Flavor", "Google")); + HttpResponse response = request.execute(); + return headerContainsMetadataFlavor(response) ? response.parseAsString() : null; + } + + @InternalApi("Visible for testing") + static boolean headerContainsMetadataFlavor(HttpResponse response) { + String metadataFlavorValue = response.getHeaders().getFirstHeaderStringValue("Metadata-Flavor"); + return "Google".equals(metadataFlavorValue); + } + + protected static String getServiceAccountProjectId() { + return getValueFromCredentialsFile(getCredentialsPath(), "project_id"); + } + + @InternalApi("Visible for testing") + static String getValueFromCredentialsFile(String credentialsPath, String key) { + if (credentialsPath != null) { + try (InputStream credentialsStream = new FileInputStream(credentialsPath)) { + JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); + JsonObjectParser parser = new JsonObjectParser(jsonFactory); + GenericJson fileContents = + parser.parseAndClose(credentialsStream, StandardCharsets.UTF_8, GenericJson.class); + return (String) fileContents.get(key); + } catch (IOException | IllegalArgumentException ex) { + return null; + } + } + return null; + } + + /** + * Returns a Service object for the current service. For instance, when using Google Cloud + * Storage, it returns a Storage object. + */ + @SuppressWarnings("unchecked") + public ServiceT getService() { + if (shouldRefreshService(service)) { + service = serviceFactory.create((OptionsT) this); + } + return service; + } + + /** + * @param cachedService The currently cached service object + * @return true if the currently cached service object should be refreshed. + */ + protected boolean shouldRefreshService(ServiceT cachedService) { + return cachedService == null; + } + + /** + * Returns a Service RPC object for the current service. For instance, when using Google Cloud + * Storage, it returns a StorageRpc object. + */ + @SuppressWarnings("unchecked") + public ServiceRpc getRpc() { + if (shouldRefreshRpc(rpc)) { + rpc = serviceRpcFactory.create((OptionsT) this); + } + return rpc; + } + + /** + * @param cachedRpc The currently cached service object + * @return true if the currently cached service object should be refreshed. + */ + protected boolean shouldRefreshRpc(ServiceRpc cachedRpc) { + return cachedRpc == null; + } + + /** + * Returns the project ID. Return value can be null (for services that don't require a project + * ID). + */ + public String getProjectId() { + return projectId; + } + + /** Returns the service host. */ + public String getHost() { + return host; + } + + /** Returns the authentication credentials. */ + public Credentials getCredentials() { + return credentials; + } + + /** Returns the authentication credentials. If required, credentials are scoped. */ + public Credentials getScopedCredentials() { + Credentials credentialsToReturn = credentials; + if (credentials instanceof GoogleCredentials + && ((GoogleCredentials) credentials).createScopedRequired()) { + credentialsToReturn = ((GoogleCredentials) credentials).createScoped(getScopes()); + } + return credentialsToReturn; + } + + /** Returns configuration parameters for request retries. */ + public RetrySettings getRetrySettings() { + return retrySettings; + } + + /** + * Returns the service's clock. Default time source uses {@link System#currentTimeMillis()} to get + * current time. + */ + public ApiClock getClock() { + return clock; + } + + /** Returns the transport-specific options for this service. */ + public TransportOptions getTransportOptions() { + return transportOptions; + } + + /** + * Returns the application's name as a string in the format {@code gcloud-java/[version]}, + * optionally prepended with externally supplied User-Agent header value (via setting custom + * header provider). + */ + public String getApplicationName() { + String libraryVersion = getLibraryVersion(); + + // We have to do the following since underlying layers often do not appreciate User-Agent + // provided as a normal header and override it or treat setting "application name" as the only + // way to append something to User-Agent header. + StringBuilder sb = new StringBuilder(); + String customUserAgentValue = getUserAgent(); + if (customUserAgentValue != null) { + sb.append(customUserAgentValue).append(' '); + } + if (libraryVersion == null) { + sb.append(getLibraryName()); + } else { + sb.append(getLibraryName()).append('/').append(libraryVersion); + } + + return sb.toString(); + } + + /** Returns the library's name, {@code gcloud-java}, as a string. */ + public static String getLibraryName() { + return "gcloud-java"; + } + + /** Returns the library's name used by x-goog-api-client header as a string. */ + public static String getGoogApiClientLibName() { + return "gccl"; + } + + /** Returns the library's version as a string. */ + public String getLibraryVersion() { + return GaxProperties.getLibraryVersion(this.getClass()); + } + + @InternalApi + public final HeaderProvider getMergedHeaderProvider(HeaderProvider internalHeaderProvider) { + Map mergedHeaders = + ImmutableMap.builder() + .putAll(internalHeaderProvider.getHeaders()) + .putAll(headerProvider.getHeaders()) + .build(); + return FixedHeaderProvider.create(mergedHeaders); + } + + @InternalApi + public final String getUserAgent() { + if (headerProvider != null) { + for (Map.Entry entry : headerProvider.getHeaders().entrySet()) { + if ("user-agent".equals(entry.getKey().toLowerCase())) { + return entry.getValue(); + } + } + } + return null; + } + + protected int baseHashCode() { + return Objects.hash( + projectId, + host, + credentials, + retrySettings, + serviceFactoryClassName, + serviceRpcFactoryClassName, + clock, + quotaProjectId); + } + + protected boolean baseEquals(ServiceOptions other) { + return Objects.equals(projectId, other.projectId) + && Objects.equals(host, other.host) + && Objects.equals(credentials, other.credentials) + && Objects.equals(retrySettings, other.retrySettings) + && Objects.equals(serviceFactoryClassName, other.serviceFactoryClassName) + && Objects.equals(serviceRpcFactoryClassName, other.serviceRpcFactoryClassName) + && Objects.equals(clock, other.clock) + && Objects.equals(quotaProjectId, other.quotaProjectId); + } + + private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { + input.defaultReadObject(); + serviceFactory = newInstance(serviceFactoryClassName); + serviceRpcFactory = newInstance(serviceRpcFactoryClassName); + } + + @SuppressWarnings("unchecked") + @InternalApi + public static T newInstance(String className) throws IOException, ClassNotFoundException { + try { + return (T) Class.forName(className).newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new IOException(e); + } + } + + public static RetrySettings getDefaultRetrySettings() { + return DEFAULT_RETRY_SETTINGS; + } + + public static RetrySettings getNoRetrySettings() { + return NO_RETRY_SETTINGS; + } + + private static RetrySettings.Builder getDefaultRetrySettingsBuilder() { + return RetrySettings.newBuilder() + .setMaxAttempts(6) + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setMaxRetryDelay(Duration.ofMillis(32_000L)) + .setRetryDelayMultiplier(2.0) + .setTotalTimeout(Duration.ofMillis(50_000L)) + .setInitialRpcTimeout(Duration.ofMillis(50_000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(50_000L)); + } + + protected abstract Set getScopes(); + + public abstract > B toBuilder(); + + /** + * Some services may have different backoff requirements listed in their SLAs. Be sure to override + * this method in options subclasses when the service's backoff requirement differs from the + * default parameters listed in {@link RetrySettings}. + */ + protected RetrySettings defaultRetrySettings() { + return getDefaultRetrySettings(); + } + + @InternalApi + public static T getFromServiceLoader(Class clazz, T defaultInstance) { + return Iterables.getFirst(ServiceLoader.load(clazz), defaultInstance); + } + + public String getClientLibToken() { + return clientLibToken; + } + + /** Returns the quotaProjectId that specifies the project used for quota and billing purposes. */ + public String getQuotaProjectId() { + return quotaProjectId; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceRpc.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceRpc.java new file mode 100644 index 000000000000..ce4bd18a6a49 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceRpc.java @@ -0,0 +1,19 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +public interface ServiceRpc {} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/StringEnumType.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/StringEnumType.java new file mode 100644 index 000000000000..647e53f8e35a --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/StringEnumType.java @@ -0,0 +1,90 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud; + +import com.google.api.core.ApiFunction; +import com.google.api.core.InternalApi; +import com.google.common.base.Preconditions; +import java.lang.reflect.Array; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * This represents a concept having a known set of acceptable String values, which can expand later + * due to new API features. + */ +@InternalApi +public class StringEnumType { + + private final Class clazz; + private final ApiFunction constructor; + private final Map knownValues = new LinkedHashMap<>(); + + public StringEnumType(Class clazz, ApiFunction constructor) { + this.clazz = Preconditions.checkNotNull(clazz); + this.constructor = Preconditions.checkNotNull(constructor); + } + + /** Create a new constant and register it in the known values. */ + public EnumT createAndRegister(String constant) { + EnumT instance = constructor.apply(constant); + knownValues.put(constant, instance); + return instance; + } + + /** + * Get the enum object for the given String constant, and throw an exception if the constant is + * not recognized. + */ + public EnumT valueOfStrict(String constant) { + EnumT value = knownValues.get(constant); + if (value != null) { + return value; + } else { + throw new IllegalArgumentException( + "Constant \"" + constant + "\" not found for enum \"" + clazz.getName() + "\""); + } + } + + /** Get the enum object for the given String constant, and allow unrecognized values. */ + public EnumT valueOf(String constant) { + if (constant == null || constant.isEmpty()) { + throw new IllegalArgumentException("Empty enum constants not allowed."); + } + EnumT value = knownValues.get(constant); + if (value != null) { + return value; + } else { + return constructor.apply(constant); + } + } + + /** Return the known values of this enum type. */ + public EnumT[] values() { + Collection valueCollection = knownValues.values(); + + @SuppressWarnings("unchecked") + final EnumT[] valueArray = (EnumT[]) Array.newInstance(clazz, valueCollection.size()); + int i = 0; + for (EnumT enumV : valueCollection) { + valueArray[i] = enumV; + i++; + } + + return valueArray; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/StringEnumValue.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/StringEnumValue.java new file mode 100644 index 000000000000..2f1ae94218ad --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/StringEnumValue.java @@ -0,0 +1,65 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud; + +import com.google.api.core.InternalApi; +import com.google.common.base.Preconditions; +import java.io.Serializable; + +/** + * This represents a specific instance of a concept having a known set of acceptable String values, + * which can expand later due to new API features. Standard Java enums can't be used in such a + * context. + */ +public abstract class StringEnumValue implements Serializable { + private static final long serialVersionUID = 1501809419544297884L; + private final String constant; + + /** Don't create subclasses outside of google-cloud-java. */ + @InternalApi("This class should only be extended within google-cloud-java") + protected StringEnumValue(String constant) { + this.constant = Preconditions.checkNotNull(constant); + } + + public String name() { + return constant; + } + + @Override + public String toString() { + return constant; + } + + @Override + public boolean equals(Object that) { + if (that == null) { + return false; + } + if (this == that) { + return true; + } + if (!(getClass().equals(that.getClass()))) { + return false; + } + StringEnumValue thatEnumValue = (StringEnumValue) that; + return this.constant.equals(thatEnumValue.constant); + } + + @Override + public int hashCode() { + return constant.hashCode(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java new file mode 100644 index 000000000000..e0308c3836e1 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Timestamp.java @@ -0,0 +1,239 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.protobuf.util.Timestamps; +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import org.threeten.bp.Instant; +import org.threeten.bp.LocalDateTime; +import org.threeten.bp.ZoneOffset; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.format.DateTimeFormatterBuilder; +import org.threeten.bp.format.DateTimeParseException; +import org.threeten.bp.temporal.TemporalAccessor; + +/** + * Represents a timestamp with nanosecond precision. Timestamps cover the range [0001-01-01, + * 9999-12-31]. + * + *

{@code Timestamp} instances are immutable. + */ +public final class Timestamp implements Comparable, Serializable { + + private static final long serialVersionUID = 5152143600571559844L; + + /** The smallest legal timestamp ("0001-01-01T00:00:00Z"). */ + public static final Timestamp MIN_VALUE = new Timestamp(-62135596800L, 0); + + /** The largest legal timestamp ("9999-12-31T23:59:59Z"). */ + public static final Timestamp MAX_VALUE = + new Timestamp(253402300799L, (int) TimeUnit.SECONDS.toNanos(1) - 1); + + private static final DateTimeFormatter format = DateTimeFormatter.ISO_LOCAL_DATE_TIME; + + private static final DateTimeFormatter timestampParser = + new DateTimeFormatterBuilder() + .appendOptional(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + .optionalStart() + .appendOffsetId() + .optionalEnd() + .toFormatter() + .withZone(ZoneOffset.UTC); + + private final long seconds; + private final int nanos; + + private Timestamp(long seconds, int nanos) { + this.seconds = seconds; + this.nanos = nanos; + } + + /** + * Creates an instance representing the value of {@code seconds} and {@code nanos} since January + * 1, 1970, 00:00:00 UTC. + * + * @param seconds seconds since January 1, 1970, 00:00:00 UTC. A negative value is the number of + * seconds before January 1, 1970, 00:00:00 UTC. + * @param nanos the fractional seconds component, in the range 0..999999999. + * @throws IllegalArgumentException if the timestamp is outside the representable range + */ + public static Timestamp ofTimeSecondsAndNanos(long seconds, int nanos) { + checkArgument( + Timestamps.isValid(seconds, nanos), "timestamp out of range: %s, %s", seconds, nanos); + return new Timestamp(seconds, nanos); + } + + /** + * Creates an instance representing the value of {@code microseconds}. + * + * @throws IllegalArgumentException if the timestamp is outside the representable range + */ + public static Timestamp ofTimeMicroseconds(long microseconds) { + long seconds = microseconds / 1_000_000; + int nanos = (int) (microseconds % 1_000_000 * 1000); + if (nanos < 0) { + seconds--; + nanos += 1_000_000_000; + } + checkArgument( + Timestamps.isValid(seconds, nanos), "timestamp out of range: %s, %s", seconds, nanos); + return new Timestamp(seconds, nanos); + } + + /** + * Creates an instance representing the value of {@code Date}. + * + * @throws IllegalArgumentException if the timestamp is outside the representable range + */ + public static Timestamp of(Date date) { + return ofTimeMicroseconds(TimeUnit.MILLISECONDS.toMicros(date.getTime())); + } + + /** Creates an instance with current time. */ + public static Timestamp now() { + java.sql.Timestamp date = new java.sql.Timestamp(System.currentTimeMillis()); + return of(date); + } + + /** + * Creates an instance representing the value of {@code timestamp}. + * + * @throws IllegalArgumentException if the timestamp is outside the representable range + */ + public static Timestamp of(java.sql.Timestamp timestamp) { + int nanos = timestamp.getNanos(); + + // A pre-epoch timestamp can be off by one second because of the way that integer division + // works. For example, -1001 / 1000 == -1. In this case, we want this result to be -2. This + // causes any pre-epoch timestamp to be off by 1 second - fix this by subtracting 1 from the + // seconds value if the seconds value is less than zero and is not divisible by 1000. + // TODO: replace with Math.floorDiv when we drop Java 7 support + long seconds = timestamp.getTime() / 1000; + if (seconds < 0 && timestamp.getTime() % 1000 != 0) { + --seconds; + } + + return Timestamp.ofTimeSecondsAndNanos(seconds, nanos); + } + + /** + * Returns the number of seconds since January 1, 1970, 00:00:00 UTC. A negative value is the + * number of seconds before January 1, 1970, 00:00:00 UTC. + */ + public long getSeconds() { + return seconds; + } + + /** Returns the fractional seconds component, in nanoseconds. */ + public int getNanos() { + return nanos; + } + + /** Returns a JDBC timestamp initialized to the same point in time as {@code this}. */ + public java.sql.Timestamp toSqlTimestamp() { + java.sql.Timestamp ts = new java.sql.Timestamp(seconds * 1000); + ts.setNanos(nanos); + return ts; + } + + /** + * Returns a new {@code java.util.Date} corresponding to this {@code timestamp}. Any + * sub-millisecond precision will be stripped. + * + * @return An approximate {@code java.util.Date} representation of this {@code timestamp}. + */ + public Date toDate() { + long secondsInMilliseconds = TimeUnit.SECONDS.toMillis(this.seconds); + long nanosInMilliseconds = TimeUnit.NANOSECONDS.toMillis(this.nanos); + return new Date(secondsInMilliseconds + nanosInMilliseconds); + } + + @Override + public int compareTo(Timestamp other) { + int r = Long.compare(seconds, other.seconds); + if (r == 0) { + r = Integer.compare(nanos, other.nanos); + } + return r; + } + + /** Creates an instance of Timestamp from {@code com.google.protobuf.Timestamp}. */ + public static Timestamp fromProto(com.google.protobuf.Timestamp proto) { + return new Timestamp(proto.getSeconds(), proto.getNanos()); + } + + /** + * Returns a {@code com.google.protobuf.Timestamp} initialized to the same point in time as {@code + * this}. + */ + public com.google.protobuf.Timestamp toProto() { + return com.google.protobuf.Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos).build(); + } + + /** + * Creates a Timestamp instance from the given string. Input string should be in the RFC 3339 + * format, like '2020-12-01T10:15:30.000Z' or with the timezone offset, such as + * '2020-12-01T10:15:30+01:00'. + * + * @param timestamp string in the RFC 3339 format + * @return created Timestamp + * @throws DateTimeParseException if unable to parse + */ + public static Timestamp parseTimestamp(String timestamp) { + TemporalAccessor temporalAccessor = timestampParser.parse(timestamp); + Instant instant = Instant.from(temporalAccessor); + return ofTimeSecondsAndNanos(instant.getEpochSecond(), instant.getNano()); + } + + private StringBuilder toString(StringBuilder b) { + format.formatTo(LocalDateTime.ofEpochSecond(seconds, 0, ZoneOffset.UTC), b); + if (nanos != 0) { + b.append(String.format(".%09d", nanos)); + } + b.append('Z'); + return b; + } + + @Override + public String toString() { + return toString(new StringBuilder()).toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Timestamp that = (Timestamp) o; + return seconds == that.seconds && nanos == that.nanos; + } + + @Override + public int hashCode() { + return Objects.hash(seconds, nanos); + } + + // TODO(user): Consider adding math operations. +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/TransportOptions.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/TransportOptions.java new file mode 100644 index 000000000000..e62fdddefcfd --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/TransportOptions.java @@ -0,0 +1,21 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud; + +import java.io.Serializable; + +/** An abstraction for transport-specific options, e.g. for http1.1 vs grpc. */ +public interface TransportOptions extends Serializable {} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/Tuple.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/Tuple.java new file mode 100644 index 000000000000..c9d2b9bc2576 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/Tuple.java @@ -0,0 +1,40 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +public class Tuple { + + private final X x; + private final Y y; + + private Tuple(X x, Y y) { + this.x = x; + this.y = y; + } + + public static Tuple of(X x, Y y) { + return new Tuple<>(x, y); + } + + public X x() { + return x; + } + + public Y y() { + return y; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/WriteChannel.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/WriteChannel.java new file mode 100644 index 000000000000..947909bb6625 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/WriteChannel.java @@ -0,0 +1,47 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import java.io.Closeable; +import java.nio.channels.WritableByteChannel; + +/** + * A channel for writing data to Google Cloud services. + * + *

Implementations of this class may further buffer data internally to reduce remote calls. + * Written data might not be visible until calling {@link #close()}. This interface implements + * {@link Restorable} to allow saving the writer's state to continue writing afterwards. + */ +public interface WriteChannel extends WritableByteChannel, Closeable, Restorable { + + /** + * Sets the minimum size that will be written by a single RPC. Written data will be buffered and + * only flushed upon reaching this size or closing the channel. + */ + void setChunkSize(int chunkSize); + + /** + * Captures the write channel state so that it can be saved and restored afterwards. The original + * {@code WriteChannel} and the restored one should not both be used. Closing one channel causes + * the other channel to close; subsequent writes will fail. + * + * @return a {@link RestorableState} object that contains the write channel state and can restore + * it afterwards. + */ + @Override + RestorableState capture(); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/package-info.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/package-info.java new file mode 100644 index 000000000000..56d9be78d696 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/package-info.java @@ -0,0 +1,18 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** Core classes for the {@code google-cloud} library. */ +package com.google.cloud; diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java new file mode 100644 index 000000000000..bd27986e1d7a --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/spi/ServiceRpcFactory.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.spi; + +import com.google.cloud.ServiceOptions; +import com.google.cloud.ServiceRpc; + +/** + * A base interface for all service RPC factories. Implementation must provide a public no-arg + * constructor. Loading of a factory implementation is done via {@link java.util.ServiceLoader}. + */ +@SuppressWarnings("rawtypes") +public interface ServiceRpcFactory { + + ServiceRpc create(OptionsT options); +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BaseEmulatorHelper.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BaseEmulatorHelper.java new file mode 100644 index 000000000000..9679c6299c02 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BaseEmulatorHelper.java @@ -0,0 +1,473 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import com.google.api.core.CurrentMillisClock; +import com.google.api.core.InternalApi; +import com.google.cloud.ExceptionHandler; +import com.google.cloud.RetryHelper; +import com.google.cloud.ServiceOptions; +import com.google.common.io.CharStreams; +import com.google.common.util.concurrent.SettableFuture; +import com.google.common.util.concurrent.UncheckedExecutionException; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.math.BigInteger; +import java.net.HttpURLConnection; +import java.net.ServerSocket; +import java.net.URL; +import java.net.URLConnection; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import org.threeten.bp.Duration; + +/** Utility class to start and stop a local service which is used by unit testing. */ +@InternalApi +public abstract class BaseEmulatorHelper { + + private final String emulator; + private final int port; + private final String projectId; + private EmulatorRunner activeRunner; + private BlockingProcessStreamReader blockingProcessReader; + + protected static final String PROJECT_ID_PREFIX = "test-project-"; + protected static final String DEFAULT_HOST = "localhost"; + protected static final int DEFAULT_PORT = 8080; + + @InternalApi("This class should only be extended within google-cloud-java") + protected BaseEmulatorHelper(String emulator, int port, String projectId) { + this.emulator = emulator; + this.port = port > 0 ? port : DEFAULT_PORT; + this.projectId = projectId; + } + + /** + * Returns the emulator runners supported by this emulator. Runners are evaluated in order, the + * first available runner is selected and executed + */ + protected abstract List getEmulatorRunners(); + + /** Returns a logger. */ + protected abstract Logger getLogger(); + + /** + * Starts the local service as a subprocess. Blocks the execution until {@code blockUntilOutput} + * is found on stdout. + */ + protected final void startProcess(String blockUntilOutput) + throws IOException, InterruptedException { + for (EmulatorRunner runner : getEmulatorRunners()) { + // Iterate through all emulator runners until find first available runner. + if (runner.isAvailable()) { + activeRunner = runner; + runner.start(); + break; + } + } + if (activeRunner != null) { + blockingProcessReader = + BlockingProcessStreamReader.start( + emulator, activeRunner.getProcess().getInputStream(), blockUntilOutput, getLogger()); + } else { + // No available runner found. + throw new IOException("No available emulator runner is found."); + } + } + + /** + * Waits for the local service's subprocess to terminate, and stop any possible thread listening + * for its output. + */ + protected final int waitForProcess(Duration timeout) + throws IOException, InterruptedException, TimeoutException { + if (activeRunner != null) { + int exitCode = activeRunner.waitFor(timeout); + activeRunner = null; + return exitCode; + } + if (blockingProcessReader != null) { + blockingProcessReader.join(); + blockingProcessReader = null; + } + return 0; + } + + private static int waitForProcess(final Process process, Duration timeout) + throws InterruptedException, TimeoutException { + if (process == null) { + return 0; + } + + final SettableFuture exitValue = SettableFuture.create(); + + Thread waiter = + new Thread( + new Runnable() { + @Override + public void run() { + try { + exitValue.set(process.waitFor()); + } catch (InterruptedException e) { + exitValue.setException(e); + } + } + }); + waiter.start(); + + try { + return exitValue.get(timeout.toMillis(), TimeUnit.MILLISECONDS); + } catch (ExecutionException e) { + if (e.getCause() instanceof InterruptedException) { + throw (InterruptedException) e.getCause(); + } + throw new UncheckedExecutionException(e); + } finally { + waiter.interrupt(); + } + } + + /** Returns the port to which the local emulator is listening. */ + public int getPort() { + return port; + } + + /** Returns the project ID associated with the local emulator. */ + public String getProjectId() { + return projectId; + } + + /** Returns service options to access the local emulator. */ + public abstract T getOptions(); + + /** Starts the local emulator. */ + public abstract void start() throws IOException, InterruptedException; + + /** Stops the local emulator. */ + public abstract void stop(Duration timeout) + throws IOException, InterruptedException, TimeoutException; + + /** Resets the internal state of the emulator. */ + public abstract void reset() throws IOException; + + protected final String sendPostRequest(String request) throws IOException { + URL url = new URL("http", DEFAULT_HOST, this.port, request); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + con.setRequestMethod("POST"); + con.setDoOutput(true); + OutputStream out = con.getOutputStream(); + out.write("".getBytes()); + out.flush(); + + InputStream in = con.getInputStream(); + String response = CharStreams.toString(new InputStreamReader(con.getInputStream())); + in.close(); + return response; + } + + protected static int findAvailablePort(int defaultPort) { + try (ServerSocket tempSocket = new ServerSocket(0)) { + return tempSocket.getLocalPort(); + } catch (IOException e) { + return defaultPort; + } + } + + protected static boolean isWindows() { + return System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows"); + } + + /** Utility interface to start and run an emulator. */ + protected interface EmulatorRunner { + + /** + * Returns {@code true} if the emulator associated to this runner is available and can be + * started. + */ + boolean isAvailable(); + + /** Starts the emulator associated to this runner. */ + void start() throws IOException; + + /** Wait for the emulator associated to this runner to terminate, returning the exit status. */ + int waitFor(Duration timeout) throws InterruptedException, TimeoutException; + + /** Returns the process associated to the emulator, if any. */ + Process getProcess(); + } + + /** Utility class to start and run an emulator from the Google Cloud SDK. */ + protected static class GcloudEmulatorRunner implements EmulatorRunner { + + private final List commandText; + private final String versionPrefix; + private final Version minVersion; + private Process process; + private static final Logger log = Logger.getLogger(GcloudEmulatorRunner.class.getName()); + + public GcloudEmulatorRunner(List commandText, String versionPrefix, String minVersion) { + this.commandText = commandText; + this.versionPrefix = versionPrefix; + this.minVersion = Version.fromString(minVersion); + } + + @Override + public boolean isAvailable() { + try { + return isGcloudInstalled() && isEmulatorUpToDate() && !commandText.isEmpty(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(System.err); + } + return false; + } + + @Override + public void start() throws IOException { + log.fine("Starting emulator via Google Cloud SDK"); + process = CommandWrapper.create().setCommand(commandText).setRedirectErrorStream().start(); + } + + @Override + public int waitFor(Duration timeout) throws InterruptedException, TimeoutException { + return waitForProcess(process, timeout); + } + + @Override + public Process getProcess() { + return process; + } + + private boolean isGcloudInstalled() { + String path = System.getenv("PATH"); + return path != null && path.contains("google-cloud-sdk"); + } + + private boolean isEmulatorUpToDate() throws IOException, InterruptedException { + Version currentVersion = getInstalledEmulatorVersion(versionPrefix); + return currentVersion != null && currentVersion.compareTo(minVersion) >= 0; + } + + private Version getInstalledEmulatorVersion(String versionPrefix) + throws IOException, InterruptedException { + Process process = + CommandWrapper.create() + .setCommand(Arrays.asList("gcloud", "version")) + // gcloud redirects all output to stderr while emulators' executables use either + // stdout or stderr with no apparent convention. To be able to properly intercept and + // block waiting for emulators to be ready we redirect everything to stdout + .setRedirectErrorStream() + .start(); + process.waitFor(); + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(process.getInputStream()))) { + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + if (line.startsWith(versionPrefix)) { + String[] lineComponents = line.split(" "); + if (lineComponents.length > 1) { + return Version.fromString(lineComponents[1]); + } + } + } + return null; + } + } + } + + /** Utility class to start and run an emulator from a download URL. */ + protected static class DownloadableEmulatorRunner implements EmulatorRunner { + + private final List commandText; + private final String md5CheckSum; + private final URL downloadUrl; + private final String fileName; + private String accessToken; + private Process process; + private static final Logger log = Logger.getLogger(DownloadableEmulatorRunner.class.getName()); + + public DownloadableEmulatorRunner( + List commandText, URL downloadUrl, String md5CheckSum) { + this.commandText = commandText; + this.md5CheckSum = md5CheckSum; + this.downloadUrl = downloadUrl; + String[] splitUrl = downloadUrl.toString().split("/"); + this.fileName = splitUrl[splitUrl.length - 1]; + } + + public DownloadableEmulatorRunner( + List commandText, URL downloadUrl, String md5CheckSum, String accessToken) { + this(commandText, downloadUrl, md5CheckSum); + this.accessToken = accessToken; + } + + @Override + public boolean isAvailable() { + try { + downloadZipFile(); + return true; + } catch (IOException e) { + return false; + } + } + + @Override + public void start() throws IOException { + ExceptionHandler retryOnAnythingExceptionHandler = + ExceptionHandler.newBuilder().retryOn(Exception.class).build(); + + Path emulatorPath = + RetryHelper.runWithRetries( + new Callable() { + @Override + public Path call() throws IOException { + return downloadEmulator(); + } + }, + ServiceOptions.getDefaultRetrySettings(), + retryOnAnythingExceptionHandler, + CurrentMillisClock.getDefaultClock()); + process = + CommandWrapper.create() + .setCommand(commandText) + .setDirectory(emulatorPath) + // gcloud redirects all output to stderr while emulators' executables use either + // stdout + // or stderr with no apparent convention. To be able to properly intercept and block + // waiting for emulators to be ready we redirect everything to stdout + .setRedirectErrorStream() + .start(); + } + + @Override + public int waitFor(Duration timeout) throws InterruptedException, TimeoutException { + return waitForProcess(process, timeout); + } + + @Override + public Process getProcess() { + return process; + } + + private Path downloadEmulator() throws IOException { + // Retrieve the file name from the download link + String[] splittedUrl = downloadUrl.toString().split("/"); + String fileName = splittedUrl[splittedUrl.length - 1]; + + // Each run is associated with its own folder that is deleted once test completes. + Path emulatorPath = Files.createTempDirectory(fileName.split("\\.")[0]); + File emulatorFolder = emulatorPath.toFile(); + emulatorFolder.deleteOnExit(); + + File zipFile = downloadZipFile(); + // Unzip the emulator + try (ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFile))) { + if (log.isLoggable(Level.FINE)) { + log.fine("Unzipping emulator"); + } + ZipEntry entry = zipIn.getNextEntry(); + while (entry != null) { + File filePath = new File(emulatorFolder, entry.getName()); + String canonicalEmulatorFolderPath = emulatorFolder.getCanonicalPath(); + String canonicalFilePath = filePath.getCanonicalPath(); + if (!canonicalFilePath.startsWith(canonicalEmulatorFolderPath + File.separator)) { + throw new IllegalStateException( + "Entry is outside of the target dir: " + entry.getName()); + } + if (!entry.isDirectory()) { + extractFile(zipIn, filePath); + } else { + filePath.mkdir(); + } + zipIn.closeEntry(); + entry = zipIn.getNextEntry(); + } + } + return emulatorPath; + } + + private File downloadZipFile() throws IOException { + // Check if we already have a local copy of the emulator and download it if not. + File zipFile = new File(System.getProperty("java.io.tmpdir"), fileName); + if (!zipFile.exists() || (md5CheckSum != null && !md5CheckSum.equals(md5(zipFile)))) { + if (log.isLoggable(Level.FINE)) { + log.fine("Fetching emulator"); + } + URLConnection urlConnection = downloadUrl.openConnection(); + if (accessToken != null) { + urlConnection.setRequestProperty("Authorization", "Bearer " + accessToken); + } + ReadableByteChannel rbc = Channels.newChannel(urlConnection.getInputStream()); + try (FileOutputStream fos = new FileOutputStream(zipFile)) { + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + } + } else { + if (log.isLoggable(Level.FINE)) { + log.fine("Using cached emulator"); + } + } + return zipFile; + } + + private void extractFile(ZipInputStream zipIn, File filePath) throws IOException { + try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath))) { + byte[] bytesIn = new byte[1024]; + int read; + while ((read = zipIn.read(bytesIn)) != -1) { + bos.write(bytesIn, 0, read); + } + } + } + + private static String md5(File zipFile) throws IOException { + try { + MessageDigest md5 = MessageDigest.getInstance("MD5"); + try (InputStream is = new BufferedInputStream(new FileInputStream(zipFile))) { + byte[] bytes = new byte[4 * 1024 * 1024]; + int len; + while ((len = is.read(bytes)) >= 0) { + md5.update(bytes, 0, len); + } + } + return String.format("%032x", new BigInteger(1, md5.digest())); + } catch (NoSuchAlgorithmException e) { + throw new IOException(e); + } + } + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BlockingProcessStreamReader.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BlockingProcessStreamReader.java new file mode 100644 index 000000000000..90fbb764d55d --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/BlockingProcessStreamReader.java @@ -0,0 +1,140 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import static com.google.common.base.MoreObjects.firstNonNull; + +import com.google.common.base.Strings; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * This class allows to read a process output stream, block until a provided string appears on the + * stream and redirect pertinent error logs to a provided logger. + */ +class BlockingProcessStreamReader extends Thread { + + private static final int LOG_LENGTH_LIMIT = 50000; + + private final BufferedReader errorReader; + private final Logger logger; + private StringBuilder currentLog; + private Level currentLogLevel; + private boolean collectionMode; + private final String emulatorTag; + private final Pattern logLinePattern; + + private BlockingProcessStreamReader( + String emulator, InputStream stream, String blockUntil, Logger logger) throws IOException { + super("blocking-process-stream-reader"); + setDaemon(true); + errorReader = new BufferedReader(new InputStreamReader(stream)); + this.logger = logger; + this.emulatorTag = "[" + emulator + "]"; + this.logLinePattern = Pattern.compile("(\\[" + emulator + "\\]\\s)?(\\w+):.*"); + if (!Strings.isNullOrEmpty(blockUntil)) { + String line; + do { + line = errorReader.readLine(); + } while (line != null && !line.contains(blockUntil)); + } + } + + @Override + public void run() { + String previousLine = ""; + String nextLine = ""; + try { + for (; ; ) { + previousLine = nextLine; + nextLine = errorReader.readLine(); + if (nextLine == null) { + break; + } + processLogLine(previousLine, nextLine); + } + } catch (IOException e) { + e.printStackTrace(System.err); + } + processLogLine(previousLine, firstNonNull(nextLine, "")); + writeLog(); + } + + private void processLogLine(String previousLine, String nextLine) { + // Each log is two lines with the following format: + // [Emulator]? [Date] [Time] [LoggingClass] [method] + // [Emulator]? [LEVEL]: error message + // [Emulator]? more data + // Exceptions and stack traces are included in error stream, separated by a newline + Level nextLogLevel = getLevel(nextLine); + if (nextLogLevel != null) { + writeLog(); + currentLog = new StringBuilder(); + currentLogLevel = nextLogLevel; + collectionMode = true; + } else if (collectionMode) { + if (currentLog.length() > LOG_LENGTH_LIMIT) { + collectionMode = false; + } else if (currentLog.length() == 0) { + // strip level out of the line + currentLog.append(emulatorTag); + currentLog.append(previousLine.split(":", 2)[1]); + currentLog.append(System.getProperty("line.separator")); + } else { + if (!previousLine.startsWith(emulatorTag)) { + currentLog.append(emulatorTag); + currentLog.append(' '); + } + currentLog.append(previousLine); + currentLog.append(System.getProperty("line.separator")); + } + } + } + + private void writeLog() { + if (currentLogLevel != null && currentLog != null && currentLog.length() != 0) { + logger.log(currentLogLevel, currentLog.toString().trim()); + } + } + + private Level getLevel(String line) { + try { + Matcher matcher = logLinePattern.matcher(line); + if (matcher.matches()) { + return Level.parse(matcher.group(2)); + } else { + return null; + } + } catch (IllegalArgumentException e) { + return null; // level wasn't supplied in this log line + } + } + + static BlockingProcessStreamReader start( + String emulator, InputStream stream, String blockUntil, Logger logger) throws IOException { + BlockingProcessStreamReader thread = + new BlockingProcessStreamReader(emulator, stream, blockUntil, logger); + thread.start(); + return thread; + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/CommandWrapper.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/CommandWrapper.java new file mode 100644 index 000000000000..79f70150a5f7 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/CommandWrapper.java @@ -0,0 +1,99 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +/** Utility class that executes system commands on both Windows and Unix. */ +class CommandWrapper { + + private final List prefix; + private List command; + private String nullFilename; + private boolean redirectOutputToNull; + private boolean redirectErrorStream; + private boolean redirectErrorInherit; + private Path directory; + + private CommandWrapper() { + this.prefix = new ArrayList<>(); + if (BaseEmulatorHelper.isWindows()) { + this.prefix.add("cmd"); + this.prefix.add("/C"); + this.nullFilename = "NUL:"; + } else { + this.prefix.add("bash"); + this.nullFilename = "/dev/null"; + } + } + + CommandWrapper setCommand(List command) { + this.command = new ArrayList<>(command.size() + this.prefix.size()); + this.command.addAll(prefix); + this.command.addAll(command); + return this; + } + + CommandWrapper setRedirectOutputToNull() { + this.redirectOutputToNull = true; + return this; + } + + CommandWrapper setRedirectErrorStream() { + this.redirectErrorStream = true; + return this; + } + + CommandWrapper setRedirectErrorInherit() { + this.redirectErrorInherit = true; + return this; + } + + CommandWrapper setDirectory(Path directory) { + this.directory = directory; + return this; + } + + ProcessBuilder getBuilder() { + ProcessBuilder builder = new ProcessBuilder(command); + if (redirectOutputToNull) { + builder.redirectOutput(new File(nullFilename)); + } + if (directory != null) { + builder.directory(directory.toFile()); + } + if (redirectErrorStream) { + builder.redirectErrorStream(true); + } + if (redirectErrorInherit) { + builder.redirectError(ProcessBuilder.Redirect.INHERIT); + } + return builder; + } + + public Process start() throws IOException { + return getBuilder().start(); + } + + static CommandWrapper create() { + return new CommandWrapper(); + } +} diff --git a/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/Version.java b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/Version.java new file mode 100644 index 000000000000..dfdc076fdf14 --- /dev/null +++ b/java-core/google-cloud-core/src/main/java/com/google/cloud/testing/Version.java @@ -0,0 +1,89 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** Simplified wrapper for emulator's versions. */ +class Version implements Comparable { + + private static final Pattern VERSION_PATTERN = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)$"); + + private final int major; + private final int minor; + private final int patch; + + private Version(int major, int minor, int patch) { + this.major = major; + this.minor = minor; + this.patch = patch; + } + + @Override + public int compareTo(Version version) { + int result = major - version.major; + if (result == 0) { + result = minor - version.minor; + if (result == 0) { + result = patch - version.patch; + } + } + return result; + } + + @Override + public String toString() { + return String.format("%d.%d.%d", major, minor, patch); + } + + @Override + public boolean equals(Object other) { + return this == other || other instanceof Version && compareTo((Version) other) == 0; + } + + @Override + public int hashCode() { + return Objects.hash(major, minor, patch); + } + + int getMajor() { + return major; + } + + int getMinor() { + return minor; + } + + int getPatch() { + return patch; + } + + static Version fromString(String version) { + Matcher matcher = VERSION_PATTERN.matcher(checkNotNull(version)); + if (matcher.matches()) { + return new Version( + Integer.valueOf(matcher.group(1)), + Integer.valueOf(matcher.group(2)), + Integer.valueOf(matcher.group(3))); + } + throw new IllegalArgumentException("Invalid version format"); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/AsyncPageImplTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/AsyncPageImplTest.java new file mode 100644 index 000000000000..241793b3bebd --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/AsyncPageImplTest.java @@ -0,0 +1,95 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.paging.AsyncPage; +import com.google.common.collect.ImmutableList; +import java.util.concurrent.ExecutionException; +import org.junit.Test; + +public class AsyncPageImplTest { + + private static final ImmutableList VALUES1 = ImmutableList.of("1", "2"); + private static final ImmutableList VALUES2 = ImmutableList.of("3", "4"); + private static final ImmutableList VALUES3 = ImmutableList.of("5", "6"); + private static final ImmutableList ALL_VALUES = + ImmutableList.builder().addAll(VALUES1).addAll(VALUES2).addAll(VALUES3).build(); + private static final ImmutableList SOME_VALUES = + ImmutableList.builder().addAll(VALUES2).addAll(VALUES3).build(); + + private static class TestPageFetcher implements AsyncPageImpl.NextPageFetcher { + private static final long serialVersionUID = 4703765400378593176L; + + private final AsyncPageImpl nextResult; + + TestPageFetcher(AsyncPageImpl nextResult) { + this.nextResult = nextResult; + } + + @Override + public ApiFuture> getNextPage() { + return ApiFutures.>immediateFuture(nextResult); + } + } + + @Test + public void testPage() { + final AsyncPageImpl nextResult = new AsyncPageImpl<>(null, "c", VALUES2); + AsyncPageImpl.NextPageFetcher fetcher = new TestPageFetcher(nextResult); + AsyncPageImpl result = new AsyncPageImpl<>(fetcher, "c", VALUES1); + assertEquals(nextResult, result.getNextPage()); + assertEquals("c", result.getNextPageToken()); + assertEquals(VALUES1, result.getValues()); + } + + @Test + public void testPageAsync() throws ExecutionException, InterruptedException { + final AsyncPageImpl nextResult = new AsyncPageImpl<>(null, "c", VALUES2); + AsyncPageImpl.NextPageFetcher fetcher = new TestPageFetcher(nextResult); + AsyncPageImpl result = new AsyncPageImpl<>(fetcher, "c", VALUES1); + assertEquals(nextResult, result.getNextPageAsync().get()); + assertEquals("c", result.getNextPageToken()); + assertEquals(VALUES1, result.getValues()); + } + + @Test + public void testIterateAll() { + final AsyncPageImpl nextResult2 = new AsyncPageImpl<>(null, "c3", VALUES3); + AsyncPageImpl.NextPageFetcher fetcher2 = new TestPageFetcher(nextResult2); + final AsyncPageImpl nextResult1 = new AsyncPageImpl<>(fetcher2, "c2", VALUES2); + AsyncPageImpl.NextPageFetcher fetcher1 = new TestPageFetcher(nextResult1); + AsyncPageImpl result = new AsyncPageImpl<>(fetcher1, "c1", VALUES1); + assertEquals(ALL_VALUES, ImmutableList.copyOf(result.iterateAll())); + } + + @Test + public void testAsyncPageAndIterateAll() throws ExecutionException, InterruptedException { + final AsyncPageImpl nextResult2 = new AsyncPageImpl<>(null, "c3", VALUES3); + AsyncPageImpl.NextPageFetcher fetcher2 = new TestPageFetcher(nextResult2); + final AsyncPageImpl nextResult1 = new AsyncPageImpl<>(fetcher2, "c2", VALUES2); + AsyncPageImpl.NextPageFetcher fetcher1 = new TestPageFetcher(nextResult1); + AsyncPageImpl result = new AsyncPageImpl<>(fetcher1, "c1", VALUES1); + assertEquals(nextResult1, result.getNextPageAsync().get()); + assertEquals("c1", result.getNextPageToken()); + assertEquals(VALUES1, result.getValues()); + assertEquals(SOME_VALUES, ImmutableList.copyOf(result.getNextPageAsync().get().iterateAll())); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseSerializationTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseSerializationTest.java new file mode 100644 index 000000000000..5dcd1726bb0e --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseSerializationTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.base.MoreObjects.firstNonNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import org.junit.Test; + +/** + * Base class for serialization tests. To use this class in your tests override the {@code + * serializableObjects()} method to return all objects that must be serializable. Also override + * {@code restorableObjects()} method to return all restorable objects whose state must be tested + * for proper serialization. Both methods can return {@code null} if no such object needs to be + * tested. + */ +public abstract class BaseSerializationTest { + + /** Returns all objects for which correct serialization must be tested. */ + protected abstract Serializable[] serializableObjects(); + + /** Returns all restorable objects whose state must be tested for proper serialization. */ + protected abstract Restorable[] restorableObjects(); + + @Test + public void testSerializableObjects() throws Exception { + for (Serializable obj : firstNonNull(serializableObjects(), new Serializable[0])) { + Object copy = serializeAndDeserialize(obj); + assertEquals(obj, obj); + assertEquals(obj, copy); + assertEquals(obj.hashCode(), copy.hashCode()); + assertEquals(obj.toString(), copy.toString()); + assertNotSame(obj, copy); + assertEquals(copy, copy); + } + } + + @Test + public void testRestorableObjects() throws Exception { + for (Restorable restorable : firstNonNull(restorableObjects(), new Restorable[0])) { + RestorableState state = restorable.capture(); + RestorableState deserializedState = serializeAndDeserialize(state); + assertEquals(state, deserializedState); + assertEquals(state.hashCode(), deserializedState.hashCode()); + assertEquals(state.toString(), deserializedState.toString()); + } + } + + @SuppressWarnings("unchecked") + public T serializeAndDeserialize(T obj) throws IOException, ClassNotFoundException { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + try (ObjectOutputStream output = new ObjectOutputStream(bytes)) { + output.writeObject(obj); + } + try (ObjectInputStream input = + new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()))) { + return (T) input.readObject(); + } + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseServiceExceptionTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseServiceExceptionTest.java new file mode 100644 index 000000000000..4bc5993f7f64 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseServiceExceptionTest.java @@ -0,0 +1,157 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.cloud.BaseServiceException.UNKNOWN_CODE; +import static com.google.common.truth.Truth.assertThat; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.BaseServiceException.ExceptionData; +import com.google.common.collect.ImmutableSet; +import java.util.Set; +import org.junit.Test; + +/** Tests for {@link BaseServiceException}. */ +public class BaseServiceExceptionTest { + + private static final int CODE = 1; + private static final int CODE_NO_REASON = 2; + private static final String MESSAGE = "some message"; + private static final String REASON = "some reason"; + private static final boolean NOT_RETRYABLE = false; + private static final boolean RETRYABLE = true; + private static final boolean IDEMPOTENT = true; + private static final String DEBUG_INFO = "debugInfo"; + private static final String LOCATION = "location"; + + private static class CustomServiceException extends BaseServiceException { + + private static final long serialVersionUID = -195251309124875103L; + + public CustomServiceException(int code, String message, String reason, boolean idempotent) { + super( + ExceptionData.from( + code, + message, + reason, + BaseServiceException.isRetryable(code, reason, idempotent, RETRYABLE_ERRORS))); + } + + private static final Set RETRYABLE_ERRORS = + ImmutableSet.of( + new Error(CODE, REASON), new Error(null, REASON), new Error(CODE_NO_REASON, null)); + } + + @Test + public void testBaseServiceException() { + BaseServiceException serviceException = + new BaseServiceException(ExceptionData.from(CODE, MESSAGE, REASON, NOT_RETRYABLE)); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertFalse(serviceException.isRetryable()); + assertNull(serviceException.getCause()); + + Exception cause = new RuntimeException(); + serviceException = + new BaseServiceException(ExceptionData.from(CODE, MESSAGE, REASON, NOT_RETRYABLE, cause)); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertFalse(serviceException.isRetryable()); + assertEquals(cause, serviceException.getCause()); + + serviceException = + new BaseServiceException( + ExceptionData.newBuilder() + .setMessage(MESSAGE) + .setCause(cause) + .setCode(CODE) + .setReason(REASON) + .setRetryable(RETRYABLE) + .setDebugInfo(DEBUG_INFO) + .setLocation(LOCATION) + .build()); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertTrue(serviceException.isRetryable()); + assertEquals(cause, serviceException.getCause()); + assertEquals(DEBUG_INFO, serviceException.getDebugInfo()); + assertEquals(LOCATION, serviceException.getLocation()); + + serviceException = new CustomServiceException(CODE, MESSAGE, REASON, IDEMPOTENT); + assertEquals(CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertTrue(serviceException.isRetryable()); + + serviceException = new CustomServiceException(CODE_NO_REASON, MESSAGE, null, IDEMPOTENT); + assertEquals(CODE_NO_REASON, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertNull(serviceException.getReason()); + assertTrue(serviceException.isRetryable()); + + serviceException = new CustomServiceException(UNKNOWN_CODE, MESSAGE, REASON, IDEMPOTENT); + assertEquals(UNKNOWN_CODE, serviceException.getCode()); + assertEquals(MESSAGE, serviceException.getMessage()); + assertEquals(REASON, serviceException.getReason()); + assertTrue(serviceException.isRetryable()); + } + + @Test + public void testTranslateAndThrow() throws Exception { + BaseServiceException cause = + new BaseServiceException(ExceptionData.from(CODE, MESSAGE, REASON, NOT_RETRYABLE)); + RetryHelper.RetryHelperException exceptionMock = + createMock(RetryHelper.RetryHelperException.class); + expect(exceptionMock.getCause()).andReturn(cause).times(2); + replay(exceptionMock); + try { + BaseServiceException.translate(exceptionMock); + } catch (BaseServiceException ex) { + assertEquals(CODE, ex.getCode()); + assertEquals(MESSAGE, ex.getMessage()); + assertFalse(ex.isRetryable()); + } finally { + verify(exceptionMock); + } + } + + @Test + @SuppressWarnings("TruthSelfEquals") + public void testError_Equal() { + BaseServiceException.Error error = new BaseServiceException.Error(0, "reason", true); + assertThat(error).isEqualTo(error); + assertThat(error.hashCode()).isEqualTo(error.hashCode()); + + BaseServiceException.Error sameError = new BaseServiceException.Error(0, "reason", true); + assertThat(error).isEqualTo(sameError); + assertThat(error.hashCode()).isEqualTo(sameError.hashCode()); + + BaseServiceException.Error error2 = new BaseServiceException.Error(1, "other reason", false); + assertThat(error).isNotEqualTo(error2); + assertThat(error.hashCode()).isNotEqualTo(error2.hashCode()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java new file mode 100644 index 000000000000..65743a347a21 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java @@ -0,0 +1,144 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import com.google.cloud.spi.ServiceRpcFactory; +import java.io.IOException; +import java.io.Serializable; +import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; +import java.util.Arrays; +import java.util.Random; +import org.junit.Before; +import org.junit.Test; + +public class BaseWriteChannelTest { + + private abstract static class CustomService implements Service {} + + private abstract static class CustomServiceOptions + extends ServiceOptions { + + private static final long serialVersionUID = 3302358029307467197L; + + protected CustomServiceOptions( + Class> serviceFactoryClass, + Class> rpcFactoryClass, + Builder builder) { + super(serviceFactoryClass, rpcFactoryClass, builder, null); + } + } + + private static final Serializable ENTITY = 42L; + private static final String UPLOAD_ID = "uploadId"; + private static final byte[] CONTENT = {0xD, 0xE, 0xA, 0xD}; + private static final int MIN_CHUNK_SIZE = 256 * 1024; // 256 KiB + private static final int DEFAULT_CHUNK_SIZE = 60 * MIN_CHUNK_SIZE; // 15MiB + private static final Random RANDOM = new Random(); + private static BaseWriteChannel channel; + + @Before + public void setUp() { + channel = + new BaseWriteChannel(null, ENTITY, UPLOAD_ID) { + @Override + public RestorableState capture() { + return null; + } + + @Override + protected void flushBuffer(int length, boolean last) {} + + @Override + protected BaseState.Builder stateBuilder() { + return null; + } + }; + } + + @Test + public void testConstructor() { + assertEquals(null, channel.getOptions()); + assertEquals(ENTITY, channel.getEntity()); + assertEquals(0, channel.getPosition()); + assertEquals(UPLOAD_ID, channel.getUploadId()); + assertEquals(0, channel.getLimit()); + assertTrue(channel.isOpen()); + assertArrayEquals(new byte[0], channel.getBuffer()); + assertEquals(DEFAULT_CHUNK_SIZE, channel.getChunkSize()); + } + + @Test + public void testClose() throws IOException { + channel.close(); + assertFalse(channel.isOpen()); + assertNull(channel.getBuffer()); + } + + @Test(expected = ClosedChannelException.class) + public void testValidateOpen() throws IOException { + channel.close(); + channel.write(ByteBuffer.allocate(42)); + } + + @Test + public void testChunkSize() { + channel.setChunkSize(42); + assertThat(channel.getChunkSize() >= MIN_CHUNK_SIZE).isTrue(); + assertThat(channel.getChunkSize() % MIN_CHUNK_SIZE).isEqualTo(0); + + channel.setChunkSize(2 * MIN_CHUNK_SIZE); + assertThat(channel.getChunkSize() >= MIN_CHUNK_SIZE).isTrue(); + assertThat(channel.getChunkSize() % MIN_CHUNK_SIZE).isEqualTo(0); + + channel.setChunkSize(2 * MIN_CHUNK_SIZE + 1); + assertThat(channel.getChunkSize() >= MIN_CHUNK_SIZE).isTrue(); + assertThat(channel.getChunkSize() % MIN_CHUNK_SIZE).isEqualTo(0); + } + + @Test + public void testWrite() throws IOException { + channel.write(ByteBuffer.wrap(CONTENT)); + assertEquals(CONTENT.length, channel.getLimit()); + assertEquals(DEFAULT_CHUNK_SIZE, channel.getBuffer().length); + assertArrayEquals(Arrays.copyOf(CONTENT, DEFAULT_CHUNK_SIZE), channel.getBuffer()); + } + + @Test + public void testWriteAndFlush() throws IOException { + ByteBuffer content = randomBuffer(DEFAULT_CHUNK_SIZE + 1); + channel.write(content); + assertEquals(DEFAULT_CHUNK_SIZE, channel.getPosition()); + assertEquals(1, channel.getLimit()); + byte[] newContent = new byte[DEFAULT_CHUNK_SIZE]; + newContent[0] = content.get(DEFAULT_CHUNK_SIZE); + assertArrayEquals(newContent, channel.getBuffer()); + } + + private static ByteBuffer randomBuffer(int size) { + byte[] byteArray = new byte[size]; + RANDOM.nextBytes(byteArray); + return ByteBuffer.wrap(byteArray); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/BatchResultTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/BatchResultTest.java new file mode 100644 index 000000000000..001bba983407 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/BatchResultTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.BaseServiceException.ExceptionData; +import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; + +public class BatchResultTest { + + private BatchResult result; + + @Before + public void setUp() { + result = new BatchResult() {}; + } + + @Test + public void testSuccess() { + assertFalse(result.completed()); + try { + result.get(); + fail("This was not completed yet."); + } catch (IllegalStateException ex) { + // expected + } + result.success(true); + assertTrue(result.get()); + // test that null is allowed + result.success(null); + } + + @Test + public void testError() { + assertFalse(result.completed()); + try { + result.get(); + fail("This was not completed yet."); + } catch (IllegalStateException ex) { + // expected + } + try { + result.error(null); + fail(); + } catch (NullPointerException exc) { + // expected + } + BaseServiceException ex = + new BaseServiceException(ExceptionData.from(0, "message", "reason", false)); + result.error(ex); + try { + result.get(); + fail("This is a failed operation and should have thrown a DnsException."); + } catch (BaseServiceException real) { + assertSame(ex, real); + } + } + + @Test + public void testNotifyError() { + final BaseServiceException ex = + new BaseServiceException(ExceptionData.from(0, "message", "reason", false)); + assertFalse(result.completed()); + BatchResult.Callback callback = + EasyMock.createStrictMock(BatchResult.Callback.class); + callback.error(ex); + EasyMock.replay(callback); + result.notify(callback); + result.error(ex); + try { + result.notify(callback); + fail("The batch has been completed."); + } catch (IllegalStateException exception) { + // expected + } + EasyMock.verify(callback); + } + + @Test + public void testNotifySuccess() { + assertFalse(result.completed()); + BatchResult.Callback callback = + EasyMock.createStrictMock(BatchResult.Callback.class); + callback.success(true); + EasyMock.replay(callback); + result.notify(callback); + result.success(true); + try { + result.notify(callback); + fail("The batch has been completed."); + } catch (IllegalStateException exception) { + // expected + } + EasyMock.verify(callback); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/ByteArrayTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/ByteArrayTest.java new file mode 100644 index 000000000000..42873f8643e9 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/ByteArrayTest.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +import com.google.common.io.ByteStreams; +import com.google.protobuf.ByteString; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ByteArrayTest { + + private static final String STRING_CONTENT = "Hello, ByteArray!"; + private static final byte[] BYTES_CONTENT = STRING_CONTENT.getBytes(StandardCharsets.UTF_8); + private static final ByteBuffer BYTE_BUFFER_CONTENT = ByteBuffer.wrap(BYTES_CONTENT); + private static final InputStream STREAM_CONTENT = new ByteArrayInputStream(BYTES_CONTENT); + private static final ByteArray STRING_ARRAY = ByteArray.copyFrom(STRING_CONTENT); + private static final ByteArray BYTES_ARRAY = ByteArray.copyFrom(BYTES_CONTENT); + private static final ByteArray BYTE_BUFFER_ARRAY = ByteArray.copyFrom(BYTE_BUFFER_CONTENT); + private static final ByteArray ARRAY = new ByteArray(ByteString.copyFrom(BYTES_CONTENT)); + + private static ByteArray streamArray; + + @BeforeClass + public static void beforeClass() throws IOException { + streamArray = ByteArray.copyFrom(STREAM_CONTENT); + BYTE_BUFFER_CONTENT.flip(); + } + + @Test + public void testCopyFromString() throws IOException { + assertEquals(STRING_CONTENT, STRING_ARRAY.toStringUtf8()); + assertArrayEquals(BYTES_CONTENT, STRING_ARRAY.toByteArray()); + assertEquals(BYTE_BUFFER_CONTENT.asReadOnlyBuffer(), STRING_ARRAY.asReadOnlyByteBuffer()); + assertArrayEquals(BYTES_CONTENT, ByteStreams.toByteArray(STRING_ARRAY.asInputStream())); + } + + @Test + public void testCopyFromByteArray() throws IOException { + assertEquals(STRING_CONTENT, BYTES_ARRAY.toStringUtf8()); + assertArrayEquals(BYTES_CONTENT, BYTES_ARRAY.toByteArray()); + assertEquals(BYTE_BUFFER_CONTENT.asReadOnlyBuffer(), BYTES_ARRAY.asReadOnlyByteBuffer()); + assertArrayEquals(BYTES_CONTENT, ByteStreams.toByteArray(BYTES_ARRAY.asInputStream())); + } + + @Test + public void testCopyFromByteBuffer() throws IOException { + assertEquals(STRING_CONTENT, BYTE_BUFFER_ARRAY.toStringUtf8()); + assertArrayEquals(BYTES_CONTENT, BYTE_BUFFER_ARRAY.toByteArray()); + assertEquals(BYTE_BUFFER_CONTENT.asReadOnlyBuffer(), BYTE_BUFFER_ARRAY.asReadOnlyByteBuffer()); + assertArrayEquals(BYTES_CONTENT, ByteStreams.toByteArray(BYTE_BUFFER_ARRAY.asInputStream())); + } + + @Test + public void testCopyFromStream() throws IOException { + assertEquals(STRING_CONTENT, streamArray.toStringUtf8()); + assertArrayEquals(BYTES_CONTENT, streamArray.toByteArray()); + assertEquals(BYTE_BUFFER_CONTENT.asReadOnlyBuffer(), streamArray.asReadOnlyByteBuffer()); + assertArrayEquals(BYTES_CONTENT, ByteStreams.toByteArray(streamArray.asInputStream())); + } + + @Test + public void testLength() { + assertEquals(BYTES_CONTENT.length, ARRAY.length()); + } + + @Test + public void testToStringUtf8() { + assertEquals(STRING_CONTENT, ARRAY.toStringUtf8()); + } + + @Test + public void testToByteArray() { + assertArrayEquals(BYTES_CONTENT, ARRAY.toByteArray()); + } + + @Test + public void testAsReadOnlyByteBuffer() { + assertEquals(BYTE_BUFFER_CONTENT.asReadOnlyBuffer(), ARRAY.asReadOnlyByteBuffer()); + } + + @Test + public void testAsInputStream() throws IOException { + assertArrayEquals(BYTES_CONTENT, ByteStreams.toByteArray(ARRAY.asInputStream())); + } + + @Test + public void testHashCode() { + assertEquals(STRING_ARRAY.hashCode(), BYTES_ARRAY.hashCode()); + assertEquals(BYTES_ARRAY.hashCode(), BYTE_BUFFER_ARRAY.hashCode()); + assertEquals(BYTE_BUFFER_ARRAY.hashCode(), streamArray.hashCode()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/ConditionTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/ConditionTest.java new file mode 100644 index 000000000000..67e0e6c2b596 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/ConditionTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; + +public final class ConditionTest { + + @Test + public void title_nullable() { + Condition condition = + Condition.newBuilder().setTitle(null).setDescription("desc").setExpression("expr").build(); + + assertThat(condition.getTitle()).isNull(); + } + + @Test + public void description_nullable() { + Condition condition = + Condition.newBuilder().setTitle("title").setDescription(null).setExpression("expr").build(); + + assertThat(condition.getDescription()).isNull(); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/DateTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/DateTest.java new file mode 100644 index 000000000000..d95efaf09459 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/DateTest.java @@ -0,0 +1,172 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.testing.SerializableTester.reserializeAndAssert; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.fail; + +import com.google.common.testing.EqualsTester; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link Date}. */ +@RunWith(JUnit4.class) +public class DateTest { + + private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + + @Test + public void parseDate() { + verifyDate("2016-09-18", 2016, 9, 18); + verifyDate("2000-01-01", 2000, 1, 1); + verifyDate("9999-12-31", 9999, 12, 31); + verifyDate("0001-01-01", 1, 1, 1); + verifyDate("2000-02-29", 2000, 2, 29); // This is a valid leap year. + verifyDate("1900-02-29", 1900, 2, 29); // This is NOT a valid leap year. + verifyDate("2001-02-29", 2001, 2, 29); // Also not a valid leap year. + verifyDate("2000-04-31", 2000, 4, 31); // Not a valid date. + } + + private void verifyDate(String input, int year, int month, int day) { + Date date = Date.parseDate(input); + assertThat(date.getYear()).isEqualTo(year); + assertThat(date.getMonth()).isEqualTo(month); + assertThat(date.getDayOfMonth()).isEqualTo(day); + } + + @Test + public void parseInvalidDates() { + parseInvalidDate("2016/09/18"); + parseInvalidDate("2016 09 18"); + parseInvalidDate("2016-9-18"); + parseInvalidDate("2016-09-18T10:00"); + parseInvalidDate(""); + parseInvalidDate("test"); + parseInvalidDate("aaaa-bb-cc"); + parseInvalidDate("aaaa-01-01"); + parseInvalidDate("2019-bb-01"); + parseInvalidDate("2019-01-cc"); + parseInvalidMonth("2000-13-01"); + parseInvalidMonth("2000-00-01"); + parseInvalidDay("2000-12-32"); + parseInvalidDay("2000-12-00"); + parseInvalidDate("10000-01-01"); + parseInvalidYear("0000-01-01"); + parseInvalidYear("-001-01-01"); + parseInvalidMonth("0001--1-01"); + parseInvalidDay("0001-01--1"); + } + + private void parseInvalidDate(String input) { + try { + Date.parseDate(input); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).contains("Invalid date"); + } + } + + private void parseInvalidYear(String input) { + try { + Date.parseDate(input); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).contains("Invalid year"); + } + } + + private void parseInvalidMonth(String input) { + try { + Date.parseDate(input); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).contains("Invalid month"); + } + } + + private void parseInvalidDay(String input) { + try { + Date.parseDate(input); + fail("Expected exception"); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage()).contains("Invalid day"); + } + } + + @Test + public void testToString() { + Date date = Date.fromYearMonthDay(10, 9, 5); + assertThat(date.toString()).isEqualTo("0010-09-05"); + date = Date.fromYearMonthDay(2016, 12, 31); + assertThat(date.toString()).isEqualTo("2016-12-31"); + date = Date.fromYearMonthDay(1, 1, 1); + assertThat(date.toString()).isEqualTo("0001-01-01"); + } + + @Test + public void equalAndHashCode() { + Date d1 = Date.fromYearMonthDay(2016, 9, 18); + Date d2 = Date.fromYearMonthDay(2016, 9, 18); + Date d3 = Date.fromYearMonthDay(2016, 9, 19); + new EqualsTester().addEqualityGroup(d1, d2).addEqualityGroup(d3).testEquals(); + } + + @Test + public void validOrdering() { + Date d1 = Date.fromYearMonthDay(2016, 9, 18); + Date d2 = Date.fromYearMonthDay(2016, 9, 19); + Date d3 = Date.fromYearMonthDay(2016, 9, 20); + Date d4 = Date.fromYearMonthDay(2016, 10, 1); + Date d5 = Date.fromYearMonthDay(2017, 1, 1); + assertDescending(d5, d4, d3, d2, d1); + } + + @Test + public void serialization() { + reserializeAndAssert(Date.fromYearMonthDay(2017, 4, 20)); + } + + @Test + public void testToJavaUtilDate() throws ParseException { + Date gcDate = Date.parseDate("2016-09-18"); + java.util.Date juDate1 = SIMPLE_DATE_FORMAT.parse("2016-09-18"); + java.util.Date juDate2 = Date.toJavaUtilDate(gcDate); + assertThat(juDate1).isEqualTo(juDate2); + } + + @Test + public void testFromJavaUtilDate() throws ParseException { + java.util.Date juDate = SIMPLE_DATE_FORMAT.parse("2016-09-18"); + Date gcDate = Date.fromJavaUtilDate(juDate); + assertThat(gcDate.getYear()).isEqualTo(2016); + assertThat(gcDate.getMonth()).isEqualTo(9); + assertThat(gcDate.getDayOfMonth()).isEqualTo(18); + } + + private void assertDescending(Date... dates) { + for (int i = 0; i < dates.length - 1; i++) { + assertThat(dates[i]).isEquivalentAccordingToCompareTo(dates[i]); + for (int j = i + 1; j < dates.length; j++) { + assertThat(dates[i]).isGreaterThan(dates[j]); + } + } + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/ExceptionHandlerTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/ExceptionHandlerTest.java new file mode 100644 index 000000000000..50e0583c89ca --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/ExceptionHandlerTest.java @@ -0,0 +1,210 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.ExceptionHandler.Interceptor; +import com.google.cloud.ExceptionHandler.Interceptor.RetryResult; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.channels.ClosedByInterruptException; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicReference; +import org.junit.Test; + +/** Tests for {@link ExceptionHandler}. */ +public class ExceptionHandlerTest { + + @Test + public void testVerifyCaller() { + class A implements Callable { + @Override + public Object call() throws IOException, InterruptedException { + return null; + } + } + + class B extends A {} + + class C extends A { + @Override + public Object call() throws FileNotFoundException { + return "c"; + } + } + + class D extends C { + @Override + public Object call() throws IllegalArgumentException { + return "d"; + } + } + + class E extends A { + @Override + public String call() throws NullPointerException { + return "e"; + } + } + + class F extends A { + @Override + public Object call() throws Error { + return "f"; + } + } + + // using default exception handler (retry upon any non-runtime exceptions) + ExceptionHandler handler = ExceptionHandler.getDefaultInstance(); + assertValidCallable(new A(), handler); + assertValidCallable(new B(), handler); + assertValidCallable(new C(), handler); + assertValidCallable(new D(), handler); + assertValidCallable(new E(), handler); + assertInvalidCallable(new F(), handler); + + handler = + ExceptionHandler.newBuilder() + .retryOn(FileNotFoundException.class, NullPointerException.class) + .build(); + assertInvalidCallable(new A(), handler); + assertInvalidCallable(new B(), handler); + assertValidCallable(new C(), handler); + assertInvalidCallable(new D(), handler); + assertValidCallable(new E(), handler); + assertInvalidCallable(new F(), handler); + } + + private static void assertValidCallable(Callable callable, ExceptionHandler handler) { + handler.verifyCaller(callable); + } + + private static void assertInvalidCallable(Callable callable, ExceptionHandler handler) { + try { + handler.verifyCaller(callable); + fail("Expected RetryHelper constructor to fail"); + } catch (IllegalArgumentException ex) { + // expected + } + } + + @Test + public void testShouldTry() { + ExceptionHandler handler = ExceptionHandler.newBuilder().retryOn(IOException.class).build(); + assertTrue(handler.shouldRetry(new IOException(), null)); + assertTrue(handler.shouldRetry(new ClosedByInterruptException(), null)); + assertFalse(handler.shouldRetry(new RuntimeException(), null)); + + ExceptionHandler.Builder builder = + ExceptionHandler.newBuilder() + .retryOn(IOException.class, NullPointerException.class) + .abortOn( + RuntimeException.class, + ClosedByInterruptException.class, + InterruptedException.class); + + handler = builder.build(); + assertTrue(handler.shouldRetry(new IOException(), null)); + assertFalse(handler.shouldRetry(new ClosedByInterruptException(), null)); + assertFalse(handler.shouldRetry(new InterruptedException(), null)); + assertFalse(handler.shouldRetry(new RuntimeException(), null)); + assertTrue(handler.shouldRetry(new NullPointerException(), null)); + + final AtomicReference before = new AtomicReference<>(RetryResult.NO_RETRY); + @SuppressWarnings("serial") + Interceptor interceptor = + new Interceptor() { + + @Override + public RetryResult afterEval(Exception exception, RetryResult retryResult) { + return retryResult == RetryResult.NO_RETRY ? RetryResult.RETRY : RetryResult.NO_RETRY; + } + + @Override + public RetryResult beforeEval(Exception exception) { + return before.get(); + } + }; + + builder.addInterceptors(interceptor); + handler = builder.build(); + assertFalse(handler.shouldRetry(new IOException(), null)); + assertFalse(handler.shouldRetry(new ClosedByInterruptException(), null)); + assertFalse(handler.shouldRetry(new InterruptedException(), null)); + assertFalse(handler.shouldRetry(new RuntimeException(), null)); + assertFalse(handler.shouldRetry(new NullPointerException(), null)); + + before.set(RetryResult.RETRY); + assertTrue(handler.shouldRetry(new IOException(), null)); + assertTrue(handler.shouldRetry(new ClosedByInterruptException(), null)); + assertTrue(handler.shouldRetry(new InterruptedException(), null)); + assertTrue(handler.shouldRetry(new RuntimeException(), null)); + assertTrue(handler.shouldRetry(new NullPointerException(), null)); + + before.set(RetryResult.CONTINUE_EVALUATION); + assertFalse(handler.shouldRetry(new IOException(), null)); + assertTrue(handler.shouldRetry(new ClosedByInterruptException(), null)); + assertTrue(handler.shouldRetry(new InterruptedException(), null)); + assertTrue(handler.shouldRetry(new RuntimeException(), null)); + assertFalse(handler.shouldRetry(new NullPointerException(), null)); + } + + @Test(expected = NullPointerException.class) + public void testNullRetryResultFromBeforeEval() { + @SuppressWarnings("serial") + Interceptor interceptor = + new Interceptor() { + + @Override + public RetryResult beforeEval(Exception exception) { + return null; + } + + @Override + public RetryResult afterEval(Exception exception, RetryResult retryResult) { + return RetryResult.CONTINUE_EVALUATION; + } + }; + + ExceptionHandler handler = ExceptionHandler.newBuilder().addInterceptors(interceptor).build(); + handler.shouldRetry(new Exception(), null); + } + + @Test(expected = NullPointerException.class) + public void testNullRetryResultFromAfterEval() { + @SuppressWarnings("serial") + Interceptor interceptor = + new Interceptor() { + + @Override + public RetryResult beforeEval(Exception exception) { + return RetryResult.CONTINUE_EVALUATION; + } + + @Override + public RetryResult afterEval(Exception exception, RetryResult retryResult) { + return null; + } + }; + + ExceptionHandler handler = ExceptionHandler.newBuilder().addInterceptors(interceptor).build(); + handler.shouldRetry(new Exception(), null); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/FieldSelectorHelperTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/FieldSelectorHelperTest.java new file mode 100644 index 000000000000..7b94ff529402 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/FieldSelectorHelperTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.FieldSelector.Helper; +import com.google.common.collect.ImmutableList; +import java.util.List; +import org.junit.Test; + +public class FieldSelectorHelperTest { + + private static final FieldSelector FIELD1 = + new FieldSelector() { + @Override + public String getSelector() { + return "field1"; + } + }; + private static final FieldSelector FIELD2 = + new FieldSelector() { + @Override + public String getSelector() { + return "field2"; + } + }; + private static final FieldSelector FIELD3 = + new FieldSelector() { + @Override + public String getSelector() { + return "field3"; + } + }; + private static final String[] FIRST_LEVEL_FIELDS = {"firstLevel1", "firstLevel2"}; + private static final List REQUIRED_FIELDS = ImmutableList.of(FIELD1, FIELD2); + private static final String CONTAINER = "container"; + + @Test + public void testSelector() { + String selector = Helper.selector(REQUIRED_FIELDS, FIELD3); + assertTrue(selector.contains("field1")); + assertTrue(selector.contains("field2")); + assertTrue(selector.contains("field3")); + assertEquals(20, selector.length()); + } + + @Test + public void testListSelector() { + String selector = Helper.listSelector(CONTAINER, REQUIRED_FIELDS, FIELD3); + assertTrue(selector.startsWith("nextPageToken,container(")); + assertTrue(selector.contains("field1")); + assertTrue(selector.contains("field2")); + assertTrue(selector.contains("field3")); + assertTrue(selector.endsWith(")")); + assertEquals(45, selector.length()); + } + + @Test + public void testListSelectorWithExtraFields() { + String selector = + Helper.listSelector(CONTAINER, REQUIRED_FIELDS, new FieldSelector[] {FIELD3}, "field4"); + assertTrue(selector.startsWith("nextPageToken,container(")); + assertTrue(selector.contains("field1")); + assertTrue(selector.contains("field2")); + assertTrue(selector.contains("field3")); + assertTrue(selector.contains("field4")); + assertTrue(selector.endsWith(")")); + assertEquals(52, selector.length()); + } + + @Test + public void testListSelectorWithFirstLevelFields() { + String selector = + Helper.listSelector( + FIRST_LEVEL_FIELDS, CONTAINER, REQUIRED_FIELDS, new FieldSelector[] {FIELD3}, "field4"); + assertTrue(selector.contains("firstLevel1")); + assertTrue(selector.contains("firstLevel2")); + assertTrue(selector.contains("nextPageToken")); + assertTrue(selector.contains("container(")); + assertTrue(selector.contains("field1")); + assertTrue(selector.contains("field2")); + assertTrue(selector.contains("field3")); + assertTrue(selector.contains("field4")); + assertTrue(selector.endsWith(")")); + assertEquals(76, selector.length()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/IdentityTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/IdentityTest.java new file mode 100644 index 000000000000..8f8abb170c84 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/IdentityTest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class IdentityTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Identity PROJECT_OWNER = Identity.projectOwner("my-sample-project"); + private static final Identity PROJECT_EDITOR = Identity.projectEditor("my-sample-project"); + private static final Identity PROJECT_VIEWER = Identity.projectViewer("my-sample-project"); + + @Test + public void testAllUsers() { + assertEquals(Identity.Type.ALL_USERS, ALL_USERS.getType()); + assertNull(ALL_USERS.getValue()); + } + + @Test + public void testAllAuthenticatedUsers() { + assertEquals(Identity.Type.ALL_AUTHENTICATED_USERS, ALL_AUTH_USERS.getType()); + assertNull(ALL_AUTH_USERS.getValue()); + } + + @Test + public void testUser() { + assertEquals(Identity.Type.USER, USER.getType()); + assertEquals("abc@gmail.com", USER.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testUserNullEmail() { + Identity.user(null); + } + + @Test + public void testServiceAccount() { + assertEquals(Identity.Type.SERVICE_ACCOUNT, SERVICE_ACCOUNT.getType()); + assertEquals("service-account@gmail.com", SERVICE_ACCOUNT.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testServiceAccountNullEmail() { + Identity.serviceAccount(null); + } + + @Test + public void testGroup() { + assertEquals(Identity.Type.GROUP, GROUP.getType()); + assertEquals("group@gmail.com", GROUP.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testGroupNullEmail() { + Identity.group(null); + } + + @Test + public void testDomain() { + assertEquals(Identity.Type.DOMAIN, DOMAIN.getType()); + assertEquals("google.com", DOMAIN.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testDomainNullId() { + Identity.domain(null); + } + + @Test + public void testProjectOwner() { + assertEquals(Identity.Type.PROJECT_OWNER, PROJECT_OWNER.getType()); + assertEquals("my-sample-project", PROJECT_OWNER.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testProjectOwnerNullId() { + Identity.projectOwner(null); + } + + @Test + public void testProjectEditor() { + assertEquals(Identity.Type.PROJECT_EDITOR, PROJECT_EDITOR.getType()); + assertEquals("my-sample-project", PROJECT_EDITOR.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testProjectEditorNullId() { + Identity.projectEditor(null); + } + + @Test + public void testProjectViewer() { + assertEquals(Identity.Type.PROJECT_VIEWER, PROJECT_VIEWER.getType()); + assertEquals("my-sample-project", PROJECT_VIEWER.getValue()); + } + + @Test(expected = NullPointerException.class) + public void testProjectViewerNullId() { + Identity.projectViewer(null); + } + + @Test + public void testIdentityToAndFromPb() { + compareIdentities(ALL_USERS, Identity.valueOf(ALL_USERS.strValue())); + compareIdentities(ALL_AUTH_USERS, Identity.valueOf(ALL_AUTH_USERS.strValue())); + compareIdentities(USER, Identity.valueOf(USER.strValue())); + compareIdentities(SERVICE_ACCOUNT, Identity.valueOf(SERVICE_ACCOUNT.strValue())); + compareIdentities(GROUP, Identity.valueOf(GROUP.strValue())); + compareIdentities(DOMAIN, Identity.valueOf(DOMAIN.strValue())); + compareIdentities(PROJECT_OWNER, Identity.valueOf(PROJECT_OWNER.strValue())); + compareIdentities(PROJECT_EDITOR, Identity.valueOf(PROJECT_EDITOR.strValue())); + compareIdentities(PROJECT_VIEWER, Identity.valueOf(PROJECT_VIEWER.strValue())); + } + + @Test(expected = IllegalArgumentException.class) + public void testValueOfEmpty() { + Identity.valueOf(""); + } + + @Test + public void testUnrecognizedToString() { + assertEquals("a:b", Identity.valueOf("a:b").strValue()); + } + + @Test + public void testValueOfThreePart() { + Identity identity = Identity.valueOf("a:b:c"); + assertEquals("A", identity.getType().name()); + assertEquals("b:c", identity.getValue()); + } + + private void compareIdentities(Identity expected, Identity actual) { + assertEquals(expected, actual); + assertEquals(expected.getType(), actual.getType()); + assertEquals(expected.getValue(), actual.getValue()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/MonitoredResourceDescriptorTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/MonitoredResourceDescriptorTest.java new file mode 100644 index 000000000000..b29896af4821 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/MonitoredResourceDescriptorTest.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import com.google.cloud.MonitoredResourceDescriptor.LabelDescriptor; +import com.google.cloud.MonitoredResourceDescriptor.LabelDescriptor.ValueType; +import com.google.common.collect.ImmutableList; +import java.util.List; +import org.junit.Test; + +public class MonitoredResourceDescriptorTest { + + private static final LabelDescriptor BOOLEAN_LABEL = + new LabelDescriptor("booleanKey", ValueType.BOOL, "Boolean label"); + private static final LabelDescriptor STRING_LABEL = + new LabelDescriptor("stringKey", ValueType.STRING, "String label"); + private static final LabelDescriptor INT_LABEL = + new LabelDescriptor("intKey", ValueType.INT64, "Int label"); + private static final LabelDescriptor INT_LABEL_NO_DESCRIPTION = + new LabelDescriptor("intKey", ValueType.INT64, null); + private static final String TYPE = "resource_type"; + private static final String NAME = "resourceName"; + private static final String DISPLAY_NAME = "Display Name"; + private static final String DESCRIPTION = "Resource Descriptor"; + private static final List LABELS = + ImmutableList.of(BOOLEAN_LABEL, STRING_LABEL, INT_LABEL); + private static final MonitoredResourceDescriptor RESOURCE_DESCRIPTOR = + MonitoredResourceDescriptor.newBuilder(TYPE) + .setName(NAME) + .setDisplayName(DISPLAY_NAME) + .setDescription(DESCRIPTION) + .setLabels(LABELS) + .build(); + + @Test + public void testLabelDescriptor() { + assertEquals("booleanKey", BOOLEAN_LABEL.getKey()); + assertEquals(ValueType.BOOL, BOOLEAN_LABEL.getValueType()); + assertEquals("Boolean label", BOOLEAN_LABEL.getDescription()); + assertEquals("stringKey", STRING_LABEL.getKey()); + assertEquals(ValueType.STRING, STRING_LABEL.getValueType()); + assertEquals("String label", STRING_LABEL.getDescription()); + assertEquals("intKey", INT_LABEL.getKey()); + assertEquals(ValueType.INT64, INT_LABEL.getValueType()); + assertEquals("Int label", INT_LABEL.getDescription()); + assertEquals("intKey", INT_LABEL_NO_DESCRIPTION.getKey()); + assertEquals(ValueType.INT64, INT_LABEL_NO_DESCRIPTION.getValueType()); + assertNull(INT_LABEL_NO_DESCRIPTION.getDescription()); + } + + @Test + public void testBuilder() { + assertEquals(TYPE, RESOURCE_DESCRIPTOR.getType()); + assertEquals(NAME, RESOURCE_DESCRIPTOR.getName()); + assertEquals(DISPLAY_NAME, RESOURCE_DESCRIPTOR.getDisplayName()); + assertEquals(DESCRIPTION, RESOURCE_DESCRIPTOR.getDescription()); + assertEquals(LABELS, RESOURCE_DESCRIPTOR.getLabels()); + MonitoredResourceDescriptor resourceDescriptor = + MonitoredResourceDescriptor.newBuilder(TYPE).build(); + assertEquals(TYPE, resourceDescriptor.getType()); + assertNull(resourceDescriptor.getName()); + assertNull(resourceDescriptor.getDisplayName()); + assertNull(resourceDescriptor.getDescription()); + assertEquals(ImmutableList.of(), resourceDescriptor.getLabels()); + } + + @Test + public void testToAndFromPbLabelDescriptor() { + compareLabelDescriptor(BOOLEAN_LABEL, LabelDescriptor.fromPb(BOOLEAN_LABEL.toPb())); + compareLabelDescriptor(STRING_LABEL, LabelDescriptor.fromPb(STRING_LABEL.toPb())); + compareLabelDescriptor(INT_LABEL, LabelDescriptor.fromPb(INT_LABEL.toPb())); + compareLabelDescriptor( + INT_LABEL_NO_DESCRIPTION, LabelDescriptor.fromPb(INT_LABEL_NO_DESCRIPTION.toPb())); + } + + @Test + public void testToAndFromPb() { + compareResourceDescriptor( + RESOURCE_DESCRIPTOR, MonitoredResourceDescriptor.fromPb(RESOURCE_DESCRIPTOR.toPb())); + MonitoredResourceDescriptor resourceDescriptor = + MonitoredResourceDescriptor.newBuilder(TYPE).build(); + compareResourceDescriptor( + resourceDescriptor, MonitoredResourceDescriptor.fromPb(resourceDescriptor.toPb())); + } + + private void compareLabelDescriptor(LabelDescriptor expected, LabelDescriptor value) { + assertEquals(expected, value); + assertEquals(expected.getKey(), value.getKey()); + assertEquals(expected.getValueType(), value.getValueType()); + assertEquals(expected.getDescription(), value.getDescription()); + assertEquals(expected.hashCode(), value.hashCode()); + assertEquals(expected.toString(), value.toString()); + } + + private void compareResourceDescriptor( + MonitoredResourceDescriptor expected, MonitoredResourceDescriptor value) { + assertEquals(expected, value); + assertEquals(expected.getType(), value.getType()); + assertEquals(expected.getName(), value.getName()); + assertEquals(expected.getDisplayName(), value.getDisplayName()); + assertEquals(expected.getDescription(), value.getDescription()); + assertEquals(expected.getLabels(), value.getLabels()); + assertEquals(expected.hashCode(), value.hashCode()); + assertEquals(expected.toString(), value.toString()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/MonitoredResourceTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/MonitoredResourceTest.java new file mode 100644 index 000000000000..6054a7aa3463 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/MonitoredResourceTest.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import org.junit.Test; + +public class MonitoredResourceTest { + + private static final String TYPE = "cloudsql_database"; + private static final Map LABELS = + ImmutableMap.of("dataset-id", "myDataset", "zone", "myZone"); + private static final MonitoredResource MONITORED_RESOURCE = + MonitoredResource.newBuilder(TYPE).setLabels(LABELS).build(); + + @Test + public void testBuilder() { + assertEquals(TYPE, MONITORED_RESOURCE.getType()); + assertEquals(LABELS, MONITORED_RESOURCE.getLabels()); + MonitoredResource monitoredResource = + MonitoredResource.newBuilder(TYPE) + .addLabel("dataset-id", "myDataset") + .addLabel("zone", "myZone") + .build(); + assertEquals(TYPE, monitoredResource.getType()); + assertEquals(LABELS, monitoredResource.getLabels()); + compareMonitoredResource(MONITORED_RESOURCE, monitoredResource); + monitoredResource = + MonitoredResource.newBuilder(TYPE) + .setType("global") + .addLabel("dataset-id", "myDataset") + .addLabel("zone", "myZone") + .clearLabels() + .build(); + assertEquals("global", monitoredResource.getType()); + assertEquals(ImmutableMap.of(), monitoredResource.getLabels()); + } + + @Test + public void testToBuilder() { + compareMonitoredResource(MONITORED_RESOURCE, MONITORED_RESOURCE.toBuilder().build()); + MonitoredResource monitoredResource = + MONITORED_RESOURCE.toBuilder().setType("global").clearLabels().build(); + assertEquals("global", monitoredResource.getType()); + assertEquals(ImmutableMap.of(), monitoredResource.getLabels()); + monitoredResource = + monitoredResource + .toBuilder() + .setType(TYPE) + .setLabels(ImmutableMap.of("dataset-id", "myDataset")) + .addLabel("zone", "myZone") + .build(); + compareMonitoredResource(MONITORED_RESOURCE, monitoredResource); + } + + @Test + public void testOf() { + MonitoredResource monitoredResource = MonitoredResource.of(TYPE, LABELS); + assertEquals(TYPE, monitoredResource.getType()); + assertEquals(LABELS, monitoredResource.getLabels()); + compareMonitoredResource(MONITORED_RESOURCE, monitoredResource); + } + + @Test + public void testToAndFromPb() { + compareMonitoredResource( + MONITORED_RESOURCE, MonitoredResource.fromPb(MONITORED_RESOURCE.toPb())); + MonitoredResource monitoredResource = + MonitoredResource.of(TYPE, ImmutableMap.of()); + compareMonitoredResource(monitoredResource, MonitoredResource.fromPb(monitoredResource.toPb())); + } + + private void compareMonitoredResource(MonitoredResource expected, MonitoredResource value) { + assertEquals(expected, value); + assertEquals(expected.getType(), value.getType()); + assertEquals(expected.getLabels(), value.getLabels()); + assertEquals(expected.hashCode(), value.hashCode()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/PageImplTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/PageImplTest.java new file mode 100644 index 000000000000..5e6a6782d6e2 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/PageImplTest.java @@ -0,0 +1,64 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; + +import com.google.api.gax.paging.Page; +import com.google.common.collect.ImmutableList; +import org.junit.Test; + +public class PageImplTest { + + private static final ImmutableList VALUES = ImmutableList.of("1", "2"); + private static final ImmutableList NEXT_VALUES = ImmutableList.of("3", "4"); + private static final ImmutableList ALL_VALUES = + ImmutableList.builder().addAll(VALUES).addAll(NEXT_VALUES).build(); + + private static class TestPageFetcher implements PageImpl.NextPageFetcher { + private static final long serialVersionUID = -8316752901403429976L; + + private final PageImpl nextResult; + + TestPageFetcher(PageImpl nextResult) { + this.nextResult = nextResult; + } + + @Override + public Page getNextPage() { + return nextResult; + } + } + + @Test + public void testPage() { + final PageImpl nextResult = new PageImpl<>(null, "c", NEXT_VALUES); + PageImpl.NextPageFetcher fetcher = new TestPageFetcher(nextResult); + PageImpl result = new PageImpl<>(fetcher, "c", VALUES); + assertEquals(nextResult, result.getNextPage()); + assertEquals("c", result.getNextPageToken()); + assertEquals(VALUES, result.getValues()); + } + + @Test + public void testIterateAll() { + final PageImpl nextResult = new PageImpl<>(null, "c", NEXT_VALUES); + PageImpl.NextPageFetcher fetcher = new TestPageFetcher(nextResult); + PageImpl result = new PageImpl<>(fetcher, "c", VALUES); + assertEquals(ALL_VALUES, ImmutableList.copyOf(result.iterateAll())); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/PolicyTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/PolicyTest.java new file mode 100644 index 000000000000..98695c2a4c56 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/PolicyTest.java @@ -0,0 +1,228 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.Policy.DefaultMarshaller; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.junit.Test; + +public class PolicyTest { + + private static final Identity ALL_USERS = Identity.allUsers(); + private static final Identity ALL_AUTH_USERS = Identity.allAuthenticatedUsers(); + private static final Identity USER = Identity.user("abc@gmail.com"); + private static final Identity SERVICE_ACCOUNT = + Identity.serviceAccount("service-account@gmail.com"); + private static final Identity GROUP = Identity.group("group@gmail.com"); + private static final Identity DOMAIN = Identity.domain("google.com"); + private static final Role VIEWER = Role.viewer(); + private static final Role EDITOR = Role.editor(); + private static final Role OWNER = Role.owner(); + private static final Map> BINDINGS = + ImmutableMap.of( + VIEWER, + ImmutableSet.of(USER, SERVICE_ACCOUNT, ALL_USERS), + EDITOR, + ImmutableSet.of(ALL_AUTH_USERS, GROUP, DOMAIN)); + private static final Policy SIMPLE_POLICY = + Policy.newBuilder() + .addIdentity(VIEWER, USER, SERVICE_ACCOUNT, ALL_USERS) + .addIdentity(EDITOR, ALL_AUTH_USERS, GROUP, DOMAIN) + .build(); + private static final Policy FULL_POLICY = + Policy.newBuilder() + .setBindings(SIMPLE_POLICY.getBindings()) + .setEtag("etag") + .setVersion(1) + .build(); + + @Test + public void testBuilder() { + assertEquals(BINDINGS, SIMPLE_POLICY.getBindings()); + assertEquals(null, SIMPLE_POLICY.getEtag()); + assertEquals(0, SIMPLE_POLICY.getVersion()); + assertEquals(BINDINGS, FULL_POLICY.getBindings()); + assertEquals("etag", FULL_POLICY.getEtag()); + assertEquals(1, FULL_POLICY.getVersion()); + Map> editorBinding = + ImmutableMap.>builder().put(EDITOR, BINDINGS.get(EDITOR)).build(); + Policy policy = FULL_POLICY.toBuilder().setBindings(editorBinding).build(); + assertEquals(editorBinding, policy.getBindings()); + assertEquals("etag", policy.getEtag()); + assertEquals(1, policy.getVersion()); + policy = SIMPLE_POLICY.toBuilder().removeRole(EDITOR).build(); + assertEquals(ImmutableMap.of(VIEWER, BINDINGS.get(VIEWER)), policy.getBindings()); + assertNull(policy.getEtag()); + assertEquals(0, policy.getVersion()); + policy = + policy + .toBuilder() + .removeIdentity(VIEWER, USER, ALL_USERS) + .addIdentity(VIEWER, DOMAIN, GROUP) + .build(); + assertEquals( + ImmutableMap.of(VIEWER, ImmutableSet.of(SERVICE_ACCOUNT, DOMAIN, GROUP)), + policy.getBindings()); + assertNull(policy.getEtag()); + assertEquals(0, policy.getVersion()); + policy = + Policy.newBuilder() + .removeIdentity(VIEWER, USER) + .addIdentity(OWNER, USER, SERVICE_ACCOUNT) + .addIdentity(EDITOR, GROUP) + .removeIdentity(EDITOR, GROUP) + .build(); + assertEquals( + ImmutableMap.of(OWNER, ImmutableSet.of(USER, SERVICE_ACCOUNT)), policy.getBindings()); + assertNull(policy.getEtag()); + assertEquals(0, policy.getVersion()); + } + + @Test + public void testPolicyOrderShouldNotMatter() { + Role role1 = Role.of("role1"); + Identity identity1 = Identity.user("user1@example.com"); + Role role2 = Role.of("role2"); + Identity identity2 = Identity.user("user2@example.com"); + Policy policy1 = + Policy.newBuilder().addIdentity(role1, identity1).addIdentity(role2, identity2).build(); + Policy policy2 = + Policy.newBuilder().addIdentity(role2, identity2).addIdentity(role1, identity1).build(); + assertEquals(policy1, policy2); + } + + @Test + public void testPolicyMultipleAddIdentitiesShouldNotMatter() { + Role role1 = Role.of("role1"); + Identity identity1 = Identity.user("user1@example.com"); + Role role2 = Role.of("role2"); + Identity identity2 = Identity.user("user2@example.com"); + Policy policy1 = + Policy.newBuilder() + .addIdentity(role1, identity1) + .addIdentity(role2, identity2) + .addIdentity(role2, identity2) + .build(); + Policy policy2 = + Policy.newBuilder().addIdentity(role2, identity2).addIdentity(role1, identity1).build(); + assertEquals(policy1, policy2); + } + + @Test + public void testIllegalPolicies() { + try { + Policy.newBuilder().addIdentity(null, USER); + fail("Null role should cause exception."); + } catch (NullPointerException ex) { + assertEquals("The role cannot be null.", ex.getMessage()); + } + try { + Policy.newBuilder().addIdentity(VIEWER, null, USER); + fail("Null identity should cause exception."); + } catch (NullPointerException ex) { + assertEquals("Null identities are not permitted.", ex.getMessage()); + } + try { + Policy.newBuilder().addIdentity(VIEWER, USER, (Identity[]) null); + fail("Null identity should cause exception."); + } catch (NullPointerException ex) { + assertEquals("Null identities are not permitted.", ex.getMessage()); + } + try { + Policy.newBuilder().setBindings((Map>) null); + fail("Null bindings map should cause exception."); + } catch (NullPointerException ex) { + assertEquals("The provided map of bindings cannot be null.", ex.getMessage()); + } + try { + Map> bindings = new HashMap<>(); + bindings.put(VIEWER, null); + Policy.newBuilder().setBindings(bindings); + fail("Null set of identities should cause exception."); + } catch (NullPointerException ex) { + assertEquals("A role cannot be assigned to a null set of identities.", ex.getMessage()); + } + try { + Map> bindings = new HashMap<>(); + Set identities = new HashSet<>(); + identities.add(null); + bindings.put(VIEWER, identities); + Policy.newBuilder().setBindings(bindings); + fail("Null identity should cause exception."); + } catch (IllegalArgumentException ex) { + assertEquals("Null identities are not permitted.", ex.getMessage()); + } + } + + @Test + public void testEqualsHashCode() { + assertNotNull(FULL_POLICY); + Policy emptyPolicy = Policy.newBuilder().build(); + Policy anotherPolicy = Policy.newBuilder().build(); + assertEquals(emptyPolicy, anotherPolicy); + assertEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode()); + assertNotEquals(FULL_POLICY, SIMPLE_POLICY); + assertNotEquals(FULL_POLICY.hashCode(), SIMPLE_POLICY.hashCode()); + Policy copy = SIMPLE_POLICY.toBuilder().build(); + assertEquals(SIMPLE_POLICY, copy); + assertEquals(SIMPLE_POLICY.hashCode(), copy.hashCode()); + } + + @Test + public void testBindings() { + assertTrue(Policy.newBuilder().build().getBindings().isEmpty()); + assertEquals(BINDINGS, SIMPLE_POLICY.getBindings()); + } + + @Test + public void testEtag() { + assertNull(SIMPLE_POLICY.getEtag()); + assertEquals("etag", FULL_POLICY.getEtag()); + } + + @Test + public void testVersion() { + assertEquals(0, SIMPLE_POLICY.getVersion()); + assertEquals(1, FULL_POLICY.getVersion()); + } + + @Test + public void testDefaultMarshaller() { + DefaultMarshaller marshaller = new DefaultMarshaller(); + Policy emptyPolicy = Policy.newBuilder().build(); + assertEquals(emptyPolicy, marshaller.fromPb(marshaller.toPb(emptyPolicy))); + assertEquals(SIMPLE_POLICY, marshaller.fromPb(marshaller.toPb(SIMPLE_POLICY))); + assertEquals(FULL_POLICY, marshaller.fromPb(marshaller.toPb(FULL_POLICY))); + com.google.iam.v1.Policy policyPb = com.google.iam.v1.Policy.getDefaultInstance(); + Policy policy = marshaller.fromPb(policyPb); + assertTrue(policy.getBindings().isEmpty()); + assertNull(policy.getEtag()); + assertEquals(0, policy.getVersion()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/PolicyV3Test.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/PolicyV3Test.java new file mode 100644 index 000000000000..bdddf656f48a --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/PolicyV3Test.java @@ -0,0 +1,281 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.Policy.DefaultMarshaller; +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import org.junit.Test; + +public class PolicyV3Test { + + private static final String ALL_USERS = "allUsers"; + private static final String ALL_AUTH_USERS = "allAuthenticatedUsers"; + private static final String USER = "user:abc@gmail.com"; + private static final String SERVICE_ACCOUNT = "serviceAccount:service-account@gmail.com"; + private static final String GROUP = "group:group@gmail.com"; + private static final String DOMAIN = "domain:google.com"; + private static final String VIEWER = "roles/viewer"; + private static final String EDITOR = "roles/editor"; + private static final String OWNER = "roles/owner"; + private static final ImmutableList MEMBERS_LIST_1 = + ImmutableList.of(USER, SERVICE_ACCOUNT, ALL_USERS); + private static final ImmutableList MEMBERS_LIST_2 = + ImmutableList.of(ALL_AUTH_USERS, GROUP, DOMAIN); + + private static final Binding VIEWER_BINDING = + Binding.newBuilder().setRole(VIEWER).setMembers(MEMBERS_LIST_1).build(); + private static final Binding EDITOR_BINDING = + Binding.newBuilder().setRole(EDITOR).setMembers(MEMBERS_LIST_2).build(); + private static final ImmutableList BINDINGS_NO_CONDITIONS = + ImmutableList.of(VIEWER_BINDING, EDITOR_BINDING); + private static final Condition CONDITION = + Condition.newBuilder() + .setTitle("Condition") + .setDescription("Condition") + .setExpression("Expr") + .build(); + private static final ImmutableList BINDINGS_WITH_CONDITIONS = + ImmutableList.of(VIEWER_BINDING.toBuilder().setCondition(CONDITION).build(), EDITOR_BINDING); + private static final Policy FULL_POLICY_V1 = + Policy.newBuilder().setBindings(BINDINGS_NO_CONDITIONS).setEtag("etag").setVersion(1).build(); + + private static final Policy FULL_POLICY_V3 = + Policy.newBuilder() + .setBindings(BINDINGS_WITH_CONDITIONS) + .setEtag("etag") + .setVersion(3) + .build(); + + private static final Policy FULL_POLICY_V3_WITH_VERSION_1 = + Policy.newBuilder() + .setBindings(BINDINGS_WITH_CONDITIONS) + .setEtag("etag") + .setVersion(1) + .build(); + + @Test + public void testBuilderV1() { + assertEquals(BINDINGS_NO_CONDITIONS, FULL_POLICY_V1.getBindingsList()); + assertEquals(1, FULL_POLICY_V1.getVersion()); + assertEquals("etag", FULL_POLICY_V1.getEtag()); + Policy policy = FULL_POLICY_V1.toBuilder().setBindings(BINDINGS_NO_CONDITIONS).build(); + assertEquals(BINDINGS_NO_CONDITIONS, policy.getBindingsList()); + assertEquals("etag", policy.getEtag()); + assertEquals(1, policy.getVersion()); + } + + @Test + public void testBuilderV3WithConditions() { + assertEquals(BINDINGS_WITH_CONDITIONS, FULL_POLICY_V3.getBindingsList()); + assertEquals(3, FULL_POLICY_V3.getVersion()); + assertEquals("etag", FULL_POLICY_V3.getEtag()); + Policy policy = FULL_POLICY_V3.toBuilder().setBindings(BINDINGS_WITH_CONDITIONS).build(); + assertEquals(BINDINGS_WITH_CONDITIONS, policy.getBindingsList()); + assertEquals("etag", policy.getEtag()); + assertEquals(3, policy.getVersion()); + } + + @Test + public void testBuilderV1ToV3Compatability() { + assertEquals(BINDINGS_WITH_CONDITIONS, FULL_POLICY_V3_WITH_VERSION_1.getBindingsList()); + assertEquals(1, FULL_POLICY_V3_WITH_VERSION_1.getVersion()); + assertEquals("etag", FULL_POLICY_V3_WITH_VERSION_1.getEtag()); + Policy policy = + FULL_POLICY_V3_WITH_VERSION_1 + .toBuilder() + .setBindings(BINDINGS_WITH_CONDITIONS) + .setVersion(3) + .build(); + assertEquals(BINDINGS_WITH_CONDITIONS, policy.getBindingsList()); + assertEquals("etag", policy.getEtag()); + assertEquals(3, policy.getVersion()); + } + + @Test + public void removeMemberFromPolicy() { + assertEquals(3, FULL_POLICY_V3.getBindingsList().get(0).getMembers().size()); + List bindings = new ArrayList<>(FULL_POLICY_V3.getBindingsList()); + + for (int i = 0; i < bindings.size(); i++) { + Binding binding = bindings.get(i); + if (binding.getRole().equals(VIEWER)) { + bindings.set(i, binding.toBuilder().removeMembers(ALL_USERS).build()); + break; + } + } + + Policy updatedPolicy = FULL_POLICY_V3.toBuilder().setBindings(bindings).build(); + assertEquals(2, updatedPolicy.getBindingsList().get(0).getMembers().size()); + } + + @Test + public void addMemberFromPolicy() { + assertEquals(3, FULL_POLICY_V3.getBindingsList().get(0).getMembers().size()); + List bindings = new ArrayList<>(FULL_POLICY_V3.getBindingsList()); + + for (int i = 0; i < bindings.size(); i++) { + Binding binding = bindings.get(i); + if (binding.getRole().equals(VIEWER)) { + bindings.set(i, binding.toBuilder().addMembers("user:example@example.com").build()); + } + } + + Policy updatedPolicy = FULL_POLICY_V3.toBuilder().setBindings(bindings).build(); + assertEquals(4, updatedPolicy.getBindingsList().get(0).getMembers().size()); + } + + @Test + public void removeBindingFromPolicy() { + assertEquals(2, FULL_POLICY_V3.getBindingsList().size()); + List bindings = new ArrayList<>(FULL_POLICY_V3.getBindingsList()); + + Iterator iterator = bindings.iterator(); + while (iterator.hasNext()) { + Binding binding = (Binding) iterator.next(); + if (binding.getRole().equals(EDITOR) && binding.getCondition() == null) { + iterator.remove(); + break; + } + } + + Policy updatedPolicy = FULL_POLICY_V3.toBuilder().setBindings(bindings).build(); + assertEquals(1, updatedPolicy.getBindingsList().size()); + } + + @Test + public void addBindingToPolicy() { + assertEquals(2, FULL_POLICY_V3.getBindingsList().size()); + List bindings = new ArrayList<>(FULL_POLICY_V3.getBindingsList()); + bindings.add(Binding.newBuilder().setRole(OWNER).setMembers(ImmutableList.of(USER)).build()); + Policy updatedPolicy = FULL_POLICY_V3.toBuilder().setBindings(bindings).build(); + assertEquals(3, updatedPolicy.getBindingsList().size()); + } + + @Test + public void testIllegalPolicies() { + try { + Binding.newBuilder().setRole(null).build(); + fail("Null role should cause exception."); + } catch (NullPointerException ex) { + assertEquals("Null role", ex.getMessage()); + } + try { + FULL_POLICY_V3 + .toBuilder() + .setBindings( + Arrays.asList( + Binding.newBuilder() + .setRole("test") + .setMembers(Arrays.asList(null, "user")) + .build())) + .build(); + fail("Null member should cause exception."); + } catch (NullPointerException ex) { + assertEquals("at index 0", ex.getMessage()); + } + try { + FULL_POLICY_V3.getBindings(); + fail("getBindings() should cause exception with Policy V3."); + } catch (IllegalArgumentException ex) { + assertEquals( + "getBindings() is only supported with version 1 policies and non-conditional policies", + ex.getMessage()); + } + try { + FULL_POLICY_V3.toBuilder().addIdentity(Role.editor(), Identity.allUsers()); + fail("getBindings() should cause exception with Policy V3."); + } catch (IllegalArgumentException ex) { + assertEquals( + "addIdentity() is only supported with version 1 policies and non-conditional policies", + ex.getMessage()); + } + try { + FULL_POLICY_V3.toBuilder().removeIdentity(Role.editor(), Identity.allUsers()); + fail("getBindings() should cause exception with Policy V3."); + } catch (IllegalArgumentException ex) { + assertEquals( + "removeIdentity() is only supported with version 1 policies and non-conditional policies", + ex.getMessage()); + } + try { + FULL_POLICY_V3.toBuilder().setBindings(FULL_POLICY_V1.getBindings()); + fail("getBindings() should cause exception with Policy V3."); + } catch (IllegalArgumentException ex) { + assertEquals( + "setBindings() is only supported with version 1 policies and non-conditional policies", + ex.getMessage()); + } + } + + @Test + public void testEqualsHashCode() { + assertNotNull(FULL_POLICY_V3); + Policy emptyPolicy = Policy.newBuilder().build(); + Policy anotherPolicy = Policy.newBuilder().build(); + assertEquals(emptyPolicy, anotherPolicy); + assertEquals(emptyPolicy.hashCode(), anotherPolicy.hashCode()); + assertNotEquals(FULL_POLICY_V3, FULL_POLICY_V1); + assertNotEquals(FULL_POLICY_V3.hashCode(), FULL_POLICY_V1.hashCode()); + Policy copy = FULL_POLICY_V1.toBuilder().build(); + assertEquals(FULL_POLICY_V1, copy); + assertEquals(FULL_POLICY_V1.hashCode(), copy.hashCode()); + } + + @Test + public void testBindings() { + assertTrue(Policy.newBuilder().build().getBindingsList().isEmpty()); + assertEquals(BINDINGS_WITH_CONDITIONS, FULL_POLICY_V3.getBindingsList()); + } + + @Test + public void testEtag() { + assertNotNull(FULL_POLICY_V3.getEtag()); + assertEquals("etag", FULL_POLICY_V3.getEtag()); + } + + @Test + public void testVersion() { + assertEquals(1, FULL_POLICY_V1.getVersion()); + assertEquals(3, FULL_POLICY_V3.getVersion()); + assertEquals(1, FULL_POLICY_V3_WITH_VERSION_1.getVersion()); + } + + @Test + public void testDefaultMarshaller() { + DefaultMarshaller marshaller = new DefaultMarshaller(); + Policy emptyPolicy = Policy.newBuilder().build(); + assertEquals(emptyPolicy, marshaller.fromPb(marshaller.toPb(emptyPolicy))); + assertEquals(FULL_POLICY_V3, marshaller.fromPb(marshaller.toPb(FULL_POLICY_V3))); + assertEquals(FULL_POLICY_V1, marshaller.fromPb(marshaller.toPb(FULL_POLICY_V1))); + com.google.iam.v1.Policy policyPb = com.google.iam.v1.Policy.getDefaultInstance(); + Policy policy = marshaller.fromPb(policyPb); + assertTrue(policy.getBindingsList().isEmpty()); + assertNull(policy.getEtag()); + assertEquals(0, policy.getVersion()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/RetryOptionTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/RetryOptionTest.java new file mode 100644 index 000000000000..ebea89f2fc04 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/RetryOptionTest.java @@ -0,0 +1,130 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import com.google.api.gax.retrying.RetrySettings; +import org.junit.Test; +import org.threeten.bp.Duration; + +public class RetryOptionTest { + + private static final RetryOption TOTAL_TIMEOUT = + RetryOption.totalTimeout(Duration.ofMillis(420L)); + private static final RetryOption INITIAL_RETRY_DELAY = + RetryOption.initialRetryDelay(Duration.ofMillis(42L)); + private static final RetryOption RETRY_DELAY_MULTIPLIER = RetryOption.retryDelayMultiplier(1.5); + private static final RetryOption MAX_RETRY_DELAY = + RetryOption.maxRetryDelay(Duration.ofMillis(100)); + private static final RetryOption MAX_ATTEMPTS = RetryOption.maxAttempts(100); + private static final RetryOption JITTERED = RetryOption.jittered(false); + + private static final RetrySettings retrySettings = + RetrySettings.newBuilder() + .setTotalTimeout(Duration.ofMillis(420L)) + .setInitialRetryDelay(Duration.ofMillis(42L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(100)) + .setMaxAttempts(100) + .setJittered(false) + .build(); + + @Test + public void testEqualsAndHashCode() { + assertEquals(TOTAL_TIMEOUT, TOTAL_TIMEOUT); + assertEquals(INITIAL_RETRY_DELAY, INITIAL_RETRY_DELAY); + assertEquals(RETRY_DELAY_MULTIPLIER, RETRY_DELAY_MULTIPLIER); + assertEquals(MAX_RETRY_DELAY, MAX_RETRY_DELAY); + assertEquals(MAX_ATTEMPTS, MAX_ATTEMPTS); + assertEquals(JITTERED, JITTERED); + + assertNotEquals(TOTAL_TIMEOUT, JITTERED); + assertNotEquals(INITIAL_RETRY_DELAY, TOTAL_TIMEOUT); + assertNotEquals(RETRY_DELAY_MULTIPLIER, INITIAL_RETRY_DELAY); + assertNotEquals(MAX_RETRY_DELAY, RETRY_DELAY_MULTIPLIER); + assertNotEquals(MAX_ATTEMPTS, MAX_RETRY_DELAY); + assertNotEquals(JITTERED, MAX_ATTEMPTS); + + RetryOption totalTimeout = RetryOption.totalTimeout(Duration.ofMillis(420L)); + RetryOption initialRetryDelay = RetryOption.initialRetryDelay(Duration.ofMillis(42L)); + RetryOption retryDelayMultiplier = RetryOption.retryDelayMultiplier(1.5); + RetryOption maxRetryDelay = RetryOption.maxRetryDelay(Duration.ofMillis(100)); + RetryOption maxAttempts = RetryOption.maxAttempts(100); + RetryOption jittered = RetryOption.jittered(false); + + assertEquals(TOTAL_TIMEOUT, totalTimeout); + assertEquals(INITIAL_RETRY_DELAY, initialRetryDelay); + assertEquals(RETRY_DELAY_MULTIPLIER, retryDelayMultiplier); + assertEquals(MAX_RETRY_DELAY, maxRetryDelay); + assertEquals(MAX_ATTEMPTS, maxAttempts); + assertEquals(JITTERED, jittered); + + assertEquals(TOTAL_TIMEOUT.hashCode(), totalTimeout.hashCode()); + assertEquals(INITIAL_RETRY_DELAY.hashCode(), initialRetryDelay.hashCode()); + assertEquals(RETRY_DELAY_MULTIPLIER.hashCode(), retryDelayMultiplier.hashCode()); + assertEquals(MAX_RETRY_DELAY.hashCode(), maxRetryDelay.hashCode()); + assertEquals(MAX_ATTEMPTS.hashCode(), maxAttempts.hashCode()); + assertEquals(JITTERED.hashCode(), jittered.hashCode()); + } + + @Test + public void testMergeToSettings() { + RetrySettings defRetrySettings = RetrySettings.newBuilder().build(); + + assertEquals(defRetrySettings, RetryOption.mergeToSettings(defRetrySettings)); + + RetrySettings mergedRetrySettings = + RetryOption.mergeToSettings( + defRetrySettings, + TOTAL_TIMEOUT, + INITIAL_RETRY_DELAY, + RETRY_DELAY_MULTIPLIER, + MAX_RETRY_DELAY, + MAX_ATTEMPTS, + JITTERED); + assertEquals(retrySettings, mergedRetrySettings); + + defRetrySettings = + defRetrySettings.toBuilder().setTotalTimeout(Duration.ofMillis(420L)).build(); + mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, TOTAL_TIMEOUT); + assertEquals(defRetrySettings, mergedRetrySettings); + + defRetrySettings = + defRetrySettings.toBuilder().setMaxRetryDelay(Duration.ofMillis(100)).build(); + mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, MAX_RETRY_DELAY); + assertEquals(defRetrySettings, mergedRetrySettings); + + defRetrySettings = + defRetrySettings.toBuilder().setInitialRetryDelay(Duration.ofMillis(42L)).build(); + mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, INITIAL_RETRY_DELAY); + assertEquals(defRetrySettings, mergedRetrySettings); + + defRetrySettings = defRetrySettings.toBuilder().setRetryDelayMultiplier(1.5).build(); + mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, RETRY_DELAY_MULTIPLIER); + assertEquals(defRetrySettings, mergedRetrySettings); + + defRetrySettings = defRetrySettings.toBuilder().setMaxAttempts(100).build(); + mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, MAX_ATTEMPTS); + assertEquals(defRetrySettings, mergedRetrySettings); + + defRetrySettings = defRetrySettings.toBuilder().setJittered(false).build(); + mergedRetrySettings = RetryOption.mergeToSettings(defRetrySettings, JITTERED); + assertEquals(defRetrySettings, mergedRetrySettings); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/RoleTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/RoleTest.java new file mode 100644 index 000000000000..d6fcdf844176 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/RoleTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; + +public class RoleTest { + + private static final Role VIEWER = Role.of("viewer"); + private static final Role EDITOR = Role.of("editor"); + private static final Role OWNER = Role.of("owner"); + + @Test + public void testOf() { + assertThat(VIEWER.getValue()).isEqualTo("roles/viewer"); + assertThat(EDITOR.getValue()).isEqualTo("roles/editor"); + assertThat(OWNER.getValue()).isEqualTo("roles/owner"); + compareRoles(VIEWER, Role.of("roles/viewer")); + compareRoles(EDITOR, Role.of("roles/editor")); + compareRoles(OWNER, Role.of("roles/owner")); + + String customRole = "projects/foo/roles/bar"; + assertThat(Role.of(customRole).getValue()).isEqualTo(customRole); + } + + @Test + public void testViewer() { + assertThat(Role.viewer().getValue()).isEqualTo("roles/viewer"); + } + + @Test + public void testEditor() { + assertThat(Role.editor().getValue()).isEqualTo("roles/editor"); + } + + @Test + public void testOwner() { + assertThat(Role.owner().getValue()).isEqualTo("roles/owner"); + } + + @Test(expected = NullPointerException.class) + public void testOfNullValue() { + Role.of(null); + } + + private void compareRoles(Role expected, Role actual) { + assertThat(actual).isEqualTo(expected); + assertThat(actual.getValue()).isEqualTo(expected.getValue()); + assertThat(actual.hashCode()).isEqualTo(expected.hashCode()); + assertThat(actual.toString()).isEqualTo(expected.toString()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/SerializationTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/SerializationTest.java new file mode 100644 index 000000000000..6c35c665b511 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/SerializationTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import com.google.api.gax.retrying.RetrySettings; +import com.google.cloud.BaseServiceException.ExceptionData; +import com.google.cloud.MonitoredResourceDescriptor.LabelDescriptor; +import com.google.cloud.MonitoredResourceDescriptor.LabelDescriptor.ValueType; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import java.io.Serializable; +import org.threeten.bp.Duration; + +public class SerializationTest extends BaseSerializationTest { + + private static final BaseServiceException BASE_SERVICE_EXCEPTION = + new BaseServiceException(ExceptionData.from(42, "message", "reason", false)); + private static final ExceptionHandler EXCEPTION_HANDLER = ExceptionHandler.getDefaultInstance(); + private static final Identity IDENTITY = Identity.allAuthenticatedUsers(); + private static final PageImpl PAGE = + new PageImpl<>(null, "cursor", ImmutableList.of("string1", "string2")); + private static final RetrySettings RETRY_SETTINGS = ServiceOptions.getDefaultRetrySettings(); + private static final Role SOME_ROLE = Role.viewer(); + private static final Policy SOME_IAM_POLICY = Policy.newBuilder().build(); + private static final RetryOption CHECKING_PERIOD = + RetryOption.initialRetryDelay(Duration.ofSeconds(42)); + private static final LabelDescriptor LABEL_DESCRIPTOR = + new LabelDescriptor("project_id", ValueType.STRING, "The project id"); + private static final MonitoredResourceDescriptor MONITORED_RESOURCE_DESCRIPTOR = + MonitoredResourceDescriptor.newBuilder("global") + .setLabels(ImmutableList.of(LABEL_DESCRIPTOR)) + .build(); + private static final MonitoredResource MONITORED_RESOURCE = + MonitoredResource.newBuilder("global") + .setLabels(ImmutableMap.of("project_id", "project")) + .build(); + private static final String JSON_KEY = + "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\"\n" + + "}"; + + @Override + protected Serializable[] serializableObjects() { + return new Serializable[] { + BASE_SERVICE_EXCEPTION, + EXCEPTION_HANDLER, + IDENTITY, + PAGE, + RETRY_SETTINGS, + SOME_ROLE, + SOME_IAM_POLICY, + CHECKING_PERIOD, + LABEL_DESCRIPTOR, + MONITORED_RESOURCE_DESCRIPTOR, + MONITORED_RESOURCE + }; + } + + @Override + protected Restorable[] restorableObjects() { + return null; + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java new file mode 100644 index 000000000000..bf75fca161fd --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java @@ -0,0 +1,496 @@ +/* + * Copyright 2015 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.truth.Truth.assertThat; +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpResponse; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.LowLevelHttpRequest; +import com.google.api.client.http.LowLevelHttpResponse; +import com.google.api.client.testing.http.HttpTesting; +import com.google.api.client.testing.http.MockHttpTransport; +import com.google.api.client.testing.http.MockLowLevelHttpRequest; +import com.google.api.client.testing.http.MockLowLevelHttpResponse; +import com.google.api.core.ApiClock; +import com.google.api.core.CurrentMillisClock; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.cloud.spi.ServiceRpcFactory; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import com.google.common.io.Files; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import org.junit.Test; + +public class ServiceOptionsTest { + private static GoogleCredentials credentials; + private static GoogleCredentials credentialsWithProjectId; + private static GoogleCredentials credentialsWithQuotaProject; + + private static final String JSON_KEY = + "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\"\n" + + "}"; + + private static final String JSON_KEY_PROJECT_ID = + "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"project_id\": \"someprojectid\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\"\n" + + "}"; + + private static final String JSON_KEY_QUOTA_PROJECT_ID = + "{\n" + + " \"private_key_id\": \"somekeyid\",\n" + + " \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggS" + + "kAgEAAoIBAQC+K2hSuFpAdrJI\\nnCgcDz2M7t7bjdlsadsasad+fvRSW6TjNQZ3p5LLQY1kSZRqBqylRkzteMOyHg" + + "aR\\n0Pmxh3ILCND5men43j3h4eDbrhQBuxfEMalkG92sL+PNQSETY2tnvXryOvmBRwa/\\nQP/9dJfIkIDJ9Fw9N4" + + "Bhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nknddadwkwewcVxHFhcZJO+XWf6ofLUXpRwiTZakGMn8EE1uVa2" + + "LgczOjwWHGi99MFjxSer5m9\\n1tCa3/KEGKiS/YL71JvjwX3mb+cewlkcmweBKZHM2JPTk0ZednFSpVZMtycjkbLa" + + "\\ndYOS8V85AgMBewECggEBAKksaldajfDZDV6nGqbFjMiizAKJolr/M3OQw16K6o3/\\n0S31xIe3sSlgW0+UbYlF" + + "4U8KifhManD1apVSC3csafaspP4RZUHFhtBywLO9pR5c\\nr6S5aLp+gPWFyIp1pfXbWGvc5VY/v9x7ya1VEa6rXvL" + + "sKupSeWAW4tMj3eo/64ge\\nsdaceaLYw52KeBYiT6+vpsnYrEkAHO1fF/LavbLLOFJmFTMxmsNaG0tuiJHgjshB\\" + + "n82DpMCbXG9YcCgI/DbzuIjsdj2JC1cascSP//3PmefWysucBQe7Jryb6NQtASmnv\\nCdDw/0jmZTEjpe4S1lxfHp" + + "lAhHFtdgYTvyYtaLZiVVkCgYEA8eVpof2rceecw/I6\\n5ng1q3Hl2usdWV/4mZMvR0fOemacLLfocX6IYxT1zA1FF" + + "JlbXSRsJMf/Qq39mOR2\\nSpW+hr4jCoHeRVYLgsbggtrevGmILAlNoqCMpGZ6vDmJpq6ECV9olliDvpPgWOP+\\nm" + + "YPDreFBGxWvQrADNbRt2dmGsrsCgYEAyUHqB2wvJHFqdmeBsaacewzV8x9WgmeX\\ngUIi9REwXlGDW0Mz50dxpxcK" + + "CAYn65+7TCnY5O/jmL0VRxU1J2mSWyWTo1C+17L0\\n3fUqjxL1pkefwecxwecvC+gFFYdJ4CQ/MHHXU81Lwl1iWdF" + + "Cd2UoGddYaOF+KNeM\\nHC7cmqra+JsCgYEAlUNywzq8nUg7282E+uICfCB0LfwejuymR93CtsFgb7cRd6ak\\nECR" + + "8FGfCpH8ruWJINllbQfcHVCX47ndLZwqv3oVFKh6pAS/vVI4dpOepP8++7y1u\\ncoOvtreXCX6XqfrWDtKIvv0vjl" + + "HBhhhp6mCcRpdQjV38H7JsyJ7lih/oNjECgYAt\\nkndj5uNl5SiuVxHFhcZJO+XWf6ofLUregtevZakGMn8EE1uVa" + + "2AY7eafmoU/nZPT\\n00YB0TBATdCbn/nBSuKDESkhSg9s2GEKQZG5hBmL5uCMfo09z3SfxZIhJdlerreP\\nJ7gSi" + + "dI12N+EZxYd4xIJh/HFDgp7RRO87f+WJkofMQKBgGTnClK1VMaCRbJZPriw\\nEfeFCoOX75MxKwXs6xgrw4W//AYG" + + "GUjDt83lD6AZP6tws7gJ2IwY/qP7+lyhjEqN\\nHtfPZRGFkGZsdaksdlaksd323423d+15/UvrlRSFPNj1tWQmNKk" + + "XyRDW4IG1Oa2p\\nrALStNBx5Y9t0/LQnFI4w3aG\\n-----END PRIVATE KEY-----\\n\",\n" + + " \"project_id\": \"someprojectid\",\n" + + " \"client_email\": \"someclientid@developer.gserviceaccount.com\",\n" + + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + + " \"type\": \"service_account\",\n" + + " \"quota_project_id\": \"some-quota-project-id\"\n" + + "}"; + + static { + credentials = loadCredentials(JSON_KEY); + credentialsWithProjectId = loadCredentials(JSON_KEY_PROJECT_ID); + credentialsWithQuotaProject = loadCredentials(JSON_KEY_QUOTA_PROJECT_ID); + } + + static GoogleCredentials loadCredentials(String credentialFile) { + try { + InputStream keyStream = new ByteArrayInputStream(credentialFile.getBytes()); + return GoogleCredentials.fromStream(keyStream); + } catch (IOException e) { + fail("Couldn't create fake JSON credentials."); + } + return null; + } + + private static final ApiClock TEST_CLOCK = new TestClock(); + private static final TestServiceOptions OPTIONS = + TestServiceOptions.newBuilder() + .setCredentials(credentials) + .setClock(TEST_CLOCK) + .setHost("host") + .setProjectId("project-id") + .setRetrySettings(ServiceOptions.getNoRetrySettings()) + .setQuotaProjectId("quota-project-id") + .build(); + private static final TestServiceOptions OPTIONS_NO_CREDENTIALS = + TestServiceOptions.newBuilder() + .setCredentials(NoCredentials.getInstance()) + .setClock(TEST_CLOCK) + .setHost("host") + .setProjectId("project-id") + .setRetrySettings(ServiceOptions.getNoRetrySettings()) + .setQuotaProjectId("quota-project-id") + .build(); + private static final TestServiceOptions DEFAULT_OPTIONS = + TestServiceOptions.newBuilder().setProjectId("project-id").build(); + private static final TestServiceOptions OPTIONS_COPY = OPTIONS.toBuilder().build(); + private static final String LIBRARY_NAME = "gcloud-java"; + private static final Pattern APPLICATION_NAME_PATTERN = Pattern.compile(LIBRARY_NAME + "/.*"); + + private static class TestClock implements ApiClock { + @Override + public long nanoTime() { + return 123_456_789_000_000L; + } + + @Override + public long millisTime() { + return 123_456_789L; + } + } + + interface TestService extends Service {} + + private static class TestServiceImpl extends BaseService + implements TestService { + private TestServiceImpl(TestServiceOptions options) { + super(options); + } + } + + public interface TestServiceFactory extends ServiceFactory {} + + private static class DefaultTestServiceFactory implements TestServiceFactory { + private static final TestServiceFactory INSTANCE = new DefaultTestServiceFactory(); + + @Override + public TestService create(TestServiceOptions options) { + return new TestServiceImpl(options); + } + } + + public interface TestServiceRpcFactory extends ServiceRpcFactory {} + + private static class DefaultTestServiceRpcFactory implements TestServiceRpcFactory { + private static final TestServiceRpcFactory INSTANCE = new DefaultTestServiceRpcFactory(); + + @Override + public TestServiceRpc create(TestServiceOptions options) { + return new DefaultTestServiceRpc(options); + } + } + + private interface TestServiceRpc extends ServiceRpc {} + + private static class DefaultTestServiceRpc implements TestServiceRpc { + DefaultTestServiceRpc(TestServiceOptions options) {} + } + + static class TestServiceOptions extends ServiceOptions { + private static class Builder + extends ServiceOptions.Builder { + private Builder() {} + + private Builder(TestServiceOptions options) { + super(options); + } + + @Override + protected TestServiceOptions build() { + return new TestServiceOptions(this); + } + } + + private TestServiceOptions(Builder builder) { + super( + TestServiceFactory.class, + TestServiceRpcFactory.class, + builder, + new TestServiceDefaults()); + } + + private static class TestServiceDefaults + implements ServiceDefaults { + + @Override + public TestServiceFactory getDefaultServiceFactory() { + return DefaultTestServiceFactory.INSTANCE; + } + + @Override + public TestServiceRpcFactory getDefaultRpcFactory() { + return DefaultTestServiceRpcFactory.INSTANCE; + } + + @Override + public TransportOptions getDefaultTransportOptions() { + return new TransportOptions() {}; + } + } + + @Override + protected Set getScopes() { + return null; + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } + + private static Builder newBuilder() { + return new Builder(); + } + + @Override + public boolean equals(Object obj) { + return obj instanceof TestServiceOptions && baseEquals((TestServiceOptions) obj); + } + + @Override + public int hashCode() { + return baseHashCode(); + } + } + + @Test + public void testBuilder() { + assertSame(credentials, OPTIONS.getCredentials()); + assertSame(TEST_CLOCK, OPTIONS.getClock()); + assertEquals("host", OPTIONS.getHost()); + assertEquals("project-id", OPTIONS.getProjectId()); + assertSame(ServiceOptions.getNoRetrySettings(), OPTIONS.getRetrySettings()); + assertSame(CurrentMillisClock.getDefaultClock(), DEFAULT_OPTIONS.getClock()); + assertEquals("https://www.googleapis.com", DEFAULT_OPTIONS.getHost()); + assertSame(ServiceOptions.getDefaultRetrySettings(), DEFAULT_OPTIONS.getRetrySettings()); + } + + @Test + public void testBuilder_quotaProjectServiceOptionTakesPrecedence() { + TestServiceOptions noCredsWithQuotaProject = + TestServiceOptions.newBuilder() + .setCredentials(NoCredentials.getInstance()) + .setProjectId("project-id") + .setQuotaProjectId("quota-project-id") + .build(); + TestServiceOptions quotaProjectCredsWithQuotaProject = + TestServiceOptions.newBuilder() + .setQuotaProjectId("quota-project-id") + .setCredentials(credentialsWithQuotaProject) + .build(); + TestServiceOptions quotaProjectCredsWithQuotaProject2 = + TestServiceOptions.newBuilder() + .setCredentials(credentialsWithQuotaProject) + .setQuotaProjectId("quota-project-id") + .build(); + TestServiceOptions quotaProjectCreds = + TestServiceOptions.newBuilder().setCredentials(credentialsWithQuotaProject).build(); + TestServiceOptions none = + TestServiceOptions.newBuilder() + .setCredentials(NoCredentials.getInstance()) + .setProjectId("project-id") + .build(); + + assertEquals("quota-project-id", noCredsWithQuotaProject.getQuotaProjectId()); + assertEquals("quota-project-id", quotaProjectCredsWithQuotaProject.getQuotaProjectId()); + assertEquals("quota-project-id", quotaProjectCredsWithQuotaProject2.getQuotaProjectId()); + assertEquals("some-quota-project-id", quotaProjectCreds.getQuotaProjectId()); + assertEquals(null, none.getQuotaProjectId()); + } + + @Test + public void testBuilderNoCredentials() { + assertEquals(NoCredentials.getInstance(), OPTIONS_NO_CREDENTIALS.getCredentials()); + assertTrue(NoCredentials.getInstance().equals(OPTIONS_NO_CREDENTIALS.getCredentials())); + assertFalse(NoCredentials.getInstance().equals(OPTIONS.getCredentials())); + assertFalse(NoCredentials.getInstance().equals(null)); + assertSame(TEST_CLOCK, OPTIONS_NO_CREDENTIALS.getClock()); + assertEquals("host", OPTIONS_NO_CREDENTIALS.getHost()); + assertEquals("project-id", OPTIONS_NO_CREDENTIALS.getProjectId()); + assertSame(ServiceOptions.getNoRetrySettings(), OPTIONS_NO_CREDENTIALS.getRetrySettings()); + assertEquals("quota-project-id", OPTIONS.getQuotaProjectId()); + } + + @Test(expected = NullPointerException.class) + public void testBuilderNullCredentials() { + TestServiceOptions.newBuilder().setCredentials(null).build(); + } + + @Test + public void testBuilderServiceAccount_setsProjectId() { + TestServiceOptions options = + TestServiceOptions.newBuilder().setCredentials(credentialsWithProjectId).build(); + assertEquals("someprojectid", options.getProjectId()); + } + + @Test + public void testBuilderServiceAccount_explicitSetProjectIdBefore() { + TestServiceOptions options = + TestServiceOptions.newBuilder() + .setProjectId("override-project-id") + .setCredentials(credentialsWithProjectId) + .build(); + assertEquals("override-project-id", options.getProjectId()); + } + + @Test + public void testBuilderServiceAccount_explicitSetProjectIdAfter() { + TestServiceOptions options = + TestServiceOptions.newBuilder() + .setCredentials(credentialsWithProjectId) + .setProjectId("override-project-id") + .build(); + assertEquals("override-project-id", options.getProjectId()); + } + + @Test + public void testGetProjectIdRequired() { + assertTrue(OPTIONS.projectIdRequired()); + } + + @Test + public void testService() { + assertTrue(OPTIONS.getService() instanceof TestServiceImpl); + } + + @Test + public void testRpc() { + assertTrue(OPTIONS.getRpc() instanceof DefaultTestServiceRpc); + } + + @Test + public void testBaseEquals() { + assertEquals(OPTIONS, OPTIONS_COPY); + assertNotEquals(DEFAULT_OPTIONS, OPTIONS); + } + + @Test + public void testLibraryName() { + assertEquals(LIBRARY_NAME, ServiceOptions.getLibraryName()); + } + + @Test + public void testApplicationName() { + assertTrue(APPLICATION_NAME_PATTERN.matcher(OPTIONS.getApplicationName()).matches()); + } + + @Test + public void testBaseHashCode() { + assertEquals(OPTIONS.hashCode(), OPTIONS_COPY.hashCode()); + assertNotEquals(DEFAULT_OPTIONS.hashCode(), OPTIONS.hashCode()); + } + + @Test + public void testGetServiceAccountProjectId() throws Exception { + File credentialsFile = File.createTempFile("credentials", ".json"); + credentialsFile.deleteOnExit(); + Files.write("{\"project_id\":\"my-project-id\"}".getBytes(), credentialsFile); + + assertEquals( + "my-project-id", + ServiceOptions.getValueFromCredentialsFile(credentialsFile.getPath(), "project_id")); + } + + @Test + public void testGetServiceAccountProjectId_badJson() throws Exception { + File credentialsFile = File.createTempFile("credentials", ".json"); + credentialsFile.deleteOnExit(); + Files.write("asdfghj".getBytes(StandardCharsets.UTF_8), credentialsFile); + + String valueFromCredentialsFile = + ServiceOptions.getValueFromCredentialsFile(credentialsFile.getPath(), "project_id"); + assertNull(valueFromCredentialsFile); + } + + @Test + public void testGetServiceAccountProjectId_nonExistentFile() throws Exception { + File credentialsFile = new File("/doesnotexist"); + + assertNull(ServiceOptions.getValueFromCredentialsFile(credentialsFile.getPath(), "project_id")); + } + + @Test + public void testResponseHeaderContainsMetaDataFlavor() throws Exception { + Multimap headers = ArrayListMultimap.create(); + headers.put("Metadata-Flavor", "Google"); + HttpResponse httpResponse = createHttpResponseWithHeader(headers); + assertThat(ServiceOptions.headerContainsMetadataFlavor(httpResponse)).isTrue(); + } + + @Test + public void testResponseHeaderDoesNotContainMetaDataFlavor() throws Exception { + Multimap headers = ArrayListMultimap.create(); + HttpResponse httpResponse = createHttpResponseWithHeader(headers); + assertThat(ServiceOptions.headerContainsMetadataFlavor(httpResponse)).isFalse(); + } + + private HttpResponse createHttpResponseWithHeader(final Multimap headers) + throws Exception { + HttpTransport mockHttpTransport = + new MockHttpTransport() { + @Override + public LowLevelHttpRequest buildRequest(String method, String url) throws IOException { + return new MockLowLevelHttpRequest() { + @Override + public LowLevelHttpResponse execute() throws IOException { + MockLowLevelHttpResponse response = new MockLowLevelHttpResponse(); + for (Map.Entry entry : headers.entries()) { + response.addHeader(entry.getKey(), entry.getValue()); + } + return response; + } + }; + } + }; + HttpRequest request = + mockHttpTransport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); + return request.execute(); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/StringEnumTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/StringEnumTest.java new file mode 100644 index 000000000000..781fbb8925ee --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/StringEnumTest.java @@ -0,0 +1,128 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import com.google.api.core.ApiFunction; +import com.google.common.testing.EqualsTester; +import java.util.Arrays; +import org.junit.Assert; +import org.junit.Test; + +public class StringEnumTest { + + public static class Letter extends StringEnumValue { + private static final long serialVersionUID = -1717976087182628526L; + + private Letter(String constant) { + super(constant); + } + + private static final ApiFunction CONSTRUCTOR = + new ApiFunction() { + @Override + public Letter apply(String constant) { + return new Letter(constant); + } + }; + + private static final StringEnumType type = + new StringEnumType(Letter.class, CONSTRUCTOR); + + public static final Letter A = type.createAndRegister("A"); + public static final Letter B = type.createAndRegister("B"); + public static final Letter C = type.createAndRegister("C"); + + public static Letter valueOfStrict(String constant) { + return type.valueOfStrict(constant); + } + + /** Get the StorageClass for the given String constant, and allow unrecognized values. */ + public static Letter valueOf(String constant) { + return type.valueOf(constant); + } + + /** Return the known values for StorageClass. */ + public static Letter[] values() { + return type.values(); + } + } + + @Test(expected = NullPointerException.class) + public void testNullClass() { + new StringEnumType(null, Letter.CONSTRUCTOR); + } + + @Test + public void testNullConstructor() { + try { + new StringEnumType(Letter.class, null); + Assert.fail(); + } catch (NullPointerException ex) { + assertNull(ex.getMessage()); + } + } + + @Test + public void testEnumInstances() { + assertThat(Letter.A.toString()).isEqualTo("A"); + } + + @Test + public void testValueOf() { + assertThat(Letter.valueOf("A")).isSameInstanceAs(Letter.A); + assertThat(Letter.valueOf("B")).isSameInstanceAs(Letter.B); + assertThat(Letter.valueOf("C")).isSameInstanceAs(Letter.C); + assertThat(Letter.valueOf("NonExistentLetter").toString()).isEqualTo("NonExistentLetter"); + } + + @Test + public void testValueOfStrict() { + assertThat(Letter.valueOfStrict("A")).isSameInstanceAs(Letter.A); + assertThat(Letter.valueOfStrict("B")).isSameInstanceAs(Letter.B); + assertThat(Letter.valueOfStrict("C")).isSameInstanceAs(Letter.C); + } + + @Test + public void testEquals() { + new EqualsTester() + .addEqualityGroup(Letter.A, Letter.valueOf("A"), Letter.valueOfStrict("A")) + .addEqualityGroup(Letter.B, Letter.valueOf("B"), Letter.valueOfStrict("B")) + .addEqualityGroup(Letter.C, Letter.valueOf("C"), Letter.valueOfStrict("C")) + .addEqualityGroup(Letter.valueOf("NonExistentLetter"), Letter.valueOf("NonExistentLetter")) + .testEquals(); + } + + @Test + public void testValueOfStrict_invalid() { + try { + Letter.valueOfStrict("NonExistentLetter"); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testValues() { + assertThat( + Arrays.asList(Letter.values()).containsAll(Arrays.asList(Letter.A, Letter.B, Letter.C))) + .isTrue(); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java new file mode 100644 index 000000000000..5eaeb0a894a3 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java @@ -0,0 +1,306 @@ +/* + * Copyright 2017 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static com.google.common.testing.SerializableTester.reserializeAndAssert; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import com.google.common.testing.EqualsTester; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; +import java.util.concurrent.TimeUnit; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Unit tests for {@link com.google.cloud.Timestamp}. */ +@RunWith(JUnit4.class) +public class TimestampTest { + private static final String TEST_TIME_ISO = "2015-10-12T15:14:54Z"; + private static final long TEST_TIME_SECONDS = 1444662894L; + private static final long TEST_TIME_MICROSECONDS = 10000100L; + private static final long TEST_TIME_MILLISECONDS = + TimeUnit.SECONDS.toMillis(1444662894L) + TimeUnit.MICROSECONDS.toMillis(1234); + private static final long TEST_TIME_MILLISECONDS_NEGATIVE = -1000L; + private static final Date TEST_DATE = new Date(TEST_TIME_MILLISECONDS); + private static final Date TEST_DATE_PRE_EPOCH = new Date(TEST_TIME_MILLISECONDS_NEGATIVE); + + @Test + public void minValue() { + // MIN_VALUE is before the start of the Gregorian calendar... use magic value. + assertThat(Timestamp.MIN_VALUE.getSeconds()).isEqualTo(-62135596800L); + assertThat(Timestamp.MIN_VALUE.getNanos()).isEqualTo(0); + } + + @Test + public void maxValue() { + TimeZone tz = TimeZone.getTimeZone("UTC"); + GregorianCalendar calendar = new GregorianCalendar(tz); + calendar.set(9999, Calendar.DECEMBER, 31, 23, 59, 59); + java.sql.Timestamp expectedMin = new java.sql.Timestamp(calendar.getTimeInMillis()); + expectedMin.setNanos(999999999); + + assertThat(Timestamp.MAX_VALUE.getSeconds()).isEqualTo(calendar.getTimeInMillis() / 1000L); + assertThat(Timestamp.MAX_VALUE.getNanos()).isEqualTo(999999999); + } + + @Test + public void ofMicroseconds() { + Timestamp timestamp = Timestamp.ofTimeMicroseconds(TEST_TIME_MICROSECONDS); + assertThat(timestamp.getSeconds()).isEqualTo(TEST_TIME_MICROSECONDS / 1000000L); + assertThat(timestamp.getNanos()).isEqualTo(TEST_TIME_MICROSECONDS % 1000000L * 1000); + } + + @Test + public void ofDate() { + Timestamp timestamp = Timestamp.of(TEST_DATE); + Long expectedSeconds = TimeUnit.MILLISECONDS.toSeconds(TEST_TIME_MILLISECONDS); + Long expectedNanos = + TimeUnit.MILLISECONDS.toNanos(TEST_TIME_MILLISECONDS) + - TimeUnit.SECONDS.toNanos(expectedSeconds); + assertThat(timestamp.getSeconds()).isEqualTo(expectedSeconds); + assertThat(timestamp.getNanos()).isEqualTo(expectedNanos); + } + + @Test + public void testOf() { + String expectedTimestampString = "1970-01-01T00:00:12.345000000Z"; + java.sql.Timestamp input = new java.sql.Timestamp(12345); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void testOf_exactSecond() { + String expectedTimestampString = "1970-01-01T00:00:12Z"; + java.sql.Timestamp input = new java.sql.Timestamp(12000); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void testOf_preEpoch() { + String expectedTimestampString = "1969-12-31T23:59:47.655000000Z"; + java.sql.Timestamp input = new java.sql.Timestamp(-12345); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void testOf_onEpoch() { + String expectedTimestampString = "1970-01-01T00:00:00Z"; + java.sql.Timestamp input = new java.sql.Timestamp(0); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void testOf_preEpochExactSecond() { + String expectedTimestampString = "1969-12-31T23:59:59Z"; + java.sql.Timestamp input = new java.sql.Timestamp(-1000); + Timestamp timestamp = Timestamp.of(input); + assertEquals(timestamp.toString(), expectedTimestampString); + } + + @Test + public void ofDatePreEpoch() { + Timestamp timestamp = Timestamp.of(TEST_DATE_PRE_EPOCH); + long expectedSeconds = TEST_TIME_MILLISECONDS_NEGATIVE / 1_000; + int expectedNanos = (int) (TEST_TIME_MILLISECONDS_NEGATIVE % 1_000 * 1000_000); + if (expectedNanos < 0) { + expectedSeconds--; + expectedNanos += 1_000_000_000; + } + assertThat(timestamp.getSeconds()).isEqualTo(expectedSeconds); + assertThat(timestamp.getNanos()).isEqualTo(expectedNanos); + } + + @Test + public void toDate() { + Timestamp timestamp = Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 1234 * 1000); + Date date = timestamp.toDate(); + assertThat(TEST_TIME_MILLISECONDS).isEqualTo(date.getTime()); + } + + @Test + public void toFromSqlTimestamp() { + long seconds = TEST_TIME_SECONDS; + int nanos = 500000000; + + java.sql.Timestamp sqlTs = new java.sql.Timestamp(seconds * 1000); + sqlTs.setNanos(nanos); + + Timestamp ts = Timestamp.of(sqlTs); + assertThat(ts.getSeconds()).isEqualTo(seconds); + assertThat(ts.getNanos()).isEqualTo(nanos); + + assertThat(ts.toSqlTimestamp()).isEqualTo(sqlTs); + } + + @Test + public void boundsSecondsMin() { + try { + Timestamp.ofTimeSecondsAndNanos(Timestamp.MIN_VALUE.getSeconds() - 1, 999999999); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void boundsSecondsMax() { + try { + Timestamp.ofTimeSecondsAndNanos(Timestamp.MAX_VALUE.getSeconds() + 1, 0); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void boundsNanosMin() { + try { + Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, -1); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void boundsNanosMax() { + try { + Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 1000000000); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void boundsSqlTimestampMin() { + try { + Timestamp.of(new java.sql.Timestamp((Timestamp.MIN_VALUE.getSeconds() - 1) * 1000)); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void boundsSqlTimestampMax() { + try { + Timestamp.of(new java.sql.Timestamp((Timestamp.MAX_VALUE.getSeconds() + 1) * 1000)); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void equalsAndHashCode() { + EqualsTester tester = new EqualsTester(); + tester.addEqualityGroup( + Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0), + Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0), + Timestamp.of(new java.sql.Timestamp(TEST_TIME_SECONDS * 1000))); + tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS + 1, 0)); + tester.addEqualityGroup(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 1)); + tester.testEquals(); + } + + @Test + public void testToString() { + assertThat(Timestamp.MIN_VALUE.toString()).isEqualTo("0001-01-01T00:00:00Z"); + assertThat(Timestamp.MAX_VALUE.toString()).isEqualTo("9999-12-31T23:59:59.999999999Z"); + assertThat(Timestamp.ofTimeSecondsAndNanos(0, 0).toString()).isEqualTo("1970-01-01T00:00:00Z"); + assertThat(Timestamp.ofTimeSecondsAndNanos(0, 100).toString()) + .isEqualTo("1970-01-01T00:00:00.000000100Z"); + assertThat(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0).toString()) + .isEqualTo(TEST_TIME_ISO); + } + + @Test + public void parseTimestamp() { + assertThat(Timestamp.parseTimestamp("0001-01-01T00:00:00Z")).isEqualTo(Timestamp.MIN_VALUE); + assertThat(Timestamp.parseTimestamp("9999-12-31T23:59:59.999999999Z")) + .isEqualTo(Timestamp.MAX_VALUE); + assertThat(Timestamp.parseTimestamp(TEST_TIME_ISO)) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0)); + } + + @Test + public void parseTimestampWithoutTimeZoneOffset() { + assertThat(Timestamp.parseTimestamp("0001-01-01T00:00:00")).isEqualTo(Timestamp.MIN_VALUE); + assertThat(Timestamp.parseTimestamp("9999-12-31T23:59:59.999999999")) + .isEqualTo(Timestamp.MAX_VALUE); + assertThat(Timestamp.parseTimestamp("2015-10-12T15:14:54")) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(TEST_TIME_SECONDS, 0)); + } + + @Test + public void parseTimestampWithTimeZoneOffset() { + assertThat(Timestamp.parseTimestamp("0001-01-01T00:00:00-00:00")) + .isEqualTo(Timestamp.MIN_VALUE); + assertThat(Timestamp.parseTimestamp("9999-12-31T23:59:59.999999999-00:00")) + .isEqualTo(Timestamp.MAX_VALUE); + assertThat(Timestamp.parseTimestamp("2020-12-06T19:21:12.123+05:30")) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(1607262672, 123000000)); + assertThat(Timestamp.parseTimestamp("2020-07-10T14:03:00-07:00")) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(1594414980, 0)); + } + + @Test + public void fromProto() { + com.google.protobuf.Timestamp proto = + com.google.protobuf.Timestamp.newBuilder().setSeconds(1234).setNanos(567).build(); + Timestamp timestamp = Timestamp.fromProto(proto); + assertThat(timestamp.getSeconds()).isEqualTo(1234); + assertThat(timestamp.getNanos()).isEqualTo(567); + } + + @Test + public void comparable() { + assertThat(Timestamp.MIN_VALUE).isLessThan(Timestamp.MAX_VALUE); + assertThat(Timestamp.MAX_VALUE).isGreaterThan(Timestamp.MIN_VALUE); + + assertThat(Timestamp.ofTimeSecondsAndNanos(100, 0)) + .isAtLeast(Timestamp.ofTimeSecondsAndNanos(100, 0)); + assertThat(Timestamp.ofTimeSecondsAndNanos(100, 0)) + .isAtMost(Timestamp.ofTimeSecondsAndNanos(100, 0)); + + assertThat(Timestamp.ofTimeSecondsAndNanos(100, 1000)) + .isLessThan(Timestamp.ofTimeSecondsAndNanos(101, 0)); + assertThat(Timestamp.ofTimeSecondsAndNanos(100, 1000)) + .isAtMost(Timestamp.ofTimeSecondsAndNanos(101, 0)); + + assertThat(Timestamp.ofTimeSecondsAndNanos(101, 0)) + .isGreaterThan(Timestamp.ofTimeSecondsAndNanos(100, 1000)); + assertThat(Timestamp.ofTimeSecondsAndNanos(101, 0)) + .isAtLeast(Timestamp.ofTimeSecondsAndNanos(100, 1000)); + } + + @Test + public void serialization() throws Exception { + reserializeAndAssert(Timestamp.parseTimestamp("9999-12-31T23:59:59.999999999Z")); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BaseEmulatorHelperTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BaseEmulatorHelperTest.java new file mode 100644 index 000000000000..b002a6198bac --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BaseEmulatorHelperTest.java @@ -0,0 +1,185 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import com.google.api.client.util.Charsets; +import com.google.cloud.ServiceOptions; +import com.google.cloud.testing.BaseEmulatorHelper.EmulatorRunner; +import com.google.common.collect.ImmutableList; +import java.io.ByteArrayInputStream; +import java.io.EOFException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; +import java.util.List; +import java.util.concurrent.TimeoutException; +import java.util.logging.Logger; +import org.easymock.EasyMock; +import org.junit.Test; +import org.threeten.bp.Duration; + +public class BaseEmulatorHelperTest { + + private static final String BLOCK_UNTIL = "Block until"; + + private static class TestEmulatorHelper extends BaseEmulatorHelper { + + private final List runners; + private final String blockUntil; + + private TestEmulatorHelper(List runners, String blockUntil) { + super("emulator", 1, "project"); + this.runners = runners; + this.blockUntil = blockUntil; + } + + @Override + protected List getEmulatorRunners() { + return runners; + } + + @Override + protected Logger getLogger() { + return null; + } + + @Override + public ServiceOptions getOptions() { + return null; + } + + @Override + public void start() throws IOException, InterruptedException { + startProcess(blockUntil); + } + + @Override + public void stop(Duration timeout) throws IOException, InterruptedException, TimeoutException { + waitForProcess(timeout); + } + + @Override + public void reset() throws IOException { + // do nothing + } + } + + @Test + public void testEmulatorHelper() throws IOException, InterruptedException, TimeoutException { + Process process = EasyMock.createStrictMock(Process.class); + InputStream stream = new ByteArrayInputStream(BLOCK_UNTIL.getBytes(Charsets.UTF_8)); + EmulatorRunner emulatorRunner = EasyMock.createStrictMock(EmulatorRunner.class); + EasyMock.expect(process.getInputStream()).andReturn(stream); + EasyMock.expect(emulatorRunner.isAvailable()).andReturn(true); + emulatorRunner.start(); + EasyMock.expectLastCall(); + EasyMock.expect(emulatorRunner.getProcess()).andReturn(process); + emulatorRunner.waitFor(Duration.ofMinutes(1)); + EasyMock.expectLastCall().andReturn(0); + EasyMock.replay(process, emulatorRunner); + TestEmulatorHelper helper = + new TestEmulatorHelper(ImmutableList.of(emulatorRunner), BLOCK_UNTIL); + helper.start(); + helper.stop(Duration.ofMinutes(1)); + EasyMock.verify(); + } + + @Test + public void testEmulatorHelperDownloadWithRetries() + throws IOException, InterruptedException, TimeoutException { + String mockExternalForm = "mockExternalForm"; + String mockInputStream = "mockInputStream"; + String mockProtocol = "mockProtocol"; + String mockFile = "mockFile"; + String mockAccessToken = "mockAccessToken"; + String mockCommandText = "mockCommandText"; + + MockURLStreamHandler mockURLStreamHandler = EasyMock.createMock(MockURLStreamHandler.class); + URLConnection mockURLConnection = EasyMock.mock(URLConnection.class); + + EasyMock.expect(mockURLStreamHandler.toExternalForm(EasyMock.anyObject(URL.class))) + .andReturn(mockExternalForm) + .anyTimes(); + EasyMock.expect(mockURLConnection.getInputStream()) + .andReturn(new ByteArrayInputStream(mockInputStream.getBytes())) + .anyTimes(); + mockURLConnection.setRequestProperty("Authorization", "Bearer " + mockAccessToken); + EasyMock.expect(mockURLStreamHandler.openConnection(EasyMock.anyObject(URL.class))) + .andThrow(new EOFException()) + .times(1); + EasyMock.expect(mockURLStreamHandler.openConnection(EasyMock.anyObject(URL.class))) + .andReturn(mockURLConnection) + .times(1); + EasyMock.replay(mockURLStreamHandler, mockURLConnection); + + URL url = new URL(mockProtocol, null, 0, mockFile, mockURLStreamHandler); + BaseEmulatorHelper.DownloadableEmulatorRunner runner = + new BaseEmulatorHelper.DownloadableEmulatorRunner( + ImmutableList.of(mockCommandText), url, null, mockAccessToken); + + File cachedFile = new File(System.getProperty("java.io.tmpdir"), mockExternalForm); + cachedFile.delete(); // Clear the cached version so we're always testing the download + + runner.start(); + + EasyMock.verify(); + + cachedFile.delete(); // Cleanup + } + + @Test + public void testEmulatorHelperMultipleRunners() + throws IOException, InterruptedException, TimeoutException { + Process process = EasyMock.createStrictMock(Process.class); + InputStream stream = new ByteArrayInputStream(BLOCK_UNTIL.getBytes(Charsets.UTF_8)); + EmulatorRunner firstRunner = EasyMock.createStrictMock(EmulatorRunner.class); + EmulatorRunner secondRunner = EasyMock.createStrictMock(EmulatorRunner.class); + EasyMock.expect(process.getInputStream()).andReturn(stream); + EasyMock.expect(firstRunner.isAvailable()).andReturn(false); + EasyMock.expect(secondRunner.isAvailable()).andReturn(true); + secondRunner.start(); + EasyMock.expectLastCall(); + EasyMock.expect(secondRunner.getProcess()).andReturn(process); + secondRunner.waitFor(Duration.ofMinutes(1)); + EasyMock.expectLastCall().andReturn(0); + EasyMock.replay(process, secondRunner); + TestEmulatorHelper helper = + new TestEmulatorHelper(ImmutableList.of(firstRunner, secondRunner), BLOCK_UNTIL); + helper.start(); + helper.stop(Duration.ofMinutes(1)); + EasyMock.verify(); + } + + /** + * URLStreamHandler has a protected method which needs to be mocked, so we need our own + * implementation in this package + */ + private class MockURLStreamHandler extends URLStreamHandler { + @Override + protected URLConnection openConnection(URL u) throws IOException { + return null; + } + + @Override + protected String toExternalForm(URL u) { + return null; + } + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BlockingProcessStreamReaderTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BlockingProcessStreamReaderTest.java new file mode 100644 index 000000000000..56b406f9634a --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BlockingProcessStreamReaderTest.java @@ -0,0 +1,99 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import static org.junit.Assert.assertEquals; + +import com.google.api.client.util.Charsets; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Timeout; + +public class BlockingProcessStreamReaderTest { + + private static final String BLOCK_UNTIL = "Dev App Server is now running"; + private static final String OUTPUT = "First Line\n" + "Second Line\n" + BLOCK_UNTIL; + private static final String OUTPUT_WITH_LOGS = + "First Line\n" + + BLOCK_UNTIL + + "\n" + + "Nov 08, 2016 2:05:44 PM io.netty.buffer.PooledByteBufAllocator \n" + + "INFO: log line 1\n" + + "log line 2\n" + + "Nov 08, 2016 2:05:44 PM io.netty.buffer.PooledByteBufAllocator \n" + + "FINE: log line 3\n"; + private static final String TAGGED_OUTPUT_WITH_LOGS = + "[emulator] First Line\n" + + "[emulator]" + + BLOCK_UNTIL + + "\n" + + "[emulator] Nov 08, 2016 2:05:44 PM io.netty.buffer.PooledByteBufAllocator \n" + + "[emulator] INFO: log line 1\n" + + "[emulator] log line 2\n" + + "[emulator] Nov 08, 2016 2:05:44 PM io.netty.buffer.PooledByteBufAllocator \n" + + "[emulator] FINE: log line 3\n"; + + @Rule public Timeout globalTimeout = Timeout.seconds(10); + + private static final class TestLogger extends Logger { + + private final Multimap logs = LinkedHashMultimap.create(); + + private TestLogger() { + super("text-logger", null); + } + + public void log(Level level, String msg) { + logs.put(level, msg); + } + + Multimap getLogs() { + return logs; + } + } + + @Test + public void testForwardLogEntry() throws IOException, InterruptedException { + TestLogger logger = new TestLogger(); + InputStream stream = new ByteArrayInputStream(OUTPUT_WITH_LOGS.getBytes(Charsets.UTF_8)); + BlockingProcessStreamReader.start("emulator", stream, BLOCK_UNTIL, logger).join(); + assertEquals( + "[emulator] log line 1" + System.lineSeparator() + "[emulator] log line 2", + logger.getLogs().get(Level.INFO).iterator().next()); + assertEquals("[emulator] log line 3", logger.getLogs().get(Level.FINE).iterator().next()); + stream.close(); + } + + @Test + public void testForwardAlreadyTaggedLogs() throws IOException, InterruptedException { + TestLogger logger = new TestLogger(); + InputStream stream = new ByteArrayInputStream(TAGGED_OUTPUT_WITH_LOGS.getBytes(Charsets.UTF_8)); + BlockingProcessStreamReader.start("emulator", stream, BLOCK_UNTIL, logger).join(); + assertEquals( + "[emulator] log line 1" + System.lineSeparator() + "[emulator] log line 2", + logger.getLogs().get(Level.INFO).iterator().next()); + assertEquals("[emulator] log line 3", logger.getLogs().get(Level.FINE).iterator().next()); + stream.close(); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/CommandWrapperTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/CommandWrapperTest.java new file mode 100644 index 000000000000..88b246c75420 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/CommandWrapperTest.java @@ -0,0 +1,120 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.ImmutableList; +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import org.junit.Test; + +public class CommandWrapperTest { + + private static final List COMMAND = ImmutableList.of("my", "command"); + private static final List WIN_COMMAND = ImmutableList.of("cmd", "/C", "my", "command"); + private static final List UNIX_COMMAND = ImmutableList.of("bash", "my", "command"); + private static final Path DIRECTORY = Paths.get("my-path"); + private static final File WIN_NULL_FILE = new File("NUL:"); + private static final File UNIX_NULL_FILE = new File("/dev/null"); + + @Test + public void testCommandWrapperCommand() { + CommandWrapper commandWrapper = CommandWrapper.create(); + commandWrapper.setCommand(COMMAND); + ProcessBuilder processBuilder = commandWrapper.getBuilder(); + if (BaseEmulatorHelper.isWindows()) { + assertEquals(WIN_COMMAND, processBuilder.command()); + } else { + assertEquals(UNIX_COMMAND, processBuilder.command()); + } + assertNull(processBuilder.directory()); + assertFalse(processBuilder.redirectErrorStream()); + assertEquals(ProcessBuilder.Redirect.PIPE, processBuilder.redirectError()); + } + + @Test + public void testCommandWrapperRedirectErrorStream() { + CommandWrapper commandWrapper = CommandWrapper.create(); + commandWrapper.setCommand(COMMAND); + commandWrapper.setRedirectErrorStream(); + ProcessBuilder processBuilder = commandWrapper.getBuilder(); + if (BaseEmulatorHelper.isWindows()) { + assertEquals(WIN_COMMAND, processBuilder.command()); + } else { + assertEquals(UNIX_COMMAND, processBuilder.command()); + } + assertNull(processBuilder.directory()); + assertTrue(processBuilder.redirectErrorStream()); + assertEquals(ProcessBuilder.Redirect.PIPE, processBuilder.redirectError()); + } + + @Test + public void testCommandWrapperRedirectErrorInherit() { + CommandWrapper commandWrapper = CommandWrapper.create(); + commandWrapper.setCommand(COMMAND); + commandWrapper.setRedirectErrorInherit(); + ProcessBuilder processBuilder = commandWrapper.getBuilder(); + if (BaseEmulatorHelper.isWindows()) { + assertEquals(WIN_COMMAND, processBuilder.command()); + } else { + assertEquals(UNIX_COMMAND, processBuilder.command()); + } + assertNull(processBuilder.directory()); + assertFalse(processBuilder.redirectErrorStream()); + assertEquals(ProcessBuilder.Redirect.INHERIT, processBuilder.redirectError()); + } + + @Test + public void testCommandWrapperDirectory() { + CommandWrapper commandWrapper = CommandWrapper.create(); + commandWrapper.setCommand(COMMAND); + commandWrapper.setDirectory(DIRECTORY); + ProcessBuilder processBuilder = commandWrapper.getBuilder(); + if (BaseEmulatorHelper.isWindows()) { + assertEquals(WIN_COMMAND, processBuilder.command()); + } else { + assertEquals(UNIX_COMMAND, processBuilder.command()); + } + assertEquals(DIRECTORY, processBuilder.directory().toPath()); + assertFalse(processBuilder.redirectErrorStream()); + assertEquals(ProcessBuilder.Redirect.PIPE, processBuilder.redirectError()); + } + + @Test + public void testCommandWrapperRedirectOutputToNull() { + CommandWrapper commandWrapper = CommandWrapper.create(); + commandWrapper.setCommand(COMMAND); + commandWrapper.setRedirectOutputToNull(); + ProcessBuilder processBuilder = commandWrapper.getBuilder(); + if (BaseEmulatorHelper.isWindows()) { + assertEquals(WIN_COMMAND, processBuilder.command()); + assertEquals(ProcessBuilder.Redirect.to(WIN_NULL_FILE), processBuilder.redirectOutput()); + } else { + assertEquals(UNIX_COMMAND, processBuilder.command()); + assertEquals(ProcessBuilder.Redirect.to(UNIX_NULL_FILE), processBuilder.redirectOutput()); + } + assertNull(processBuilder.directory()); + assertFalse(processBuilder.redirectErrorStream()); + assertEquals(ProcessBuilder.Redirect.PIPE, processBuilder.redirectError()); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/VersionTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/VersionTest.java new file mode 100644 index 000000000000..fe65026b600a --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/VersionTest.java @@ -0,0 +1,103 @@ +/* + * Copyright 2016 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Assert; +import org.junit.Test; + +public class VersionTest { + + @Test + public void testFromString() { + Version version = Version.fromString("2016.01.13"); + assertEquals(2016, version.getMajor()); + assertEquals(1, version.getMinor()); + assertEquals(13, version.getPatch()); + version = Version.fromString("1.2.0"); + assertEquals(1, version.getMajor()); + assertEquals(2, version.getMinor()); + assertEquals(0, version.getPatch()); + } + + @Test + public void testFromStringWithAlphas() { + try { + Version.fromString("2016.01.hello"); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testFromStringMissingPatch() { + try { + Version.fromString("2016.01"); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testFromStringMissingMinor() { + try { + Version.fromString("2016"); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testFromStringEmpty() { + try { + Version.fromString(""); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testFromStringNull() { + try { + Version.fromString(null); + Assert.fail(); + } catch (NullPointerException ex) { + assertNull(ex.getMessage()); + } + } + + @Test + public void testCompare() { + Version version = Version.fromString("2016.01.13"); + Version sameVersion = Version.fromString("2016.01.13"); + Version olderVersion = Version.fromString("2015.12.01"); + Version newerVersion = Version.fromString("2016.08.12"); + assertEquals(0, version.compareTo(sameVersion)); + assertTrue(version.compareTo(olderVersion) > 0); + assertTrue(version.compareTo(newerVersion) < 0); + Version otherVersion = Version.fromString("1.2.0"); + assertTrue(version.compareTo(otherVersion) > 0); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/MultipleAttemptsRule.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/MultipleAttemptsRule.java new file mode 100644 index 000000000000..86fd82c7b930 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/MultipleAttemptsRule.java @@ -0,0 +1,107 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.util.ArrayList; +import java.util.List; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.MultipleFailureException; +import org.junit.runners.model.Statement; + +/** + * A JUnit rule that allows multiple attempts of a test execution before ultimately reporting + * failure for the test. Attempts will be attempted with an exponential backoff which defaults to a + * starting duration of 1 second. + * + *

If after the maximum number of attempts the test has still not succeeded, all failures will be + * propagated as the result of the test allowing all errors to be visible (regardless if they are + * the same failure or different ones). + * + *

To use this rule add the field declaration to your JUnit 4 Test class: + * + *

Note: It is important that the field is public + * + *

{@code
+ * @Rule
+ * public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
+ * }
+ * + * @see org.junit.Rule + */ +public final class MultipleAttemptsRule implements TestRule { + private final long initialBackoffMillis; + private final int maxAttemptCount; + + /** + * Construct a {@link MultipleAttemptsRule} which will attempt a test up to {@code attemptCount} + * times before ultimately reporting failure of the test. + * + *

The initialBackoffMillis will be set to 1000L. + * + * @param maxAttemptCount max number of attempts before reporting failure, must be greater than 0 + * @see #MultipleAttemptsRule(int, long) + */ + public MultipleAttemptsRule(int maxAttemptCount) { + this(maxAttemptCount, 1000L); + } + + /** + * Construct a {@link MultipleAttemptsRule} which will attempt a test up to {@code attemptCount} + * times before ultimately reporting failure of the test. + * + *

The {@code initialBackoffMillis} will be used as the first pause duration before + * reattempting the test. + * + * @param maxAttemptCount max number of attempts before reporting failure, must be greater than 0 + * @param initialBackoffMillis initial duration in millis to wait between attempts, must be + * greater than or equal to 0 + */ + public MultipleAttemptsRule(int maxAttemptCount, long initialBackoffMillis) { + checkArgument(maxAttemptCount > 0, "attemptCount must be > 0"); + checkArgument(initialBackoffMillis >= 0, "initialBackoffMillis must be >= 0"); + this.initialBackoffMillis = initialBackoffMillis; + this.maxAttemptCount = maxAttemptCount; + } + + @Override + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + List failures = new ArrayList<>(); + + long retryIntervalMillis = initialBackoffMillis; + + for (int i = 1; i <= maxAttemptCount; i++) { + try { + base.evaluate(); + return; + } catch (Throwable t) { + failures.add(t); + Thread.sleep(retryIntervalMillis); + retryIntervalMillis *= 1.5f; + } + } + + MultipleFailureException.assertEmpty(failures); + } + }; + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdErrCaptureRule.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdErrCaptureRule.java new file mode 100644 index 000000000000..1640d950e3f7 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdErrCaptureRule.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4; + +import java.io.PrintStream; +import org.junit.Rule; + +/** + * A JUnit rule that allows the capturing stderr (i.e. {@link System#err} during the scope of a + * test. + * + *

Note: If some part of the system holds a reference System.err before this rule is loaded + * into the test lifecycle there is no way for this rule to capture the output. Ensure this rule is + * declared as high in your test file as possible, and ordered using {@link Rule#order()} before + * other Rules if necessary. + * + *

To use this rule add the field declaration to your JUnit 4 Test class: + * + *

Note: It is important that the field is public + * + *

{@code
+ * @Rule
+ * public StdErrCaptureRule stdErrCaptureRule = new StdErrCaptureRule();
+ * }
+ * + * @see org.junit.Rule + * @see Rule#order() + */ +public final class StdErrCaptureRule extends StdXCaptureRule { + + public StdErrCaptureRule() {} + + @Override + protected PrintStream getOriginal() { + return System.err; + } + + @Override + protected void set(PrintStream ps) { + System.setErr(ps); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdOutCaptureRule.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdOutCaptureRule.java new file mode 100644 index 000000000000..0a33997cde21 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdOutCaptureRule.java @@ -0,0 +1,56 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4; + +import java.io.PrintStream; +import org.junit.Rule; + +/** + * A JUnit rule that allows the capturing stdout (i.e. {@link System#out} during the scope of a + * test. + * + *

Note: If some part of the system holds a reference System.out before this rule is loaded + * into the test lifecycle there is no way for this rule to capture the output. Ensure this rule is + * declared as high in your test file as possible, and ordered using {@link Rule#order()} before + * other Rules if necessary. + * + *

To use this rule add the field declaration to your JUnit 4 Test class: + * + *

Note: It is important that the field is public + * + *

{@code
+ * @Rule
+ * public StdOutCaptureRule stdOutCaptureRule = new StdOutCaptureRule();
+ * }
+ * + * @see org.junit.Rule + * @see Rule#order() + */ +public final class StdOutCaptureRule extends StdXCaptureRule { + + public StdOutCaptureRule() {} + + @Override + protected PrintStream getOriginal() { + return System.out; + } + + @Override + protected void set(PrintStream ps) { + System.setOut(ps); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdXCaptureRule.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdXCaptureRule.java new file mode 100644 index 000000000000..ba17e3e324bc --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdXCaptureRule.java @@ -0,0 +1,188 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4; + +import com.google.common.base.Charsets; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +abstract class StdXCaptureRule implements TestRule { + + private final ByteArrayOutputStream byteArrayOutputStream; + + public StdXCaptureRule() { + byteArrayOutputStream = new ByteArrayOutputStream(); + } + + protected abstract PrintStream getOriginal(); + + protected abstract void set(PrintStream ps); + + /** + * Get a handle to the raw bytes written during the running test so far. + * + * @return A read-only {@link ByteArrayOutputStream} representing the raw bytes written so far. + *

Note the following behavior of the return value: + *

    + *
  1. Calling any "write" method call will result in an {@link IllegalStateException} + *
  2. Calls to {@link ByteArrayOutputStream#toByteArray()} will result in a new copy of the + * underlying array up to that point + *
  3. Calls to {@link ByteArrayOutputStream#flush()} will be silently ignored + *
  4. Calls to {@link ByteArrayOutputStream#close()} will be silently ignored + *
+ */ + public ByteArrayOutputStream getCapturedOutput() { + return new ReadOnlyByteArrayOutputStream(byteArrayOutputStream); + } + + /** + * Return a UTF-8 {@link String} of all bytes written during the running test so far. + * + * @return UTF-8 {@link String} of all bytes written + */ + public String getCapturedOutputAsUtf8String() { + return new String(byteArrayOutputStream.toByteArray(), Charsets.UTF_8); + } + + @Override + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + PrintStream originalOut = getOriginal(); + TeeOutputStream tee = new TeeOutputStream(System.out, byteArrayOutputStream); + boolean outReplaced = false; + try { + set(new PrintStream(tee)); + outReplaced = true; + base.evaluate(); + } finally { + if (outReplaced) { + set(originalOut); + } + } + } + }; + } + + private static final class TeeOutputStream extends OutputStream { + private final OutputStream left; + private final OutputStream right; + + public TeeOutputStream(OutputStream left, OutputStream right) { + this.left = left; + this.right = right; + } + + @Override + public void write(int b) throws IOException { + try { + left.write(b); + } finally { + right.write(b); + } + } + + @Override + public void flush() throws IOException { + try { + left.flush(); + } finally { + right.flush(); + } + } + } + + private static final class ReadOnlyByteArrayOutputStream extends ByteArrayOutputStream { + private final ByteArrayOutputStream delegate; + + public ReadOnlyByteArrayOutputStream(ByteArrayOutputStream delegate) { + this.delegate = delegate; + } + + @Override + public synchronized void write(int b) { + throw getIllegalStateException("write(b)"); + } + + @Override + public synchronized void write(byte[] b, int off, int len) { + throw getIllegalStateException("write(byte[], off, len)"); + } + + @Override + public synchronized void writeTo(OutputStream out) { + throw getIllegalStateException("writeOt(out)"); + } + + @Override + public synchronized void reset() { + throw getIllegalStateException("reset()"); + } + + @Override + public synchronized byte[] toByteArray() { + return delegate.toByteArray(); + } + + @Override + public void close() { + // ignore + } + + @Override + public synchronized int size() { + return delegate.size(); + } + + @Override + public synchronized String toString() { + return delegate.toString(); + } + + @Override + public synchronized String toString(String charsetName) throws UnsupportedEncodingException { + return delegate.toString(charsetName); + } + + @SuppressWarnings("deprecation") + @Override + public synchronized String toString(int hibyte) { + return delegate.toString(hibyte); + } + + @Override + public void flush() { + // ignore + } + + @Override + public void write(byte[] b) { + throw getIllegalStateException("write(byte[])"); + } + + private IllegalStateException getIllegalStateException(String desc) { + return new IllegalStateException(desc + " is forbidden"); + } + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdXCaptureRuleTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdXCaptureRuleTest.java new file mode 100644 index 000000000000..17d167e1af9a --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/StdXCaptureRuleTest.java @@ -0,0 +1,76 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.PrintStream; +import org.junit.Test; + +public final class StdXCaptureRuleTest { + + @Test(expected = IllegalStateException.class) + public void returnedByteArrayOutputStreamIsReadOnly_writeByte() { + getStdXCaptureRule().getCapturedOutput().write(0); + } + + @Test(expected = IllegalStateException.class) + public void returnedByteArrayOutputStreamIsReadOnly_writeByteArray() throws IOException { + getStdXCaptureRule().getCapturedOutput().write(new byte[] {0}); + } + + @Test(expected = IllegalStateException.class) + public void returnedByteArrayOutputStreamIsReadOnly_writeByteArrayRange() { + getStdXCaptureRule().getCapturedOutput().write(new byte[] {0}, 0, 1); + } + + @Test(expected = IllegalStateException.class) + public void returnedByteArrayOutputStreamIsReadOnly_writeTo() throws IOException { + getStdXCaptureRule().getCapturedOutput().writeTo(System.out); + } + + @Test(expected = IllegalStateException.class) + public void returnedByteArrayOutputStreamIsReadOnly_reset() { + getStdXCaptureRule().getCapturedOutput().reset(); + } + + @Test + public void returnedByteArrayOutputStreamIsReadOnly_close() throws IOException { + getStdXCaptureRule().getCapturedOutput().close(); + } + + @Test + public void returnedByteArrayOutputStreamIsReadOnly_flush() throws IOException { + getStdXCaptureRule().getCapturedOutput().flush(); + } + + private static StdXCaptureRule getStdXCaptureRule() { + return new StdXCaptureRule() { + @Override + protected PrintStream getOriginal() { + fail("unexpected call"); + return null; + } + + @Override + protected void set(PrintStream ps) { + fail("unexpected call"); + } + }; + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/MultipleAttemptsRuleTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/MultipleAttemptsRuleTest.java new file mode 100644 index 000000000000..e1c98b19530e --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/MultipleAttemptsRuleTest.java @@ -0,0 +1,87 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4.tests; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import com.google.cloud.testing.junit4.MultipleAttemptsRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runners.model.MultipleFailureException; +import org.junit.runners.model.Statement; + +public final class MultipleAttemptsRuleTest { + + private static final int NUMBER_OF_ATTEMPTS = 5; + + @Rule public MultipleAttemptsRule rr = new MultipleAttemptsRule(NUMBER_OF_ATTEMPTS, 0); + + private int numberAttempted = 0; + + @Test + public void wontPassUntil5() { + numberAttempted += 1; + assertEquals(NUMBER_OF_ATTEMPTS, numberAttempted); + } + + @Test(expected = IllegalArgumentException.class) + public void errorConstructing_attemptLessThan1() { + new MultipleAttemptsRule(0); + } + + @Test + public void errorConstructing_attemptEquals1() { + new MultipleAttemptsRule(1); + } + + @Test(expected = IllegalArgumentException.class) + public void errorConstructing_attemptGreaterThanOrEqualTo1AndBackoffLessThan0() { + new MultipleAttemptsRule(1, -1); + } + + @Test + public void errorConstructing_attemptGreaterThanOrEqualTo1AndBackoffEqualTo0() { + new MultipleAttemptsRule(1, 0); + } + + @Test + public void allErrorPropagated() { + MultipleAttemptsRule rule = new MultipleAttemptsRule(3, 0); + Statement statement = + rule.apply( + new Statement() { + private int counter = 1; + + @Override + public void evaluate() { + fail("attempt " + counter++); + } + }, + null); + + try { + statement.evaluate(); + } catch (MultipleFailureException mfe) { + // pass + assertThat(mfe.getFailures()).hasSize(3); + } catch (Throwable throwable) { + fail("unexpected error: " + throwable.getMessage()); + } + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/StdErrCaptureRuleTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/StdErrCaptureRuleTest.java new file mode 100644 index 000000000000..565bb08f12aa --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/StdErrCaptureRuleTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4.tests; + +import static org.junit.Assert.assertEquals; + +import com.google.cloud.testing.junit4.StdErrCaptureRule; +import org.junit.Rule; +import org.junit.Test; + +public class StdErrCaptureRuleTest { + + @Rule public StdErrCaptureRule stdOutCap = new StdErrCaptureRule(); + + @Test + public void captureSuccessful() { + System.err.println("err world"); + String expected = "err world" + System.lineSeparator(); + String actual = stdOutCap.getCapturedOutputAsUtf8String(); + assertEquals(expected, actual); + } +} diff --git a/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/StdOutCaptureRuleTest.java b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/StdOutCaptureRuleTest.java new file mode 100644 index 000000000000..8230debded28 --- /dev/null +++ b/java-core/google-cloud-core/src/test/java/com/google/cloud/testing/junit4/tests/StdOutCaptureRuleTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.testing.junit4.tests; + +import static org.junit.Assert.assertEquals; + +import com.google.cloud.testing.junit4.StdOutCaptureRule; +import org.junit.Rule; +import org.junit.Test; + +public class StdOutCaptureRuleTest { + + @Rule public StdOutCaptureRule stdOutCap = new StdOutCaptureRule(); + + @Test + public void captureSuccessful() { + System.out.println("hello world"); + String expected = "hello world" + System.lineSeparator(); + String actual = stdOutCap.getCapturedOutputAsUtf8String(); + assertEquals(expected, actual); + } +} diff --git a/java-core/pom.xml b/java-core/pom.xml new file mode 100644 index 000000000000..cf7143c69e97 --- /dev/null +++ b/java-core/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + com.google.cloud + google-cloud-core-parent + pom + 2.9.5-SNAPSHOT + Google Cloud Core Parent + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-jar-parent + 1.4.0-SNAPSHOT + ../google-cloud-jar-parent/pom.xml + + + + UTF-8 + UTF-8 + github + google-cloud-core-parent + + + + google-cloud-core + google-cloud-core-http + google-cloud-core-grpc + google-cloud-core-bom + + diff --git a/java-iam/.OwlBot.yaml b/java-iam/.OwlBot.yaml new file mode 100644 index 000000000000..5ec827e307bb --- /dev/null +++ b/java-iam/.OwlBot.yaml @@ -0,0 +1,30 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +deep-remove-regex: + - "/java-iam/grpc-google-.*/src" + - "/java-iam/proto-google-.*/src" + +deep-preserve-regex: + - "/java-iam/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java" + - "/java-iam/samples/snippets/generated" + +deep-copy-regex: + - source: "/google/iam/v2beta/google-cloud-iam-v2beta-java/gapic-google-cloud-iam-v2beta-java/src" + dest: "/owl-bot-staging/java-iam/v2beta/google-iam-policy/src" + - source: "/google/iam/v2/google-cloud-iam-v2-java/gapic-google-cloud-iam-v2-java/src" + dest: "/owl-bot-staging/java-iam/v2/google-iam-policy/src" + +api-name: iam diff --git a/java-iam/.repo-metadata.json b/java-iam/.repo-metadata.json new file mode 100644 index 000000000000..3b4b6df1faf0 --- /dev/null +++ b/java-iam/.repo-metadata.json @@ -0,0 +1,17 @@ +{ + "api_shortname": "iam", + "name_pretty": "IAM", + "product_documentation": "n/a", + "api_description": "n/a", + "client_documentation": "https://cloud.google.com/java/docs/reference/proto-google-iam-v1/latest/history", + "release_level": "stable", + "transport": "grpc", + "requires_billing": true, + "language": "java", + "repo": "googleapis/java-iam", + "repo_short": "java-iam", + "library_type": "OTHER", + "distribution_name": "com.google.cloud:google-iam-policy", + "excluded_poms": "proto-google-iam-v1-bom,google-iam-policy,proto-google-iam-v1", + "excluded_dependencies": "google-iam-policy" +} diff --git a/java-iam/CHANGELOG.md b/java-iam/CHANGELOG.md new file mode 100644 index 000000000000..d8d4838f4495 --- /dev/null +++ b/java-iam/CHANGELOG.md @@ -0,0 +1,718 @@ +# Changelog + +## [1.7.0](https://github.com/googleapis/java-iam/compare/v1.6.23...v1.7.0) (2023-01-10) + + +### Features + +* Removing migrated grpc- and proto- modules from repository ([#592](https://github.com/googleapis/java-iam/issues/592)) ([9c4b9aa](https://github.com/googleapis/java-iam/commit/9c4b9aace04fc72868f4dcaf289eb0a8f35d4e1f)) + + +### Bug Fixes + +* Remove 'unstable API' message from README.md ([#570](https://github.com/googleapis/java-iam/issues/570)) ([8da89f5](https://github.com/googleapis/java-iam/commit/8da89f59cbe323b2cc5eb2b483485e424622b027)) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.23 ([#578](https://github.com/googleapis/java-iam/issues/578)) ([aa49b5e](https://github.com/googleapis/java-iam/commit/aa49b5efaf53fcafc0bbd7662e8b016fcfc2ff61)) + +## [1.6.23](https://github.com/googleapis/java-iam/compare/v1.6.22...v1.6.23) (2022-12-20) + + +### Dependencies + +* Update dependency com.google.api:api-common to v2.3.1 ([#567](https://github.com/googleapis/java-iam/issues/567)) ([17e62e8](https://github.com/googleapis/java-iam/commit/17e62e80f0ea8c2d4edfe6bb16ef5ee7acbc22f3)) +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.14.0 ([#571](https://github.com/googleapis/java-iam/issues/571)) ([9c48311](https://github.com/googleapis/java-iam/commit/9c48311fbac25f9c9545f3404a42cdadf8ebb243)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.1.0 ([#565](https://github.com/googleapis/java-iam/issues/565)) ([32be2fb](https://github.com/googleapis/java-iam/commit/32be2fb0cfafa3681489c18e367cf12f22c567d3)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.22 ([#560](https://github.com/googleapis/java-iam/issues/560)) ([de39d89](https://github.com/googleapis/java-iam/commit/de39d89c08c9e45bc977ea393570a8d01cf48af2)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.12 ([#563](https://github.com/googleapis/java-iam/issues/563)) ([607e260](https://github.com/googleapis/java-iam/commit/607e2601b71ff1fb51406e6c97dd79208296f404)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.12 ([#564](https://github.com/googleapis/java-iam/issues/564)) ([4b2b26b](https://github.com/googleapis/java-iam/commit/4b2b26bd29d88ccb602a71225d6e2decb49b9649)) +* Update dependency io.grpc:grpc-protobuf to v1.51.1 ([#573](https://github.com/googleapis/java-iam/issues/573)) ([2143ec8](https://github.com/googleapis/java-iam/commit/2143ec8a90dbcdb128dffea9777fa9d183c3068e)) +* Update dependency io.grpc:grpc-stub to v1.51.1 ([#574](https://github.com/googleapis/java-iam/issues/574)) ([488496a](https://github.com/googleapis/java-iam/commit/488496aa09c9d976bf0c450fb8584f07e7c74c03)) + +## [1.6.22](https://github.com/googleapis/java-iam/compare/v1.6.21...v1.6.22) (2022-11-28) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.21 ([#557](https://github.com/googleapis/java-iam/issues/557)) ([c108c89](https://github.com/googleapis/java-iam/commit/c108c89e97a9b5f11541a9c704d9da582868cf32)) + +## [1.6.21](https://github.com/googleapis/java-iam/compare/v1.6.20...v1.6.21) (2022-11-23) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.20 ([#554](https://github.com/googleapis/java-iam/issues/554)) ([940af38](https://github.com/googleapis/java-iam/commit/940af38f2b1e4ea7846d5fe2b174b5c6f8962a67)) + +## [1.6.20](https://github.com/googleapis/java-iam/compare/v1.6.19...v1.6.20) (2022-11-22) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.19 ([#551](https://github.com/googleapis/java-iam/issues/551)) ([cd4a411](https://github.com/googleapis/java-iam/commit/cd4a411647e67ebe88c690d6ca4532d4011b4029)) + +## [1.6.19](https://github.com/googleapis/java-iam/compare/v1.6.18...v1.6.19) (2022-11-22) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.18 ([#548](https://github.com/googleapis/java-iam/issues/548)) ([34ed3ea](https://github.com/googleapis/java-iam/commit/34ed3ea40572a3598d372e9c9d6d5a4077de86d6)) + +## [1.6.18](https://github.com/googleapis/java-iam/compare/v1.6.17...v1.6.18) (2022-11-22) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.17 ([#545](https://github.com/googleapis/java-iam/issues/545)) ([0bcbf61](https://github.com/googleapis/java-iam/commit/0bcbf6163950bbc3d282a7ae199fc8f5e32f195b)) + +## [1.6.17](https://github.com/googleapis/java-iam/compare/v1.6.16...v1.6.17) (2022-11-21) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.16 ([#542](https://github.com/googleapis/java-iam/issues/542)) ([deca3f1](https://github.com/googleapis/java-iam/commit/deca3f14b9ead487536cb7c94a20dc4c26800a2b)) + +## [1.6.16](https://github.com/googleapis/java-iam/compare/v1.6.15...v1.6.16) (2022-11-20) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.15 ([#539](https://github.com/googleapis/java-iam/issues/539)) ([adafd85](https://github.com/googleapis/java-iam/commit/adafd8543da0fc1552fea7c965c1d1a2ecfda449)) + +## [1.6.15](https://github.com/googleapis/java-iam/compare/v1.6.14...v1.6.15) (2022-11-18) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.14 ([#536](https://github.com/googleapis/java-iam/issues/536)) ([4e15368](https://github.com/googleapis/java-iam/commit/4e15368f6924253fe9e54d08ba7bd1b38b23b944)) + +## [1.6.14](https://github.com/googleapis/java-iam/compare/v1.6.13...v1.6.14) (2022-11-18) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.13 ([#532](https://github.com/googleapis/java-iam/issues/532)) ([66c5b64](https://github.com/googleapis/java-iam/commit/66c5b64e8ad0457b5c9289ac75e581a6b25ca643)) + +## [1.6.13](https://github.com/googleapis/java-iam/compare/v1.6.12...v1.6.13) (2022-11-17) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.12 ([#526](https://github.com/googleapis/java-iam/issues/526)) ([1379eee](https://github.com/googleapis/java-iam/commit/1379eee913abdf9fbf047a869331506df3fce78a)) +* Update dependency io.grpc:grpc-protobuf to v1.51.0 ([#527](https://github.com/googleapis/java-iam/issues/527)) ([3d93f1d](https://github.com/googleapis/java-iam/commit/3d93f1d50e814122b39400ff385226c5b47f67f4)) +* Update dependency io.grpc:grpc-stub to v1.51.0 ([#528](https://github.com/googleapis/java-iam/issues/528)) ([7e42c24](https://github.com/googleapis/java-iam/commit/7e42c24069fe81ec2430b3a03777a1aad8275b66)) + +## [1.6.12](https://github.com/googleapis/java-iam/compare/v1.6.11...v1.6.12) (2022-11-16) + + +### Dependencies + +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.13.0 ([#522](https://github.com/googleapis/java-iam/issues/522)) ([37e4984](https://github.com/googleapis/java-iam/commit/37e4984d96e78117225ccccaf807386f6b699e04)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.11 ([#521](https://github.com/googleapis/java-iam/issues/521)) ([dd07607](https://github.com/googleapis/java-iam/commit/dd07607d4de0dfb6b1f0852fcaf18c9c035c5467)) + +## [1.6.11](https://github.com/googleapis/java-iam/compare/v1.6.10...v1.6.11) (2022-11-15) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.10 ([#518](https://github.com/googleapis/java-iam/issues/518)) ([93a1e60](https://github.com/googleapis/java-iam/commit/93a1e60f4feb89a1ff1104aa890df01764d99944)) + +## [1.6.10](https://github.com/googleapis/java-iam/compare/v1.6.9...v1.6.10) (2022-11-14) + + +### Dependencies + +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20221108-2.0.0 ([#514](https://github.com/googleapis/java-iam/issues/514)) ([c754e5a](https://github.com/googleapis/java-iam/commit/c754e5af64a4e67c9fd8b3db8019e208f39da3ba)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.9 ([#513](https://github.com/googleapis/java-iam/issues/513)) ([e7e1836](https://github.com/googleapis/java-iam/commit/e7e18368d573f333057faead618bc24ad2199e6c)) + +## [1.6.9](https://github.com/googleapis/java-iam/compare/v1.6.8...v1.6.9) (2022-11-09) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.8 ([#509](https://github.com/googleapis/java-iam/issues/509)) ([706621d](https://github.com/googleapis/java-iam/commit/706621d7a70ddc29a69230416dc723508629eac1)) + +## [1.6.8](https://github.com/googleapis/java-iam/compare/v1.6.7...v1.6.8) (2022-11-08) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.6 ([#506](https://github.com/googleapis/java-iam/issues/506)) ([cc4c8aa](https://github.com/googleapis/java-iam/commit/cc4c8aa4dccb6ae97e95a9d176a9ffea5a16dc38)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.7 ([#502](https://github.com/googleapis/java-iam/issues/502)) ([b31c868](https://github.com/googleapis/java-iam/commit/b31c8686ab53b82589bc080e19aa2187457c92ee)) + +## [1.6.7](https://github.com/googleapis/java-iam/compare/v1.6.6...v1.6.7) (2022-10-31) + + +### Dependencies + +* Update dependency com.google.api:api-common to v2.2.2 ([#497](https://github.com/googleapis/java-iam/issues/497)) ([bfcb37f](https://github.com/googleapis/java-iam/commit/bfcb37f9d46553a13a51bc8c437b6af046cb3c6c)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.6 ([#492](https://github.com/googleapis/java-iam/issues/492)) ([cb7b782](https://github.com/googleapis/java-iam/commit/cb7b782017eb0ecf4914e4a1de252706bec70d6f)) +* Update dependency com.google.http-client:google-http-client-jackson2 to v1.42.3 ([#498](https://github.com/googleapis/java-iam/issues/498)) ([002b226](https://github.com/googleapis/java-iam/commit/002b2266fd9db19bade62e219970e7050d2bbbc0)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.9 ([#495](https://github.com/googleapis/java-iam/issues/495)) ([ef4f95b](https://github.com/googleapis/java-iam/commit/ef4f95b393a02b96f41743b3bcd8349dda0f9822)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.9 ([#493](https://github.com/googleapis/java-iam/issues/493)) ([fb776ce](https://github.com/googleapis/java-iam/commit/fb776ce04129a55ea9ff0b964df624b64b5865a4)) + +## [1.6.6](https://github.com/googleapis/java-iam/compare/v1.6.5...v1.6.6) (2022-10-25) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.5 ([#489](https://github.com/googleapis/java-iam/issues/489)) ([ab8be40](https://github.com/googleapis/java-iam/commit/ab8be4088259b25799aa5df0e7cfe944a7da7956)) + +## [1.6.5](https://github.com/googleapis/java-iam/compare/v1.6.4...v1.6.5) (2022-10-24) + + +### Dependencies + +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20221016-2.0.0 ([#479](https://github.com/googleapis/java-iam/issues/479)) ([728084c](https://github.com/googleapis/java-iam/commit/728084cba18609a511dd04d67a59a8b0a4c2a63d)) +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.12.1 ([#478](https://github.com/googleapis/java-iam/issues/478)) ([94e2ca1](https://github.com/googleapis/java-iam/commit/94e2ca1930ec67bf1d837e044c8a72d64b6eae45)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.5 ([#486](https://github.com/googleapis/java-iam/issues/486)) ([292042e](https://github.com/googleapis/java-iam/commit/292042ea315d3bff5b07e86b73d82fa290364a8a)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.4 ([#475](https://github.com/googleapis/java-iam/issues/475)) ([b86f46c](https://github.com/googleapis/java-iam/commit/b86f46cd9115b5d07d867766e37d402d054768a2)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.8 ([#481](https://github.com/googleapis/java-iam/issues/481)) ([cb74130](https://github.com/googleapis/java-iam/commit/cb741301c1add6eb5e790de44caa7961e2ea055d)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.8 ([#482](https://github.com/googleapis/java-iam/issues/482)) ([176de6c](https://github.com/googleapis/java-iam/commit/176de6cb499db8fde987f69df35038d9872fad25)) +* Update dependency io.grpc:grpc-protobuf to v1.50.0 ([#476](https://github.com/googleapis/java-iam/issues/476)) ([358383f](https://github.com/googleapis/java-iam/commit/358383fef13874226454c05464a615651ec5b0fb)) +* Update dependency io.grpc:grpc-protobuf to v1.50.2 ([#483](https://github.com/googleapis/java-iam/issues/483)) ([3c9999b](https://github.com/googleapis/java-iam/commit/3c9999b9b4daca5aa343005ca89055f7172ba2dc)) +* Update dependency io.grpc:grpc-stub to v1.50.2 ([#477](https://github.com/googleapis/java-iam/issues/477)) ([e2255ec](https://github.com/googleapis/java-iam/commit/e2255ecfe43a7aef250802cd1829771d4b3691d8)) + +## [1.6.4](https://github.com/googleapis/java-iam/compare/v1.6.3...v1.6.4) (2022-10-10) + + +### Dependencies + +* Update dependency com.google.cloud:google-iam-policy to v1.6.3 ([#472](https://github.com/googleapis/java-iam/issues/472)) ([8f911be](https://github.com/googleapis/java-iam/commit/8f911bef57b66ab9dd092ed7912702c038e8565e)) + +## [1.6.3](https://github.com/googleapis/java-iam/compare/v1.6.2...v1.6.3) (2022-10-07) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#468](https://github.com/googleapis/java-iam/issues/468)) ([f6be604](https://github.com/googleapis/java-iam/commit/f6be6047506561a7b6f1dc5b5ea925207075d3ac)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.2 ([#467](https://github.com/googleapis/java-iam/issues/467)) ([0af193b](https://github.com/googleapis/java-iam/commit/0af193bbcedcfa7e7e9b53eaeb509fba5df974b3)) + +## [1.6.2](https://github.com/googleapis/java-iam/compare/v1.6.1...v1.6.2) (2022-10-02) + + +### Documentation + +* **samples:** Update package names to match v2 ([#424](https://github.com/googleapis/java-iam/issues/424)) ([7fda749](https://github.com/googleapis/java-iam/commit/7fda74962365073996bf1f0a6229bbf8984d1d09)) + + +### Dependencies + +* Update dependency cachetools to v5 ([#459](https://github.com/googleapis/java-iam/issues/459)) ([3984974](https://github.com/googleapis/java-iam/commit/3984974630ccd0921f12d276dbc22eb6798e74a9)) +* Update dependency certifi to v2022.9.24 ([#440](https://github.com/googleapis/java-iam/issues/440)) ([e0ebd9e](https://github.com/googleapis/java-iam/commit/e0ebd9e20a25e6edf7b913dea0943909ec28effb)) +* Update dependency charset-normalizer to v2.1.1 ([#444](https://github.com/googleapis/java-iam/issues/444)) ([4bac18b](https://github.com/googleapis/java-iam/commit/4bac18bd92702502730b878f10dcb12b39dfa1cf)) +* Update dependency click to v8.1.3 ([#445](https://github.com/googleapis/java-iam/issues/445)) ([e21bea2](https://github.com/googleapis/java-iam/commit/e21bea21af318e34220a649e9ec4bd9214f11feb)) +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220911-2.0.0 ([#435](https://github.com/googleapis/java-iam/issues/435)) ([63a136b](https://github.com/googleapis/java-iam/commit/63a136b56dff577ac1e630293c80bd10539c1930)) +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220925-2.0.0 ([#439](https://github.com/googleapis/java-iam/issues/439)) ([85b1d0f](https://github.com/googleapis/java-iam/commit/85b1d0f68950095c3ffd1ecda7eedc82ac5a92b1)) +* Update dependency com.google.cloud:google-iam-policy to v1.6.1 ([#434](https://github.com/googleapis/java-iam/issues/434)) ([b468d86](https://github.com/googleapis/java-iam/commit/b468d86fdeb55b3f463a5c03c61f37f467bfeef6)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.7 ([#463](https://github.com/googleapis/java-iam/issues/463)) ([a58810f](https://github.com/googleapis/java-iam/commit/a58810f3f6fc641b74cb92d358f71f9461ad9664)) +* Update dependency gcp-releasetool to v1.8.8 ([#441](https://github.com/googleapis/java-iam/issues/441)) ([89469a8](https://github.com/googleapis/java-iam/commit/89469a845e62479ab0f34a219486020d398aaf70)) +* Update dependency google-api-core to v2.10.1 ([#446](https://github.com/googleapis/java-iam/issues/446)) ([69dbd0d](https://github.com/googleapis/java-iam/commit/69dbd0d656656943851a9f5b159b4de0f7665a5d)) +* Update dependency google-auth to v2.12.0 ([#447](https://github.com/googleapis/java-iam/issues/447)) ([10fed85](https://github.com/googleapis/java-iam/commit/10fed85610182533b695fe741fe8e158e7b3799a)) +* Update dependency google-cloud-core to v2.3.2 ([#442](https://github.com/googleapis/java-iam/issues/442)) ([709e0b4](https://github.com/googleapis/java-iam/commit/709e0b407610ee5fec6bb38b695504c245f5d003)) +* Update dependency google-cloud-storage to v2.5.0 ([#448](https://github.com/googleapis/java-iam/issues/448)) ([4ef1f8e](https://github.com/googleapis/java-iam/commit/4ef1f8e6f5317ba339b94613a120d540acd90f57)) +* Update dependency google-crc32c to v1.5.0 ([#449](https://github.com/googleapis/java-iam/issues/449)) ([e54b847](https://github.com/googleapis/java-iam/commit/e54b8479589cb2350356c78c2f2a44a841e8f904)) +* Update dependency googleapis-common-protos to v1.56.4 ([#443](https://github.com/googleapis/java-iam/issues/443)) ([d060a5b](https://github.com/googleapis/java-iam/commit/d060a5b90ba189f1118b4ad899c7a0e9ad39bf44)) +* Update dependency importlib-metadata to v4.12.0 ([#450](https://github.com/googleapis/java-iam/issues/450)) ([248b90a](https://github.com/googleapis/java-iam/commit/248b90a6f715d881856a50e55df45b19a695ff32)) +* Update dependency io.grpc:grpc-protobuf to v1.49.2 ([#464](https://github.com/googleapis/java-iam/issues/464)) ([406e890](https://github.com/googleapis/java-iam/commit/406e89048c62e264dcf93ef5c940734e7367a00f)) +* Update dependency io.grpc:grpc-stub to v1.49.2 ([#465](https://github.com/googleapis/java-iam/issues/465)) ([8735303](https://github.com/googleapis/java-iam/commit/8735303fc9eb7b1198ce2a2019e33ad5f63ec1cf)) +* Update dependency jeepney to v0.8.0 ([#451](https://github.com/googleapis/java-iam/issues/451)) ([0721ab8](https://github.com/googleapis/java-iam/commit/0721ab835c3a0588632916e70b2d92ff51824de6)) +* Update dependency jinja2 to v3.1.2 ([#452](https://github.com/googleapis/java-iam/issues/452)) ([514f80c](https://github.com/googleapis/java-iam/commit/514f80c8f051a8bb2f2fbf19d0e130c12b70ee9a)) +* Update dependency markupsafe to v2.1.1 ([#454](https://github.com/googleapis/java-iam/issues/454)) ([d6123a7](https://github.com/googleapis/java-iam/commit/d6123a709b01e1c40ce8423ebd70ed5a6c4ae4a0)) +* Update dependency protobuf to v3.20.2 ([#455](https://github.com/googleapis/java-iam/issues/455)) ([c9a631a](https://github.com/googleapis/java-iam/commit/c9a631ac0ba852fee31ddd458bb40bd78a081b75)) +* Update dependency protobuf to v4 ([#460](https://github.com/googleapis/java-iam/issues/460)) ([7738293](https://github.com/googleapis/java-iam/commit/773829323697e3c5785eb9b7bf7000fd296921b7)) +* Update dependency pyjwt to v2.5.0 ([#461](https://github.com/googleapis/java-iam/issues/461)) ([5f1659f](https://github.com/googleapis/java-iam/commit/5f1659f2cb1a20d9a034e1f6214ec793d2ef908c)) +* Update dependency requests to v2.28.1 ([#456](https://github.com/googleapis/java-iam/issues/456)) ([c390fee](https://github.com/googleapis/java-iam/commit/c390fee02a5545c567d45cc4375a5eb549d9765f)) +* Update dependency typing-extensions to v4.3.0 ([#457](https://github.com/googleapis/java-iam/issues/457)) ([913effd](https://github.com/googleapis/java-iam/commit/913effd62b170e96ebd74456b02692f462cedc40)) +* Update dependency zipp to v3.8.1 ([#458](https://github.com/googleapis/java-iam/issues/458)) ([5afe18a](https://github.com/googleapis/java-iam/commit/5afe18a7c6c0ef89b603455cea5569be71b27173)) + +## [1.6.1](https://github.com/googleapis/java-iam/compare/v1.6.0...v1.6.1) (2022-09-21) + + +### Dependencies + +* Update dependency com.google.protobuf:protobuf-java to v3.21.6 ([#425](https://github.com/googleapis/java-iam/issues/425)) ([61cbdf4](https://github.com/googleapis/java-iam/commit/61cbdf4c4ad3c559670cc39c864dfd03f8303667)) + +## [1.6.0](https://github.com/googleapis/java-iam/compare/v1.5.2...v1.6.0) (2022-09-20) + + +### Features + +* Add v2 client ([#423](https://github.com/googleapis/java-iam/issues/423)) ([6b6c24f](https://github.com/googleapis/java-iam/commit/6b6c24f11093d2ccc5e5005337576db7c9626ec0)) +* Update the public IAM Deny v2beta API ([5894873](https://github.com/googleapis/java-iam/commit/58948731feee6462ae75f6fe11c31e36e9ec6fce)) + + +### Documentation + +* **samples:** Update param values ([#401](https://github.com/googleapis/java-iam/issues/401)) ([8879c28](https://github.com/googleapis/java-iam/commit/8879c28cac3543c441be636da626bcc3c10509da)) + + +### Dependencies + +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220710-1.32.1 ([#383](https://github.com/googleapis/java-iam/issues/383)) ([0670b46](https://github.com/googleapis/java-iam/commit/0670b461db649b2be307735aa128e8273d42d38f)) +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220710-2.0.0 ([#396](https://github.com/googleapis/java-iam/issues/396)) ([ec96383](https://github.com/googleapis/java-iam/commit/ec96383900c271ddf96a58772ff459c6879c106f)) +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220731-2.0.0 ([#402](https://github.com/googleapis/java-iam/issues/402)) ([39605e5](https://github.com/googleapis/java-iam/commit/39605e5b1cb4ee9fea068e36a6452e02710ae03d)) +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220807-2.0.0 ([#407](https://github.com/googleapis/java-iam/issues/407)) ([475fa93](https://github.com/googleapis/java-iam/commit/475fa93c1b5affb19eec36856e719041d5bf56af)) +* Update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220828-2.0.0 ([#417](https://github.com/googleapis/java-iam/issues/417)) ([f3b365d](https://github.com/googleapis/java-iam/commit/f3b365df695b61515871c24dd2d14cde015ad599)) +* Update dependency com.google.apis:google-api-services-iam to v2beta-rev20220713-1.32.1 ([#390](https://github.com/googleapis/java-iam/issues/390)) ([9bef280](https://github.com/googleapis/java-iam/commit/9bef280b9c871ad9333daa8f027b8679f91ccbb1)) +* Update dependency com.google.apis:google-api-services-iam to v2beta-rev20220713-2.0.0 ([#403](https://github.com/googleapis/java-iam/issues/403)) ([7a8270b](https://github.com/googleapis/java-iam/commit/7a8270b691b5c749c90185659bd3a51480c3e1c4)) +* Update dependency com.google.apis:google-api-services-iamcredentials to v1-rev20211203-2.0.0 ([#404](https://github.com/googleapis/java-iam/issues/404)) ([ee3537d](https://github.com/googleapis/java-iam/commit/ee3537d763c389d25d887fb1b2cfc61ff4101d65)) +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.10.0 ([#406](https://github.com/googleapis/java-iam/issues/406)) ([56284df](https://github.com/googleapis/java-iam/commit/56284df32ee657a5055e6dea3bd7b25772c218ea)) +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.11.0 ([#419](https://github.com/googleapis/java-iam/issues/419)) ([3375ba3](https://github.com/googleapis/java-iam/commit/3375ba3a5b44d97370233238a63e1a310b5b605a)) +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.8.1 ([#385](https://github.com/googleapis/java-iam/issues/385)) ([e6199b3](https://github.com/googleapis/java-iam/commit/e6199b3c094f606359c8e469a853a283cd82c836)) +* Update dependency com.google.auth:google-auth-library-oauth2-http to v1.9.0 ([#400](https://github.com/googleapis/java-iam/issues/400)) ([aa4e5b6](https://github.com/googleapis/java-iam/commit/aa4e5b6ec5af98925c4353c9393e33c423c67a60)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#395](https://github.com/googleapis/java-iam/issues/395)) ([a88edd6](https://github.com/googleapis/java-iam/commit/a88edd61e1a66c5f48185dd5e8a2a61e5e9a002e)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.1 ([#399](https://github.com/googleapis/java-iam/issues/399)) ([bf814a9](https://github.com/googleapis/java-iam/commit/bf814a9faf878195676937cfe793b4a20fff6f06)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#420](https://github.com/googleapis/java-iam/issues/420)) ([e358921](https://github.com/googleapis/java-iam/commit/e358921e5ade85359a97b6a19af7a8397227c428)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#426](https://github.com/googleapis/java-iam/issues/426)) ([6da2bd2](https://github.com/googleapis/java-iam/commit/6da2bd228c5e3b9f6d9d35e95b955c7fbd65807d)) +* Update dependency com.google.http-client:google-http-client-jackson2 to v1.42.2 ([#386](https://github.com/googleapis/java-iam/issues/386)) ([de1b271](https://github.com/googleapis/java-iam/commit/de1b27180bf93a5c9b5a9a274f9d5a2c2ff5afc1)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.3 ([#391](https://github.com/googleapis/java-iam/issues/391)) ([02a3c56](https://github.com/googleapis/java-iam/commit/02a3c56b1143d497b98e2f437d9b36ea468e36ea)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.4 ([#393](https://github.com/googleapis/java-iam/issues/393)) ([f4c649b](https://github.com/googleapis/java-iam/commit/f4c649b67c0a8fa950487b3e3b2f10ab85136165)) +* Update dependency com.google.protobuf:protobuf-java to v3.21.5 ([#405](https://github.com/googleapis/java-iam/issues/405)) ([66b27cb](https://github.com/googleapis/java-iam/commit/66b27cb9722cac68af7844447524f149fb08b3b0)) +* Update dependency io.grpc:grpc-protobuf to v1.48.0 ([#388](https://github.com/googleapis/java-iam/issues/388)) ([d7beea4](https://github.com/googleapis/java-iam/commit/d7beea4de4aff35f998b017c6d6136c76ec1e36b)) +* Update dependency io.grpc:grpc-protobuf to v1.48.1 ([#397](https://github.com/googleapis/java-iam/issues/397)) ([512a655](https://github.com/googleapis/java-iam/commit/512a6554067bbbe9ac400f833a0a8cd4bfaef785)) +* Update dependency io.grpc:grpc-protobuf to v1.49.0 ([#413](https://github.com/googleapis/java-iam/issues/413)) ([93ac43d](https://github.com/googleapis/java-iam/commit/93ac43deb5a663bd22b5d14f8ba7a4bdff6928cd)) +* Update dependency io.grpc:grpc-protobuf to v1.49.1 ([#427](https://github.com/googleapis/java-iam/issues/427)) ([c7b26dd](https://github.com/googleapis/java-iam/commit/c7b26dd62e4b22634f15e4eb19d96c3dfc919d11)) +* Update dependency io.grpc:grpc-stub to v1.48.0 ([#389](https://github.com/googleapis/java-iam/issues/389)) ([c76beb0](https://github.com/googleapis/java-iam/commit/c76beb01ba7a59cdfe60fc498f33881faadafe89)) +* Update dependency io.grpc:grpc-stub to v1.48.1 ([#398](https://github.com/googleapis/java-iam/issues/398)) ([4917a59](https://github.com/googleapis/java-iam/commit/4917a59ae856825e6e96a5b3ca0d766b8a931de6)) +* Update dependency io.grpc:grpc-stub to v1.49.0 ([#414](https://github.com/googleapis/java-iam/issues/414)) ([1d98460](https://github.com/googleapis/java-iam/commit/1d9846000bf41f20907dfcbc11574e88f91cc8f8)) +* Update dependency io.grpc:grpc-stub to v1.49.1 ([#428](https://github.com/googleapis/java-iam/issues/428)) ([ad6f449](https://github.com/googleapis/java-iam/commit/ad6f449c6fdfbf91a89561359ef2f124e9d8dfa2)) + +## [1.5.2](https://github.com/googleapis/java-iam/compare/v1.5.1...v1.5.2) (2022-07-13) + + +### Bug Fixes + +* enable longpaths support for windows test ([#1485](https://github.com/googleapis/java-iam/issues/1485)) ([#381](https://github.com/googleapis/java-iam/issues/381)) ([436496a](https://github.com/googleapis/java-iam/commit/436496a0c8d710bca7df3bf3d1dd96ce2d8099a8)) + +## [1.5.1](https://github.com/googleapis/java-iam/compare/v1.5.0...v1.5.1) (2022-07-12) + + +### Documentation + +* **samples:** add iam deny samples and test ([#371](https://github.com/googleapis/java-iam/issues/371)) ([c503444](https://github.com/googleapis/java-iam/commit/c50344450dcaaeed31ea33c494edf507c9b6ff6b)) + + +### Dependencies + +* update dependency com.google.apis:google-api-services-cloudresourcemanager to v3-rev20220619-1.32.1 ([#375](https://github.com/googleapis/java-iam/issues/375)) ([9102337](https://github.com/googleapis/java-iam/commit/91023372c5ba198e428e0a5f87f657334f65d5da)) +* update dependency com.google.auth:google-auth-library-oauth2-http to v1.8.0 ([#377](https://github.com/googleapis/java-iam/issues/377)) ([2687617](https://github.com/googleapis/java-iam/commit/268761726c8b70010d243b7f0c58db45a6590ef4)) +* update dependency com.google.http-client:google-http-client-jackson2 to v1.42.1 ([#378](https://github.com/googleapis/java-iam/issues/378)) ([7ea1243](https://github.com/googleapis/java-iam/commit/7ea1243a734745d04edba01c75e996737f97eee5)) + +## [1.5.0](https://github.com/googleapis/java-iam/compare/v1.4.1...v1.5.0) (2022-06-30) + + +### Features + +* add v2beta client ([#364](https://github.com/googleapis/java-iam/issues/364)) ([0904baa](https://github.com/googleapis/java-iam/commit/0904baa7be7dda2b0c8ec9e68ade548d173761fd)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#367](https://github.com/googleapis/java-iam/issues/367)) ([ece5f7d](https://github.com/googleapis/java-iam/commit/ece5f7dda5fcba488f1416593114ba6ab8ab31ef)) +* update dependency com.google.protobuf:protobuf-java to v3.21.2 ([#368](https://github.com/googleapis/java-iam/issues/368)) ([64b6349](https://github.com/googleapis/java-iam/commit/64b6349880792f3a534aa879ca1f0044d25603be)) + +## [1.4.1](https://github.com/googleapis/java-iam/compare/v1.4.0...v1.4.1) (2022-06-13) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.2.1 ([#358](https://github.com/googleapis/java-iam/issues/358)) ([e70e79f](https://github.com/googleapis/java-iam/commit/e70e79f3a8e6f3e2deac17d57489a5d6266e3e44)) +* update dependency com.google.protobuf:protobuf-java to v3.21.0 ([#354](https://github.com/googleapis/java-iam/issues/354)) ([0856c38](https://github.com/googleapis/java-iam/commit/0856c38dbc50cbe785e4f92a2f8ae55683a09613)) +* update dependency com.google.protobuf:protobuf-java to v3.21.1 ([#355](https://github.com/googleapis/java-iam/issues/355)) ([91c7aa3](https://github.com/googleapis/java-iam/commit/91c7aa3b03c30dbea09baf0eb674e92f5605b14d)) +* update dependency io.grpc:grpc-protobuf to v1.47.0 ([#356](https://github.com/googleapis/java-iam/issues/356)) ([560c161](https://github.com/googleapis/java-iam/commit/560c1614ca01e56479a4a8a732f3575f243076ef)) +* update dependency io.grpc:grpc-stub to v1.47.0 ([#357](https://github.com/googleapis/java-iam/issues/357)) ([37b9061](https://github.com/googleapis/java-iam/commit/37b906144fee70a5050c8e67e820435b2d42f781)) + +## [1.4.0](https://github.com/googleapis/java-iam/compare/v1.3.4...v1.4.0) (2022-05-19) + + +### Features + +* add build scripts for native image testing in Java 17 ([#1440](https://github.com/googleapis/java-iam/issues/1440)) ([#350](https://github.com/googleapis/java-iam/issues/350)) ([e83f148](https://github.com/googleapis/java-iam/commit/e83f148350c6e208f0290bf100f5b35461024073)) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.2.0 ([#348](https://github.com/googleapis/java-iam/issues/348)) ([2013a52](https://github.com/googleapis/java-iam/commit/2013a526838de4d21694d59d256f48bf5976b109)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.12.0 ([#349](https://github.com/googleapis/java-iam/issues/349)) ([e458fbe](https://github.com/googleapis/java-iam/commit/e458fbe851f27fd2a3c0ea487f71ddccc88173f7)) + +### [1.3.4](https://github.com/googleapis/java-iam/compare/v1.3.3...v1.3.4) (2022-05-10) + + +### Dependencies + +* update dependency io.grpc:grpc-protobuf to v1.46.0 ([#340](https://github.com/googleapis/java-iam/issues/340)) ([8ed87ef](https://github.com/googleapis/java-iam/commit/8ed87ef24ba184a1b1b386554aca94ae1fbbf9e6)) +* update dependency io.grpc:grpc-stub to v1.46.0 ([#341](https://github.com/googleapis/java-iam/issues/341)) ([92c7276](https://github.com/googleapis/java-iam/commit/92c72768d6ea7715da121c5504b95e598de770a0)) + +### [1.3.3](https://github.com/googleapis/java-iam/compare/v1.3.2...v1.3.3) (2022-04-22) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-java to v3.20.1 ([#337](https://github.com/googleapis/java-iam/issues/337)) ([83302e1](https://github.com/googleapis/java-iam/commit/83302e12860ca82234bd3f74234c373164e27ffb)) + +### [1.3.2](https://github.com/googleapis/java-iam/compare/v1.3.1...v1.3.2) (2022-04-15) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.10.0 ([#332](https://github.com/googleapis/java-iam/issues/332)) ([78e6341](https://github.com/googleapis/java-iam/commit/78e6341388c63e6eabeb5fbb3ab21bbdc965ddef)) + +### [1.3.1](https://github.com/googleapis/java-iam/compare/v1.3.0...v1.3.1) (2022-04-11) + + +### Dependencies + +* revert dependency com.google.protobuf:protobuf-java to v3.19.4 ([#329](https://github.com/googleapis/java-iam/issues/329)) ([0e679c5](https://github.com/googleapis/java-iam/commit/0e679c5b63ac438f3f3f53b5a920c876450e0a94)) + +## [1.3.0](https://github.com/googleapis/java-iam/compare/v1.2.12...v1.3.0) (2022-04-05) + + +### Features + +* AuditConfig for IAM v1 ([#325](https://github.com/googleapis/java-iam/issues/325)) ([6798520](https://github.com/googleapis/java-iam/commit/6798520ca2b4b98f16492d4bb16be38e9eef3e36)) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-java to v3.20.0 ([#324](https://github.com/googleapis/java-iam/issues/324)) ([c6209ac](https://github.com/googleapis/java-iam/commit/c6209ac7e33059d5169c65e86145bc25731e40e4)) +* update dependency io.grpc:grpc-protobuf to v1.45.1 ([#321](https://github.com/googleapis/java-iam/issues/321)) ([9dc32a4](https://github.com/googleapis/java-iam/commit/9dc32a4ba44803bdd8aed85d44ee4aebddc3f972)) +* update dependency io.grpc:grpc-stub to v1.45.1 ([#322](https://github.com/googleapis/java-iam/issues/322)) ([b114670](https://github.com/googleapis/java-iam/commit/b11467055d678e7474bb4ed4bb6d74184029ed5d)) + +### [1.2.12](https://github.com/googleapis/java-iam/compare/v1.2.11...v1.2.12) (2022-03-29) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.9.0 ([#318](https://github.com/googleapis/java-iam/issues/318)) ([9c856cb](https://github.com/googleapis/java-iam/commit/9c856cb07e8bea3fb50d627afb6dc054cc8859b2)) + +### [1.2.11](https://github.com/googleapis/java-iam/compare/v1.2.10...v1.2.11) (2022-03-25) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.5 ([#313](https://github.com/googleapis/java-iam/issues/313)) ([b52eee2](https://github.com/googleapis/java-iam/commit/b52eee23a3b6c2b51bbc19929f58f9c5215fb3f4)) + +### [1.2.10](https://github.com/googleapis/java-iam/compare/v1.2.9...v1.2.10) (2022-03-10) + + +### Dependencies + +* update dependency io.grpc:grpc-protobuf to v1.45.0 ([#310](https://github.com/googleapis/java-iam/issues/310)) ([2abec16](https://github.com/googleapis/java-iam/commit/2abec16ca95bffd6c3bdcaf4c98c53f8cb118a59)) + +### [1.2.9](https://github.com/googleapis/java-iam/compare/v1.2.8...v1.2.9) (2022-03-09) + + +### Dependencies + +* update dependency io.grpc:grpc-stub to v1.45.0 ([#307](https://github.com/googleapis/java-iam/issues/307)) ([756e6b0](https://github.com/googleapis/java-iam/commit/756e6b0399cfd29006a1c3f8e5bca9e6ef9892bc)) + +### [1.2.8](https://github.com/googleapis/java-iam/compare/v1.2.7...v1.2.8) (2022-03-08) + + +### Dependencies + +* update actions/checkout action to v3 ([#297](https://github.com/googleapis/java-iam/issues/297)) ([868362a](https://github.com/googleapis/java-iam/commit/868362ad7b801e79409e2415e51aee858055334c)) + +### [1.2.7](https://github.com/googleapis/java-iam/compare/v1.2.6...v1.2.7) (2022-03-02) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.8.0 ([#299](https://github.com/googleapis/java-iam/issues/299)) ([6cf3f84](https://github.com/googleapis/java-iam/commit/6cf3f841fff069816b02e40e98b4dc22ebfd06e5)) + +### [1.2.6](https://github.com/googleapis/java-iam/compare/v1.2.5...v1.2.6) (2022-03-01) + + +### Dependencies + +* update dependency io.grpc:grpc-protobuf to v1.44.1 ([#290](https://github.com/googleapis/java-iam/issues/290)) ([47cd461](https://github.com/googleapis/java-iam/commit/47cd461fd06a1529f6dc928a9e76893ebb489a39)) +* update dependency io.grpc:grpc-stub to v1.44.1 ([#291](https://github.com/googleapis/java-iam/issues/291)) ([83a2206](https://github.com/googleapis/java-iam/commit/83a2206864380ac1e4ed94af364a5809e32d358c)) + +### [1.2.5](https://github.com/googleapis/java-iam/compare/v1.2.4...v1.2.5) (2022-02-17) + + +### Dependencies + +* update actions/github-script action to v6 ([#287](https://github.com/googleapis/java-iam/issues/287)) ([eb96321](https://github.com/googleapis/java-iam/commit/eb96321d998fa6acf7285c878c4c044535a54af5)) + +### [1.2.4](https://github.com/googleapis/java-iam/compare/v1.2.3...v1.2.4) (2022-02-11) + + +### Dependencies + +* update actions/github-script action to v6 ([#284](https://github.com/googleapis/java-iam/issues/284)) ([4ab2967](https://github.com/googleapis/java-iam/commit/4ab2967034373c322df5f6a37ab5e66d3d38ae2b)) + +### [1.2.3](https://github.com/googleapis/java-iam/compare/v1.2.2...v1.2.3) (2022-02-08) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.4 ([#280](https://github.com/googleapis/java-iam/issues/280)) ([cabdb90](https://github.com/googleapis/java-iam/commit/cabdb90c8dca2a27a25318c07c03de2a6c45af1e)) + +### [1.2.2](https://github.com/googleapis/java-iam/compare/v1.2.1...v1.2.2) (2022-02-03) + + +### Dependencies + +* **java:** update actions/github-script action to v5 ([#1339](https://github.com/googleapis/java-iam/issues/1339)) ([#267](https://github.com/googleapis/java-iam/issues/267)) ([afbdd89](https://github.com/googleapis/java-iam/commit/afbdd893410c9d64c6c6d0f1b74c309000eff36c)) +* update dependency com.google.api:api-common to v2.1.3 ([#271](https://github.com/googleapis/java-iam/issues/271)) ([6668de8](https://github.com/googleapis/java-iam/commit/6668de8094446a57285f32c41487ab69be771d31)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.7.0 ([#273](https://github.com/googleapis/java-iam/issues/273)) ([97081c0](https://github.com/googleapis/java-iam/commit/97081c0facc1a32cc0bc705f1f7a7d4cddb8a558)) +* update dependency com.google.protobuf:protobuf-java to v3.19.3 ([#262](https://github.com/googleapis/java-iam/issues/262)) ([38187e9](https://github.com/googleapis/java-iam/commit/38187e92462656ba6cdb4f85e87b3fe577f0f212)) +* update dependency com.google.protobuf:protobuf-java to v3.19.4 ([#272](https://github.com/googleapis/java-iam/issues/272)) ([b82ca63](https://github.com/googleapis/java-iam/commit/b82ca6382332c37813916e379f3849c1b6ef7385)) +* update dependency io.grpc:grpc-protobuf to v1.44.0 ([#269](https://github.com/googleapis/java-iam/issues/269)) ([fb94161](https://github.com/googleapis/java-iam/commit/fb941613e346fc6ae5fd46beff0e899061d78653)) +* update dependency io.grpc:grpc-stub to v1.44.0 ([#270](https://github.com/googleapis/java-iam/issues/270)) ([e586dd2](https://github.com/googleapis/java-iam/commit/e586dd27aca076d42c7ff956d66ce025d41f7973)) + +### [1.2.1](https://www.github.com/googleapis/java-iam/compare/v1.2.0...v1.2.1) (2022-01-07) + + +### Bug Fixes + +* **java:** run Maven in plain console-friendly mode ([#1301](https://www.github.com/googleapis/java-iam/issues/1301)) ([#251](https://www.github.com/googleapis/java-iam/issues/251)) ([011932e](https://www.github.com/googleapis/java-iam/commit/011932e2c0a1c9d1444cef5e25420616c604b91e)) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.2 ([#256](https://www.github.com/googleapis/java-iam/issues/256)) ([29c0f8d](https://www.github.com/googleapis/java-iam/commit/29c0f8dad438424400fbeaffd54d00326ce0954d)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.6.0 ([#257](https://www.github.com/googleapis/java-iam/issues/257)) ([8d41821](https://www.github.com/googleapis/java-iam/commit/8d4182108e826f9f0a236ece2fb19f96c1c65e88)) +* update dependency com.google.protobuf:protobuf-java to v3.19.2 ([#254](https://www.github.com/googleapis/java-iam/issues/254)) ([38dd15b](https://www.github.com/googleapis/java-iam/commit/38dd15b8afb5d3f0238e4f0d1323003b04425ff2)) +* update dependency io.grpc:grpc-protobuf to v1.43.2 ([#246](https://www.github.com/googleapis/java-iam/issues/246)) ([5f752dd](https://www.github.com/googleapis/java-iam/commit/5f752ddd31d3c3ac314aa792a8ed4eca35b53f81)) +* update dependency io.grpc:grpc-stub to v1.43.2 ([#247](https://www.github.com/googleapis/java-iam/issues/247)) ([1c60bb5](https://www.github.com/googleapis/java-iam/commit/1c60bb5f559fba678e6c20e52bd6f412a4032435)) + +## [1.2.0](https://www.github.com/googleapis/java-iam/compare/v1.1.7...v1.2.0) (2021-12-06) + + +### Features + +* Introduce Native Image testing build script changes ([#219](https://www.github.com/googleapis/java-iam/issues/219)) ([58c9a81](https://www.github.com/googleapis/java-iam/commit/58c9a81c55274b64c5e6877c9f909466a672c385)) + + +### Bug Fixes + +* **java:** add -ntp flag to native image testing command ([#1299](https://www.github.com/googleapis/java-iam/issues/1299)) ([#244](https://www.github.com/googleapis/java-iam/issues/244)) ([1a32e01](https://www.github.com/googleapis/java-iam/commit/1a32e01dc223e8ff11ff6483f1f7ae49f43b8de1)) +* **java:** java 17 dependency arguments ([#228](https://www.github.com/googleapis/java-iam/issues/228)) ([e609515](https://www.github.com/googleapis/java-iam/commit/e6095159733fb75e0fcc0620c7e6c93ef9586489)) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.0 ([#225](https://www.github.com/googleapis/java-iam/issues/225)) ([ec4debe](https://www.github.com/googleapis/java-iam/commit/ec4debeb779d3561d6ce10d2bc7f871a1f84ae8c)) +* update dependency com.google.api:api-common to v2.1.1 ([#239](https://www.github.com/googleapis/java-iam/issues/239)) ([40da45b](https://www.github.com/googleapis/java-iam/commit/40da45bffe1ab87036e9d90121e9e9ed302d86a3)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.0 ([#237](https://www.github.com/googleapis/java-iam/issues/237)) ([8dd21a9](https://www.github.com/googleapis/java-iam/commit/8dd21a9bf054701abdded0e6dd231e08452c13af)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.1 ([#243](https://www.github.com/googleapis/java-iam/issues/243)) ([fb72c8c](https://www.github.com/googleapis/java-iam/commit/fb72c8c4c19a580be8f17ee1ec5562c3200f37fb)) +* update dependency com.google.protobuf:protobuf-java to v3.19.1 ([#223](https://www.github.com/googleapis/java-iam/issues/223)) ([744abaf](https://www.github.com/googleapis/java-iam/commit/744abaf723ee59e5749bde76be6520f2e9e843e9)) +* update dependency io.grpc:grpc-protobuf to v1.42.0 ([#230](https://www.github.com/googleapis/java-iam/issues/230)) ([36a09e7](https://www.github.com/googleapis/java-iam/commit/36a09e753f1439d1975c5b388d460d84646f9190)) +* update dependency io.grpc:grpc-protobuf to v1.42.1 ([#235](https://www.github.com/googleapis/java-iam/issues/235)) ([1a3b49c](https://www.github.com/googleapis/java-iam/commit/1a3b49c3841709a4be09c342bc756c2824eba27c)) +* update dependency io.grpc:grpc-stub to v1.42.0 ([#231](https://www.github.com/googleapis/java-iam/issues/231)) ([d1903a9](https://www.github.com/googleapis/java-iam/commit/d1903a91193b22a1ec9ceac79770bf6ae6ea24d5)) +* update dependency io.grpc:grpc-stub to v1.42.1 ([#236](https://www.github.com/googleapis/java-iam/issues/236)) ([efa953f](https://www.github.com/googleapis/java-iam/commit/efa953f548cbf563fa88ee70ed538f898797c0f4)) + +### [1.1.7](https://www.github.com/googleapis/java-iam/compare/v1.1.6...v1.1.7) (2021-10-19) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.4.0 ([#220](https://www.github.com/googleapis/java-iam/issues/220)) ([dece964](https://www.github.com/googleapis/java-iam/commit/dece9643c9500a9f9c76e8fddee700447b4f6ab8)) + +### [1.1.6](https://www.github.com/googleapis/java-iam/compare/v1.1.5...v1.1.6) (2021-10-08) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.0.5 ([#214](https://www.github.com/googleapis/java-iam/issues/214)) ([f8b8caf](https://www.github.com/googleapis/java-iam/commit/f8b8cafd4e8c7617cac3a2ef4aaa855e4a1dbd8a)) + +### [1.1.5](https://www.github.com/googleapis/java-iam/compare/v1.1.4...v1.1.5) (2021-10-06) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.0.4 ([#210](https://www.github.com/googleapis/java-iam/issues/210)) ([8986cea](https://www.github.com/googleapis/java-iam/commit/8986cea79bb26b4a19014f81a557ed39711ac0d1)) + +### [1.1.4](https://www.github.com/googleapis/java-iam/compare/v1.1.3...v1.1.4) (2021-10-06) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-java to v3.18.1 ([#207](https://www.github.com/googleapis/java-iam/issues/207)) ([8dc9164](https://www.github.com/googleapis/java-iam/commit/8dc91645300940d9a20ff174e15c30bf34edda5e)) + +### [1.1.3](https://www.github.com/googleapis/java-iam/compare/v1.1.2...v1.1.3) (2021-09-24) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.3.0 ([#197](https://www.github.com/googleapis/java-iam/issues/197)) ([8594f40](https://www.github.com/googleapis/java-iam/commit/8594f4074be618506a553ba4436a6fc4fd9993ff)) +* update dependency io.grpc:grpc-protobuf to v1.41.0 ([#198](https://www.github.com/googleapis/java-iam/issues/198)) ([7862c1d](https://www.github.com/googleapis/java-iam/commit/7862c1de5798ed933279521e19cb2b4c6181871b)) +* update dependency io.grpc:grpc-stub to v1.41.0 ([#199](https://www.github.com/googleapis/java-iam/issues/199)) ([bf30e86](https://www.github.com/googleapis/java-iam/commit/bf30e86f21729716838e38a6527c16b2b09bc600)) + +### [1.1.2](https://www.github.com/googleapis/java-iam/compare/v1.1.1...v1.1.2) (2021-09-15) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-java to v3.18.0 ([#192](https://www.github.com/googleapis/java-iam/issues/192)) ([5f8f8f7](https://www.github.com/googleapis/java-iam/commit/5f8f8f7e69de53530425ab416c3b1dd21a2ce783)) + +### [1.1.1](https://www.github.com/googleapis/java-iam/compare/v1.1.0...v1.1.1) (2021-09-14) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.10.6 ([#178](https://www.github.com/googleapis/java-iam/issues/178)) ([05754fa](https://www.github.com/googleapis/java-iam/commit/05754fa01b0cb71e7c0e8be5c5947abd8301e55f)) +* update dependency com.google.api:api-common to v2 ([#182](https://www.github.com/googleapis/java-iam/issues/182)) ([87b589f](https://www.github.com/googleapis/java-iam/commit/87b589f978d94d465ab4d067584305d834f8be0e)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.0 ([#183](https://www.github.com/googleapis/java-iam/issues/183)) ([049d5bf](https://www.github.com/googleapis/java-iam/commit/049d5bf50d690765e8eef20e9eb098c13068b559)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.1 ([#189](https://www.github.com/googleapis/java-iam/issues/189)) ([c450ac3](https://www.github.com/googleapis/java-iam/commit/c450ac3e3e409f51e60015a501843f8de3d8eb8e)) +* update dependency io.grpc:grpc-protobuf to v1.40.1 ([#180](https://www.github.com/googleapis/java-iam/issues/180)) ([c1eeb9c](https://www.github.com/googleapis/java-iam/commit/c1eeb9cbf5dbaa21a3e9524d5f97807e5b0fb909)) +* update dependency io.grpc:grpc-stub to v1.40.1 ([#181](https://www.github.com/googleapis/java-iam/issues/181)) ([a5dbb9e](https://www.github.com/googleapis/java-iam/commit/a5dbb9e395e769f1604ab87c844ab5fe67a8a850)) + +## [1.1.0](https://www.github.com/googleapis/java-iam/compare/v1.0.14...v1.1.0) (2021-08-23) + + +### Features + +* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#148](https://www.github.com/googleapis/java-iam/issues/148)) ([05ef13b](https://www.github.com/googleapis/java-iam/commit/05ef13bfcf31bc8ef7d99bead3f3d9d4d4ffa8f9)) + + +### Bug Fixes + +* Add `shopt -s nullglob` to dependencies script ([#157](https://www.github.com/googleapis/java-iam/issues/157)) ([dcdffb7](https://www.github.com/googleapis/java-iam/commit/dcdffb70f9bba71121061a7def1b9d39525a9514)) +* Update dependencies.sh to not break on mac ([#155](https://www.github.com/googleapis/java-iam/issues/155)) ([f3993d8](https://www.github.com/googleapis/java-iam/commit/f3993d83efceda7f06e9da2624f418f6c69984e8)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.2.0 ([#147](https://www.github.com/googleapis/java-iam/issues/147)) ([ac861d0](https://www.github.com/googleapis/java-iam/commit/ac861d07dea6348cc1f8dc4cac991044f6f0702c)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.3.0 ([#154](https://www.github.com/googleapis/java-iam/issues/154)) ([6ba854f](https://www.github.com/googleapis/java-iam/commit/6ba854faefc1d4592062dbbeda0c3226bcb1412c)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.4.0 ([#158](https://www.github.com/googleapis/java-iam/issues/158)) ([67c523d](https://www.github.com/googleapis/java-iam/commit/67c523dc179802fcbec5a16893b955a4b3b7e4aa)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2 ([#168](https://www.github.com/googleapis/java-iam/issues/168)) ([86c46ff](https://www.github.com/googleapis/java-iam/commit/86c46ffc3f5348771b854f0996cc625f8889b012)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.1.0 ([#173](https://www.github.com/googleapis/java-iam/issues/173)) ([4788fec](https://www.github.com/googleapis/java-iam/commit/4788fecaf84b9772b1a7d866825dd97fa09ac42b)) + +### [1.0.14](https://www.github.com/googleapis/java-iam/compare/v1.0.13...v1.0.14) (2021-05-11) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.1.0 ([#142](https://www.github.com/googleapis/java-iam/issues/142)) ([109ec5e](https://www.github.com/googleapis/java-iam/commit/109ec5ee3d5882fa840d4af6ad49d1a2c237bd28)) + +### [1.0.13](https://www.github.com/googleapis/java-iam/compare/v1.0.12...v1.0.13) (2021-04-23) + + +### Bug Fixes + +* release scripts from issuing overlapping phases ([#132](https://www.github.com/googleapis/java-iam/issues/132)) ([9af3e17](https://www.github.com/googleapis/java-iam/commit/9af3e17ae469bd1b654942e1539a364dac08ac75)) +* typo ([#129](https://www.github.com/googleapis/java-iam/issues/129)) ([42c037a](https://www.github.com/googleapis/java-iam/commit/42c037a09184dd1a03a28b23a1dc8c4eca10cfd0)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.1 ([#133](https://www.github.com/googleapis/java-iam/issues/133)) ([fb23683](https://www.github.com/googleapis/java-iam/commit/fb236830857bbbe17eaa71a1dd9f0ec424e238a3)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1 ([#136](https://www.github.com/googleapis/java-iam/issues/136)) ([be35bdf](https://www.github.com/googleapis/java-iam/commit/be35bdf2b8b8c271e8aba4a493994512bce24e95)) + +### [1.0.12](https://www.github.com/googleapis/java-iam/compare/v1.0.11...v1.0.12) (2021-04-09) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.0 ([#125](https://www.github.com/googleapis/java-iam/issues/125)) ([f06c16c](https://www.github.com/googleapis/java-iam/commit/f06c16cd0cc443cfdc115b299e223147f98f7bfc)) + +### [1.0.11](https://www.github.com/googleapis/java-iam/compare/v1.0.10...v1.0.11) (2021-03-11) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.1 ([#118](https://www.github.com/googleapis/java-iam/issues/118)) ([0268594](https://www.github.com/googleapis/java-iam/commit/02685944cef7c500a2ae28674a2873e40e840504)) + +### [1.0.10](https://www.github.com/googleapis/java-iam/compare/v1.0.9...v1.0.10) (2021-02-25) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.0 ([#112](https://www.github.com/googleapis/java-iam/issues/112)) ([83b637d](https://www.github.com/googleapis/java-iam/commit/83b637d88dba6c456d99b5bf547a765a83a91994)) + +### [1.0.9](https://www.github.com/googleapis/java-iam/compare/v1.0.8...v1.0.9) (2021-02-19) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.19.0 ([#108](https://www.github.com/googleapis/java-iam/issues/108)) ([73c3243](https://www.github.com/googleapis/java-iam/commit/73c32437092c05d8c17f46544c77d39102167a02)) + +### [1.0.8](https://www.github.com/googleapis/java-iam/compare/v1.0.7...v1.0.8) (2021-01-14) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.18.0 ([#87](https://www.github.com/googleapis/java-iam/issues/87)) ([1d2dda2](https://www.github.com/googleapis/java-iam/commit/1d2dda295cb73db94f79c8dc6957c682dbf87182)) + +### [1.0.7](https://www.github.com/googleapis/java-iam/compare/v1.0.6...v1.0.7) (2021-01-13) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.1 ([#85](https://www.github.com/googleapis/java-iam/issues/85)) ([6e80faa](https://www.github.com/googleapis/java-iam/commit/6e80faa75433d1333344b66d632b48ab8e710b08)) + +### [1.0.6](https://www.github.com/googleapis/java-iam/compare/v1.0.5...v1.0.6) (2020-12-15) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.0 ([#80](https://www.github.com/googleapis/java-iam/issues/80)) ([a43419f](https://www.github.com/googleapis/java-iam/commit/a43419f88458f6ea904acea8814164f0d9755b5b)) + +### [1.0.5](https://www.github.com/googleapis/java-iam/compare/v1.0.4...v1.0.5) (2020-12-14) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.1 ([5f7cf81](https://www.github.com/googleapis/java-iam/commit/5f7cf81b8b82447155db8a23b16477a9c5e29a57)) + +### [1.0.4](https://www.github.com/googleapis/java-iam/compare/v1.0.3...v1.0.4) (2020-12-02) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.0 ([#68](https://www.github.com/googleapis/java-iam/issues/68)) ([c8cd19f](https://www.github.com/googleapis/java-iam/commit/c8cd19fa85ebd148b681d354b4807d042ba5308e)) + +### [1.0.3](https://www.github.com/googleapis/java-iam/compare/v1.0.2...v1.0.3) (2020-11-02) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.14.1 ([#61](https://www.github.com/googleapis/java-iam/issues/61)) ([6050071](https://www.github.com/googleapis/java-iam/commit/605007103cd0a18dc30e3b5c5b39118391723d61)) + +### [1.0.2](https://www.github.com/googleapis/java-iam/compare/v1.0.1...v1.0.2) (2020-10-22) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.13.0 ([#53](https://www.github.com/googleapis/java-iam/issues/53)) ([9aeabf1](https://www.github.com/googleapis/java-iam/commit/9aeabf1e63d4b020345a35df75c38151b217775f)) + +### [1.0.1](https://www.github.com/googleapis/java-iam/compare/v1.0.0...v1.0.1) (2020-09-21) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.9.0 ([#30](https://www.github.com/googleapis/java-iam/issues/30)) ([16c878b](https://www.github.com/googleapis/java-iam/commit/16c878bb9b704a97b78393a54dfa59ab06f1327a)) + +## [1.0.0](https://www.github.com/googleapis/java-iam/compare/v0.14.0...v1.0.0) (2020-08-12) + + +### Features + +* promote to 1.0.0 ([#16](https://www.github.com/googleapis/java-iam/issues/16)) ([84ff001](https://www.github.com/googleapis/java-iam/commit/84ff001e68e55145104095bc9193872f5e5623e4)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.6 ([#20](https://www.github.com/googleapis/java-iam/issues/20)) ([2613432](https://www.github.com/googleapis/java-iam/commit/2613432f698b6a857946ab5277d9ee55e6579f77)) + +## [0.14.0](https://www.github.com/googleapis/java-iam/compare/v0.13.0...v0.14.0) (2020-08-11) + + +### Features + +* **deps:** adopt flatten plugin and google-cloud-shared-dependencies ([#14](https://www.github.com/googleapis/java-iam/issues/14)) ([82c4bf5](https://www.github.com/googleapis/java-iam/commit/82c4bf50f419b7f57f9a0d15a554b7e8509b99db)) + + +### Dependencies + +* update dependency com.google.api.grpc:proto-google-common-protos to v1.18.0 ([#2](https://www.github.com/googleapis/java-iam/issues/2)) ([81a7470](https://www.github.com/googleapis/java-iam/commit/81a7470ee9633ff052ccb679cbe37b0079ee51ef)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.2 ([#18](https://www.github.com/googleapis/java-iam/issues/18)) ([13767ef](https://www.github.com/googleapis/java-iam/commit/13767ef1890b5c81cab43baee28a1b535e5b7211)) +* update dependency com.google.protobuf:protobuf-bom to v3.12.0 ([#6](https://www.github.com/googleapis/java-iam/issues/6)) ([73b7a4a](https://www.github.com/googleapis/java-iam/commit/73b7a4a03411326f88e49c2efbd1e34d2170dc1b)) +* update dependency com.google.protobuf:protobuf-bom to v3.12.2 ([#8](https://www.github.com/googleapis/java-iam/issues/8)) ([5f005b4](https://www.github.com/googleapis/java-iam/commit/5f005b45498dc87aeb8cab35d72fbaae04386c24)) +* update dependency io.grpc:grpc-bom to v1.30.0 ([#10](https://www.github.com/googleapis/java-iam/issues/10)) ([f69ac15](https://www.github.com/googleapis/java-iam/commit/f69ac15807aafc345f980091feadd4eb3996976c)) diff --git a/java-iam/README.md b/java-iam/README.md new file mode 100644 index 000000000000..4074f1f0951c --- /dev/null +++ b/java-iam/README.md @@ -0,0 +1,65 @@ +# Google IAM Policy Protos + +Java protobuf classes for IAM Policy. + +[![Maven][maven-version-image]][maven-version-link] +![Stability][stability-image] + +- [Client Library Documentation][javadocs] + +## Java Versions + +Java 7 or above is required for using this client. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +## Contributing + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING][contributing] for more information how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +## CI Status + +| Java Version | Status | +| -------------- | --------------------------------------------------------- | +| Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1] | +| Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2] | +| Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3] | +| Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4] | +| Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5] | + +[javadocs]: https://googleapis.dev/java/google-iam/latest/index.html +[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java7.svg +[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java7.html +[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java8.svg +[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java8.html +[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java8-osx.svg +[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java8-osx.html +[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java8-win.svg +[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java8-win.html +[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java11.svg +[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-iam/java11.html +[stability-image]: https://img.shields.io/badge/stability-ga-green +[maven-version-image]: https://img.shields.io/maven-central/v/com.google.api.grpc/proto-google-iam-v1.svg +[maven-version-link]: https://search.maven.org/search?q=g:com.google.api.grpc%20AND%20a:proto-google-iam-v1&core=gav +[authentication]: https://github.com/googleapis/google-cloud-java#authentication +[developer-console]: https://console.developers.google.com/ +[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects +[cloud-sdk]: https://cloud.google.com/sdk/ +[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/main/troubleshooting/readme.md#troubleshooting +[contributing]: https://github.com/googleapis/java-iam/blob/main/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/java-iam/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[license]: https://github.com/googleapis/java-iam/blob/main/LICENSE +[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing +[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM diff --git a/java-iam/google-iam-policy-bom/pom.xml b/java-iam/google-iam-policy-bom/pom.xml new file mode 100644 index 000000000000..1f36cafa0dd1 --- /dev/null +++ b/java-iam/google-iam-policy-bom/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + com.google.cloud + google-iam-policy-bom + 1.7.1-SNAPSHOT + pom + + + com.google.cloud + google-cloud-pom-parent + 1.4.0-SNAPSHOT + ../../google-cloud-pom-parent/pom.xml + + + Google IAM Policy BOM + + BOM for Google IAM Policy + + + + true + + + + + + com.google.cloud + google-iam-policy + 1.7.1-SNAPSHOT + + + + diff --git a/java-iam/google-iam-policy/pom.xml b/java-iam/google-iam-policy/pom.xml new file mode 100644 index 000000000000..9489d9700e47 --- /dev/null +++ b/java-iam/google-iam-policy/pom.xml @@ -0,0 +1,110 @@ + + + 4.0.0 + com.google.cloud + google-iam-policy + 1.7.1-SNAPSHOT + jar + Google IAM Policy + Eventarc lets you asynchronously deliver events from Google services, SaaS, and your own apps using loosely coupled services that react to state changes. + + com.google.cloud + google-iam-policy-parent + 1.7.1-SNAPSHOT + + + google-iam-policy + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.api + api-common + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + + com.google.api.grpc + proto-google-iam-v2beta + + + com.google.api.grpc + proto-google-iam-v2 + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax-grpc + + + com.google.api + gax-httpjson + + + org.threeten + threetenbp + + + + + junit + junit + test + + + + com.google.api.grpc + grpc-google-iam-v2beta + test + + + com.google.api.grpc + grpc-google-iam-v2 + test + + + + com.google.api + gax + testlib + test + + + com.google.api + gax-grpc + testlib + test + + + com.google.api + gax-httpjson + testlib + test + + + diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesClient.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesClient.java new file mode 100644 index 000000000000..3e57043ffcb0 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesClient.java @@ -0,0 +1,883 @@ +/* + * 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.iam.v2; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.iam.v2.stub.PoliciesStub; +import com.google.iam.v2.stub.PoliciesStubSettings; +import com.google.longrunning.Operation; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: An interface for managing Identity and Access Management (IAM) policies. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ *   String name = "name3373707";
+ *   Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ * + *

Note: close() needs to be called on the PoliciesClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of PoliciesSettings to create(). + * For example: + * + *

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings policiesSettings =
+ *     PoliciesSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings policiesSettings =
+ *     PoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings policiesSettings = PoliciesSettings.newHttpJsonBuilder().build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class PoliciesClient implements BackgroundResource { + private final PoliciesSettings settings; + private final PoliciesStub stub; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; + + /** Constructs an instance of PoliciesClient with default settings. */ + public static final PoliciesClient create() throws IOException { + return create(PoliciesSettings.newBuilder().build()); + } + + /** + * Constructs an instance of PoliciesClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final PoliciesClient create(PoliciesSettings settings) throws IOException { + return new PoliciesClient(settings); + } + + /** + * Constructs an instance of PoliciesClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(PoliciesSettings). + */ + public static final PoliciesClient create(PoliciesStub stub) { + return new PoliciesClient(stub); + } + + /** + * Constructs an instance of PoliciesClient, 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 PoliciesClient(PoliciesSettings settings) throws IOException { + this.settings = settings; + this.stub = ((PoliciesStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + protected PoliciesClient(PoliciesStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + public final PoliciesSettings getSettings() { + return settings; + } + + public PoliciesStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final com.google.longrunning.OperationsClient getOperationsClient() { + return operationsClient; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String parent = "parent-995424086";
+   *   for (Policy element : policiesClient.listPolicies(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The resource that the policy is attached to, along with the kind of + * policy to list. Format: `policies/{attachment_point}/denypolicies` + *

The attachment point is identified by its URL-encoded full resource name, which means + * that the forward-slash character, `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(String parent) { + ListPoliciesRequest request = ListPoliciesRequest.newBuilder().setParent(parent).build(); + return listPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Policy element : policiesClient.listPolicies(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request) { + return listPoliciesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = policiesClient.listPoliciesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Policy element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listPoliciesPagedCallable() { + return stub.listPoliciesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListPoliciesResponse response = policiesClient.listPoliciesCallable().call(request);
+   *     for (Policy element : response.getPoliciesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listPoliciesCallable() { + return stub.listPoliciesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String name = "name3373707";
+   *   Policy response = policiesClient.getPolicy(name);
+   * }
+   * }
+ * + * @param name Required. The resource name of the policy to retrieve. Format: + * `policies/{attachment_point}/denypolicies/{policy_id}` + *

Use the URL-encoded full resource name, which means that the forward-slash character, + * `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(String name) { + GetPolicyRequest request = GetPolicyRequest.newBuilder().setName(name).build(); + return getPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build();
+   *   Policy response = policiesClient.getPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(GetPolicyRequest request) { + return getPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future = policiesClient.getPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getPolicyCallable() { + return stub.getPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String parent = "parent-995424086";
+   *   Policy policy = Policy.newBuilder().build();
+   *   String policyId = "policyId546908653";
+   *   Policy response = policiesClient.createPolicyAsync(parent, policy, policyId).get();
+   * }
+   * }
+ * + * @param parent Required. The resource that the policy is attached to, along with the kind of + * policy to create. Format: `policies/{attachment_point}/denypolicies` + *

The attachment point is identified by its URL-encoded full resource name, which means + * that the forward-slash character, `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @param policy Required. The policy to create. + * @param policyId The ID to use for this policy, which will become the final component of the + * policy's resource name. The ID must contain 3 to 63 characters. It can contain lowercase + * letters and numbers, as well as dashes (`-`) and periods (`.`). The first character must be + * a lowercase letter. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture createPolicyAsync( + String parent, Policy policy, String policyId) { + CreatePolicyRequest request = + CreatePolicyRequest.newBuilder() + .setParent(parent) + .setPolicy(policy) + .setPolicyId(policyId) + .build(); + return createPolicyAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setPolicyId("policyId546908653")
+   *           .build();
+   *   Policy response = policiesClient.createPolicyAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture createPolicyAsync( + CreatePolicyRequest request) { + return createPolicyOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setPolicyId("policyId546908653")
+   *           .build();
+   *   OperationFuture future =
+   *       policiesClient.createPolicyOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + createPolicyOperationCallable() { + return stub.createPolicyOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setPolicyId("policyId546908653")
+   *           .build();
+   *   ApiFuture future = policiesClient.createPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createPolicyCallable() { + return stub.createPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the specified policy. + * + *

You can update only the rules and the display name for the policy. + * + *

To update a policy, you should use a read-modify-write loop: + * + *

1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the + * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. + * + *

This pattern helps prevent conflicts between concurrent updates. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   Policy response = policiesClient.updatePolicyAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture updatePolicyAsync( + UpdatePolicyRequest request) { + return updatePolicyOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the specified policy. + * + *

You can update only the rules and the display name for the policy. + * + *

To update a policy, you should use a read-modify-write loop: + * + *

1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the + * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. + * + *

This pattern helps prevent conflicts between concurrent updates. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   OperationFuture future =
+   *       policiesClient.updatePolicyOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + updatePolicyOperationCallable() { + return stub.updatePolicyOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the specified policy. + * + *

You can update only the rules and the display name for the policy. + * + *

To update a policy, you should use a read-modify-write loop: + * + *

1. Use [GetPolicy][google.iam.v2.Policies.GetPolicy] to read the current version of the + * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. + * + *

This pattern helps prevent conflicts between concurrent updates. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   ApiFuture future = policiesClient.updatePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable updatePolicyCallable() { + return stub.updatePolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String name = "name3373707";
+   *   Policy response = policiesClient.deletePolicyAsync(name).get();
+   * }
+   * }
+ * + * @param name Required. The resource name of the policy to delete. Format: + * `policies/{attachment_point}/denypolicies/{policy_id}` + *

Use the URL-encoded full resource name, which means that the forward-slash character, + * `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture deletePolicyAsync(String name) { + DeletePolicyRequest request = DeletePolicyRequest.newBuilder().setName(name).build(); + return deletePolicyAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+   *   Policy response = policiesClient.deletePolicyAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture deletePolicyAsync( + DeletePolicyRequest request) { + return deletePolicyOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+   *   OperationFuture future =
+   *       policiesClient.deletePolicyOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + deletePolicyOperationCallable() { + return stub.deletePolicyOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+   *   ApiFuture future = policiesClient.deletePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deletePolicyCallable() { + return stub.deletePolicyCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListPoliciesPagedResponse + extends AbstractPagedListResponse< + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + ListPoliciesPage, + ListPoliciesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListPoliciesPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListPoliciesPagedResponse(ListPoliciesPage page) { + super(page, ListPoliciesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListPoliciesPage + extends AbstractPage { + + private ListPoliciesPage( + PageContext context, + ListPoliciesResponse response) { + super(context, response); + } + + private static ListPoliciesPage createEmptyPage() { + return new ListPoliciesPage(null, null); + } + + @Override + protected ListPoliciesPage createPage( + PageContext context, + ListPoliciesResponse response) { + return new ListPoliciesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListPoliciesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + ListPoliciesPage, + ListPoliciesFixedSizeCollection> { + + private ListPoliciesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListPoliciesFixedSizeCollection createEmptyCollection() { + return new ListPoliciesFixedSizeCollection(null, 0); + } + + @Override + protected ListPoliciesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListPoliciesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesSettings.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesSettings.java new file mode 100644 index 000000000000..06ec905be736 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/PoliciesSettings.java @@ -0,0 +1,284 @@ +/* + * 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.iam.v2; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.iam.v2.stub.PoliciesStubSettings; +import com.google.longrunning.Operation; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link PoliciesClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (iam.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of getPolicy to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings.Builder policiesSettingsBuilder = PoliciesSettings.newBuilder();
+ * policiesSettingsBuilder
+ *     .getPolicySettings()
+ *     .setRetrySettings(
+ *         policiesSettingsBuilder.getPolicySettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * PoliciesSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class PoliciesSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to listPolicies. */ + public PagedCallSettings + listPoliciesSettings() { + return ((PoliciesStubSettings) getStubSettings()).listPoliciesSettings(); + } + + /** Returns the object with the settings used for calls to getPolicy. */ + public UnaryCallSettings getPolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).getPolicySettings(); + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public UnaryCallSettings createPolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).createPolicySettings(); + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public OperationCallSettings + createPolicyOperationSettings() { + return ((PoliciesStubSettings) getStubSettings()).createPolicyOperationSettings(); + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public UnaryCallSettings updatePolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).updatePolicySettings(); + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public OperationCallSettings + updatePolicyOperationSettings() { + return ((PoliciesStubSettings) getStubSettings()).updatePolicyOperationSettings(); + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public UnaryCallSettings deletePolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).deletePolicySettings(); + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public OperationCallSettings + deletePolicyOperationSettings() { + return ((PoliciesStubSettings) getStubSettings()).deletePolicyOperationSettings(); + } + + public static final PoliciesSettings create(PoliciesStubSettings stub) throws IOException { + return new PoliciesSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return PoliciesStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return PoliciesStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return PoliciesStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return PoliciesStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return PoliciesStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PoliciesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return PoliciesStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PoliciesStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected PoliciesSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for PoliciesSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(PoliciesStubSettings.newBuilder(clientContext)); + } + + protected Builder(PoliciesSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(PoliciesStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(PoliciesStubSettings.newBuilder()); + } + + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PoliciesStubSettings.newHttpJsonBuilder()); + } + + public PoliciesStubSettings.Builder getStubSettingsBuilder() { + return ((PoliciesStubSettings.Builder) getStubSettings()); + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listPolicies. */ + public PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings() { + return getStubSettingsBuilder().listPoliciesSettings(); + } + + /** Returns the builder for the settings used for calls to getPolicy. */ + public UnaryCallSettings.Builder getPolicySettings() { + return getStubSettingsBuilder().getPolicySettings(); + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public UnaryCallSettings.Builder createPolicySettings() { + return getStubSettingsBuilder().createPolicySettings(); + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public OperationCallSettings.Builder + createPolicyOperationSettings() { + return getStubSettingsBuilder().createPolicyOperationSettings(); + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public UnaryCallSettings.Builder updatePolicySettings() { + return getStubSettingsBuilder().updatePolicySettings(); + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public OperationCallSettings.Builder + updatePolicyOperationSettings() { + return getStubSettingsBuilder().updatePolicyOperationSettings(); + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public UnaryCallSettings.Builder deletePolicySettings() { + return getStubSettingsBuilder().deletePolicySettings(); + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public OperationCallSettings.Builder + deletePolicyOperationSettings() { + return getStubSettingsBuilder().deletePolicyOperationSettings(); + } + + @Override + public PoliciesSettings build() throws IOException { + return new PoliciesSettings(this); + } + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/gapic_metadata.json b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/gapic_metadata.json new file mode 100644 index 000000000000..4277cbfcc4ab --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.iam.v2", + "libraryPackage": "com.google.iam.v2", + "services": { + "Policies": { + "clients": { + "grpc": { + "libraryClient": "PoliciesClient", + "rpcs": { + "CreatePolicy": { + "methods": ["createPolicyAsync", "createPolicyAsync", "createPolicyOperationCallable", "createPolicyCallable"] + }, + "DeletePolicy": { + "methods": ["deletePolicyAsync", "deletePolicyAsync", "deletePolicyOperationCallable", "deletePolicyCallable"] + }, + "GetPolicy": { + "methods": ["getPolicy", "getPolicy", "getPolicyCallable"] + }, + "ListPolicies": { + "methods": ["listPolicies", "listPolicies", "listPoliciesPagedCallable", "listPoliciesCallable"] + }, + "UpdatePolicy": { + "methods": ["updatePolicyAsync", "updatePolicyOperationCallable", "updatePolicyCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/package-info.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/package-info.java new file mode 100644 index 000000000000..1994b92c0cd1 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/package-info.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. + */ + +/** + * A client to Identity and Access Management (IAM) API + * + *

The interfaces provided are listed below, along with usage samples. + * + *

======================= PoliciesClient ======================= + * + *

Service Description: An interface for managing Identity and Access Management (IAM) policies. + * + *

Sample for PoliciesClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ *   String name = "name3373707";
+ *   Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.iam.v2; + +import javax.annotation.Generated; diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesCallableFactory.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesCallableFactory.java new file mode 100644 index 000000000000..a09e64777e3f --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesCallableFactory.java @@ -0,0 +1,113 @@ +/* + * 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.iam.v2.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the Policies service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcPoliciesCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesStub.java new file mode 100644 index 000000000000..61258f90181e --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/GrpcPoliciesStub.java @@ -0,0 +1,330 @@ +/* + * 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.iam.v2.stub; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableMap; +import com.google.iam.v2.CreatePolicyRequest; +import com.google.iam.v2.DeletePolicyRequest; +import com.google.iam.v2.GetPolicyRequest; +import com.google.iam.v2.ListPoliciesRequest; +import com.google.iam.v2.ListPoliciesResponse; +import com.google.iam.v2.Policy; +import com.google.iam.v2.PolicyOperationMetadata; +import com.google.iam.v2.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.GrpcOperationsStub; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcPoliciesStub extends PoliciesStub { + private static final MethodDescriptor + listPoliciesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2.Policies/ListPolicies") + .setRequestMarshaller(ProtoUtils.marshaller(ListPoliciesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListPoliciesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2.Policies/GetPolicy") + .setRequestMarshaller(ProtoUtils.marshaller(GetPolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + createPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2.Policies/CreatePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(CreatePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updatePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2.Policies/UpdatePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(UpdatePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + deletePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2.Policies/DeletePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(DeletePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private final UnaryCallable listPoliciesCallable; + private final UnaryCallable + listPoliciesPagedCallable; + private final UnaryCallable getPolicyCallable; + private final UnaryCallable createPolicyCallable; + private final OperationCallable + createPolicyOperationCallable; + private final UnaryCallable updatePolicyCallable; + private final OperationCallable + updatePolicyOperationCallable; + private final UnaryCallable deletePolicyCallable; + private final OperationCallable + deletePolicyOperationCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcPoliciesStub create(PoliciesStubSettings settings) throws IOException { + return new GrpcPoliciesStub(settings, ClientContext.create(settings)); + } + + public static final GrpcPoliciesStub create(ClientContext clientContext) throws IOException { + return new GrpcPoliciesStub(PoliciesStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcPoliciesStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcPoliciesStub( + PoliciesStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcPoliciesStub, 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 GrpcPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcPoliciesCallableFactory()); + } + + /** + * Constructs an instance of GrpcPoliciesStub, 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 GrpcPoliciesStub( + PoliciesStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings listPoliciesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listPoliciesMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); + GrpcCallSettings getPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getPolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + GrpcCallSettings createPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createPolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); + GrpcCallSettings updatePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updatePolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("policy.name", String.valueOf(request.getPolicy().getName())); + return params.build(); + }) + .build(); + GrpcCallSettings deletePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deletePolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + + this.listPoliciesCallable = + callableFactory.createUnaryCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.listPoliciesPagedCallable = + callableFactory.createPagedCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.getPolicyCallable = + callableFactory.createUnaryCallable( + getPolicyTransportSettings, settings.getPolicySettings(), clientContext); + this.createPolicyCallable = + callableFactory.createUnaryCallable( + createPolicyTransportSettings, settings.createPolicySettings(), clientContext); + this.createPolicyOperationCallable = + callableFactory.createOperationCallable( + createPolicyTransportSettings, + settings.createPolicyOperationSettings(), + clientContext, + operationsStub); + this.updatePolicyCallable = + callableFactory.createUnaryCallable( + updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); + this.updatePolicyOperationCallable = + callableFactory.createOperationCallable( + updatePolicyTransportSettings, + settings.updatePolicyOperationSettings(), + clientContext, + operationsStub); + this.deletePolicyCallable = + callableFactory.createUnaryCallable( + deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext); + this.deletePolicyOperationCallable = + callableFactory.createOperationCallable( + deletePolicyTransportSettings, + settings.deletePolicyOperationSettings(), + clientContext, + operationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable listPoliciesCallable() { + return listPoliciesCallable; + } + + @Override + public UnaryCallable listPoliciesPagedCallable() { + return listPoliciesPagedCallable; + } + + @Override + public UnaryCallable getPolicyCallable() { + return getPolicyCallable; + } + + @Override + public UnaryCallable createPolicyCallable() { + return createPolicyCallable; + } + + @Override + public OperationCallable + createPolicyOperationCallable() { + return createPolicyOperationCallable; + } + + @Override + public UnaryCallable updatePolicyCallable() { + return updatePolicyCallable; + } + + @Override + public OperationCallable + updatePolicyOperationCallable() { + return updatePolicyOperationCallable; + } + + @Override + public UnaryCallable deletePolicyCallable() { + return deletePolicyCallable; + } + + @Override + public OperationCallable + deletePolicyOperationCallable() { + return deletePolicyOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesCallableFactory.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesCallableFactory.java new file mode 100644 index 000000000000..27bd9b725e7f --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesCallableFactory.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.iam.v2.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 Policies service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPoliciesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesStub.java new file mode 100644 index 000000000000..a0fbb9339af8 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/HttpJsonPoliciesStub.java @@ -0,0 +1,481 @@ +/* + * 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.iam.v2.stub; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +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.iam.v2.CreatePolicyRequest; +import com.google.iam.v2.DeletePolicyRequest; +import com.google.iam.v2.GetPolicyRequest; +import com.google.iam.v2.ListPoliciesRequest; +import com.google.iam.v2.ListPoliciesResponse; +import com.google.iam.v2.Policy; +import com.google.iam.v2.PolicyOperationMetadata; +import com.google.iam.v2.UpdatePolicyRequest; +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 Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonPoliciesStub extends PoliciesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(PolicyOperationMetadata.getDescriptor()) + .add(Policy.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listPoliciesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2.Policies/ListPolicies") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=policies/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListPoliciesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2.Policies/GetPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2.Policies/CreatePolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{parent=policies/*/*}", + 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, "policyId", request.getPolicyId()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("policy", request.getPolicy(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreatePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updatePolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2.Policies/UpdatePolicy") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{policy.name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "policy.name", request.getPolicy().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("policy", request.getPolicy(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdatePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deletePolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2.Policies/DeletePolicy") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/{name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeletePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listPoliciesCallable; + private final UnaryCallable + listPoliciesPagedCallable; + private final UnaryCallable getPolicyCallable; + private final UnaryCallable createPolicyCallable; + private final OperationCallable + createPolicyOperationCallable; + private final UnaryCallable updatePolicyCallable; + private final OperationCallable + updatePolicyOperationCallable; + private final UnaryCallable deletePolicyCallable; + private final OperationCallable + deletePolicyOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPoliciesStub create(PoliciesStubSettings settings) + throws IOException { + return new HttpJsonPoliciesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPoliciesStub create(ClientContext clientContext) throws IOException { + return new HttpJsonPoliciesStub( + PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPoliciesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPoliciesStub( + PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonPoliciesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub( + PoliciesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listPoliciesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listPoliciesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updatePolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updatePolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deletePolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listPoliciesCallable = + callableFactory.createUnaryCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.listPoliciesPagedCallable = + callableFactory.createPagedCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.getPolicyCallable = + callableFactory.createUnaryCallable( + getPolicyTransportSettings, settings.getPolicySettings(), clientContext); + this.createPolicyCallable = + callableFactory.createUnaryCallable( + createPolicyTransportSettings, settings.createPolicySettings(), clientContext); + this.createPolicyOperationCallable = + callableFactory.createOperationCallable( + createPolicyTransportSettings, + settings.createPolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updatePolicyCallable = + callableFactory.createUnaryCallable( + updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); + this.updatePolicyOperationCallable = + callableFactory.createOperationCallable( + updatePolicyTransportSettings, + settings.updatePolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deletePolicyCallable = + callableFactory.createUnaryCallable( + deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext); + this.deletePolicyOperationCallable = + callableFactory.createOperationCallable( + deletePolicyTransportSettings, + settings.deletePolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listPoliciesMethodDescriptor); + methodDescriptors.add(getPolicyMethodDescriptor); + methodDescriptors.add(createPolicyMethodDescriptor); + methodDescriptors.add(updatePolicyMethodDescriptor); + methodDescriptors.add(deletePolicyMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listPoliciesCallable() { + return listPoliciesCallable; + } + + @Override + public UnaryCallable listPoliciesPagedCallable() { + return listPoliciesPagedCallable; + } + + @Override + public UnaryCallable getPolicyCallable() { + return getPolicyCallable; + } + + @Override + public UnaryCallable createPolicyCallable() { + return createPolicyCallable; + } + + @Override + public OperationCallable + createPolicyOperationCallable() { + return createPolicyOperationCallable; + } + + @Override + public UnaryCallable updatePolicyCallable() { + return updatePolicyCallable; + } + + @Override + public OperationCallable + updatePolicyOperationCallable() { + return updatePolicyOperationCallable; + } + + @Override + public UnaryCallable deletePolicyCallable() { + return deletePolicyCallable; + } + + @Override + public OperationCallable + deletePolicyOperationCallable() { + return deletePolicyOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStub.java new file mode 100644 index 000000000000..90d52e011f07 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStub.java @@ -0,0 +1,94 @@ +/* + * 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.iam.v2.stub; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.iam.v2.CreatePolicyRequest; +import com.google.iam.v2.DeletePolicyRequest; +import com.google.iam.v2.GetPolicyRequest; +import com.google.iam.v2.ListPoliciesRequest; +import com.google.iam.v2.ListPoliciesResponse; +import com.google.iam.v2.Policy; +import com.google.iam.v2.PolicyOperationMetadata; +import com.google.iam.v2.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class PoliciesStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; + } + + public UnaryCallable listPoliciesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listPoliciesPagedCallable()"); + } + + public UnaryCallable listPoliciesCallable() { + throw new UnsupportedOperationException("Not implemented: listPoliciesCallable()"); + } + + public UnaryCallable getPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getPolicyCallable()"); + } + + public OperationCallable + createPolicyOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createPolicyOperationCallable()"); + } + + public UnaryCallable createPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: createPolicyCallable()"); + } + + public OperationCallable + updatePolicyOperationCallable() { + throw new UnsupportedOperationException("Not implemented: updatePolicyOperationCallable()"); + } + + public UnaryCallable updatePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: updatePolicyCallable()"); + } + + public OperationCallable + deletePolicyOperationCallable() { + throw new UnsupportedOperationException("Not implemented: deletePolicyOperationCallable()"); + } + + public UnaryCallable deletePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: deletePolicyCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStubSettings.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStubSettings.java new file mode 100644 index 000000000000..2a9434e11fb0 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2/stub/PoliciesStubSettings.java @@ -0,0 +1,627 @@ +/* + * 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.iam.v2.stub; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.iam.v2.CreatePolicyRequest; +import com.google.iam.v2.DeletePolicyRequest; +import com.google.iam.v2.GetPolicyRequest; +import com.google.iam.v2.ListPoliciesRequest; +import com.google.iam.v2.ListPoliciesResponse; +import com.google.iam.v2.Policy; +import com.google.iam.v2.PolicyOperationMetadata; +import com.google.iam.v2.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link PoliciesStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (iam.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of getPolicy to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesStubSettings.Builder policiesSettingsBuilder = PoliciesStubSettings.newBuilder();
+ * policiesSettingsBuilder
+ *     .getPolicySettings()
+ *     .setRetrySettings(
+ *         policiesSettingsBuilder.getPolicySettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * PoliciesStubSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class PoliciesStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings; + private final UnaryCallSettings getPolicySettings; + private final UnaryCallSettings createPolicySettings; + private final OperationCallSettings + createPolicyOperationSettings; + private final UnaryCallSettings updatePolicySettings; + private final OperationCallSettings + updatePolicyOperationSettings; + private final UnaryCallSettings deletePolicySettings; + private final OperationCallSettings + deletePolicyOperationSettings; + + private static final PagedListDescriptor + LIST_POLICIES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListPoliciesRequest injectToken(ListPoliciesRequest payload, String token) { + return ListPoliciesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListPoliciesRequest injectPageSize(ListPoliciesRequest payload, int pageSize) { + return ListPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListPoliciesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListPoliciesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListPoliciesResponse payload) { + return payload.getPoliciesList() == null + ? ImmutableList.of() + : payload.getPoliciesList(); + } + }; + + private static final PagedListResponseFactory< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + LIST_POLICIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListPoliciesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_POLICIES_PAGE_STR_DESC, request, context); + return ListPoliciesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to listPolicies. */ + public PagedCallSettings + listPoliciesSettings() { + return listPoliciesSettings; + } + + /** Returns the object with the settings used for calls to getPolicy. */ + public UnaryCallSettings getPolicySettings() { + return getPolicySettings; + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public UnaryCallSettings createPolicySettings() { + return createPolicySettings; + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public OperationCallSettings + createPolicyOperationSettings() { + return createPolicyOperationSettings; + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public UnaryCallSettings updatePolicySettings() { + return updatePolicySettings; + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public OperationCallSettings + updatePolicyOperationSettings() { + return updatePolicyOperationSettings; + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public UnaryCallSettings deletePolicySettings() { + return deletePolicySettings; + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public OperationCallSettings + deletePolicyOperationSettings() { + return deletePolicyOperationSettings; + } + + public PoliciesStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcPoliciesStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPoliciesStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "iam.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "iam.mtls.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + .setUseJwtAccessWithScope(true); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PoliciesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected PoliciesStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listPoliciesSettings = settingsBuilder.listPoliciesSettings().build(); + getPolicySettings = settingsBuilder.getPolicySettings().build(); + createPolicySettings = settingsBuilder.createPolicySettings().build(); + createPolicyOperationSettings = settingsBuilder.createPolicyOperationSettings().build(); + updatePolicySettings = settingsBuilder.updatePolicySettings().build(); + updatePolicyOperationSettings = settingsBuilder.updatePolicyOperationSettings().build(); + deletePolicySettings = settingsBuilder.deletePolicySettings().build(); + deletePolicyOperationSettings = settingsBuilder.deletePolicyOperationSettings().build(); + } + + /** Builder for PoliciesStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings; + private final UnaryCallSettings.Builder getPolicySettings; + private final UnaryCallSettings.Builder createPolicySettings; + private final OperationCallSettings.Builder< + CreatePolicyRequest, Policy, PolicyOperationMetadata> + createPolicyOperationSettings; + private final UnaryCallSettings.Builder updatePolicySettings; + private final OperationCallSettings.Builder< + UpdatePolicyRequest, Policy, PolicyOperationMetadata> + updatePolicyOperationSettings; + private final UnaryCallSettings.Builder deletePolicySettings; + private final OperationCallSettings.Builder< + DeletePolicyRequest, Policy, PolicyOperationMetadata> + deletePolicyOperationSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(10000L)) + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listPoliciesSettings = PagedCallSettings.newBuilder(LIST_POLICIES_PAGE_STR_FACT); + getPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createPolicyOperationSettings = OperationCallSettings.newBuilder(); + updatePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updatePolicyOperationSettings = OperationCallSettings.newBuilder(); + deletePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deletePolicyOperationSettings = OperationCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listPoliciesSettings, + getPolicySettings, + createPolicySettings, + updatePolicySettings, + deletePolicySettings); + initDefaults(this); + } + + protected Builder(PoliciesStubSettings settings) { + super(settings); + + listPoliciesSettings = settings.listPoliciesSettings.toBuilder(); + getPolicySettings = settings.getPolicySettings.toBuilder(); + createPolicySettings = settings.createPolicySettings.toBuilder(); + createPolicyOperationSettings = settings.createPolicyOperationSettings.toBuilder(); + updatePolicySettings = settings.updatePolicySettings.toBuilder(); + updatePolicyOperationSettings = settings.updatePolicyOperationSettings.toBuilder(); + deletePolicySettings = settings.deletePolicySettings.toBuilder(); + deletePolicyOperationSettings = settings.deletePolicyOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listPoliciesSettings, + getPolicySettings, + createPolicySettings, + updatePolicySettings, + deletePolicySettings); + } + + private static Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .listPoliciesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .getPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .createPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .updatePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .deletePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .createPolicyOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Policy.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + builder + .updatePolicyOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Policy.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + builder + .deletePolicyOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Policy.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listPolicies. */ + public PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings() { + return listPoliciesSettings; + } + + /** Returns the builder for the settings used for calls to getPolicy. */ + public UnaryCallSettings.Builder getPolicySettings() { + return getPolicySettings; + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public UnaryCallSettings.Builder createPolicySettings() { + return createPolicySettings; + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + createPolicyOperationSettings() { + return createPolicyOperationSettings; + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public UnaryCallSettings.Builder updatePolicySettings() { + return updatePolicySettings; + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + updatePolicyOperationSettings() { + return updatePolicyOperationSettings; + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public UnaryCallSettings.Builder deletePolicySettings() { + return deletePolicySettings; + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + deletePolicyOperationSettings() { + return deletePolicyOperationSettings; + } + + @Override + public PoliciesStubSettings build() throws IOException { + return new PoliciesStubSettings(this); + } + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java new file mode 100644 index 000000000000..b74080f7997e --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java @@ -0,0 +1,884 @@ +/* + * 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.iam.v2beta; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.iam.v2beta.stub.PoliciesStub; +import com.google.iam.v2beta.stub.PoliciesStubSettings; +import com.google.longrunning.Operation; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: An interface for managing Identity and Access Management (IAM) policies. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ *   String name = "name3373707";
+ *   Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ * + *

Note: close() needs to be called on the PoliciesClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of PoliciesSettings to create(). + * For example: + * + *

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings policiesSettings =
+ *     PoliciesSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings policiesSettings =
+ *     PoliciesSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings policiesSettings = PoliciesSettings.newHttpJsonBuilder().build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class PoliciesClient implements BackgroundResource { + private final PoliciesSettings settings; + private final PoliciesStub stub; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; + + /** Constructs an instance of PoliciesClient with default settings. */ + public static final PoliciesClient create() throws IOException { + return create(PoliciesSettings.newBuilder().build()); + } + + /** + * Constructs an instance of PoliciesClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final PoliciesClient create(PoliciesSettings settings) throws IOException { + return new PoliciesClient(settings); + } + + /** + * Constructs an instance of PoliciesClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(PoliciesSettings). + */ + public static final PoliciesClient create(PoliciesStub stub) { + return new PoliciesClient(stub); + } + + /** + * Constructs an instance of PoliciesClient, 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 PoliciesClient(PoliciesSettings settings) throws IOException { + this.settings = settings; + this.stub = ((PoliciesStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + protected PoliciesClient(PoliciesStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + public final PoliciesSettings getSettings() { + return settings; + } + + public PoliciesStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final com.google.longrunning.OperationsClient getOperationsClient() { + return operationsClient; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String parent = "parent-995424086";
+   *   for (Policy element : policiesClient.listPolicies(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The resource that the policy is attached to, along with the kind of + * policy to list. Format: `policies/{attachment_point}/denypolicies` + *

The attachment point is identified by its URL-encoded full resource name, which means + * that the forward-slash character, `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(String parent) { + ListPoliciesRequest request = ListPoliciesRequest.newBuilder().setParent(parent).build(); + return listPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Policy element : policiesClient.listPolicies(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request) { + return listPoliciesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = policiesClient.listPoliciesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Policy element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listPoliciesPagedCallable() { + return stub.listPoliciesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves the policies of the specified kind that are attached to a resource. + * + *

The response lists only policy metadata. In particular, policy rules are omitted. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListPoliciesResponse response = policiesClient.listPoliciesCallable().call(request);
+   *     for (Policy element : response.getPoliciesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listPoliciesCallable() { + return stub.listPoliciesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String name = "name3373707";
+   *   Policy response = policiesClient.getPolicy(name);
+   * }
+   * }
+ * + * @param name Required. The resource name of the policy to retrieve. Format: + * `policies/{attachment_point}/denypolicies/{policy_id}` + *

Use the URL-encoded full resource name, which means that the forward-slash character, + * `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(String name) { + GetPolicyRequest request = GetPolicyRequest.newBuilder().setName(name).build(); + return getPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build();
+   *   Policy response = policiesClient.getPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(GetPolicyRequest request) { + return getPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build();
+   *   ApiFuture future = policiesClient.getPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getPolicyCallable() { + return stub.getPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String parent = "parent-995424086";
+   *   Policy policy = Policy.newBuilder().build();
+   *   String policyId = "policyId546908653";
+   *   Policy response = policiesClient.createPolicyAsync(parent, policy, policyId).get();
+   * }
+   * }
+ * + * @param parent Required. The resource that the policy is attached to, along with the kind of + * policy to create. Format: `policies/{attachment_point}/denypolicies` + *

The attachment point is identified by its URL-encoded full resource name, which means + * that the forward-slash character, `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @param policy Required. The policy to create. + * @param policyId The ID to use for this policy, which will become the final component of the + * policy's resource name. The ID must contain 3 to 63 characters. It can contain lowercase + * letters and numbers, as well as dashes (`-`) and periods (`.`). The first character must be + * a lowercase letter. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture createPolicyAsync( + String parent, Policy policy, String policyId) { + CreatePolicyRequest request = + CreatePolicyRequest.newBuilder() + .setParent(parent) + .setPolicy(policy) + .setPolicyId(policyId) + .build(); + return createPolicyAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setPolicyId("policyId546908653")
+   *           .build();
+   *   Policy response = policiesClient.createPolicyAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture createPolicyAsync( + CreatePolicyRequest request) { + return createPolicyOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setPolicyId("policyId546908653")
+   *           .build();
+   *   OperationFuture future =
+   *       policiesClient.createPolicyOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + createPolicyOperationCallable() { + return stub.createPolicyOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a policy. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .setPolicyId("policyId546908653")
+   *           .build();
+   *   ApiFuture future = policiesClient.createPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createPolicyCallable() { + return stub.createPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the specified policy. + * + *

You can update only the rules and the display name for the policy. + * + *

To update a policy, you should use a read-modify-write loop: + * + *

1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the + * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. + * + *

This pattern helps prevent conflicts between concurrent updates. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   Policy response = policiesClient.updatePolicyAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture updatePolicyAsync( + UpdatePolicyRequest request) { + return updatePolicyOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the specified policy. + * + *

You can update only the rules and the display name for the policy. + * + *

To update a policy, you should use a read-modify-write loop: + * + *

1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the + * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. + * + *

This pattern helps prevent conflicts between concurrent updates. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   OperationFuture future =
+   *       policiesClient.updatePolicyOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + updatePolicyOperationCallable() { + return stub.updatePolicyOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates the specified policy. + * + *

You can update only the rules and the display name for the policy. + * + *

To update a policy, you should use a read-modify-write loop: + * + *

1. Use [GetPolicy][google.iam.v2beta.Policies.GetPolicy] to read the current version of the + * policy. 2. Modify the policy as needed. 3. Use `UpdatePolicy` to write the updated policy. + * + *

This pattern helps prevent conflicts between concurrent updates. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   ApiFuture future = policiesClient.updatePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable updatePolicyCallable() { + return stub.updatePolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   String name = "name3373707";
+   *   Policy response = policiesClient.deletePolicyAsync(name).get();
+   * }
+   * }
+ * + * @param name Required. The resource name of the policy to delete. Format: + * `policies/{attachment_point}/denypolicies/{policy_id}` + *

Use the URL-encoded full resource name, which means that the forward-slash character, + * `/`, must be written as `%2F`. For example, + * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. + *

For organizations and folders, use the numeric ID in the full resource name. For + * projects, you can use the alphanumeric or the numeric ID. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture deletePolicyAsync(String name) { + DeletePolicyRequest request = DeletePolicyRequest.newBuilder().setName(name).build(); + return deletePolicyAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+   *   Policy response = policiesClient.deletePolicyAsync(request).get();
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture deletePolicyAsync( + DeletePolicyRequest request) { + return deletePolicyOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+   *   OperationFuture future =
+   *       policiesClient.deletePolicyOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + deletePolicyOperationCallable() { + return stub.deletePolicyOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a policy. This action is permanent. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build();
+   *   ApiFuture future = policiesClient.deletePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deletePolicyCallable() { + return stub.deletePolicyCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListPoliciesPagedResponse + extends AbstractPagedListResponse< + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + ListPoliciesPage, + ListPoliciesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListPoliciesPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListPoliciesPagedResponse(ListPoliciesPage page) { + super(page, ListPoliciesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListPoliciesPage + extends AbstractPage { + + private ListPoliciesPage( + PageContext context, + ListPoliciesResponse response) { + super(context, response); + } + + private static ListPoliciesPage createEmptyPage() { + return new ListPoliciesPage(null, null); + } + + @Override + protected ListPoliciesPage createPage( + PageContext context, + ListPoliciesResponse response) { + return new ListPoliciesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListPoliciesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + ListPoliciesPage, + ListPoliciesFixedSizeCollection> { + + private ListPoliciesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListPoliciesFixedSizeCollection createEmptyCollection() { + return new ListPoliciesFixedSizeCollection(null, 0); + } + + @Override + protected ListPoliciesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListPoliciesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java new file mode 100644 index 000000000000..de80d3ce6603 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java @@ -0,0 +1,285 @@ +/* + * 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.iam.v2beta; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.iam.v2beta.stub.PoliciesStubSettings; +import com.google.longrunning.Operation; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link PoliciesClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (iam.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of getPolicy to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesSettings.Builder policiesSettingsBuilder = PoliciesSettings.newBuilder();
+ * policiesSettingsBuilder
+ *     .getPolicySettings()
+ *     .setRetrySettings(
+ *         policiesSettingsBuilder.getPolicySettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * PoliciesSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class PoliciesSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to listPolicies. */ + public PagedCallSettings + listPoliciesSettings() { + return ((PoliciesStubSettings) getStubSettings()).listPoliciesSettings(); + } + + /** Returns the object with the settings used for calls to getPolicy. */ + public UnaryCallSettings getPolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).getPolicySettings(); + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public UnaryCallSettings createPolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).createPolicySettings(); + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public OperationCallSettings + createPolicyOperationSettings() { + return ((PoliciesStubSettings) getStubSettings()).createPolicyOperationSettings(); + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public UnaryCallSettings updatePolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).updatePolicySettings(); + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public OperationCallSettings + updatePolicyOperationSettings() { + return ((PoliciesStubSettings) getStubSettings()).updatePolicyOperationSettings(); + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public UnaryCallSettings deletePolicySettings() { + return ((PoliciesStubSettings) getStubSettings()).deletePolicySettings(); + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public OperationCallSettings + deletePolicyOperationSettings() { + return ((PoliciesStubSettings) getStubSettings()).deletePolicyOperationSettings(); + } + + public static final PoliciesSettings create(PoliciesStubSettings stub) throws IOException { + return new PoliciesSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return PoliciesStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return PoliciesStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return PoliciesStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return PoliciesStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return PoliciesStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PoliciesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return PoliciesStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PoliciesStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected PoliciesSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for PoliciesSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(PoliciesStubSettings.newBuilder(clientContext)); + } + + protected Builder(PoliciesSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(PoliciesStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(PoliciesStubSettings.newBuilder()); + } + + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PoliciesStubSettings.newHttpJsonBuilder()); + } + + public PoliciesStubSettings.Builder getStubSettingsBuilder() { + return ((PoliciesStubSettings.Builder) getStubSettings()); + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listPolicies. */ + public PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings() { + return getStubSettingsBuilder().listPoliciesSettings(); + } + + /** Returns the builder for the settings used for calls to getPolicy. */ + public UnaryCallSettings.Builder getPolicySettings() { + return getStubSettingsBuilder().getPolicySettings(); + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public UnaryCallSettings.Builder createPolicySettings() { + return getStubSettingsBuilder().createPolicySettings(); + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public OperationCallSettings.Builder + createPolicyOperationSettings() { + return getStubSettingsBuilder().createPolicyOperationSettings(); + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public UnaryCallSettings.Builder updatePolicySettings() { + return getStubSettingsBuilder().updatePolicySettings(); + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public OperationCallSettings.Builder + updatePolicyOperationSettings() { + return getStubSettingsBuilder().updatePolicyOperationSettings(); + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public UnaryCallSettings.Builder deletePolicySettings() { + return getStubSettingsBuilder().deletePolicySettings(); + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public OperationCallSettings.Builder + deletePolicyOperationSettings() { + return getStubSettingsBuilder().deletePolicyOperationSettings(); + } + + @Override + public PoliciesSettings build() throws IOException { + return new PoliciesSettings(this); + } + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json new file mode 100644 index 000000000000..54136f109a7b --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json @@ -0,0 +1,33 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.iam.v2beta", + "libraryPackage": "com.google.iam.v2beta", + "services": { + "Policies": { + "clients": { + "grpc": { + "libraryClient": "PoliciesClient", + "rpcs": { + "CreatePolicy": { + "methods": ["createPolicyAsync", "createPolicyAsync", "createPolicyOperationCallable", "createPolicyCallable"] + }, + "DeletePolicy": { + "methods": ["deletePolicyAsync", "deletePolicyAsync", "deletePolicyOperationCallable", "deletePolicyCallable"] + }, + "GetPolicy": { + "methods": ["getPolicy", "getPolicy", "getPolicyCallable"] + }, + "ListPolicies": { + "methods": ["listPolicies", "listPolicies", "listPoliciesPagedCallable", "listPoliciesCallable"] + }, + "UpdatePolicy": { + "methods": ["updatePolicyAsync", "updatePolicyOperationCallable", "updatePolicyCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java new file mode 100644 index 000000000000..e5ed70548cda --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.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. + */ + +/** + * A client to Identity and Access Management (IAM) API + * + *

The interfaces provided are listed below, along with usage samples. + * + *

======================= PoliciesClient ======================= + * + *

Service Description: An interface for managing Identity and Access Management (IAM) policies. + * + *

Sample for PoliciesClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (PoliciesClient policiesClient = PoliciesClient.create()) {
+ *   String name = "name3373707";
+ *   Policy response = policiesClient.getPolicy(name);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.iam.v2beta; + +import javax.annotation.Generated; diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesCallableFactory.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesCallableFactory.java new file mode 100644 index 000000000000..d2ee2059c5fa --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesCallableFactory.java @@ -0,0 +1,115 @@ +/* + * 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.iam.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the Policies service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class GrpcPoliciesCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesStub.java new file mode 100644 index 000000000000..0e1396311ee3 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/GrpcPoliciesStub.java @@ -0,0 +1,332 @@ +/* + * 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.iam.v2beta.stub; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableMap; +import com.google.iam.v2beta.CreatePolicyRequest; +import com.google.iam.v2beta.DeletePolicyRequest; +import com.google.iam.v2beta.GetPolicyRequest; +import com.google.iam.v2beta.ListPoliciesRequest; +import com.google.iam.v2beta.ListPoliciesResponse; +import com.google.iam.v2beta.Policy; +import com.google.iam.v2beta.PolicyOperationMetadata; +import com.google.iam.v2beta.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.GrpcOperationsStub; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class GrpcPoliciesStub extends PoliciesStub { + private static final MethodDescriptor + listPoliciesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2beta.Policies/ListPolicies") + .setRequestMarshaller(ProtoUtils.marshaller(ListPoliciesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListPoliciesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2beta.Policies/GetPolicy") + .setRequestMarshaller(ProtoUtils.marshaller(GetPolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + createPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2beta.Policies/CreatePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(CreatePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updatePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2beta.Policies/UpdatePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(UpdatePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + deletePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.iam.v2beta.Policies/DeletePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(DeletePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .build(); + + private final UnaryCallable listPoliciesCallable; + private final UnaryCallable + listPoliciesPagedCallable; + private final UnaryCallable getPolicyCallable; + private final UnaryCallable createPolicyCallable; + private final OperationCallable + createPolicyOperationCallable; + private final UnaryCallable updatePolicyCallable; + private final OperationCallable + updatePolicyOperationCallable; + private final UnaryCallable deletePolicyCallable; + private final OperationCallable + deletePolicyOperationCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcPoliciesStub create(PoliciesStubSettings settings) throws IOException { + return new GrpcPoliciesStub(settings, ClientContext.create(settings)); + } + + public static final GrpcPoliciesStub create(ClientContext clientContext) throws IOException { + return new GrpcPoliciesStub(PoliciesStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcPoliciesStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcPoliciesStub( + PoliciesStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcPoliciesStub, 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 GrpcPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcPoliciesCallableFactory()); + } + + /** + * Constructs an instance of GrpcPoliciesStub, 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 GrpcPoliciesStub( + PoliciesStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings listPoliciesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listPoliciesMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); + GrpcCallSettings getPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getPolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + GrpcCallSettings createPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createPolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + }) + .build(); + GrpcCallSettings updatePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updatePolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("policy.name", String.valueOf(request.getPolicy().getName())); + return params.build(); + }) + .build(); + GrpcCallSettings deletePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deletePolicyMethodDescriptor) + .setParamsExtractor( + request -> { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + }) + .build(); + + this.listPoliciesCallable = + callableFactory.createUnaryCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.listPoliciesPagedCallable = + callableFactory.createPagedCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.getPolicyCallable = + callableFactory.createUnaryCallable( + getPolicyTransportSettings, settings.getPolicySettings(), clientContext); + this.createPolicyCallable = + callableFactory.createUnaryCallable( + createPolicyTransportSettings, settings.createPolicySettings(), clientContext); + this.createPolicyOperationCallable = + callableFactory.createOperationCallable( + createPolicyTransportSettings, + settings.createPolicyOperationSettings(), + clientContext, + operationsStub); + this.updatePolicyCallable = + callableFactory.createUnaryCallable( + updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); + this.updatePolicyOperationCallable = + callableFactory.createOperationCallable( + updatePolicyTransportSettings, + settings.updatePolicyOperationSettings(), + clientContext, + operationsStub); + this.deletePolicyCallable = + callableFactory.createUnaryCallable( + deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext); + this.deletePolicyOperationCallable = + callableFactory.createOperationCallable( + deletePolicyTransportSettings, + settings.deletePolicyOperationSettings(), + clientContext, + operationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable listPoliciesCallable() { + return listPoliciesCallable; + } + + @Override + public UnaryCallable listPoliciesPagedCallable() { + return listPoliciesPagedCallable; + } + + @Override + public UnaryCallable getPolicyCallable() { + return getPolicyCallable; + } + + @Override + public UnaryCallable createPolicyCallable() { + return createPolicyCallable; + } + + @Override + public OperationCallable + createPolicyOperationCallable() { + return createPolicyOperationCallable; + } + + @Override + public UnaryCallable updatePolicyCallable() { + return updatePolicyCallable; + } + + @Override + public OperationCallable + updatePolicyOperationCallable() { + return updatePolicyOperationCallable; + } + + @Override + public UnaryCallable deletePolicyCallable() { + return deletePolicyCallable; + } + + @Override + public OperationCallable + deletePolicyOperationCallable() { + return deletePolicyOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.java new file mode 100644 index 000000000000..bc1cb4da7324 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.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.iam.v2beta.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 Policies service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPoliciesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java new file mode 100644 index 000000000000..ece66dcf8634 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java @@ -0,0 +1,481 @@ +/* + * 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.iam.v2beta.stub; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +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.iam.v2beta.CreatePolicyRequest; +import com.google.iam.v2beta.DeletePolicyRequest; +import com.google.iam.v2beta.GetPolicyRequest; +import com.google.iam.v2beta.ListPoliciesRequest; +import com.google.iam.v2beta.ListPoliciesResponse; +import com.google.iam.v2beta.Policy; +import com.google.iam.v2beta.PolicyOperationMetadata; +import com.google.iam.v2beta.UpdatePolicyRequest; +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 Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPoliciesStub extends PoliciesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Policy.getDescriptor()) + .add(PolicyOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listPoliciesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/ListPolicies") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=policies/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListPoliciesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/GetPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/CreatePolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=policies/*/*}", + 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, "policyId", request.getPolicyId()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("policy", request.getPolicy(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreatePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updatePolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/UpdatePolicy") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{policy.name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "policy.name", request.getPolicy().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("policy", request.getPolicy(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdatePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deletePolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/DeletePolicy") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeletePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listPoliciesCallable; + private final UnaryCallable + listPoliciesPagedCallable; + private final UnaryCallable getPolicyCallable; + private final UnaryCallable createPolicyCallable; + private final OperationCallable + createPolicyOperationCallable; + private final UnaryCallable updatePolicyCallable; + private final OperationCallable + updatePolicyOperationCallable; + private final UnaryCallable deletePolicyCallable; + private final OperationCallable + deletePolicyOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPoliciesStub create(PoliciesStubSettings settings) + throws IOException { + return new HttpJsonPoliciesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPoliciesStub create(ClientContext clientContext) throws IOException { + return new HttpJsonPoliciesStub( + PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPoliciesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPoliciesStub( + PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonPoliciesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub( + PoliciesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listPoliciesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listPoliciesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updatePolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updatePolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deletePolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listPoliciesCallable = + callableFactory.createUnaryCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.listPoliciesPagedCallable = + callableFactory.createPagedCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.getPolicyCallable = + callableFactory.createUnaryCallable( + getPolicyTransportSettings, settings.getPolicySettings(), clientContext); + this.createPolicyCallable = + callableFactory.createUnaryCallable( + createPolicyTransportSettings, settings.createPolicySettings(), clientContext); + this.createPolicyOperationCallable = + callableFactory.createOperationCallable( + createPolicyTransportSettings, + settings.createPolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updatePolicyCallable = + callableFactory.createUnaryCallable( + updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); + this.updatePolicyOperationCallable = + callableFactory.createOperationCallable( + updatePolicyTransportSettings, + settings.updatePolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deletePolicyCallable = + callableFactory.createUnaryCallable( + deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext); + this.deletePolicyOperationCallable = + callableFactory.createOperationCallable( + deletePolicyTransportSettings, + settings.deletePolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listPoliciesMethodDescriptor); + methodDescriptors.add(getPolicyMethodDescriptor); + methodDescriptors.add(createPolicyMethodDescriptor); + methodDescriptors.add(updatePolicyMethodDescriptor); + methodDescriptors.add(deletePolicyMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listPoliciesCallable() { + return listPoliciesCallable; + } + + @Override + public UnaryCallable listPoliciesPagedCallable() { + return listPoliciesPagedCallable; + } + + @Override + public UnaryCallable getPolicyCallable() { + return getPolicyCallable; + } + + @Override + public UnaryCallable createPolicyCallable() { + return createPolicyCallable; + } + + @Override + public OperationCallable + createPolicyOperationCallable() { + return createPolicyOperationCallable; + } + + @Override + public UnaryCallable updatePolicyCallable() { + return updatePolicyCallable; + } + + @Override + public OperationCallable + updatePolicyOperationCallable() { + return updatePolicyOperationCallable; + } + + @Override + public UnaryCallable deletePolicyCallable() { + return deletePolicyCallable; + } + + @Override + public OperationCallable + deletePolicyOperationCallable() { + return deletePolicyOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java new file mode 100644 index 000000000000..540fa89d6a7f --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java @@ -0,0 +1,96 @@ +/* + * 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.iam.v2beta.stub; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.iam.v2beta.CreatePolicyRequest; +import com.google.iam.v2beta.DeletePolicyRequest; +import com.google.iam.v2beta.GetPolicyRequest; +import com.google.iam.v2beta.ListPoliciesRequest; +import com.google.iam.v2beta.ListPoliciesResponse; +import com.google.iam.v2beta.Policy; +import com.google.iam.v2beta.PolicyOperationMetadata; +import com.google.iam.v2beta.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public abstract class PoliciesStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; + } + + public UnaryCallable listPoliciesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listPoliciesPagedCallable()"); + } + + public UnaryCallable listPoliciesCallable() { + throw new UnsupportedOperationException("Not implemented: listPoliciesCallable()"); + } + + public UnaryCallable getPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getPolicyCallable()"); + } + + public OperationCallable + createPolicyOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createPolicyOperationCallable()"); + } + + public UnaryCallable createPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: createPolicyCallable()"); + } + + public OperationCallable + updatePolicyOperationCallable() { + throw new UnsupportedOperationException("Not implemented: updatePolicyOperationCallable()"); + } + + public UnaryCallable updatePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: updatePolicyCallable()"); + } + + public OperationCallable + deletePolicyOperationCallable() { + throw new UnsupportedOperationException("Not implemented: deletePolicyOperationCallable()"); + } + + public UnaryCallable deletePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: deletePolicyCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java new file mode 100644 index 000000000000..7bfcfdf50cf6 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java @@ -0,0 +1,628 @@ +/* + * 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.iam.v2beta.stub; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.iam.v2beta.CreatePolicyRequest; +import com.google.iam.v2beta.DeletePolicyRequest; +import com.google.iam.v2beta.GetPolicyRequest; +import com.google.iam.v2beta.ListPoliciesRequest; +import com.google.iam.v2beta.ListPoliciesResponse; +import com.google.iam.v2beta.Policy; +import com.google.iam.v2beta.PolicyOperationMetadata; +import com.google.iam.v2beta.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link PoliciesStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (iam.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of getPolicy to 30 seconds: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * PoliciesStubSettings.Builder policiesSettingsBuilder = PoliciesStubSettings.newBuilder();
+ * policiesSettingsBuilder
+ *     .getPolicySettings()
+ *     .setRetrySettings(
+ *         policiesSettingsBuilder.getPolicySettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * PoliciesStubSettings policiesSettings = policiesSettingsBuilder.build();
+ * }
+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class PoliciesStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings; + private final UnaryCallSettings getPolicySettings; + private final UnaryCallSettings createPolicySettings; + private final OperationCallSettings + createPolicyOperationSettings; + private final UnaryCallSettings updatePolicySettings; + private final OperationCallSettings + updatePolicyOperationSettings; + private final UnaryCallSettings deletePolicySettings; + private final OperationCallSettings + deletePolicyOperationSettings; + + private static final PagedListDescriptor + LIST_POLICIES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListPoliciesRequest injectToken(ListPoliciesRequest payload, String token) { + return ListPoliciesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListPoliciesRequest injectPageSize(ListPoliciesRequest payload, int pageSize) { + return ListPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListPoliciesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListPoliciesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListPoliciesResponse payload) { + return payload.getPoliciesList() == null + ? ImmutableList.of() + : payload.getPoliciesList(); + } + }; + + private static final PagedListResponseFactory< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + LIST_POLICIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListPoliciesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_POLICIES_PAGE_STR_DESC, request, context); + return ListPoliciesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to listPolicies. */ + public PagedCallSettings + listPoliciesSettings() { + return listPoliciesSettings; + } + + /** Returns the object with the settings used for calls to getPolicy. */ + public UnaryCallSettings getPolicySettings() { + return getPolicySettings; + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public UnaryCallSettings createPolicySettings() { + return createPolicySettings; + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public OperationCallSettings + createPolicyOperationSettings() { + return createPolicyOperationSettings; + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public UnaryCallSettings updatePolicySettings() { + return updatePolicySettings; + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public OperationCallSettings + updatePolicyOperationSettings() { + return updatePolicyOperationSettings; + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public UnaryCallSettings deletePolicySettings() { + return deletePolicySettings; + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public OperationCallSettings + deletePolicyOperationSettings() { + return deletePolicyOperationSettings; + } + + public PoliciesStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcPoliciesStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPoliciesStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "iam.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "iam.mtls.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + .setUseJwtAccessWithScope(true); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PoliciesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected PoliciesStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listPoliciesSettings = settingsBuilder.listPoliciesSettings().build(); + getPolicySettings = settingsBuilder.getPolicySettings().build(); + createPolicySettings = settingsBuilder.createPolicySettings().build(); + createPolicyOperationSettings = settingsBuilder.createPolicyOperationSettings().build(); + updatePolicySettings = settingsBuilder.updatePolicySettings().build(); + updatePolicyOperationSettings = settingsBuilder.updatePolicyOperationSettings().build(); + deletePolicySettings = settingsBuilder.deletePolicySettings().build(); + deletePolicyOperationSettings = settingsBuilder.deletePolicyOperationSettings().build(); + } + + /** Builder for PoliciesStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings; + private final UnaryCallSettings.Builder getPolicySettings; + private final UnaryCallSettings.Builder createPolicySettings; + private final OperationCallSettings.Builder< + CreatePolicyRequest, Policy, PolicyOperationMetadata> + createPolicyOperationSettings; + private final UnaryCallSettings.Builder updatePolicySettings; + private final OperationCallSettings.Builder< + UpdatePolicyRequest, Policy, PolicyOperationMetadata> + updatePolicyOperationSettings; + private final UnaryCallSettings.Builder deletePolicySettings; + private final OperationCallSettings.Builder< + DeletePolicyRequest, Policy, PolicyOperationMetadata> + deletePolicyOperationSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.UNAVAILABLE))); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(10000L)) + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listPoliciesSettings = PagedCallSettings.newBuilder(LIST_POLICIES_PAGE_STR_FACT); + getPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createPolicyOperationSettings = OperationCallSettings.newBuilder(); + updatePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updatePolicyOperationSettings = OperationCallSettings.newBuilder(); + deletePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deletePolicyOperationSettings = OperationCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listPoliciesSettings, + getPolicySettings, + createPolicySettings, + updatePolicySettings, + deletePolicySettings); + initDefaults(this); + } + + protected Builder(PoliciesStubSettings settings) { + super(settings); + + listPoliciesSettings = settings.listPoliciesSettings.toBuilder(); + getPolicySettings = settings.getPolicySettings.toBuilder(); + createPolicySettings = settings.createPolicySettings.toBuilder(); + createPolicyOperationSettings = settings.createPolicyOperationSettings.toBuilder(); + updatePolicySettings = settings.updatePolicySettings.toBuilder(); + updatePolicyOperationSettings = settings.updatePolicyOperationSettings.toBuilder(); + deletePolicySettings = settings.deletePolicySettings.toBuilder(); + deletePolicyOperationSettings = settings.deletePolicyOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listPoliciesSettings, + getPolicySettings, + createPolicySettings, + updatePolicySettings, + deletePolicySettings); + } + + private static Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .listPoliciesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .getPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .createPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .updatePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .deletePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .createPolicyOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Policy.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + builder + .updatePolicyOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Policy.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + builder + .deletePolicyOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Policy.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(PolicyOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listPolicies. */ + public PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings() { + return listPoliciesSettings; + } + + /** Returns the builder for the settings used for calls to getPolicy. */ + public UnaryCallSettings.Builder getPolicySettings() { + return getPolicySettings; + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public UnaryCallSettings.Builder createPolicySettings() { + return createPolicySettings; + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + createPolicyOperationSettings() { + return createPolicyOperationSettings; + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public UnaryCallSettings.Builder updatePolicySettings() { + return updatePolicySettings; + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + updatePolicyOperationSettings() { + return updatePolicyOperationSettings; + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public UnaryCallSettings.Builder deletePolicySettings() { + return deletePolicySettings; + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + @BetaApi( + "The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder + deletePolicyOperationSettings() { + return deletePolicyOperationSettings; + } + + @Override + public PoliciesStubSettings build() throws IOException { + return new PoliciesStubSettings(this); + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/MockPolicies.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/MockPolicies.java new file mode 100644 index 000000000000..52054775d531 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/MockPolicies.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.iam.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockPolicies implements MockGrpcService { + private final MockPoliciesImpl serviceImpl; + + public MockPolicies() { + serviceImpl = new MockPoliciesImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/MockPoliciesImpl.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/MockPoliciesImpl.java new file mode 100644 index 000000000000..a77354b79a58 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/MockPoliciesImpl.java @@ -0,0 +1,165 @@ +/* + * 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.iam.v2; + +import com.google.api.core.BetaApi; +import com.google.iam.v2.PoliciesGrpc.PoliciesImplBase; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockPoliciesImpl extends PoliciesImplBase { + private List requests; + private Queue responses; + + public MockPoliciesImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listPolicies( + ListPoliciesRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListPoliciesResponse) { + requests.add(request); + responseObserver.onNext(((ListPoliciesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListPolicies, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListPoliciesResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getPolicy(GetPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createPolicy( + CreatePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreatePolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updatePolicy( + UpdatePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdatePolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deletePolicy( + DeletePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeletePolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/PoliciesClientHttpJsonTest.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/PoliciesClientHttpJsonTest.java new file mode 100644 index 000000000000..91228b7801e4 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/PoliciesClientHttpJsonTest.java @@ -0,0 +1,399 @@ +/* + * 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.iam.v2; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +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.common.collect.Lists; +import com.google.iam.v2.stub.HttpJsonPoliciesStub; +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 PoliciesClientHttpJsonTest { + private static MockHttpService mockService; + private static PoliciesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPoliciesStub.getMethodDescriptors(), PoliciesSettings.getDefaultEndpoint()); + PoliciesSettings settings = + PoliciesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PoliciesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PoliciesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listPoliciesTest() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "policies/policie-1456/policie-1456"; + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().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 listPoliciesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "policies/policie-1456/policie-1456"; + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + mockService.addResponse(expectedResponse); + + String name = "policies/policie-3260/policie-3260/policie-3260"; + + Policy actualResponse = client.getPolicy(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 getPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "policies/policie-3260/policie-3260/policie-3260"; + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "policies/policie-1456/policie-1456"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + + Policy actualResponse = client.createPolicyAsync(parent, policy, policyId).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 createPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "policies/policie-1456/policie-1456"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + client.createPolicyAsync(parent, policy, policyId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updatePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updatePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder() + .setPolicy( + Policy.newBuilder() + .setName("policies/policie-3260/policie-3260/policie-3260") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build()) + .build(); + + Policy actualResponse = client.updatePolicyAsync(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 updatePolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder() + .setPolicy( + Policy.newBuilder() + .setName("policies/policie-3260/policie-3260/policie-3260") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build()) + .build(); + client.updatePolicyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deletePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "policies/policie-3260/policie-3260/policie-3260"; + + Policy actualResponse = client.deletePolicyAsync(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 deletePolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "policies/policie-3260/policie-3260/policie-3260"; + client.deletePolicyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/PoliciesClientTest.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/PoliciesClientTest.java new file mode 100644 index 000000000000..81c53a73ed9d --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2/PoliciesClientTest.java @@ -0,0 +1,355 @@ +/* + * 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.iam.v2; + +import static com.google.iam.v2.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; +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 PoliciesClientTest { + private static MockPolicies mockPolicies; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private PoliciesClient client; + + @BeforeClass + public static void startStaticServer() { + mockPolicies = new MockPolicies(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), Arrays.asList(mockPolicies)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + PoliciesSettings settings = + PoliciesSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PoliciesClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void listPoliciesTest() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockPolicies.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0)); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListPoliciesRequest actualRequest = ((ListPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listPoliciesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String parent = "parent-995424086"; + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + mockPolicies.addResponse(expectedResponse); + + String name = "name3373707"; + + Policy actualResponse = client.getPolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetPolicyRequest actualRequest = ((GetPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String name = "name3373707"; + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockPolicies.addResponse(resultOperation); + + String parent = "parent-995424086"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + + Policy actualResponse = client.createPolicyAsync(parent, policy, policyId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreatePolicyRequest actualRequest = ((CreatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertEquals(policyId, actualRequest.getPolicyId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String parent = "parent-995424086"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + client.createPolicyAsync(parent, policy, policyId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void updatePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updatePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockPolicies.addResponse(resultOperation); + + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build(); + + Policy actualResponse = client.updatePolicyAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdatePolicyRequest actualRequest = ((UpdatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updatePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build(); + client.updatePolicyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void deletePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .setManagingAuthority("managingAuthority867537025") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockPolicies.addResponse(resultOperation); + + String name = "name3373707"; + + Policy actualResponse = client.deletePolicyAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeletePolicyRequest actualRequest = ((DeletePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deletePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String name = "name3373707"; + client.deletePolicyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPolicies.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPolicies.java new file mode 100644 index 000000000000..d68e492149f8 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPolicies.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.iam.v2beta; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockPolicies implements MockGrpcService { + private final MockPoliciesImpl serviceImpl; + + public MockPolicies() { + serviceImpl = new MockPoliciesImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPoliciesImpl.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPoliciesImpl.java new file mode 100644 index 000000000000..645a7a8642c8 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/MockPoliciesImpl.java @@ -0,0 +1,165 @@ +/* + * 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.iam.v2beta; + +import com.google.api.core.BetaApi; +import com.google.iam.v2beta.PoliciesGrpc.PoliciesImplBase; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockPoliciesImpl extends PoliciesImplBase { + private List requests; + private Queue responses; + + public MockPoliciesImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listPolicies( + ListPoliciesRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListPoliciesResponse) { + requests.add(request); + responseObserver.onNext(((ListPoliciesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListPolicies, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListPoliciesResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getPolicy(GetPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetPolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createPolicy( + CreatePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreatePolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updatePolicy( + UpdatePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdatePolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deletePolicy( + DeletePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeletePolicy, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java new file mode 100644 index 000000000000..0c1623809983 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java @@ -0,0 +1,393 @@ +/* + * 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.iam.v2beta; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +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.common.collect.Lists; +import com.google.iam.v2beta.stub.HttpJsonPoliciesStub; +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 PoliciesClientHttpJsonTest { + private static MockHttpService mockService; + private static PoliciesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPoliciesStub.getMethodDescriptors(), PoliciesSettings.getDefaultEndpoint()); + PoliciesSettings settings = + PoliciesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PoliciesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PoliciesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listPoliciesTest() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "policies/policie-1456/policie-1456"; + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().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 listPoliciesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "policies/policie-1456/policie-1456"; + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "policies/policie-3260/policie-3260/policie-3260"; + + Policy actualResponse = client.getPolicy(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 getPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "policies/policie-3260/policie-3260/policie-3260"; + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "policies/policie-1456/policie-1456"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + + Policy actualResponse = client.createPolicyAsync(parent, policy, policyId).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 createPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "policies/policie-1456/policie-1456"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + client.createPolicyAsync(parent, policy, policyId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updatePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updatePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder() + .setPolicy( + Policy.newBuilder() + .setName("policies/policie-3260/policie-3260/policie-3260") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build()) + .build(); + + Policy actualResponse = client.updatePolicyAsync(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 updatePolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder() + .setPolicy( + Policy.newBuilder() + .setName("policies/policie-3260/policie-3260/policie-3260") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build()) + .build(); + client.updatePolicyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deletePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "policies/policie-3260/policie-3260/policie-3260"; + + Policy actualResponse = client.deletePolicyAsync(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 deletePolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "policies/policie-3260/policie-3260/policie-3260"; + client.deletePolicyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java new file mode 100644 index 000000000000..ba966bb1b1f2 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java @@ -0,0 +1,351 @@ +/* + * 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.iam.v2beta; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; +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 PoliciesClientTest { + private static MockPolicies mockPolicies; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private PoliciesClient client; + + @BeforeClass + public static void startStaticServer() { + mockPolicies = new MockPolicies(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), Arrays.asList(mockPolicies)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + PoliciesSettings settings = + PoliciesSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PoliciesClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void listPoliciesTest() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockPolicies.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0)); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListPoliciesRequest actualRequest = ((ListPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listPoliciesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String parent = "parent-995424086"; + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + mockPolicies.addResponse(expectedResponse); + + String name = "name3373707"; + + Policy actualResponse = client.getPolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetPolicyRequest actualRequest = ((GetPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String name = "name3373707"; + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockPolicies.addResponse(resultOperation); + + String parent = "parent-995424086"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + + Policy actualResponse = client.createPolicyAsync(parent, policy, policyId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreatePolicyRequest actualRequest = ((CreatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertEquals(policyId, actualRequest.getPolicyId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String parent = "parent-995424086"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + client.createPolicyAsync(parent, policy, policyId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void updatePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updatePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockPolicies.addResponse(resultOperation); + + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build(); + + Policy actualResponse = client.updatePolicyAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdatePolicyRequest actualRequest = ((UpdatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updatePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build(); + client.updatePolicyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void deletePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockPolicies.addResponse(resultOperation); + + String name = "name3373707"; + + Policy actualResponse = client.deletePolicyAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockPolicies.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeletePolicyRequest actualRequest = ((DeletePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deletePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockPolicies.addException(exception); + + try { + String name = "name3373707"; + client.deletePolicyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } +} diff --git a/java-iam/owlbot.py b/java-iam/owlbot.py new file mode 100644 index 000000000000..3f53f0819f14 --- /dev/null +++ b/java-iam/owlbot.py @@ -0,0 +1,37 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This script is used to synthesize generated parts of this library.""" + +import synthtool as s +from synthtool.languages import java + +for library in s.get_staging_dirs(): + # put any special-case replacements here + s.move(library) + +s.remove_staging_dirs() +java.common_templates(monorepo=True, excludes=[ + ".github/*", + ".kokoro/*", + "samples/*", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "java.header", + "license-checks.xml", + "renovate.json", + ".gitignore" +]) diff --git a/java-iam/pom.xml b/java-iam/pom.xml new file mode 100644 index 000000000000..11c3db276fe0 --- /dev/null +++ b/java-iam/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + com.google.cloud + google-iam-policy-parent + pom + 1.7.1-SNAPSHOT + Google IAM Policy Parent + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-jar-parent + 1.4.0-SNAPSHOT + ../google-cloud-jar-parent/pom.xml + + + + UTF-8 + UTF-8 + github + google-iam-parent + + + + google-iam-policy + google-iam-policy-bom + + + diff --git a/java-iam/synth.metadata b/java-iam/synth.metadata new file mode 100644 index 000000000000..884257a9aa5d --- /dev/null +++ b/java-iam/synth.metadata @@ -0,0 +1,125 @@ +{ + "sources": [ + { + "git": { + "name": ".", + "remote": "https://github.com/googleapis/java-iam.git", + "sha": "0bde6b4db52bf09a4f1f0fbbb7519b82a4e7eb39" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "2921f9fb3bfbd16f6b2da0104373e2b47a80a65e", + "internalRef": "408420890" + } + }, + { + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "7a7c48f96e90d1cdc3ab0cc8293279fdcb10fd36" + } + } + ], + "generatedFiles": [ + ".github/CODEOWNERS", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/blunderbuss.yml", + ".github/generated-files-bot.yml", + ".github/release-please.yml", + ".github/release-trigger.yml", + ".github/snippet-bot.yml", + ".github/sync-repo-settings.yaml", + ".github/trusted-contribution.yml", + ".github/workflows/approve-readme.yaml", + ".github/workflows/auto-release.yaml", + ".github/workflows/ci.yaml", + ".kokoro/build.bat", + ".kokoro/build.sh", + ".kokoro/coerce_logs.sh", + ".kokoro/common.cfg", + ".kokoro/common.sh", + ".kokoro/continuous/common.cfg", + ".kokoro/continuous/java8.cfg", + ".kokoro/dependencies.sh", + ".kokoro/nightly/common.cfg", + ".kokoro/nightly/integration.cfg", + ".kokoro/nightly/java11.cfg", + ".kokoro/nightly/java7.cfg", + ".kokoro/nightly/java8-osx.cfg", + ".kokoro/nightly/java8-win.cfg", + ".kokoro/nightly/java8.cfg", + ".kokoro/nightly/samples.cfg", + ".kokoro/populate-secrets.sh", + ".kokoro/presubmit/clirr.cfg", + ".kokoro/presubmit/common.cfg", + ".kokoro/presubmit/dependencies.cfg", + ".kokoro/presubmit/graalvm-native.cfg", + ".kokoro/presubmit/integration.cfg", + ".kokoro/presubmit/java11.cfg", + ".kokoro/presubmit/java7.cfg", + ".kokoro/presubmit/java8-osx.cfg", + ".kokoro/presubmit/java8-win.cfg", + ".kokoro/presubmit/java8.cfg", + ".kokoro/presubmit/linkage-monitor.cfg", + ".kokoro/presubmit/lint.cfg", + ".kokoro/presubmit/samples.cfg", + ".kokoro/readme.sh", + ".kokoro/release/bump_snapshot.cfg", + ".kokoro/release/common.cfg", + ".kokoro/release/common.sh", + ".kokoro/release/drop.cfg", + ".kokoro/release/drop.sh", + ".kokoro/release/promote.cfg", + ".kokoro/release/promote.sh", + ".kokoro/release/publish_javadoc.cfg", + ".kokoro/release/publish_javadoc.sh", + ".kokoro/release/publish_javadoc11.cfg", + ".kokoro/release/publish_javadoc11.sh", + ".kokoro/release/snapshot.cfg", + ".kokoro/release/snapshot.sh", + ".kokoro/release/stage.cfg", + ".kokoro/release/stage.sh", + ".kokoro/trampoline.sh", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "codecov.yaml", + "grpc-google-iam-v1/src/main/java/com/google/iam/v1/IAMPolicyGrpc.java", + "java.header", + "license-checks.xml", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/AuditConfigDelta.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/AuditConfigDeltaOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/Binding.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/BindingDelta.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/BindingDeltaOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/BindingOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/GetIamPolicyRequest.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/GetIamPolicyRequestOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/GetPolicyOptions.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/GetPolicyOptionsOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/IamPolicyProto.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/OptionsProto.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/Policy.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/PolicyDelta.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/PolicyDeltaOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/PolicyOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/PolicyProto.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/SetIamPolicyRequest.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/SetIamPolicyRequestOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/TestIamPermissionsRequest.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/TestIamPermissionsRequestOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/TestIamPermissionsResponse.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/TestIamPermissionsResponseOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/logging/AuditData.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/logging/AuditDataOrBuilder.java", + "proto-google-iam-v1/src/main/java/com/google/iam/v1/logging/AuditDataProto.java", + "renovate.json" + ] +} \ No newline at end of file diff --git a/java-shared-dependencies/CHANGELOG.md b/java-shared-dependencies/CHANGELOG.md new file mode 100644 index 000000000000..f9737573f697 --- /dev/null +++ b/java-shared-dependencies/CHANGELOG.md @@ -0,0 +1,1105 @@ +# Changelog + + +## [3.1.2](https://github.com/googleapis/java-shared-dependencies/compare/v3.1.1...v3.1.2) (2023-01-20) + + +### Bug Fixes + +* **java:** Skip fixing poms for special modules ([#1744](https://github.com/googleapis/java-shared-dependencies/issues/1744)) ([#971](https://github.com/googleapis/java-shared-dependencies/issues/971)) ([74a96f1](https://github.com/googleapis/java-shared-dependencies/commit/74a96f1155418bde285877b72b4d7e600d08beb6)) + + +### Dependencies + +* Update dependency com.google.api:gapic-generator-java-bom to v2.14.0 ([#972](https://github.com/googleapis/java-shared-dependencies/issues/972)) ([2c742b5](https://github.com/googleapis/java-shared-dependencies/commit/2c742b56afc441f4922e6f6c737d3c3374ceadec)) +* Update dependency com.google.cloud:google-cloud-core-bom to v2.9.3 ([#974](https://github.com/googleapis/java-shared-dependencies/issues/974)) ([e4cb2ae](https://github.com/googleapis/java-shared-dependencies/commit/e4cb2ae34648c61ac40b7c9628e4ec088186fd57)) +* Update google.core.version to v2.9.2 ([#969](https://github.com/googleapis/java-shared-dependencies/issues/969)) ([aa946a6](https://github.com/googleapis/java-shared-dependencies/commit/aa946a6e33a5c8c3d6ae37bb07c3872c0bab793b)) +* Update google.core.version to v2.9.4 ([#976](https://github.com/googleapis/java-shared-dependencies/issues/976)) ([718246c](https://github.com/googleapis/java-shared-dependencies/commit/718246c985488b138eb0113b5a3200d3eb2af31d)) + +## [3.1.1](https://github.com/googleapis/java-shared-dependencies/compare/v3.1.0...v3.1.1) (2023-01-09) + + +### Dependencies + +* Adding `gapic-generator-java-bom` to `first-party-dependencies` ([#957](https://github.com/googleapis/java-shared-dependencies/issues/957)) ([f051e6e](https://github.com/googleapis/java-shared-dependencies/commit/f051e6ee0ad4a705014d9d2f8211ddad464b3ca4)) +* Update dependency com.google.api-client:google-api-client-bom to v2.1.2 ([#956](https://github.com/googleapis/java-shared-dependencies/issues/956)) ([dbfde36](https://github.com/googleapis/java-shared-dependencies/commit/dbfde36f5b0806192ea99d45382c84cff518f500)) +* Update dependency com.google.api:api-common to v2.3.1 ([#947](https://github.com/googleapis/java-shared-dependencies/issues/947)) ([f35c3bf](https://github.com/googleapis/java-shared-dependencies/commit/f35c3bf518e8b488ddeb28a6ff86719b24a62df5)) +* Update dependency com.google.auth:google-auth-library-bom to v1.14.0 ([#950](https://github.com/googleapis/java-shared-dependencies/issues/950)) ([e5609ca](https://github.com/googleapis/java-shared-dependencies/commit/e5609ca23657e1c37825c6d8930da1fb5080b8a6)) +* Update dependency com.google.code.gson:gson to v2.10.1 ([#958](https://github.com/googleapis/java-shared-dependencies/issues/958)) ([bd35327](https://github.com/googleapis/java-shared-dependencies/commit/bd353274c16d01915923a6fa34796d0b78672fb0)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.17.0 ([#955](https://github.com/googleapis/java-shared-dependencies/issues/955)) ([b656786](https://github.com/googleapis/java-shared-dependencies/commit/b6567863e659ff3eb6cc7b4b42a42acc7ebd24ed)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.18.0 ([#961](https://github.com/googleapis/java-shared-dependencies/issues/961)) ([0c4ff89](https://github.com/googleapis/java-shared-dependencies/commit/0c4ff895e103164dc0c95bc9789f9a3dc6c2f1a4)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.12 ([#948](https://github.com/googleapis/java-shared-dependencies/issues/948)) ([812ce38](https://github.com/googleapis/java-shared-dependencies/commit/812ce38e95de4db15184f9dd38bbd4c2affa2133)) +* Update dependency io.grpc:grpc-bom to v1.51.1 ([#953](https://github.com/googleapis/java-shared-dependencies/issues/953)) ([a86e70a](https://github.com/googleapis/java-shared-dependencies/commit/a86e70ac7be07cdb3b69d0cf4fc1afedbf7048fd)) +* Update dependency org.checkerframework:checker-qual to v3.29.0 ([#959](https://github.com/googleapis/java-shared-dependencies/issues/959)) ([784a79b](https://github.com/googleapis/java-shared-dependencies/commit/784a79b49b109d18858fd603dbdd37a4947280af)) +* Update dependency org.threeten:threetenbp to v1.6.5 ([#946](https://github.com/googleapis/java-shared-dependencies/issues/946)) ([403555e](https://github.com/googleapis/java-shared-dependencies/commit/403555e4010aef84e909e0b0e48cf5571d9e3184)) +* Update google.core.version to v2.9.1 ([#962](https://github.com/googleapis/java-shared-dependencies/issues/962)) ([c1e648d](https://github.com/googleapis/java-shared-dependencies/commit/c1e648d5045f871ed5670f949978430ad2d49484)) +* Update iam.version to v1.6.23 ([#954](https://github.com/googleapis/java-shared-dependencies/issues/954)) ([bb4730e](https://github.com/googleapis/java-shared-dependencies/commit/bb4730e7dcac57b6653825d63c7408d2182b0a27)) + +## [3.1.0](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.6...v3.1.0) (2022-12-05) + + +### Features + +* Next release from main branch is 3.1.0 ([#910](https://github.com/googleapis/java-shared-dependencies/issues/910)) ([3e36bc6](https://github.com/googleapis/java-shared-dependencies/commit/3e36bc6c5a6ffff771480200ecf5908cb347a50a)) + + +### Dependencies + +* Update dependency com.fasterxml.jackson:jackson-bom to v2.14.1 ([#924](https://github.com/googleapis/java-shared-dependencies/issues/924)) ([c630375](https://github.com/googleapis/java-shared-dependencies/commit/c630375d5059b4ac367979a2507c3870840c08e4)) +* Update dependency com.google.api-client:google-api-client-bom to v2.1.0 ([#934](https://github.com/googleapis/java-shared-dependencies/issues/934)) ([8af7b00](https://github.com/googleapis/java-shared-dependencies/commit/8af7b00cf0758df4015b1999d6f824ba1864be00)) +* Update dependency com.google.api-client:google-api-client-bom to v2.1.1 ([#941](https://github.com/googleapis/java-shared-dependencies/issues/941)) ([6a6e3e7](https://github.com/googleapis/java-shared-dependencies/commit/6a6e3e7d3232c7d74f92849a98e607a6d22b7b4e)) +* Update dependency com.google.auth:google-auth-library-bom to v1.13.0 ([#917](https://github.com/googleapis/java-shared-dependencies/issues/917)) ([1e2448c](https://github.com/googleapis/java-shared-dependencies/commit/1e2448c60cbe3e215b4f9f772d8e0c7cb1434bd0)) +* Update dependency com.google.cloud:grpc-gcp to v1.3.2 ([#942](https://github.com/googleapis/java-shared-dependencies/issues/942)) ([66c3e2a](https://github.com/googleapis/java-shared-dependencies/commit/66c3e2acda213fe9aea60b85f8543e3fdeaa2ecf)) +* Update dependency com.google.cloud.tools:dependencies to v1.5.13 ([#914](https://github.com/googleapis/java-shared-dependencies/issues/914)) ([9c0fa2c](https://github.com/googleapis/java-shared-dependencies/commit/9c0fa2c06ed04a3dddd9f0fd908865279393d373)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.10 ([#936](https://github.com/googleapis/java-shared-dependencies/issues/936)) ([f8abca8](https://github.com/googleapis/java-shared-dependencies/commit/f8abca8e075c59461c88b8c79fd1c5cd5eacb509)) +* Update dependency io.grpc:grpc-bom to v1.51.0 ([#919](https://github.com/googleapis/java-shared-dependencies/issues/919)) ([713b331](https://github.com/googleapis/java-shared-dependencies/commit/713b331a39917725ed4bd95c80c083c23d2a192e)) +* Update dependency io.perfmark:perfmark-api to v0.26.0 ([#907](https://github.com/googleapis/java-shared-dependencies/issues/907)) ([950cca6](https://github.com/googleapis/java-shared-dependencies/commit/950cca6df2d7e7d24ab8dd7e32c7a264e89d721f)) +* Update dependency org.apache.httpcomponents:httpclient to v4.5.14 ([#943](https://github.com/googleapis/java-shared-dependencies/issues/943)) ([7590b65](https://github.com/googleapis/java-shared-dependencies/commit/7590b6538290d3f9892b2b302505d3ecfca69530)) +* Update dependency org.apache.httpcomponents:httpcore to v4.4.16 ([#933](https://github.com/googleapis/java-shared-dependencies/issues/933)) ([6a68eb9](https://github.com/googleapis/java-shared-dependencies/commit/6a68eb96179a13cf324b4a4026ff6877d447a334)) +* Update dependency org.checkerframework:checker-qual to v3.28.0 ([#940](https://github.com/googleapis/java-shared-dependencies/issues/940)) ([5ea57c3](https://github.com/googleapis/java-shared-dependencies/commit/5ea57c3f5490c3cf7048e71dfab63aba8d7b874f)) +* Update gax.version to v2.20.1 ([#937](https://github.com/googleapis/java-shared-dependencies/issues/937)) ([ca30914](https://github.com/googleapis/java-shared-dependencies/commit/ca30914b59516c634de24b1fa33c8a6c454a0cef)) +* Update google.common-protos.version to v2.11.0 ([#935](https://github.com/googleapis/java-shared-dependencies/issues/935)) ([e92f583](https://github.com/googleapis/java-shared-dependencies/commit/e92f58361c0062414c34b669161f9d6284b0903f)) +* Update google.core.version to v2.8.28 ([#909](https://github.com/googleapis/java-shared-dependencies/issues/909)) ([79a731e](https://github.com/googleapis/java-shared-dependencies/commit/79a731e057fa7b1ac5f4bc6ae15869726bc9c20a)) +* Update google.core.version to v2.9.0 ([#944](https://github.com/googleapis/java-shared-dependencies/issues/944)) ([a50513b](https://github.com/googleapis/java-shared-dependencies/commit/a50513bc8902d059a7b53dc852b02b7e2f9bc3e6)) +* Update iam.version to v1.6.10 ([#915](https://github.com/googleapis/java-shared-dependencies/issues/915)) ([2c06312](https://github.com/googleapis/java-shared-dependencies/commit/2c06312732a56fd94f0ce8447062b42b3da15c92)) +* Update iam.version to v1.6.11 ([#916](https://github.com/googleapis/java-shared-dependencies/issues/916)) ([10b152d](https://github.com/googleapis/java-shared-dependencies/commit/10b152ded8ceded5ae3c60774ea8e75c7b69d9d8)) +* Update iam.version to v1.6.12 ([#918](https://github.com/googleapis/java-shared-dependencies/issues/918)) ([db57153](https://github.com/googleapis/java-shared-dependencies/commit/db57153752380dacb773530aef8079ff68772fc9)) +* Update iam.version to v1.6.13 ([#920](https://github.com/googleapis/java-shared-dependencies/issues/920)) ([763197e](https://github.com/googleapis/java-shared-dependencies/commit/763197e94a34620a2e234885fcdbdcb5fba144c2)) +* Update iam.version to v1.6.14 ([#921](https://github.com/googleapis/java-shared-dependencies/issues/921)) ([036cf6f](https://github.com/googleapis/java-shared-dependencies/commit/036cf6f0df788e9bffd5e21bfd8e560a797ed37d)) +* Update iam.version to v1.6.15 ([#922](https://github.com/googleapis/java-shared-dependencies/issues/922)) ([98b11a7](https://github.com/googleapis/java-shared-dependencies/commit/98b11a72f3818e4505d468c47b7c8105a3b55847)) +* Update iam.version to v1.6.16 ([#923](https://github.com/googleapis/java-shared-dependencies/issues/923)) ([b44d6ba](https://github.com/googleapis/java-shared-dependencies/commit/b44d6babd71d89ed27a0d7cac229d04111bb39e7)) +* Update iam.version to v1.6.17 ([#925](https://github.com/googleapis/java-shared-dependencies/issues/925)) ([f24a7f8](https://github.com/googleapis/java-shared-dependencies/commit/f24a7f8577ca90153d86b9ed3eab5954c1fc5500)) +* Update iam.version to v1.6.18 ([#926](https://github.com/googleapis/java-shared-dependencies/issues/926)) ([c77314d](https://github.com/googleapis/java-shared-dependencies/commit/c77314d5bdfbe960e6f71fb8dc044a60d1973038)) +* Update iam.version to v1.6.19 ([#927](https://github.com/googleapis/java-shared-dependencies/issues/927)) ([2990cf0](https://github.com/googleapis/java-shared-dependencies/commit/2990cf020e526ddba54c2a0542ef8e01f4f517f5)) +* Update iam.version to v1.6.20 ([#928](https://github.com/googleapis/java-shared-dependencies/issues/928)) ([7dbd204](https://github.com/googleapis/java-shared-dependencies/commit/7dbd204cdc0df7107c656e28766afeb14f6793c4)) +* Update iam.version to v1.6.21 ([#929](https://github.com/googleapis/java-shared-dependencies/issues/929)) ([cec2265](https://github.com/googleapis/java-shared-dependencies/commit/cec2265e43eaac7cc1be3c9bb42c0d93872f4075)) +* Update iam.version to v1.6.22 ([#931](https://github.com/googleapis/java-shared-dependencies/issues/931)) ([812ccf4](https://github.com/googleapis/java-shared-dependencies/commit/812ccf46fb0ada475dea2f6eb53839be8940dbde)) +* Update iam.version to v1.6.8 ([#906](https://github.com/googleapis/java-shared-dependencies/issues/906)) ([68ebe06](https://github.com/googleapis/java-shared-dependencies/commit/68ebe06101ec5b24fddb48012e3487c37827ba6a)) +* Update iam.version to v1.6.9 ([#912](https://github.com/googleapis/java-shared-dependencies/issues/912)) ([6a3097b](https://github.com/googleapis/java-shared-dependencies/commit/6a3097b559319f643f63727bd6d4ce5d30091317)) + +## [3.0.6](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.5...v3.0.6) (2022-11-07) + + +### Dependencies + +* Update dependency com.fasterxml.jackson:jackson-bom to v2.14.0 ([#901](https://github.com/googleapis/java-shared-dependencies/issues/901)) ([33c5511](https://github.com/googleapis/java-shared-dependencies/commit/33c55112ff485da1d7a0a32d8b6dade33aa04ff8)) +* Update dependency com.google.api-client:google-api-client-bom to v2.0.1 ([#899](https://github.com/googleapis/java-shared-dependencies/issues/899)) ([4029e89](https://github.com/googleapis/java-shared-dependencies/commit/4029e89be507ddfa030515565fdb6fbf8997324e)) +* Update dependency com.google.api:api-common to v2.2.2 ([#892](https://github.com/googleapis/java-shared-dependencies/issues/892)) ([5c59fbd](https://github.com/googleapis/java-shared-dependencies/commit/5c59fbd3c3cf3efbfda50420c8048e3ff257084c)) +* Update dependency com.google.cloud:grpc-gcp to v1.3.1 ([#884](https://github.com/googleapis/java-shared-dependencies/issues/884)) ([9fffe24](https://github.com/googleapis/java-shared-dependencies/commit/9fffe243b631565a00b0a848a6c73163b1dd33a4)) +* Update dependency com.google.code.gson:gson to v2.10 ([#887](https://github.com/googleapis/java-shared-dependencies/issues/887)) ([15017de](https://github.com/googleapis/java-shared-dependencies/commit/15017de39a35f90bc1b38b828edc23fdce524a07)) +* Update dependency com.google.http-client:google-http-client-bom to v1.42.3 ([#893](https://github.com/googleapis/java-shared-dependencies/issues/893)) ([4c0de9b](https://github.com/googleapis/java-shared-dependencies/commit/4c0de9bd188bfab5fe126c8b01b4d7168f8a5079)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.9 ([#889](https://github.com/googleapis/java-shared-dependencies/issues/889)) ([8576271](https://github.com/googleapis/java-shared-dependencies/commit/85762716d1bbb97c447f86451094fb8af2528470)) +* Update dependency io.grpc:grpc-bom to v1.50.2 ([#878](https://github.com/googleapis/java-shared-dependencies/issues/878)) ([fd569af](https://github.com/googleapis/java-shared-dependencies/commit/fd569af1e5f1b195e2421fc9e02d8b67afe1c638)) +* Update dependency org.checkerframework:checker-qual to v3.27.0 ([#896](https://github.com/googleapis/java-shared-dependencies/issues/896)) ([f0f7931](https://github.com/googleapis/java-shared-dependencies/commit/f0f7931937a0ed9a32fd87cd58c82b787d368242)) +* Update dependency org.threeten:threetenbp to v1.6.4 ([#894](https://github.com/googleapis/java-shared-dependencies/issues/894)) ([899682d](https://github.com/googleapis/java-shared-dependencies/commit/899682d0405645d9d5288b298af2fda228414669)) +* Update gax.version to v2.19.5 ([#903](https://github.com/googleapis/java-shared-dependencies/issues/903)) ([3e4d8b3](https://github.com/googleapis/java-shared-dependencies/commit/3e4d8b35d3f682b07326ffa0a3e552d097f25a65)) +* Update google.common-protos.version to v2.10.0 ([#900](https://github.com/googleapis/java-shared-dependencies/issues/900)) ([53b54c3](https://github.com/googleapis/java-shared-dependencies/commit/53b54c35f3a7c19df488921a6077e7a9bfb0b103)) +* Update google.core.version to v2.8.23 ([#885](https://github.com/googleapis/java-shared-dependencies/issues/885)) ([686dd7c](https://github.com/googleapis/java-shared-dependencies/commit/686dd7c8f541189302e8cac4ae72ed7d967b5b3f)) +* Update google.core.version to v2.8.24 ([#890](https://github.com/googleapis/java-shared-dependencies/issues/890)) ([1effda3](https://github.com/googleapis/java-shared-dependencies/commit/1effda381c7b886f5ae4d2dac9473da821e655fe)) +* Update google.core.version to v2.8.27 ([#902](https://github.com/googleapis/java-shared-dependencies/issues/902)) ([3bcb804](https://github.com/googleapis/java-shared-dependencies/commit/3bcb804dec4358ed0a9c6c35cf4c35f817821e9a)) +* Update iam.version to v1.6.6 ([#886](https://github.com/googleapis/java-shared-dependencies/issues/886)) ([03d0690](https://github.com/googleapis/java-shared-dependencies/commit/03d0690f01f9217e31dd65d55c28a47f2f2deb22)) +* Update iam.version to v1.6.7 ([#895](https://github.com/googleapis/java-shared-dependencies/issues/895)) ([6cebc20](https://github.com/googleapis/java-shared-dependencies/commit/6cebc205daa98b96a8b27b3fc3cd222319b27e59)) + +## [3.0.5](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.4...v3.0.5) (2022-10-20) + + +### Dependencies + +* Update dependency com.fasterxml.jackson:jackson-bom to v2.13.4.20221013 ([#868](https://github.com/googleapis/java-shared-dependencies/issues/868)) ([ffa7272](https://github.com/googleapis/java-shared-dependencies/commit/ffa7272e6d4775905e64173b3617555ee355019d)) +* Update dependency com.google.auth:google-auth-library-bom to v1.12.0 ([#870](https://github.com/googleapis/java-shared-dependencies/issues/870)) ([6e76f19](https://github.com/googleapis/java-shared-dependencies/commit/6e76f19133515b755b78185ce0135943e878a368)) +* Update dependency com.google.auth:google-auth-library-bom to v1.12.1 ([#871](https://github.com/googleapis/java-shared-dependencies/issues/871)) ([f7f5dc2](https://github.com/googleapis/java-shared-dependencies/commit/f7f5dc26dd54f33954bdf5d43314020de58e055b)) +* Update dependency com.google.cloud:grpc-gcp to v1.3.0 ([#867](https://github.com/googleapis/java-shared-dependencies/issues/867)) ([1927a92](https://github.com/googleapis/java-shared-dependencies/commit/1927a926c615eabbf0e7377c65232e0e5268220e)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.16 ([#865](https://github.com/googleapis/java-shared-dependencies/issues/865)) ([b1734ec](https://github.com/googleapis/java-shared-dependencies/commit/b1734ec1c20e7bdf2582b31fde4648aa9f8de2fe)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.8 ([#872](https://github.com/googleapis/java-shared-dependencies/issues/872)) ([1c303f2](https://github.com/googleapis/java-shared-dependencies/commit/1c303f2aa5145da4c93605a2d1088e8a3884de81)) +* Update dependency gcp-releasetool to v1.8.10 ([#853](https://github.com/googleapis/java-shared-dependencies/issues/853)) ([c815a59](https://github.com/googleapis/java-shared-dependencies/commit/c815a5996d28676de015d5dd41e2b0405f4bb9dc)) +* Update dependency google-api-core to v2.10.2 ([#858](https://github.com/googleapis/java-shared-dependencies/issues/858)) ([387a156](https://github.com/googleapis/java-shared-dependencies/commit/387a15662db0b20e72fe5bf961c02eb2bc4e75d9)) +* Update dependency io.grpc:grpc-bom to v1.50.0 ([#866](https://github.com/googleapis/java-shared-dependencies/issues/866)) ([3d3d443](https://github.com/googleapis/java-shared-dependencies/commit/3d3d4434636e605f47082641e8e495bbce8f9515)) +* Update dependency io.grpc:grpc-bom to v1.50.1 ([#873](https://github.com/googleapis/java-shared-dependencies/issues/873)) ([956309d](https://github.com/googleapis/java-shared-dependencies/commit/956309d76c9de46885711a77afbfce0d28971096)) +* Update dependency org.checkerframework:checker-qual to v3.26.0 ([#852](https://github.com/googleapis/java-shared-dependencies/issues/852)) ([6926b33](https://github.com/googleapis/java-shared-dependencies/commit/6926b33b83d1aa63e0c78b7b8c72cd1d80e28ef3)) +* Update dependency org.threeten:threetenbp to v1.6.3 ([#869](https://github.com/googleapis/java-shared-dependencies/issues/869)) ([fa4999b](https://github.com/googleapis/java-shared-dependencies/commit/fa4999b6310940e62456e83dad3ec76a7406a218)) +* Update dependency typing-extensions to v4.4.0 ([#854](https://github.com/googleapis/java-shared-dependencies/issues/854)) ([43bd31b](https://github.com/googleapis/java-shared-dependencies/commit/43bd31b66eef50d82ecf8a692053f10eb385d5c1)) +* Update dependency zipp to v3.9.0 ([#859](https://github.com/googleapis/java-shared-dependencies/issues/859)) ([a070ad0](https://github.com/googleapis/java-shared-dependencies/commit/a070ad04ef1bab5690487ba13dd4060827851edf)) +* Update gax.version to v2.19.4 ([#875](https://github.com/googleapis/java-shared-dependencies/issues/875)) ([227bdd8](https://github.com/googleapis/java-shared-dependencies/commit/227bdd86f368b89309814c615828544c29871a5d)) +* Update google.core.version to v2.8.21 ([#861](https://github.com/googleapis/java-shared-dependencies/issues/861)) ([8b502bd](https://github.com/googleapis/java-shared-dependencies/commit/8b502bd43760a2e52cf107567011d9c5132e74bd)) +* Update google.core.version to v2.8.22 ([#879](https://github.com/googleapis/java-shared-dependencies/issues/879)) ([0360e93](https://github.com/googleapis/java-shared-dependencies/commit/0360e931dc45034d3c3c554f2c29ad7ea4a0a9bb)) +* Update iam.version to v1.6.3 ([#857](https://github.com/googleapis/java-shared-dependencies/issues/857)) ([b39e683](https://github.com/googleapis/java-shared-dependencies/commit/b39e6838c3f3f6ef2b350efe8aec1b622893421a)) +* Update iam.version to v1.6.4 ([#862](https://github.com/googleapis/java-shared-dependencies/issues/862)) ([85c9794](https://github.com/googleapis/java-shared-dependencies/commit/85c979401c34454b2d5681eed9d8b3b3679413be)) + +## [3.0.4](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.3...v3.0.4) (2022-10-03) + + +### Dependencies + +* Update dependency cachetools to v5 ([#816](https://github.com/googleapis/java-shared-dependencies/issues/816)) ([3f6c408](https://github.com/googleapis/java-shared-dependencies/commit/3f6c408210c931c286235f61c7aadea5bf5cfe4d)) +* Update dependency certifi to v2022.9.24 ([#818](https://github.com/googleapis/java-shared-dependencies/issues/818)) ([5f04b97](https://github.com/googleapis/java-shared-dependencies/commit/5f04b97c2343146600e8c9ee65afdeb58f5743a6)) +* Update dependency charset-normalizer to v2.1.1 ([#822](https://github.com/googleapis/java-shared-dependencies/issues/822)) ([6997c5a](https://github.com/googleapis/java-shared-dependencies/commit/6997c5acad937ebe3594330de73261a424d42cf3)) +* Update dependency click to v8.1.3 ([#823](https://github.com/googleapis/java-shared-dependencies/issues/823)) ([42bf9f8](https://github.com/googleapis/java-shared-dependencies/commit/42bf9f834fdafea60f2be7ccbf7d363e058cd7c2)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.7 ([#837](https://github.com/googleapis/java-shared-dependencies/issues/837)) ([d31e507](https://github.com/googleapis/java-shared-dependencies/commit/d31e5077c7e036de5e238e9a611df7ced527574a)) +* Update dependency gcp-releasetool to v1.8.8 ([#819](https://github.com/googleapis/java-shared-dependencies/issues/819)) ([8245d97](https://github.com/googleapis/java-shared-dependencies/commit/8245d975fb12e81454ec7664f9a7c9809bbac697)) +* Update dependency gcp-releasetool to v1.8.9 ([#846](https://github.com/googleapis/java-shared-dependencies/issues/846)) ([04e3283](https://github.com/googleapis/java-shared-dependencies/commit/04e32831c6e87c372444901013a747d2d02ce38d)) +* Update dependency google-api-core to v2.10.1 ([#824](https://github.com/googleapis/java-shared-dependencies/issues/824)) ([818b9aa](https://github.com/googleapis/java-shared-dependencies/commit/818b9aa2ac99d8b1f9b39a74b626122aed5f1d94)) +* Update dependency google-auth to v2.12.0 ([#825](https://github.com/googleapis/java-shared-dependencies/issues/825)) ([07c544b](https://github.com/googleapis/java-shared-dependencies/commit/07c544b5e0fa9f7110bbc957570f7a405962072e)) +* Update dependency google-cloud-core to v2.3.2 ([#820](https://github.com/googleapis/java-shared-dependencies/issues/820)) ([2a219e8](https://github.com/googleapis/java-shared-dependencies/commit/2a219e86f187ba5ad72f2570bd58ca6100128c43)) +* Update dependency google-cloud-storage to v2.5.0 ([#826](https://github.com/googleapis/java-shared-dependencies/issues/826)) ([bb10d18](https://github.com/googleapis/java-shared-dependencies/commit/bb10d1858a515f09d365362ffa0110a5b362c96b)) +* Update dependency google-crc32c to v1.5.0 ([#827](https://github.com/googleapis/java-shared-dependencies/issues/827)) ([7e5dae6](https://github.com/googleapis/java-shared-dependencies/commit/7e5dae60d667cb84b9ee4f6c977bdc35e79e4cf6)) +* Update dependency google-resumable-media to v2.4.0 ([#838](https://github.com/googleapis/java-shared-dependencies/issues/838)) ([ad82d63](https://github.com/googleapis/java-shared-dependencies/commit/ad82d6378f64039da383509638fb4782908eb4bc)) +* Update dependency googleapis-common-protos to v1.56.4 ([#821](https://github.com/googleapis/java-shared-dependencies/issues/821)) ([93d7745](https://github.com/googleapis/java-shared-dependencies/commit/93d77458c9bbf84ec367cdb4caaa41e6f71675c6)) +* Update dependency importlib-metadata to v4.12.0 ([#832](https://github.com/googleapis/java-shared-dependencies/issues/832)) ([ee19fb1](https://github.com/googleapis/java-shared-dependencies/commit/ee19fb1ca5a2a2e1985297e3b72d44de68bc72e3)) +* Update dependency importlib-metadata to v4.13.0 ([#843](https://github.com/googleapis/java-shared-dependencies/issues/843)) ([d2ede60](https://github.com/googleapis/java-shared-dependencies/commit/d2ede601eee8c875780c7eb5924623537480c509)) +* Update dependency importlib-metadata to v5 ([#845](https://github.com/googleapis/java-shared-dependencies/issues/845)) ([03ac7e8](https://github.com/googleapis/java-shared-dependencies/commit/03ac7e800274c5f58d2bc4ddd0561bfcdea1bb27)) +* Update dependency io.grpc:grpc-bom to v1.49.1 ([#802](https://github.com/googleapis/java-shared-dependencies/issues/802)) ([b8c54bf](https://github.com/googleapis/java-shared-dependencies/commit/b8c54bf8f1ddecc788cee151f8afe42de45bdc9d)) +* Update dependency io.grpc:grpc-bom to v1.49.2 ([#842](https://github.com/googleapis/java-shared-dependencies/issues/842)) ([1b1cfa2](https://github.com/googleapis/java-shared-dependencies/commit/1b1cfa27d05f7732da12721305cf41dcbebda232)) +* Update dependency jeepney to v0.8.0 ([#833](https://github.com/googleapis/java-shared-dependencies/issues/833)) ([15d2f9f](https://github.com/googleapis/java-shared-dependencies/commit/15d2f9f52b5a3259db0813df3d2424e256ccb372)) +* Update dependency jinja2 to v3.1.2 ([#834](https://github.com/googleapis/java-shared-dependencies/issues/834)) ([c188f95](https://github.com/googleapis/java-shared-dependencies/commit/c188f95acdb3349f1c4b3ed56e5fffb75e8fbc8d)) +* Update dependency keyring to v23.9.3 ([#828](https://github.com/googleapis/java-shared-dependencies/issues/828)) ([b185aaa](https://github.com/googleapis/java-shared-dependencies/commit/b185aaae716d4d97cb64f0426cac0e778f11223d)) +* Update dependency markupsafe to v2.1.1 ([#829](https://github.com/googleapis/java-shared-dependencies/issues/829)) ([add2825](https://github.com/googleapis/java-shared-dependencies/commit/add2825bd34cd80f529dbe0dadb3c84219177916)) +* Update dependency org.threeten:threetenbp to v1.6.2 ([#808](https://github.com/googleapis/java-shared-dependencies/issues/808)) ([2d2eabd](https://github.com/googleapis/java-shared-dependencies/commit/2d2eabd14d8150207885ea47280c0f7ff3d2962f)) +* Update dependency protobuf to v3.20.2 ([#830](https://github.com/googleapis/java-shared-dependencies/issues/830)) ([5afa76f](https://github.com/googleapis/java-shared-dependencies/commit/5afa76f9ef4705aecba49abc7bb93982fb1ecf3e)) +* Update dependency protobuf to v3.20.3 ([#839](https://github.com/googleapis/java-shared-dependencies/issues/839)) ([d9fc7dd](https://github.com/googleapis/java-shared-dependencies/commit/d9fc7ddd3e663458e6ea3f78a3c6241377df0319)) +* Update dependency protobuf to v4 ([#817](https://github.com/googleapis/java-shared-dependencies/issues/817)) ([ee8d154](https://github.com/googleapis/java-shared-dependencies/commit/ee8d154287ccd256b4dcfa48f28f5ec61a91fe3e)) +* Update dependency pyjwt to v2.5.0 ([#812](https://github.com/googleapis/java-shared-dependencies/issues/812)) ([4d4528e](https://github.com/googleapis/java-shared-dependencies/commit/4d4528e8ce269d49b99d2dbc4fcda2dc37a058cb)) +* Update dependency requests to v2.28.1 ([#813](https://github.com/googleapis/java-shared-dependencies/issues/813)) ([a3a8d89](https://github.com/googleapis/java-shared-dependencies/commit/a3a8d89b0117007a7108553c70aa82dd289e1691)) +* Update dependency typing-extensions to v4.3.0 ([#814](https://github.com/googleapis/java-shared-dependencies/issues/814)) ([da875e5](https://github.com/googleapis/java-shared-dependencies/commit/da875e5e91fa9d8c177e6c3afc9e34242eb914b7)) +* Update dependency zipp to v3.8.1 ([#815](https://github.com/googleapis/java-shared-dependencies/issues/815)) ([15585fd](https://github.com/googleapis/java-shared-dependencies/commit/15585fd0216013fe93be011f93f391f6269aa777)) +* Update gax.version to v2.19.2 ([#847](https://github.com/googleapis/java-shared-dependencies/issues/847)) ([c4afe1f](https://github.com/googleapis/java-shared-dependencies/commit/c4afe1fdc88af29ab039cea618d52c15c90e43e9)) +* Update google.common-protos.version to v2.9.3 ([#803](https://github.com/googleapis/java-shared-dependencies/issues/803)) ([a3e8e5e](https://github.com/googleapis/java-shared-dependencies/commit/a3e8e5eb53a8da14abf3b8d81a4f34fbb2f3b8f9)) +* Update google.common-protos.version to v2.9.5 ([#831](https://github.com/googleapis/java-shared-dependencies/issues/831)) ([1c901db](https://github.com/googleapis/java-shared-dependencies/commit/1c901db8a7740afaec3e809e51d4d369fbf469c4)) +* Update google.common-protos.version to v2.9.6 ([#844](https://github.com/googleapis/java-shared-dependencies/issues/844)) ([9e156be](https://github.com/googleapis/java-shared-dependencies/commit/9e156be59bd89959f04252c3045b8cd7a8be8070)) +* Update google.core.version to v2.8.13 ([#804](https://github.com/googleapis/java-shared-dependencies/issues/804)) ([45ae571](https://github.com/googleapis/java-shared-dependencies/commit/45ae57142bd6d5334eedd46243736b200a459795)) +* Update google.core.version to v2.8.14 ([#805](https://github.com/googleapis/java-shared-dependencies/issues/805)) ([02c9397](https://github.com/googleapis/java-shared-dependencies/commit/02c9397a84bf3fcca8d04e4c9867cc47689abde2)) +* Update google.core.version to v2.8.15 ([#807](https://github.com/googleapis/java-shared-dependencies/issues/807)) ([980856c](https://github.com/googleapis/java-shared-dependencies/commit/980856c43981992a3d08f69eac83aeada752d244)) +* Update google.core.version to v2.8.16 ([#810](https://github.com/googleapis/java-shared-dependencies/issues/810)) ([c2b2c9a](https://github.com/googleapis/java-shared-dependencies/commit/c2b2c9a327fd588f69524bb93a17e5d4ae8f5a42)) +* Update google.core.version to v2.8.17 ([#835](https://github.com/googleapis/java-shared-dependencies/issues/835)) ([3def21d](https://github.com/googleapis/java-shared-dependencies/commit/3def21df2e4253e3df0da064b6c4e472df079d2b)) +* Update google.core.version to v2.8.18 ([#840](https://github.com/googleapis/java-shared-dependencies/issues/840)) ([46566dc](https://github.com/googleapis/java-shared-dependencies/commit/46566dc18c4b1ed41c482b4ce21b92651e2f9dc5)) +* Update google.core.version to v2.8.19 ([#841](https://github.com/googleapis/java-shared-dependencies/issues/841)) ([99afde9](https://github.com/googleapis/java-shared-dependencies/commit/99afde97ea498f549eb75cc58c4ed88edf81b20d)) +* Update google.core.version to v2.8.20 ([#848](https://github.com/googleapis/java-shared-dependencies/issues/848)) ([c980c4f](https://github.com/googleapis/java-shared-dependencies/commit/c980c4fdfc8890d812b4881ba5b87bfd21269a5f)) +* Update iam.version to v1.6.1 ([#806](https://github.com/googleapis/java-shared-dependencies/issues/806)) ([a50158d](https://github.com/googleapis/java-shared-dependencies/commit/a50158d3b83cf8e02d8ee08c94e512b5669a927b)) +* Update iam.version to v1.6.2 ([#849](https://github.com/googleapis/java-shared-dependencies/issues/849)) ([e43ac96](https://github.com/googleapis/java-shared-dependencies/commit/e43ac96bc189a096a9311c9b03e85c86bea07e99)) + +## [3.0.3](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.2...v3.0.3) (2022-09-14) + + +### Dependencies + +* Google-cloud-core 2.8.12 ([#799](https://github.com/googleapis/java-shared-dependencies/issues/799)) ([1b3db8d](https://github.com/googleapis/java-shared-dependencies/commit/1b3db8d1e17c49ebae79fc96164fa9058e1df6e3)) +* Moving gson to first-party-dependencies ([#800](https://github.com/googleapis/java-shared-dependencies/issues/800)) ([a41fcc1](https://github.com/googleapis/java-shared-dependencies/commit/a41fcc11d32e02e5af2837561792e3919f6d4b3f)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.6 ([#797](https://github.com/googleapis/java-shared-dependencies/issues/797)) ([bc5fdc9](https://github.com/googleapis/java-shared-dependencies/commit/bc5fdc9b3af7973c28f063a9ac156fe2af562814)) +* Update gax.version to v2.19.1 ([#798](https://github.com/googleapis/java-shared-dependencies/issues/798)) ([84e5487](https://github.com/googleapis/java-shared-dependencies/commit/84e5487b2e3dce4bb60badecebde788c3cb702b8)) +* Update google.core.version to v2.8.11 ([#793](https://github.com/googleapis/java-shared-dependencies/issues/793)) ([63c1297](https://github.com/googleapis/java-shared-dependencies/commit/63c129722aa0b821031ff5b4c11004adf7b12044)) + +## [3.0.2](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.1...v3.0.2) (2022-09-08) + + +### Dependencies + +* Update dependency com.fasterxml.jackson:jackson-bom to v2.13.4 ([#789](https://github.com/googleapis/java-shared-dependencies/issues/789)) ([6cf91a9](https://github.com/googleapis/java-shared-dependencies/commit/6cf91a96b9ea6af0fb845b50582dac7aa2892cab)) +* Update dependency com.google.auth:google-auth-library-bom to v1.10.0 ([#781](https://github.com/googleapis/java-shared-dependencies/issues/781)) ([8859e61](https://github.com/googleapis/java-shared-dependencies/commit/8859e61808bfc5cd9546e27e945fc855b36d2554)) +* Update dependency com.google.auth:google-auth-library-bom to v1.11.0 ([#790](https://github.com/googleapis/java-shared-dependencies/issues/790)) ([3431a47](https://github.com/googleapis/java-shared-dependencies/commit/3431a471cbf874a67a4f1a42e31f0ed891dedc92)) +* Update dependency com.google.auth:google-auth-library-bom to v1.9.0 ([#773](https://github.com/googleapis/java-shared-dependencies/issues/773)) ([27fc79f](https://github.com/googleapis/java-shared-dependencies/commit/27fc79f00ee70011df6a368bb8fcfad7f0ce41f0)) +* Update dependency com.google.errorprone:error_prone_annotations to v2.15.0 ([#776](https://github.com/googleapis/java-shared-dependencies/issues/776)) ([bf333b8](https://github.com/googleapis/java-shared-dependencies/commit/bf333b8c88072d21cb959db4d3328bbb55d9ef5c)) +* Update dependency com.google.protobuf:protobuf-bom to v3.21.5 ([#780](https://github.com/googleapis/java-shared-dependencies/issues/780)) ([da7f44d](https://github.com/googleapis/java-shared-dependencies/commit/da7f44d71d6d7f372b5313dab68ce220308614d4)) +* Update dependency io.grpc:grpc-bom to v1.48.1 ([#768](https://github.com/googleapis/java-shared-dependencies/issues/768)) ([5c7768d](https://github.com/googleapis/java-shared-dependencies/commit/5c7768d3c9665dd356de6c39c0a6a5fa6e992f2e)) +* Update dependency io.grpc:grpc-bom to v1.49.0 ([#786](https://github.com/googleapis/java-shared-dependencies/issues/786)) ([8734812](https://github.com/googleapis/java-shared-dependencies/commit/8734812f1b4e2faaa48caf41eff59a85892ae344)) +* Update dependency org.checkerframework:checker-qual to v3.24.0 ([#775](https://github.com/googleapis/java-shared-dependencies/issues/775)) ([df74b7b](https://github.com/googleapis/java-shared-dependencies/commit/df74b7b0dd5dd592523f302d9fb36adb5991cb0b)) +* Update dependency org.checkerframework:checker-qual to v3.25.0 ([#788](https://github.com/googleapis/java-shared-dependencies/issues/788)) ([207035b](https://github.com/googleapis/java-shared-dependencies/commit/207035bd04c9305899eea540acbefaf06a7b1ec9)) +* Update dependency org.threeten:threetenbp to v1.6.1 ([#782](https://github.com/googleapis/java-shared-dependencies/issues/782)) ([0f218ae](https://github.com/googleapis/java-shared-dependencies/commit/0f218aeb6aa33cf1da4a8b1d6c82bbf87946dab9)) +* Update gax.version to v2.19.0 ([#785](https://github.com/googleapis/java-shared-dependencies/issues/785)) ([4448331](https://github.com/googleapis/java-shared-dependencies/commit/4448331c4c6d88ea8076260776d1d47d24aa19fa)) +* Update google.core.version to v2.8.10 ([#787](https://github.com/googleapis/java-shared-dependencies/issues/787)) ([3c344d5](https://github.com/googleapis/java-shared-dependencies/commit/3c344d515e3b9215db5a1f8ef550d800d974e558)) +* Update google.core.version to v2.8.7 ([#774](https://github.com/googleapis/java-shared-dependencies/issues/774)) ([d0cd5e8](https://github.com/googleapis/java-shared-dependencies/commit/d0cd5e8f6ca88787fe0dbf7f30c849cb4c4fae5e)) +* Update google.core.version to v2.8.8 ([#777](https://github.com/googleapis/java-shared-dependencies/issues/777)) ([f00571c](https://github.com/googleapis/java-shared-dependencies/commit/f00571cd1e9f1c4e011fba4a1e1674c1d8d60200)) +* Update google.core.version to v2.8.9 ([#784](https://github.com/googleapis/java-shared-dependencies/issues/784)) ([aa8e505](https://github.com/googleapis/java-shared-dependencies/commit/aa8e505dbb1214b2239e55d5ac83b00c167d77e4)) + +## [3.0.1](https://github.com/googleapis/java-shared-dependencies/compare/v3.0.0...v3.0.1) (2022-08-02) + + +### Dependencies + +* update dependency com.google.code.gson:gson to v2.9.1 ([#766](https://github.com/googleapis/java-shared-dependencies/issues/766)) ([f7b2b06](https://github.com/googleapis/java-shared-dependencies/commit/f7b2b06b80e3e95ff8ab9b1d6a2638ef3069298a)) +* update gax.version to v2.18.7 ([#767](https://github.com/googleapis/java-shared-dependencies/issues/767)) ([9650368](https://github.com/googleapis/java-shared-dependencies/commit/96503682e98cdf348ea2c1365a03a60f4322c712)) +* update google.core.version to v2.8.6 ([#770](https://github.com/googleapis/java-shared-dependencies/issues/770)) ([cfd4377](https://github.com/googleapis/java-shared-dependencies/commit/cfd4377dc178cebb4724065d55d185ce03988d55)) + +## [3.0.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.13.0...v3.0.0) (2022-07-29) + + +### Bug Fixes + +* enable longpaths support for windows test ([#1485](https://github.com/googleapis/java-shared-dependencies/issues/1485)) ([#738](https://github.com/googleapis/java-shared-dependencies/issues/738)) ([11bc8f8](https://github.com/googleapis/java-shared-dependencies/commit/11bc8f81f28be88a97fdeafca21724e33638770c)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.35.2 ([#729](https://github.com/googleapis/java-shared-dependencies/issues/729)) ([1fa59af](https://github.com/googleapis/java-shared-dependencies/commit/1fa59af80abb9f278f57658c10158567e825fec6)) +* update dependency com.google.api-client:google-api-client-bom to v2 ([#746](https://github.com/googleapis/java-shared-dependencies/issues/746)) ([2dcb2e0](https://github.com/googleapis/java-shared-dependencies/commit/2dcb2e071e0ba0eea21bb575bd13cd559d4a1ca6)) +* update dependency com.google.api.grpc:grpc-google-common-protos to v2.9.2 ([#741](https://github.com/googleapis/java-shared-dependencies/issues/741)) ([3352d6c](https://github.com/googleapis/java-shared-dependencies/commit/3352d6c36111c04e3f6f3e6360470fa3efb10d8f)) +* update dependency com.google.auth:google-auth-library-bom to v1.8.0 ([#726](https://github.com/googleapis/java-shared-dependencies/issues/726)) ([2c5d64c](https://github.com/googleapis/java-shared-dependencies/commit/2c5d64c127db8384e49113acfeac6928716a2d7f)) +* update dependency com.google.auth:google-auth-library-bom to v1.8.1 ([#742](https://github.com/googleapis/java-shared-dependencies/issues/742)) ([4f53527](https://github.com/googleapis/java-shared-dependencies/commit/4f53527bda7f40896711b7c1d1c02453321ffbc8)) +* update dependency com.google.cloud:first-party-dependencies to v2 ([#747](https://github.com/googleapis/java-shared-dependencies/issues/747)) ([e970ac0](https://github.com/googleapis/java-shared-dependencies/commit/e970ac0599941c825dc2516146a7c6673e68a9b9)) +* update dependency com.google.cloud:grpc-gcp to v1.2.1 ([#751](https://github.com/googleapis/java-shared-dependencies/issues/751)) ([b3284b6](https://github.com/googleapis/java-shared-dependencies/commit/b3284b6ee52a96a6ea8696a05a94443df9ee5b9f)) +* update dependency com.google.cloud:third-party-dependencies to v2 ([#748](https://github.com/googleapis/java-shared-dependencies/issues/748)) ([573b41a](https://github.com/googleapis/java-shared-dependencies/commit/573b41a69504372741cbeb01dd200e7c71967186)) +* update dependency com.google.http-client:google-http-client-bom to v1.42.1 ([#730](https://github.com/googleapis/java-shared-dependencies/issues/730)) ([6b47126](https://github.com/googleapis/java-shared-dependencies/commit/6b47126686b603a5d112e097ce6aa3a1880daf6f)) +* update dependency com.google.http-client:google-http-client-bom to v1.42.2 ([#749](https://github.com/googleapis/java-shared-dependencies/issues/749)) ([299d7b0](https://github.com/googleapis/java-shared-dependencies/commit/299d7b0d4920644e2c3070d12dd1d97da17a5e88)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.2 ([#722](https://github.com/googleapis/java-shared-dependencies/issues/722)) ([7a96b12](https://github.com/googleapis/java-shared-dependencies/commit/7a96b1259a526b63e9376fd6cc18b27cddeb5f0f)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.3 ([#756](https://github.com/googleapis/java-shared-dependencies/issues/756)) ([3d0bac2](https://github.com/googleapis/java-shared-dependencies/commit/3d0bac23487aebb94267c0708f41ff6c02a028a4)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.4 ([#759](https://github.com/googleapis/java-shared-dependencies/issues/759)) ([5a54ef1](https://github.com/googleapis/java-shared-dependencies/commit/5a54ef1a2d56244166d4fcc46041d62c0dc4b411)) +* update dependency io.grpc:grpc-bom to v1.48.0 ([#752](https://github.com/googleapis/java-shared-dependencies/issues/752)) ([20ac908](https://github.com/googleapis/java-shared-dependencies/commit/20ac908932a5e7c8e581bdfcd68579d7e1cedd5f)) +* update dependency org.checkerframework:checker-qual to v3.23.0 ([#736](https://github.com/googleapis/java-shared-dependencies/issues/736)) ([fc01d8f](https://github.com/googleapis/java-shared-dependencies/commit/fc01d8f93f391f12fdb800d5006f0b4505832eeb)) +* update gax.version to v2.18.3 ([#731](https://github.com/googleapis/java-shared-dependencies/issues/731)) ([e8ee554](https://github.com/googleapis/java-shared-dependencies/commit/e8ee554707acb2f71c739d08e2ff02fbe43ffa52)) +* update gax.version to v2.18.4 ([#735](https://github.com/googleapis/java-shared-dependencies/issues/735)) ([11c7415](https://github.com/googleapis/java-shared-dependencies/commit/11c74152a84697924de3a0e838b05f606c3098f7)) +* update gax.version to v2.18.5 ([#758](https://github.com/googleapis/java-shared-dependencies/issues/758)) ([7469fc1](https://github.com/googleapis/java-shared-dependencies/commit/7469fc1cc5095b39a5738e60156711a268f6e052)) +* update gax.version to v2.18.6 ([#763](https://github.com/googleapis/java-shared-dependencies/issues/763)) ([b5ca2f7](https://github.com/googleapis/java-shared-dependencies/commit/b5ca2f7b4d81c705823253f4f03363a32d2be48b)) +* update google.common-protos.version to v2.9.1 ([#724](https://github.com/googleapis/java-shared-dependencies/issues/724)) ([5213dbb](https://github.com/googleapis/java-shared-dependencies/commit/5213dbbfa9c9b73d2420ec2be7782f16c9c4955f)) +* update google.core.version to v2.8.1 ([#725](https://github.com/googleapis/java-shared-dependencies/issues/725)) ([575858a](https://github.com/googleapis/java-shared-dependencies/commit/575858a60f76e46bbc2a2435c2b6c01c8f4ab681)) +* update google.core.version to v2.8.3 ([#760](https://github.com/googleapis/java-shared-dependencies/issues/760)) ([cb10ae4](https://github.com/googleapis/java-shared-dependencies/commit/cb10ae4b76939215ea465af74163b3d4ad65a548)) +* update google.core.version to v2.8.4 ([#762](https://github.com/googleapis/java-shared-dependencies/issues/762)) ([821daaf](https://github.com/googleapis/java-shared-dependencies/commit/821daafefdbcfdfe6e363e580747538096a562ef)) +* update google.core.version to v2.8.5 ([#764](https://github.com/googleapis/java-shared-dependencies/issues/764)) ([a1f8f50](https://github.com/googleapis/java-shared-dependencies/commit/a1f8f501b54143a2cec8e72efd4ceb3ce47f13ae)) +* update iam.version to v1.5.0 ([#732](https://github.com/googleapis/java-shared-dependencies/issues/732)) ([9dce0e5](https://github.com/googleapis/java-shared-dependencies/commit/9dce0e5199c1e425119adc804304958f58003a27)) +* update iam.version to v1.5.1 ([#737](https://github.com/googleapis/java-shared-dependencies/issues/737)) ([df39168](https://github.com/googleapis/java-shared-dependencies/commit/df391685d42fcb1b04f03ab1380a594893bdce37)) +* update iam.version to v1.5.2 ([#743](https://github.com/googleapis/java-shared-dependencies/issues/743)) ([cdde697](https://github.com/googleapis/java-shared-dependencies/commit/cdde697f25a89fc8c2ec7eae6b7c54f69977bb1c)) + +## [2.13.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.12.0...v2.13.0) (2022-06-22) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.35.0 ([#709](https://github.com/googleapis/java-shared-dependencies/issues/709)) ([239f8c3](https://github.com/googleapis/java-shared-dependencies/commit/239f8c33a11e233e6af79aee8c7e68cd156a0554)) +* update dependency com.google.api-client:google-api-client-bom to v1.35.1 ([#713](https://github.com/googleapis/java-shared-dependencies/issues/713)) ([6559b45](https://github.com/googleapis/java-shared-dependencies/commit/6559b45b027dba783a9525d35e32183d78773cbe)) +* update dependency com.google.api:api-common to v2.2.1 ([#710](https://github.com/googleapis/java-shared-dependencies/issues/710)) ([650d4c5](https://github.com/googleapis/java-shared-dependencies/commit/650d4c5f8c3cfce711257d47280ad773cd2e2414)) +* update dependency com.google.errorprone:error_prone_annotations to v2.14.0 ([#701](https://github.com/googleapis/java-shared-dependencies/issues/701)) ([d24730f](https://github.com/googleapis/java-shared-dependencies/commit/d24730f78669f80b109e590b903446e5552e3e36)) +* update dependency com.google.http-client:google-http-client-bom to v1.42.0 ([#711](https://github.com/googleapis/java-shared-dependencies/issues/711)) ([5168a18](https://github.com/googleapis/java-shared-dependencies/commit/5168a181722128d434a0d0d2ab5cc485686bbc78)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.34.0 ([#708](https://github.com/googleapis/java-shared-dependencies/issues/708)) ([620336e](https://github.com/googleapis/java-shared-dependencies/commit/620336e6733e2017116e5e8a7b403b183a728bc1)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.34.1 ([#712](https://github.com/googleapis/java-shared-dependencies/issues/712)) ([a2c18a5](https://github.com/googleapis/java-shared-dependencies/commit/a2c18a5bc4152cc9034cec691a29f54a35c38a51)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.0 ([#703](https://github.com/googleapis/java-shared-dependencies/issues/703)) ([5f9fe12](https://github.com/googleapis/java-shared-dependencies/commit/5f9fe1200b4bdf4c54bf947c21bd3ed02f26f990)) +* update dependency com.google.protobuf:protobuf-bom to v3.21.1 ([#705](https://github.com/googleapis/java-shared-dependencies/issues/705)) ([c68edfb](https://github.com/googleapis/java-shared-dependencies/commit/c68edfbe7e1993e1112640b867b29aa2fbcf7579)) +* update dependency io.grpc:grpc-bom to v1.47.0 ([#707](https://github.com/googleapis/java-shared-dependencies/issues/707)) ([d02918a](https://github.com/googleapis/java-shared-dependencies/commit/d02918a0418cd65d1d247f27afb0637f1f8f5666)) +* update dependency org.checkerframework:checker-qual to v3.22.1 ([#706](https://github.com/googleapis/java-shared-dependencies/issues/706)) ([545843b](https://github.com/googleapis/java-shared-dependencies/commit/545843b492cead230b8cc72a1dae7d4922f33b39)) +* update dependency org.checkerframework:checker-qual to v3.22.2 ([#717](https://github.com/googleapis/java-shared-dependencies/issues/717)) ([142852a](https://github.com/googleapis/java-shared-dependencies/commit/142852a37140f221197f5c71aed451def353b1e0)) +* update gax.version to v2.18.2 ([#718](https://github.com/googleapis/java-shared-dependencies/issues/718)) ([5f8156e](https://github.com/googleapis/java-shared-dependencies/commit/5f8156e55c6a07b018a8c5efafa68be781b4288b)) +* update google.common-protos.version to v2.9.0 ([#714](https://github.com/googleapis/java-shared-dependencies/issues/714)) ([9e5591e](https://github.com/googleapis/java-shared-dependencies/commit/9e5591ec3035350450ecbfebd00e08216433b06c)) +* update google.core.version to v2.8.0 ([#719](https://github.com/googleapis/java-shared-dependencies/issues/719)) ([4023c60](https://github.com/googleapis/java-shared-dependencies/commit/4023c6063a2c5b5308da531df1a08c90c491965d)) +* update iam.version to v1.4.0 ([#700](https://github.com/googleapis/java-shared-dependencies/issues/700)) ([c1097a4](https://github.com/googleapis/java-shared-dependencies/commit/c1097a46ab0739b0b7234bc510e4c3d9ce2c2861)) +* update iam.version to v1.4.1 ([#716](https://github.com/googleapis/java-shared-dependencies/issues/716)) ([e2dc7c2](https://github.com/googleapis/java-shared-dependencies/commit/e2dc7c21c39e007878841e2664d548ec44a72d54)) + +## [2.12.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.11.0...v2.12.0) (2022-05-19) + + +### Features + +* add build scripts for native image testing in Java 17 ([#1440](https://github.com/googleapis/java-shared-dependencies/issues/1440)) ([#697](https://github.com/googleapis/java-shared-dependencies/issues/697)) ([f10ec4e](https://github.com/googleapis/java-shared-dependencies/commit/f10ec4e664d8fde868effe366b7182a5fad08dd0)) + + +### Dependencies + +* update gax.version to v2.18.1 ([#695](https://github.com/googleapis/java-shared-dependencies/issues/695)) ([09bc61c](https://github.com/googleapis/java-shared-dependencies/commit/09bc61c9152a99bfe87554a07324f15ae6217d6e)) +* update google.core.version to v2.7.1 ([#698](https://github.com/googleapis/java-shared-dependencies/issues/698)) ([43de259](https://github.com/googleapis/java-shared-dependencies/commit/43de2593f1a6e8fa5e34799364ab683246ddd449)) + +## [2.11.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.10.0...v2.11.0) (2022-05-18) + + +### Features + +* next release from main branch is 2.11.0 ([#674](https://github.com/googleapis/java-shared-dependencies/issues/674)) ([611e3b7](https://github.com/googleapis/java-shared-dependencies/commit/611e3b7c50108a71efc94415166b85d2bf8647e5)) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.13.3 ([#689](https://github.com/googleapis/java-shared-dependencies/issues/689)) ([03897e3](https://github.com/googleapis/java-shared-dependencies/commit/03897e30a71f8f1aa37233da2433ee5afccc1d61)) +* update dependency com.google.api-client:google-api-client-bom to v1.34.1 ([#685](https://github.com/googleapis/java-shared-dependencies/issues/685)) ([9bc0557](https://github.com/googleapis/java-shared-dependencies/commit/9bc0557d8ce2f3d8dc7c8ffafdd36fd4c03e2df5)) +* update dependency com.google.api:api-common to v2.2.0 ([#690](https://github.com/googleapis/java-shared-dependencies/issues/690)) ([47a8736](https://github.com/googleapis/java-shared-dependencies/commit/47a87365e51f73132b15b054d85f8c9baa8e89f6)) +* update dependency com.google.auth:google-auth-library-bom to v1.7.0 ([#691](https://github.com/googleapis/java-shared-dependencies/issues/691)) ([ec6aab7](https://github.com/googleapis/java-shared-dependencies/commit/ec6aab72eaed43574efe47a696bba6a612f161bb)) +* update dependency com.google.errorprone:error_prone_annotations to v2.13.1 ([#672](https://github.com/googleapis/java-shared-dependencies/issues/672)) ([8c7e530](https://github.com/googleapis/java-shared-dependencies/commit/8c7e530d3c7170b2fb76cc27a05164524ba4e00b)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.8 ([#684](https://github.com/googleapis/java-shared-dependencies/issues/684)) ([1305356](https://github.com/googleapis/java-shared-dependencies/commit/1305356775247dbb641b60654ac56da43513088e)) +* update dependency com.google.protobuf:protobuf-bom to v3.20.1 ([#678](https://github.com/googleapis/java-shared-dependencies/issues/678)) ([3e6d4a1](https://github.com/googleapis/java-shared-dependencies/commit/3e6d4a1a8e5d45723071a62c99bb1ab87d2b2b84)) +* update dependency io.grpc:grpc-bom to v1.46.0 ([#680](https://github.com/googleapis/java-shared-dependencies/issues/680)) ([b8a052b](https://github.com/googleapis/java-shared-dependencies/commit/b8a052b75a1bc2703500b4f31c5c6dac887ab8be)) +* update dependency org.checkerframework:checker-qual to v3.22.0 ([#683](https://github.com/googleapis/java-shared-dependencies/issues/683)) ([b0a30cd](https://github.com/googleapis/java-shared-dependencies/commit/b0a30cdecae8dcfb3a6d36e3f194c39a0086673e)) +* update gax.version to v2.17.0 ([#687](https://github.com/googleapis/java-shared-dependencies/issues/687)) ([e0e89ea](https://github.com/googleapis/java-shared-dependencies/commit/e0e89eade481effc723c9c7261f2ebf4e5883621)) +* update gax.version to v2.18.0 ([#692](https://github.com/googleapis/java-shared-dependencies/issues/692)) ([9536612](https://github.com/googleapis/java-shared-dependencies/commit/9536612c77af1e4d912c5b63515ea6f750e53810)) +* update google.core.version to v2.6.1 ([#671](https://github.com/googleapis/java-shared-dependencies/issues/671)) ([e3d1aeb](https://github.com/googleapis/java-shared-dependencies/commit/e3d1aebed31f8e91109d5865afd9525ac3595c90)) +* update google.core.version to v2.7.0 ([#693](https://github.com/googleapis/java-shared-dependencies/issues/693)) ([2171677](https://github.com/googleapis/java-shared-dependencies/commit/2171677e16190de9f37dc16c924d829ea8ccd86c)) +* update iam.version to v1.3.2 ([#673](https://github.com/googleapis/java-shared-dependencies/issues/673)) ([9882baa](https://github.com/googleapis/java-shared-dependencies/commit/9882baa3ecc8d7584788af1916f0d8c5ec670b5c)) +* update iam.version to v1.3.3 ([#679](https://github.com/googleapis/java-shared-dependencies/issues/679)) ([9fe34c8](https://github.com/googleapis/java-shared-dependencies/commit/9fe34c89eabed5eeebad986bffeeeb64dbbc38c1)) +* update iam.version to v1.3.4 ([#686](https://github.com/googleapis/java-shared-dependencies/issues/686)) ([4e95b3a](https://github.com/googleapis/java-shared-dependencies/commit/4e95b3a1d4302812338c220df316391c19ef7473)) +* update opencensus.version to v0.31.1 ([#682](https://github.com/googleapis/java-shared-dependencies/issues/682)) ([5d25746](https://github.com/googleapis/java-shared-dependencies/commit/5d25746bc6c9329b240204cbe7b83e2fee4c6cb3)) + +## [2.10.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.9.0...v2.10.0) (2022-04-15) + + +### Dependencies + +* google-cloud-core 2.6.0 ([#668](https://github.com/googleapis/java-shared-dependencies/issues/668)) ([22f4d18](https://github.com/googleapis/java-shared-dependencies/commit/22f4d1809cbb9848174b3569ab527e4bef00d443)) +* reverting protobuf to 3.19.4 ([#657](https://github.com/googleapis/java-shared-dependencies/issues/657)) ([8501e6d](https://github.com/googleapis/java-shared-dependencies/commit/8501e6d842c10d2370bbd5d5246070134336bddd)) +* update dependency com.fasterxml.jackson:jackson-bom to v2.13.2.20220328 ([#646](https://github.com/googleapis/java-shared-dependencies/issues/646)) ([7bfd6d7](https://github.com/googleapis/java-shared-dependencies/commit/7bfd6d7073859d1955b91b368c6713a72ffa14b6)) +* update dependency com.google.api-client:google-api-client-bom to v1.34.0 ([#662](https://github.com/googleapis/java-shared-dependencies/issues/662)) ([1b8e378](https://github.com/googleapis/java-shared-dependencies/commit/1b8e378fe0ccf2a28c759868caaf5ba593a95728)) +* update dependency com.google.errorprone:error_prone_annotations to v2.12.1 ([#652](https://github.com/googleapis/java-shared-dependencies/issues/652)) ([1cc80ee](https://github.com/googleapis/java-shared-dependencies/commit/1cc80ee984ebcad9bc2a95e2f28c0a49fe924b37)) +* update dependency com.google.errorprone:error_prone_annotations to v2.13.0 ([#669](https://github.com/googleapis/java-shared-dependencies/issues/669)) ([61b7834](https://github.com/googleapis/java-shared-dependencies/commit/61b78341b34a251722be4805a6bdd895cd64836c)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.6 ([#654](https://github.com/googleapis/java-shared-dependencies/issues/654)) ([140ef40](https://github.com/googleapis/java-shared-dependencies/commit/140ef405bc17ed83f5ce177df59affca14fbe49c)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.7 ([#658](https://github.com/googleapis/java-shared-dependencies/issues/658)) ([f6f93e5](https://github.com/googleapis/java-shared-dependencies/commit/f6f93e5b9172c9684623c4c148e4a8fe2fae1e94)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.2 ([#655](https://github.com/googleapis/java-shared-dependencies/issues/655)) ([20cd9ed](https://github.com/googleapis/java-shared-dependencies/commit/20cd9eda112c96836a5ab7485a4247ed2bc0edb8)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.3 ([#663](https://github.com/googleapis/java-shared-dependencies/issues/663)) ([f011a46](https://github.com/googleapis/java-shared-dependencies/commit/f011a46c551dba16851b4f8c919c40452fc5d5c3)) +* update dependency com.google.protobuf:protobuf-bom to v3.20.0 ([#651](https://github.com/googleapis/java-shared-dependencies/issues/651)) ([ad2ff73](https://github.com/googleapis/java-shared-dependencies/commit/ad2ff73207dd6493321c77d8eca0022baf13b4ce)) +* update dependency io.grpc:grpc-bom to v1.45.1 ([#647](https://github.com/googleapis/java-shared-dependencies/issues/647)) ([38e46fc](https://github.com/googleapis/java-shared-dependencies/commit/38e46fc4f03af0a02f30ce4a2fa222c71797ae15)) +* update dependency org.checkerframework:checker-qual to v3.21.4 ([#650](https://github.com/googleapis/java-shared-dependencies/issues/650)) ([125e80a](https://github.com/googleapis/java-shared-dependencies/commit/125e80ab2c3225a00c03f5ff5de94872ebb94303)) +* update gax.version to v2.15.0 ([#649](https://github.com/googleapis/java-shared-dependencies/issues/649)) ([c7f32a6](https://github.com/googleapis/java-shared-dependencies/commit/c7f32a68b14520104432282ac9598643700162eb)) +* update gax.version to v2.16.0 ([#664](https://github.com/googleapis/java-shared-dependencies/issues/664)) ([caaf941](https://github.com/googleapis/java-shared-dependencies/commit/caaf941643af04295f5527a0144587d7bf040862)) +* update google.common-protos.version to v2.8.1 ([#656](https://github.com/googleapis/java-shared-dependencies/issues/656)) ([df4a4a2](https://github.com/googleapis/java-shared-dependencies/commit/df4a4a2130a3cdb2965ea42962d1ea6a85506ba7)) +* update google.common-protos.version to v2.8.2 ([#659](https://github.com/googleapis/java-shared-dependencies/issues/659)) ([b499e2b](https://github.com/googleapis/java-shared-dependencies/commit/b499e2bc99506d48d26e35bf6e68c09409ce8b11)) +* update google.common-protos.version to v2.8.3 ([#660](https://github.com/googleapis/java-shared-dependencies/issues/660)) ([461081c](https://github.com/googleapis/java-shared-dependencies/commit/461081c0cf73057c1f6e07fc573453ad467a60ae)) +* update iam.version to v1.3.0 ([#648](https://github.com/googleapis/java-shared-dependencies/issues/648)) ([6670c4f](https://github.com/googleapis/java-shared-dependencies/commit/6670c4f61fcf075c543bfd148eea49796e0662ce)) +* update iam.version to v1.3.1 ([#661](https://github.com/googleapis/java-shared-dependencies/issues/661)) ([cc8fbe6](https://github.com/googleapis/java-shared-dependencies/commit/cc8fbe6eae03341c2ece7d3356febc843a74a812)) + +## [2.9.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.8.0...v2.9.0) (2022-03-28) + + +### Dependencies + +* guava 31.1 ([#635](https://github.com/googleapis/java-shared-dependencies/issues/635)) ([0939b06](https://github.com/googleapis/java-shared-dependencies/commit/0939b063a79cd4ffafb49cf04861ce577e35efd6)) +* update dependency com.fasterxml.jackson:jackson-bom to v2.13.2 ([#626](https://github.com/googleapis/java-shared-dependencies/issues/626)) ([6014663](https://github.com/googleapis/java-shared-dependencies/commit/601466339c9631faa88033d1ff1e31582fb67b7b)) +* update dependency com.fasterxml.jackson:jackson-bom to v2.13.2.20220324 ([#636](https://github.com/googleapis/java-shared-dependencies/issues/636)) ([6c833fa](https://github.com/googleapis/java-shared-dependencies/commit/6c833faa7815147013999bfc2bb6935fd8fe6b34)) +* update dependency com.google.api-client:google-api-client-bom to v1.33.4 ([#642](https://github.com/googleapis/java-shared-dependencies/issues/642)) ([57bd912](https://github.com/googleapis/java-shared-dependencies/commit/57bd9124ce8981b7b3b5d0c87b7c1e5f935b7150)) +* update dependency com.google.api:api-common to v2.1.5 ([#637](https://github.com/googleapis/java-shared-dependencies/issues/637)) ([d3a00fa](https://github.com/googleapis/java-shared-dependencies/commit/d3a00fa5ce9908000122d8365fb2f2d0e388494b)) +* update dependency com.google.auth:google-auth-library-bom to v1.6.0 ([#631](https://github.com/googleapis/java-shared-dependencies/issues/631)) ([53dc7c2](https://github.com/googleapis/java-shared-dependencies/commit/53dc7c2fe255a6c7ca059dd414449bf96780f936)) +* update dependency com.google.cloud:google-cloud-core-bom to v2.5.11 ([#644](https://github.com/googleapis/java-shared-dependencies/issues/644)) ([4331dcc](https://github.com/googleapis/java-shared-dependencies/commit/4331dcc331e8377fcc57e5404321611186ca22cb)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.5 ([#638](https://github.com/googleapis/java-shared-dependencies/issues/638)) ([e007d23](https://github.com/googleapis/java-shared-dependencies/commit/e007d2381bd388a1c199fc3f31d0b965f8ae592d)) +* update dependency io.grpc:grpc-bom to v1.45.0 ([#630](https://github.com/googleapis/java-shared-dependencies/issues/630)) ([20334e3](https://github.com/googleapis/java-shared-dependencies/commit/20334e30d256897cd7ef52c646e5c4549cd7ae69)) +* update dependency org.threeten:threetenbp to v1.6.0 ([#633](https://github.com/googleapis/java-shared-dependencies/issues/633)) ([1a2716d](https://github.com/googleapis/java-shared-dependencies/commit/1a2716d22e442c5cd6adea9449756b9ac3ddbf8e)) +* update gax.version to v2.13.0 ([#641](https://github.com/googleapis/java-shared-dependencies/issues/641)) ([b863746](https://github.com/googleapis/java-shared-dependencies/commit/b863746727fadd45c35198f58eb862f47fe14945)) +* update google.common-protos.version to v2.8.0 ([#639](https://github.com/googleapis/java-shared-dependencies/issues/639)) ([252afba](https://github.com/googleapis/java-shared-dependencies/commit/252afba1df8e4cfdf2574d127097b0978b7778c0)) +* update google.core.version to v2.5.10 ([#628](https://github.com/googleapis/java-shared-dependencies/issues/628)) ([fec6f51](https://github.com/googleapis/java-shared-dependencies/commit/fec6f5121384a04a389bad6f6477a9a5ce468016)) +* update iam.version to v1.2.10 ([#625](https://github.com/googleapis/java-shared-dependencies/issues/625)) ([0d7ca29](https://github.com/googleapis/java-shared-dependencies/commit/0d7ca2924bd24abe14883c173156bb4dc5fb90bf)) + +## [2.8.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.7.0...v2.8.0) (2022-03-02) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.33.2 ([#602](https://github.com/googleapis/java-shared-dependencies/issues/602)) ([85b132f](https://github.com/googleapis/java-shared-dependencies/commit/85b132f5830772646025b6a9fbbb970a941b86b5)) +* update dependency com.google.api:api-common to v2.1.4 ([#605](https://github.com/googleapis/java-shared-dependencies/issues/605)) ([ca7d49a](https://github.com/googleapis/java-shared-dependencies/commit/ca7d49aee26b6d90abd2afd61c20861d2307fe9c)) +* update dependency com.google.auth:google-auth-library-bom to v1.5.3 ([#614](https://github.com/googleapis/java-shared-dependencies/issues/614)) ([e6413f3](https://github.com/googleapis/java-shared-dependencies/commit/e6413f3b1be78473ace7085c344eda2d78cdf01a)) +* update dependency com.google.cloud:google-cloud-core to v2.5.6 ([#621](https://github.com/googleapis/java-shared-dependencies/issues/621)) ([3d5669f](https://github.com/googleapis/java-shared-dependencies/commit/3d5669f215689dd2df71200ffe37d5a9d385cda8)) +* update dependency com.google.code.gson:gson to v2.9.0 ([#611](https://github.com/googleapis/java-shared-dependencies/issues/611)) ([f59c28d](https://github.com/googleapis/java-shared-dependencies/commit/f59c28d8cd30ada1237f7722135ba148dce6315e)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.4 ([#608](https://github.com/googleapis/java-shared-dependencies/issues/608)) ([f9a4f23](https://github.com/googleapis/java-shared-dependencies/commit/f9a4f23d3a32148ac59e53eaae6558ccbceca12c)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.1 ([#606](https://github.com/googleapis/java-shared-dependencies/issues/606)) ([3882494](https://github.com/googleapis/java-shared-dependencies/commit/3882494770d48fcc02ed19088aa06612a8e440eb)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.4 ([#593](https://github.com/googleapis/java-shared-dependencies/issues/593)) ([1e155bf](https://github.com/googleapis/java-shared-dependencies/commit/1e155bfc957bbb7e25d2e0994cdecaa81843bdc5)) +* update dependency io.grpc:grpc-bom to v1.44.1 ([#613](https://github.com/googleapis/java-shared-dependencies/issues/613)) ([3038a2c](https://github.com/googleapis/java-shared-dependencies/commit/3038a2c86cd20c91b65f2d7926eeb739147a68db)) +* update dependency junit:junit to v4.13.2 ([#607](https://github.com/googleapis/java-shared-dependencies/issues/607)) ([987e617](https://github.com/googleapis/java-shared-dependencies/commit/987e61796c7a093e005fe8832cf39275c391b2c1)) +* update dependency org.checkerframework:checker-qual to v3.21.3 ([#596](https://github.com/googleapis/java-shared-dependencies/issues/596)) ([ac5083c](https://github.com/googleapis/java-shared-dependencies/commit/ac5083cd010924dc128f041c2cdbab20166a6bf0)) +* update gax.version to v2.12.2 ([#592](https://github.com/googleapis/java-shared-dependencies/issues/592)) ([713ff8d](https://github.com/googleapis/java-shared-dependencies/commit/713ff8dd94f939c417524616bc47c771a3fbe0cf)) +* update google.common-protos.version to v2.7.4 ([#603](https://github.com/googleapis/java-shared-dependencies/issues/603)) ([bb9b4c7](https://github.com/googleapis/java-shared-dependencies/commit/bb9b4c7e39552cc73b3b9d4c826b26e8cb74459f)) +* update google.core.version ([#599](https://github.com/googleapis/java-shared-dependencies/issues/599)) ([327d0df](https://github.com/googleapis/java-shared-dependencies/commit/327d0df9b57203c0d4f426de0380770d3d7910d6)) +* update iam.version to v1.2.6 ([#598](https://github.com/googleapis/java-shared-dependencies/issues/598)) ([2801439](https://github.com/googleapis/java-shared-dependencies/commit/280143964c7c3b93a8d7f67215ba2cc74ffce761)) + +## [2.7.0](https://github.com/googleapis/java-shared-dependencies/compare/v2.6.0...v2.7.0) (2022-01-28) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.13.1 ([#555](https://github.com/googleapis/java-shared-dependencies/issues/555)) ([67b5663](https://github.com/googleapis/java-shared-dependencies/commit/67b56635509215fd132b2ffbcaed995a6de93879)) +* update dependency com.google.api-client:google-api-client-bom to v1.33.1 ([#580](https://github.com/googleapis/java-shared-dependencies/issues/580)) ([895dba2](https://github.com/googleapis/java-shared-dependencies/commit/895dba2afef6c295b0e21a4ccd27feee1b6af8e2)) +* update dependency com.google.api:api-common to v2.1.3 ([#587](https://github.com/googleapis/java-shared-dependencies/issues/587)) ([5dbbce8](https://github.com/googleapis/java-shared-dependencies/commit/5dbbce80baa045818757912e6db4f222c12b75f6)) +* update dependency com.google.auth:google-auth-library-bom to v1.4.0 ([#578](https://github.com/googleapis/java-shared-dependencies/issues/578)) ([c274c62](https://github.com/googleapis/java-shared-dependencies/commit/c274c62905192bcc48c82104bf50cbeaa1894c2b)) +* update dependency com.google.errorprone:error_prone_annotations to v2.11.0 ([#582](https://github.com/googleapis/java-shared-dependencies/issues/582)) ([314da38](https://github.com/googleapis/java-shared-dependencies/commit/314da38c9f12cf425b5d1be8297e9f2a78d13948)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.2 ([#579](https://github.com/googleapis/java-shared-dependencies/issues/579)) ([c8df06d](https://github.com/googleapis/java-shared-dependencies/commit/c8df06ddb3f4a975e928bbdd9dfae293e81efa39)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.33.0 ([#576](https://github.com/googleapis/java-shared-dependencies/issues/576)) ([3315988](https://github.com/googleapis/java-shared-dependencies/commit/3315988059ca0223f078b0f760960674bfa8c04a)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.3 ([#571](https://github.com/googleapis/java-shared-dependencies/issues/571)) ([c1931e1](https://github.com/googleapis/java-shared-dependencies/commit/c1931e1c4611ca3d1e2afac1c9e983cf1ec4a7de)) +* update dependency io.grpc:grpc-bom to v1.44.0 ([#586](https://github.com/googleapis/java-shared-dependencies/issues/586)) ([52c47b7](https://github.com/googleapis/java-shared-dependencies/commit/52c47b7425af438ba1a82dac87f9002353a6a87a)) +* update dependency org.checkerframework:checker-qual to v3.21.1 ([#554](https://github.com/googleapis/java-shared-dependencies/issues/554)) ([81bbb91](https://github.com/googleapis/java-shared-dependencies/commit/81bbb91774ab67161371bfd0dfd143de89dee4c9)) +* update gax.version to v2.11.0 ([#581](https://github.com/googleapis/java-shared-dependencies/issues/581)) ([1899612](https://github.com/googleapis/java-shared-dependencies/commit/189961226f84cdd4e283780d2c7d4a4dffc3e00c)) +* update gax.version to v2.9.0 ([#573](https://github.com/googleapis/java-shared-dependencies/issues/573)) ([ee5e38e](https://github.com/googleapis/java-shared-dependencies/commit/ee5e38efea574eeb2b5803192da98ba1ce1c8e6e)) +* update google.common-protos.version to v2.7.2 ([#588](https://github.com/googleapis/java-shared-dependencies/issues/588)) ([caac0e6](https://github.com/googleapis/java-shared-dependencies/commit/caac0e68e336b801becb6322b5b81fce1824ad8a)) +* update google.core.version to v2.4.0 ([#589](https://github.com/googleapis/java-shared-dependencies/issues/589)) ([6a292e3](https://github.com/googleapis/java-shared-dependencies/commit/6a292e3530a06d6b228f3154ed4e979ef68d7aeb)) +* update iam.version to v1.2.1 ([#569](https://github.com/googleapis/java-shared-dependencies/issues/569)) ([62dd270](https://github.com/googleapis/java-shared-dependencies/commit/62dd2705b257c4bb539bfe619234f38d0e13b138)) +* update opencensus.version to v0.30.0 ([#552](https://github.com/googleapis/java-shared-dependencies/issues/552)) ([ebae62e](https://github.com/googleapis/java-shared-dependencies/commit/ebae62eca75234db4fd571f42b8ed0f6ce1bd1f7)) +* update opencensus.version to v0.31.0 ([#585](https://github.com/googleapis/java-shared-dependencies/issues/585)) ([021b066](https://github.com/googleapis/java-shared-dependencies/commit/021b066a833af1629c89fcca593d16b9786ee0bf)) + +## [2.6.0](https://www.github.com/googleapis/java-shared-dependencies/compare/2.5.1...v2.6.0) (2022-01-07) + + +### Bug Fixes + +* **java:** add -ntp flag to native image testing command ([#1299](https://www.github.com/googleapis/java-shared-dependencies/issues/1299)) ([#546](https://www.github.com/googleapis/java-shared-dependencies/issues/546)) ([d8bb8d9](https://www.github.com/googleapis/java-shared-dependencies/commit/d8bb8d9d8e3b8c582f768cd3164e8580ec334511)) +* **java:** run Maven in plain console-friendly mode ([#1301](https://www.github.com/googleapis/java-shared-dependencies/issues/1301)) ([#557](https://www.github.com/googleapis/java-shared-dependencies/issues/557)) ([6b57d08](https://www.github.com/googleapis/java-shared-dependencies/commit/6b57d08816ec6c1dfb637cae022624e896930ad8)) + + +### Dependencies + +* gRPC upgrade to 1.43.2 ([#567](https://www.github.com/googleapis/java-shared-dependencies/issues/567)) ([c946655](https://www.github.com/googleapis/java-shared-dependencies/commit/c94665571f26d24fbbb3f89ef5a3db99663bfdba)) +* update dependency com.google.api-client:google-api-client-bom to v1.33.0 ([#563](https://www.github.com/googleapis/java-shared-dependencies/issues/563)) ([0aedddb](https://www.github.com/googleapis/java-shared-dependencies/commit/0aedddb9a535753767d56f5910f355c7a1c8509c)) +* update dependency com.google.api:api-common to v2.1.2 ([2f154a3](https://www.github.com/googleapis/java-shared-dependencies/commit/2f154a3ff759211438c72859e98b314c7ff8405f)) +* update dependency com.google.http-client:google-http-client-bom to v1.41.0 ([#562](https://www.github.com/googleapis/java-shared-dependencies/issues/562)) ([6da0735](https://www.github.com/googleapis/java-shared-dependencies/commit/6da0735d4db9df998d11c549488a024b800bed65)) +* update dependency io.grpc:grpc-bom to v1.43.1 ([#553](https://www.github.com/googleapis/java-shared-dependencies/issues/553)) ([b787c8f](https://www.github.com/googleapis/java-shared-dependencies/commit/b787c8f2032b7ffc9797158c3ff214b7813f34b7)) +* update dependency org.apache.httpcomponents:httpcore to v4.4.15 ([#550](https://www.github.com/googleapis/java-shared-dependencies/issues/550)) ([e2d3dba](https://www.github.com/googleapis/java-shared-dependencies/commit/e2d3dbad6dd54c117abb5ab1b6137cfee4e5a32b)) +* update dependency org.checkerframework:checker-qual to v3.20.0 ([#549](https://www.github.com/googleapis/java-shared-dependencies/issues/549)) ([586df59](https://www.github.com/googleapis/java-shared-dependencies/commit/586df5949d4ddca11d0705d696882c32d8436c31)) +* update gax.version to v2.8.0 ([#564](https://www.github.com/googleapis/java-shared-dependencies/issues/564)) ([9ad5d4f](https://www.github.com/googleapis/java-shared-dependencies/commit/9ad5d4f5385753a0c5739ef400f5d346e3342b84)) +* update gax.version to v2.8.1 ([2f154a3](https://www.github.com/googleapis/java-shared-dependencies/commit/2f154a3ff759211438c72859e98b314c7ff8405f)) +* update google.common-protos.version to v2.7.1 ([#561](https://www.github.com/googleapis/java-shared-dependencies/issues/561)) ([9aa860d](https://www.github.com/googleapis/java-shared-dependencies/commit/9aa860d92f745f1d4382eb16439bf17ac6ca8ae9)) +* update google.core.version to v2.3.5 ([#565](https://www.github.com/googleapis/java-shared-dependencies/issues/565)) ([2f154a3](https://www.github.com/googleapis/java-shared-dependencies/commit/2f154a3ff759211438c72859e98b314c7ff8405f)) +* update iam.version to v1.2.0 ([#547](https://www.github.com/googleapis/java-shared-dependencies/issues/547)) ([3232c82](https://www.github.com/googleapis/java-shared-dependencies/commit/3232c828b628cb604a200b3e569e56e758e5e11d)) +* upgrading protobuf to 3.19.2 ([#560](https://www.github.com/googleapis/java-shared-dependencies/issues/560)) ([7ef3325](https://www.github.com/googleapis/java-shared-dependencies/commit/7ef33250f5473348d3546210b7a534360f476101)) + +### [2.5.1](https://www.github.com/googleapis/java-shared-dependencies/compare/2.5.0...v2.5.1) (2021-12-03) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.1 ([#533](https://www.github.com/googleapis/java-shared-dependencies/issues/533)) ([4e23adb](https://www.github.com/googleapis/java-shared-dependencies/commit/4e23adb666dfaa18ae8bf869aca030153de16d62)) +* update gax.version to v2.7.1 ([#544](https://www.github.com/googleapis/java-shared-dependencies/issues/544)) ([5a0c480](https://www.github.com/googleapis/java-shared-dependencies/commit/5a0c480671fa834e600edc6ac6fe77967d1b79b3)) +* update google.common-protos.version to v2.7.0 ([#542](https://www.github.com/googleapis/java-shared-dependencies/issues/542)) ([af97eb5](https://www.github.com/googleapis/java-shared-dependencies/commit/af97eb5d9cff397080fdb3d4a6dbf7c2692e0358)) +* update google.core.version to v2.3.3 ([#534](https://www.github.com/googleapis/java-shared-dependencies/issues/534)) ([885acef](https://www.github.com/googleapis/java-shared-dependencies/commit/885acefe4ff5313eb53dc43b4825ca597b97dcfd)) + +## [2.5.0](https://www.github.com/googleapis/java-shared-dependencies/compare/2.4.0...v2.5.0) (2021-11-12) + + +### Features + +* next release from main branch is 2.5.0 ([#510](https://www.github.com/googleapis/java-shared-dependencies/issues/510)) ([ca9eb8a](https://www.github.com/googleapis/java-shared-dependencies/commit/ca9eb8a40ae81d69de0d82d9499ef21b0136ae49)) + + +### Bug Fixes + +* dependencies.sh to work with Java 17 ([#516](https://www.github.com/googleapis/java-shared-dependencies/issues/516)) ([8422c1d](https://www.github.com/googleapis/java-shared-dependencies/commit/8422c1d7e9ef479f348e63c530789050b5235426)) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.1.0 ([#508](https://www.github.com/googleapis/java-shared-dependencies/issues/508)) ([ae32d16](https://www.github.com/googleapis/java-shared-dependencies/commit/ae32d1689c78fc1469206c8c0df0ebaca59edd2c)) +* update dependency com.google.auth:google-auth-library-bom to v1.2.2 ([#506](https://www.github.com/googleapis/java-shared-dependencies/issues/506)) ([b9a8209](https://www.github.com/googleapis/java-shared-dependencies/commit/b9a82098655f29e858bd0c7a9b1049a379e5062a)) +* update dependency com.google.auth:google-auth-library-bom to v1.3.0 ([#524](https://www.github.com/googleapis/java-shared-dependencies/issues/524)) ([fc07879](https://www.github.com/googleapis/java-shared-dependencies/commit/fc07879fa6531e39b21977fe77abc19354a1fd33)) +* update dependency com.google.code.gson:gson to v2.8.9 ([#509](https://www.github.com/googleapis/java-shared-dependencies/issues/509)) ([bece99b](https://www.github.com/googleapis/java-shared-dependencies/commit/bece99bb3e0365e60e7376ba18d046ab6436a235)) +* update dependency com.google.errorprone:error_prone_annotations to v2.10.0 ([#512](https://www.github.com/googleapis/java-shared-dependencies/issues/512)) ([c281f13](https://www.github.com/googleapis/java-shared-dependencies/commit/c281f137525e2111e97349657be578ed1fc832f2)) +* update dependency com.google.protobuf:protobuf-bom to v3.19.1 ([#505](https://www.github.com/googleapis/java-shared-dependencies/issues/505)) ([94cde96](https://www.github.com/googleapis/java-shared-dependencies/commit/94cde96069900f9f8c2ff9a522671d03b26828bd)) +* update dependency io.grpc:grpc-bom to v1.42.1 ([#513](https://www.github.com/googleapis/java-shared-dependencies/issues/513)) ([0d2b774](https://www.github.com/googleapis/java-shared-dependencies/commit/0d2b774287a132821cc6fe2789140086bc48d525)) +* update dependency org.checkerframework:checker-qual to v3.19.0 ([#501](https://www.github.com/googleapis/java-shared-dependencies/issues/501)) ([2b3e0b5](https://www.github.com/googleapis/java-shared-dependencies/commit/2b3e0b5ddc3a645b20a837f3123394f1ca114f08)) +* update dependency org.threeten:threetenbp to v1.5.2 ([#514](https://www.github.com/googleapis/java-shared-dependencies/issues/514)) ([4885f40](https://www.github.com/googleapis/java-shared-dependencies/commit/4885f402e2c70435cd10d4f1b893df9873808c56)) +* update gax.version to v2.7.0 ([#515](https://www.github.com/googleapis/java-shared-dependencies/issues/515)) ([567e728](https://www.github.com/googleapis/java-shared-dependencies/commit/567e728b0e59233a04e2d04183e6a0c36cca2437)) +* update google.core.version to v2.3.0 ([#530](https://www.github.com/googleapis/java-shared-dependencies/issues/530)) ([78e87e9](https://www.github.com/googleapis/java-shared-dependencies/commit/78e87e96befab34dc4a494e752aeb473cd14a156)) +* update iam.version to v1.1.7 ([#504](https://www.github.com/googleapis/java-shared-dependencies/issues/504)) ([63dd583](https://www.github.com/googleapis/java-shared-dependencies/commit/63dd583c80f35b01a66fd1908d41467468c66436)) + +## [2.4.0](https://www.github.com/googleapis/java-shared-dependencies/compare/2.3.0...v2.4.0) (2021-10-18) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.13.0 ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update dependency com.google.api-client:google-api-client-bom to v1.32.2 ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update dependency com.google.api:api-common to v2.0.5 ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update dependency com.google.auth:google-auth-library-bom to v1.2.1 ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update dependency com.google.guava:guava-bom to v31 ([#498](https://www.github.com/googleapis/java-shared-dependencies/issues/498)) ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update dependency com.google.http-client:google-http-client-bom to v1.40.1 ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update dependency com.google.protobuf:protobuf-bom to v3.18.1 ([#494](https://www.github.com/googleapis/java-shared-dependencies/issues/494)) ([a30e376](https://www.github.com/googleapis/java-shared-dependencies/commit/a30e3762b5fb0e2d31304d211c12eb2c1320f0c1)) +* update dependency io.grpc:grpc-bom to v1.41.0 ([#482](https://www.github.com/googleapis/java-shared-dependencies/issues/482)) ([8a7d227](https://www.github.com/googleapis/java-shared-dependencies/commit/8a7d227f2a1dab9ff23d247a4e6131c817804c36)) +* update gax.version to v2.6.1 ([dba11b5](https://www.github.com/googleapis/java-shared-dependencies/commit/dba11b5fe14d39cdd62357e7bb1b82831c481150)) +* update iam.version to v1.1.6 ([#485](https://www.github.com/googleapis/java-shared-dependencies/issues/485)) ([cef7e09](https://www.github.com/googleapis/java-shared-dependencies/commit/cef7e090bbc2e3ae775fa83505f98df286ba7d42)) + +## [2.3.0](https://www.github.com/googleapis/java-shared-dependencies/compare/2.2.1...v2.3.0) (2021-09-22) + + +### Dependencies + +* keep protobuf at 3.17.3 (not the latest 3.18.0) ([#476](https://www.github.com/googleapis/java-shared-dependencies/issues/476)) ([e207c81](https://www.github.com/googleapis/java-shared-dependencies/commit/e207c818f220967e3618d7a9d36f2cf26c07892e)) +* update gax.version to v2.5.0 ([#479](https://www.github.com/googleapis/java-shared-dependencies/issues/479)) ([e22e62a](https://www.github.com/googleapis/java-shared-dependencies/commit/e22e62a3b248023ae94da2a02ec50006377a5157)) +* update google.core.version to v2.1.4 ([#473](https://www.github.com/googleapis/java-shared-dependencies/issues/473)) ([116f278](https://www.github.com/googleapis/java-shared-dependencies/commit/116f2783dfc18f215905ceaff9f85f331f83472b)) +* update google.core.version to v2.1.6 ([#478](https://www.github.com/googleapis/java-shared-dependencies/issues/478)) ([9e09728](https://www.github.com/googleapis/java-shared-dependencies/commit/9e0972834764b25e5e194e0e805efc5453120df3)) +* update iam.version to v1.1.1 ([#470](https://www.github.com/googleapis/java-shared-dependencies/issues/470)) ([3b6e960](https://www.github.com/googleapis/java-shared-dependencies/commit/3b6e96050af8d976a30165481d764d8226143a39)) +* update iam.version to v1.1.2 ([#472](https://www.github.com/googleapis/java-shared-dependencies/issues/472)) ([85329cc](https://www.github.com/googleapis/java-shared-dependencies/commit/85329cc6c13d16fe2eeeb076959ee16a752c1f9e)) + +### [2.2.1](https://www.github.com/googleapis/java-shared-dependencies/compare/2.2.0...v2.2.1) (2021-09-13) + + +### Dependencies + +* update gax.version to v2.4.1 ([#464](https://www.github.com/googleapis/java-shared-dependencies/issues/464)) ([bc7c6d7](https://www.github.com/googleapis/java-shared-dependencies/commit/bc7c6d7ca161ebfa31895c375d65bca29d4c7336)) +* update google.core.version to v2.1.3 ([#465](https://www.github.com/googleapis/java-shared-dependencies/issues/465)) ([848f608](https://www.github.com/googleapis/java-shared-dependencies/commit/848f608ae850bd2dd80ec56034eb0c9a18f0415b)) + +## [2.2.0](https://www.github.com/googleapis/java-shared-dependencies/compare/2.1.0...v2.2.0) (2021-08-31) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.12.5 ([#456](https://www.github.com/googleapis/java-shared-dependencies/issues/456)) ([05b58e8](https://www.github.com/googleapis/java-shared-dependencies/commit/05b58e84ff6617bdcbb1ea644aa6e061bdea0319)) +* update dependency com.google.api:api-common to v2.0.2 ([#450](https://www.github.com/googleapis/java-shared-dependencies/issues/450)) ([51caebe](https://www.github.com/googleapis/java-shared-dependencies/commit/51caebe89bfade98866f63952bf82bc663a0179a)) +* update dependency com.google.http-client:google-http-client-bom to v1.40.0 ([#455](https://www.github.com/googleapis/java-shared-dependencies/issues/455)) ([82a5e42](https://www.github.com/googleapis/java-shared-dependencies/commit/82a5e42b06570a2c7c9d53b03161b110a44487a1)) +* update dependency com.google.oauth-client:google-oauth-client-bom to v1.32.1 ([#447](https://www.github.com/googleapis/java-shared-dependencies/issues/447)) ([9d2b895](https://www.github.com/googleapis/java-shared-dependencies/commit/9d2b8958f62daa6a3015a8ac052762fb3d79b35b)) +* update dependency io.grpc:grpc-bom to v1.40.1 ([#451](https://www.github.com/googleapis/java-shared-dependencies/issues/451)) ([df668ea](https://www.github.com/googleapis/java-shared-dependencies/commit/df668ead8830a40acf9d5605d47f93c465b779c0)) +* update gax.version to v2.4.0 ([#458](https://www.github.com/googleapis/java-shared-dependencies/issues/458)) ([a797d9e](https://www.github.com/googleapis/java-shared-dependencies/commit/a797d9eb8a4bcb3025a9511eae61271278a4a5c9)) +* update google.common-protos.version to v2.5.0 ([#457](https://www.github.com/googleapis/java-shared-dependencies/issues/457)) ([38c7bb9](https://www.github.com/googleapis/java-shared-dependencies/commit/38c7bb925414d90ff3065650d06589f79bcab9b6)) +* update google.core.version to v2.1.1 ([#449](https://www.github.com/googleapis/java-shared-dependencies/issues/449)) ([b28723a](https://www.github.com/googleapis/java-shared-dependencies/commit/b28723ace0c27ebc73f23a2d094e0fe9ba8a9075)) +* update google.core.version to v2.1.2 ([#459](https://www.github.com/googleapis/java-shared-dependencies/issues/459)) ([df4d5b7](https://www.github.com/googleapis/java-shared-dependencies/commit/df4d5b7717386f5e0e2cca87bd9afc56b2c7aee8)) +* update iam.version to v1.1.0 ([#448](https://www.github.com/googleapis/java-shared-dependencies/issues/448)) ([3967928](https://www.github.com/googleapis/java-shared-dependencies/commit/39679287f3ef8c1cbca5dfc8aca3f69cfee3d4a6)) + +## [2.1.0](https://www.github.com/googleapis/java-shared-dependencies/compare/2.0.1...v2.1.0) (2021-08-23) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v1.1.0 ([#439](https://www.github.com/googleapis/java-shared-dependencies/issues/439)) ([ca52bd9](https://www.github.com/googleapis/java-shared-dependencies/commit/ca52bd9c099c96bf7b5a57aa85d39b58a610c875)) +* update dependency com.google.cloud:google-cloud-core-bom to v2.1.0 ([#444](https://www.github.com/googleapis/java-shared-dependencies/issues/444)) ([ff914c6](https://www.github.com/googleapis/java-shared-dependencies/commit/ff914c6de9e3e7fa6ba75591d3d5077c5421827d)) +* update dependency com.google.code.gson:gson to v2.8.8 ([#442](https://www.github.com/googleapis/java-shared-dependencies/issues/442)) ([79a093f](https://www.github.com/googleapis/java-shared-dependencies/commit/79a093f9ccea4d47cf8b678570a1c9699029a8b2)) +* update dependency com.google.errorprone:error_prone_annotations to v2.9.0 ([#441](https://www.github.com/googleapis/java-shared-dependencies/issues/441)) ([e644a4b](https://www.github.com/googleapis/java-shared-dependencies/commit/e644a4b504ab8aa5771f9be36861d1730ea9bcc9)) +* update dependency io.grpc:grpc-bom to v1.40.0 ([#438](https://www.github.com/googleapis/java-shared-dependencies/issues/438)) ([c3f8fb4](https://www.github.com/googleapis/java-shared-dependencies/commit/c3f8fb4408f5dc6c7f7dc0e14f0c24fa755433a5)) +* update gax.version to v2.3.0 ([#437](https://www.github.com/googleapis/java-shared-dependencies/issues/437)) ([e59aaad](https://www.github.com/googleapis/java-shared-dependencies/commit/e59aaadd76e40ab5ea31c3e812686a4ba0471a49)) + +### [2.0.1](https://www.github.com/googleapis/java-shared-dependencies/compare/2.0.0...v2.0.1) (2021-08-11) + + +### Dependencies + +* update dependency com.google.api:api-common to v2.0.1 ([#431](https://www.github.com/googleapis/java-shared-dependencies/issues/431)) ([b1a52c8](https://www.github.com/googleapis/java-shared-dependencies/commit/b1a52c83e19be7be80086f2010e928171b046f62)) +* update gax.version to v2.1.0 ([#432](https://www.github.com/googleapis/java-shared-dependencies/issues/432)) ([7f53006](https://www.github.com/googleapis/java-shared-dependencies/commit/7f53006d021e839f52325a87d7c4715eff88818d)) +* update google.core.version to v2.0.4 ([#430](https://www.github.com/googleapis/java-shared-dependencies/issues/430)) ([d0465ad](https://www.github.com/googleapis/java-shared-dependencies/commit/d0465ad3a79993d4e854078ea992e53ab9add07f)) +* update google.core.version to v2.0.5 ([#434](https://www.github.com/googleapis/java-shared-dependencies/issues/434)) ([af00753](https://www.github.com/googleapis/java-shared-dependencies/commit/af0075390034cba5cefede8260ab03f728d525a8)) + +## [2.0.0](https://www.github.com/googleapis/java-shared-dependencies/compare/1.4.0...v2.0.0) (2021-08-03) + + +### ⚠ BREAKING CHANGES + +* promote to 2.0.0 (#428) + +### Features + +* promote to 2.0.0 ([#428](https://www.github.com/googleapis/java-shared-dependencies/issues/428)) ([4db31f2](https://www.github.com/googleapis/java-shared-dependencies/commit/4db31f29f1668d4743e8af8996b0c4b30e6831b3)) + + +### Documentation + +* we don't use this as a parent pom ([#407](https://www.github.com/googleapis/java-shared-dependencies/issues/407)) ([4c86aaf](https://www.github.com/googleapis/java-shared-dependencies/commit/4c86aafc05097b6702056f5cb37736127b6df306)) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.12.4 ([#398](https://www.github.com/googleapis/java-shared-dependencies/issues/398)) ([f0d49b5](https://www.github.com/googleapis/java-shared-dependencies/commit/f0d49b54ba334f9351c66c9924e3d0d2ed7c0016)) +* update dependency com.google.api:api-common to v1.10.6 ([#411](https://www.github.com/googleapis/java-shared-dependencies/issues/411)) ([79801b5](https://www.github.com/googleapis/java-shared-dependencies/commit/79801b5fee08a8c97e275ed3674ab6c83b204a90)) +* update dependency com.google.api:api-common to v2 ([#414](https://www.github.com/googleapis/java-shared-dependencies/issues/414)) ([17f6e68](https://www.github.com/googleapis/java-shared-dependencies/commit/17f6e68a2792843dd41d3877c095e97c052c5ac0)) +* update dependency com.google.auth:google-auth-library-bom to v0.27.0 ([#400](https://www.github.com/googleapis/java-shared-dependencies/issues/400)) ([0d5a95b](https://www.github.com/googleapis/java-shared-dependencies/commit/0d5a95b84076684f84b0fdbb93a706113f44457d)) +* update dependency com.google.auth:google-auth-library-bom to v1 ([#413](https://www.github.com/googleapis/java-shared-dependencies/issues/413)) ([94897d3](https://www.github.com/googleapis/java-shared-dependencies/commit/94897d30bb1cac0059e272b058f6221fb7e4733f)) +* update dependency com.google.cloud:grpc-gcp to v1.1.0 ([#403](https://www.github.com/googleapis/java-shared-dependencies/issues/403)) ([3cc59f1](https://www.github.com/googleapis/java-shared-dependencies/commit/3cc59f15ebb31a7f97c9f3d78057022afabe75e9)) +* update dependency com.google.errorprone:error_prone_annotations to v2.8.0 ([#406](https://www.github.com/googleapis/java-shared-dependencies/issues/406)) ([2905787](https://www.github.com/googleapis/java-shared-dependencies/commit/29057879adeda8bc40a903ef3b5feafc83c3d972)) +* update dependency com.google.errorprone:error_prone_annotations to v2.8.1 ([#426](https://www.github.com/googleapis/java-shared-dependencies/issues/426)) ([853b68b](https://www.github.com/googleapis/java-shared-dependencies/commit/853b68b16c88c3abb745ee1f71ba4bb317cbc680)) +* update gax.version to v1.67.0 ([#405](https://www.github.com/googleapis/java-shared-dependencies/issues/405)) ([632dcd0](https://www.github.com/googleapis/java-shared-dependencies/commit/632dcd0a9f10b034a2a2ec92c7c3413490dd2a03)) +* update gax.version to v2 (major) ([#418](https://www.github.com/googleapis/java-shared-dependencies/issues/418)) ([670a9e0](https://www.github.com/googleapis/java-shared-dependencies/commit/670a9e0a9588a7e592eb5dd8c0cb9ab08e07293e)) +* update google.core.version to v1.96.1 ([#417](https://www.github.com/googleapis/java-shared-dependencies/issues/417)) ([49db9cb](https://www.github.com/googleapis/java-shared-dependencies/commit/49db9cb473c8d3d794ad57a41cfc223239482174)) +* update google.core.version to v2 (major) ([#427](https://www.github.com/googleapis/java-shared-dependencies/issues/427)) ([8cc7a92](https://www.github.com/googleapis/java-shared-dependencies/commit/8cc7a922cc3ba10a157e3649d7a783bbbcbee010)) +* update guava to 30.1.1-jre ([#423](https://www.github.com/googleapis/java-shared-dependencies/issues/423)) ([94aca59](https://www.github.com/googleapis/java-shared-dependencies/commit/94aca597804d7b45aae22811b277c44281e62d64)) + +## [1.4.0](https://www.github.com/googleapis/java-shared-dependencies/compare/1.3.0...v1.4.0) (2021-06-30) + + +### Features + +* add grpc-gcp to dependencyManagement ([#389](https://www.github.com/googleapis/java-shared-dependencies/issues/389)) ([57fd2e6](https://www.github.com/googleapis/java-shared-dependencies/commit/57fd2e646e28e37e0b5e4e1b37425d4897a8776f)) + + +### Bug Fixes + +* Add `shopt -s nullglob` to dependencies script ([#392](https://www.github.com/googleapis/java-shared-dependencies/issues/392)) ([f8f29df](https://www.github.com/googleapis/java-shared-dependencies/commit/f8f29df1c9cc6eca517c99113fb9509fd611ac92)) +* Add common httpclient and oauth dependencies ([#391](https://www.github.com/googleapis/java-shared-dependencies/issues/391)) ([09660e1](https://www.github.com/googleapis/java-shared-dependencies/commit/09660e1e50c96dcd7df4e80d8ad357f8256eda6c)) +* Update dependencies.sh to not break on mac ([#384](https://www.github.com/googleapis/java-shared-dependencies/issues/384)) ([0ae2841](https://www.github.com/googleapis/java-shared-dependencies/commit/0ae2841d7ce2885d041795c58a38d2d3973c2e5a)) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.32.1 ([#390](https://www.github.com/googleapis/java-shared-dependencies/issues/390)) ([00288c1](https://www.github.com/googleapis/java-shared-dependencies/commit/00288c18d09616582c8bec961ecc5c00ef1d4288)) +* update dependency com.google.api:api-common to v1.10.4 ([#385](https://www.github.com/googleapis/java-shared-dependencies/issues/385)) ([5f2b39b](https://www.github.com/googleapis/java-shared-dependencies/commit/5f2b39b5bdc4cec9d5ab2f050e11000ed372d057)) +* update dependency com.google.api:gax-grpc to v1.65.1 ([#382](https://www.github.com/googleapis/java-shared-dependencies/issues/382)) ([a2a1547](https://www.github.com/googleapis/java-shared-dependencies/commit/a2a15471dee21207a0b97b3bc8f6f59d6a4a2d13)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.3 ([#379](https://www.github.com/googleapis/java-shared-dependencies/issues/379)) ([6f43eb5](https://www.github.com/googleapis/java-shared-dependencies/commit/6f43eb553dca98140d343bee3f1003096d79ee6c)) +* update dependency io.grpc:grpc-bom to v1.38.1 ([#386](https://www.github.com/googleapis/java-shared-dependencies/issues/386)) ([7b1d4cf](https://www.github.com/googleapis/java-shared-dependencies/commit/7b1d4cf317fbd75b91d6a63f82b5fc2f46eaf3ca)) +* update dependency io.grpc:grpc-bom to v1.39.0 ([#394](https://www.github.com/googleapis/java-shared-dependencies/issues/394)) ([ebc8af6](https://www.github.com/googleapis/java-shared-dependencies/commit/ebc8af6b3f850b58b35d9720a7a0b1545d4616bd)) +* update gax.version to v1.66.0 ([#395](https://www.github.com/googleapis/java-shared-dependencies/issues/395)) ([c73f73e](https://www.github.com/googleapis/java-shared-dependencies/commit/c73f73e84740a8117be342a66e179eaf3e29c6fd)) +* update google.core.version to v1.95.1 ([#381](https://www.github.com/googleapis/java-shared-dependencies/issues/381)) ([4496153](https://www.github.com/googleapis/java-shared-dependencies/commit/44961532f621b0ab19e9e7feebb7d588aef5d423)) +* update google.core.version to v1.95.2 ([#383](https://www.github.com/googleapis/java-shared-dependencies/issues/383)) ([7216859](https://www.github.com/googleapis/java-shared-dependencies/commit/7216859bcd67fa1ce1119831c33c50a2d5b79324)) +* update google.core.version to v1.95.3 ([#388](https://www.github.com/googleapis/java-shared-dependencies/issues/388)) ([354e4e8](https://www.github.com/googleapis/java-shared-dependencies/commit/354e4e811f4ba886406681a4261ac0455a9eb2d2)) +* update google.core.version to v1.95.4 ([#393](https://www.github.com/googleapis/java-shared-dependencies/issues/393)) ([be78ad8](https://www.github.com/googleapis/java-shared-dependencies/commit/be78ad85e31d8876eabafee7aa8242712573cb46)) + +## [1.3.0](https://www.github.com/googleapis/java-shared-dependencies/compare/1.2.0...v1.3.0) (2021-06-03) + + +### Features + +* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#365](https://www.github.com/googleapis/java-shared-dependencies/issues/365)) ([7e8309b](https://www.github.com/googleapis/java-shared-dependencies/commit/7e8309bf67ade0fe2b09f792848136cd88b4d2e4)) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v0.26.0 ([#368](https://www.github.com/googleapis/java-shared-dependencies/issues/368)) ([38256a8](https://www.github.com/googleapis/java-shared-dependencies/commit/38256a82cb6896c3f5e5ea6ca5d8d671c412bf84)) +* update dependency com.google.cloud:google-cloud-core-bom to v1.95.0 ([#377](https://www.github.com/googleapis/java-shared-dependencies/issues/377)) ([297ea62](https://www.github.com/googleapis/java-shared-dependencies/commit/297ea621e02f8c0679c8b07ed399d11eaacecc14)) +* update dependency com.google.code.gson:gson to v2.8.7 ([#370](https://www.github.com/googleapis/java-shared-dependencies/issues/370)) ([cdc1b8e](https://www.github.com/googleapis/java-shared-dependencies/commit/cdc1b8ea1c93f97b712081ca8dc8ea57f342b69e)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.1 ([#369](https://www.github.com/googleapis/java-shared-dependencies/issues/369)) ([5a19574](https://www.github.com/googleapis/java-shared-dependencies/commit/5a19574bc626bb3c6b573ed1d177e8907188dec1)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.2 ([#374](https://www.github.com/googleapis/java-shared-dependencies/issues/374)) ([83516e6](https://www.github.com/googleapis/java-shared-dependencies/commit/83516e691b99e5e5d22d27e561781a5ade5fb514)) +* update dependency io.grpc:grpc-bom to v1.38.0 ([#364](https://www.github.com/googleapis/java-shared-dependencies/issues/364)) ([00db570](https://www.github.com/googleapis/java-shared-dependencies/commit/00db5701c3b0aa609f3778c06911a9a0248ca342)) +* update gax.version to v1.65.0 ([#376](https://www.github.com/googleapis/java-shared-dependencies/issues/376)) ([b793a0d](https://www.github.com/googleapis/java-shared-dependencies/commit/b793a0d7744ff1b0f8ae5d3d13ec4776ae8d3089)) +* update google.common-protos.version to v2.3.1 ([#366](https://www.github.com/googleapis/java-shared-dependencies/issues/366)) ([7d6a7fa](https://www.github.com/googleapis/java-shared-dependencies/commit/7d6a7fa7a2cad2b3f2ecf45e42d2ed5db0b60a43)) +* update google.common-protos.version to v2.3.2 ([#375](https://www.github.com/googleapis/java-shared-dependencies/issues/375)) ([68a47ad](https://www.github.com/googleapis/java-shared-dependencies/commit/68a47ad3243f3e980db74c9c8505a1b3063c131b)) + +## [1.2.0](https://www.github.com/googleapis/java-shared-dependencies/compare/1.1.0...v1.2.0) (2021-05-18) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.31.5 ([#353](https://www.github.com/googleapis/java-shared-dependencies/issues/353)) ([8d72ab0](https://www.github.com/googleapis/java-shared-dependencies/commit/8d72ab003e08c864aedc17fc190ba26f393bf0c7)) +* update dependency com.google.errorprone:error_prone_annotations to v2.7.1 ([#360](https://www.github.com/googleapis/java-shared-dependencies/issues/360)) ([8f952d0](https://www.github.com/googleapis/java-shared-dependencies/commit/8f952d05745358fc426a1a2dcb688da5d5010239)) +* update dependency com.google.protobuf:protobuf-bom to v3.17.0 ([#355](https://www.github.com/googleapis/java-shared-dependencies/issues/355)) ([09858fb](https://www.github.com/googleapis/java-shared-dependencies/commit/09858fb4f1b78a77e828501597d20df4db0ebfcf)) +* update dependency io.grpc:grpc-bom to v1.37.1 ([#359](https://www.github.com/googleapis/java-shared-dependencies/issues/359)) ([bc9869e](https://www.github.com/googleapis/java-shared-dependencies/commit/bc9869e914314f951afd69f2acae95c414398f43)) +* update google.common-protos.version to v2.2.1 ([#358](https://www.github.com/googleapis/java-shared-dependencies/issues/358)) ([a3ed764](https://www.github.com/googleapis/java-shared-dependencies/commit/a3ed764a0e5143ee323d4b69c9747b8265d349e2)) +* update iam.version to v1.0.14 ([#352](https://www.github.com/googleapis/java-shared-dependencies/issues/352)) ([bea9a01](https://www.github.com/googleapis/java-shared-dependencies/commit/bea9a01788ac1332a4bc7e06574ef5701700fe90)) + +## [1.1.0](https://www.github.com/googleapis/java-shared-dependencies/compare/1.0.0...v1.1.0) (2021-05-10) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.16.0 ([#348](https://www.github.com/googleapis/java-shared-dependencies/issues/348)) ([0aacfde](https://www.github.com/googleapis/java-shared-dependencies/commit/0aacfdeec70e30803734db8287c47e4fad5481ef)) +* update gax.version to v1.64.0 ([#345](https://www.github.com/googleapis/java-shared-dependencies/issues/345)) ([478bd35](https://www.github.com/googleapis/java-shared-dependencies/commit/478bd35296293e81c7e70157f50bfbebdc1bb54d)) +* update iam.version to v1.0.13 ([#343](https://www.github.com/googleapis/java-shared-dependencies/issues/343)) ([3637923](https://www.github.com/googleapis/java-shared-dependencies/commit/363792392b71deff5cc5731104b631122fba5e61)) + +## [1.0.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.21.1...v1.0.0) (2021-04-23) + + +### Features + +* promote to 1.0.0 ([#341](https://www.github.com/googleapis/java-shared-dependencies/issues/341)) ([eddce7b](https://www.github.com/googleapis/java-shared-dependencies/commit/eddce7bda196d757c0bb93a05574cc742e3d7ff6)) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.10.3 ([#340](https://www.github.com/googleapis/java-shared-dependencies/issues/340)) ([6a7fc33](https://www.github.com/googleapis/java-shared-dependencies/commit/6a7fc33548c199d5f310b3ee5024907882d22726)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.4 ([#334](https://www.github.com/googleapis/java-shared-dependencies/issues/334)) ([e5c747d](https://www.github.com/googleapis/java-shared-dependencies/commit/e5c747d245194effc258ae706e7764153010cd53)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.5 ([#338](https://www.github.com/googleapis/java-shared-dependencies/issues/338)) ([ffa1df5](https://www.github.com/googleapis/java-shared-dependencies/commit/ffa1df5497b5365f520b665a202b8caf6521fc9d)) +* update dependency org.threeten:threetenbp to v1.5.1 ([#335](https://www.github.com/googleapis/java-shared-dependencies/issues/335)) ([c8c6df4](https://www.github.com/googleapis/java-shared-dependencies/commit/c8c6df48e7f80944544939e502f4f08543af2631)) +* update google.core.version to v1.94.8 ([#342](https://www.github.com/googleapis/java-shared-dependencies/issues/342)) ([d946dd2](https://www.github.com/googleapis/java-shared-dependencies/commit/d946dd2299aac32f969a2226a1391e1e73f00e62)) + +### [0.21.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.21.0...v0.21.1) (2021-04-19) + + +### Bug Fixes + +* release scripts from issuing overlapping phases ([#332](https://www.github.com/googleapis/java-shared-dependencies/issues/332)) ([e289825](https://www.github.com/googleapis/java-shared-dependencies/commit/e289825a3bc45b4796db7ce4347f8d9d9251a410)) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.12.3 ([#329](https://www.github.com/googleapis/java-shared-dependencies/issues/329)) ([a77b4fc](https://www.github.com/googleapis/java-shared-dependencies/commit/a77b4fcc2ea5caf366c76a4698bac6d4c9abc92e)) +* update dependency com.google.api-client:google-api-client-bom to v1.31.4 ([#326](https://www.github.com/googleapis/java-shared-dependencies/issues/326)) ([409d24f](https://www.github.com/googleapis/java-shared-dependencies/commit/409d24f8a0cac30e41ca45eb2711aecb335d70dd)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.3 ([#328](https://www.github.com/googleapis/java-shared-dependencies/issues/328)) ([88cfc08](https://www.github.com/googleapis/java-shared-dependencies/commit/88cfc08952881200e23ed95cfa2eebad85ec7ab3)) +* update google.core.version to v1.94.7 ([#324](https://www.github.com/googleapis/java-shared-dependencies/issues/324)) ([0412c88](https://www.github.com/googleapis/java-shared-dependencies/commit/0412c88468940c1182bc0761bfe269a6688fe7b7)) +* update iam.version to v1.0.12 ([#327](https://www.github.com/googleapis/java-shared-dependencies/issues/327)) ([548d5f5](https://www.github.com/googleapis/java-shared-dependencies/commit/548d5f53c4f264f1cbb9ca72fdfe4608ab16b480)) + +## [0.21.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.20.1...v0.21.0) (2021-04-09) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v0.25.0 ([#310](https://www.github.com/googleapis/java-shared-dependencies/issues/310)) ([8f3a0f0](https://www.github.com/googleapis/java-shared-dependencies/commit/8f3a0f002b787f7b27cfe031654fa20bf342f839)) +* update dependency com.google.auth:google-auth-library-bom to v0.25.2 ([#311](https://www.github.com/googleapis/java-shared-dependencies/issues/311)) ([6c47a3e](https://www.github.com/googleapis/java-shared-dependencies/commit/6c47a3edbd9da04ba255487a66c0f3a41393217d)) +* update dependency com.google.errorprone:error_prone_annotations to v2.6.0 ([#315](https://www.github.com/googleapis/java-shared-dependencies/issues/315)) ([dc254ca](https://www.github.com/googleapis/java-shared-dependencies/commit/dc254ca7359b68fe9411f7b96130ffb416b45c6f)) +* update dependency com.google.http-client:google-http-client-bom to v1.39.1 ([#309](https://www.github.com/googleapis/java-shared-dependencies/issues/309)) ([37225e2](https://www.github.com/googleapis/java-shared-dependencies/commit/37225e2d1b32a618765391720b57ff29e7b8f7f9)) +* update dependency com.google.http-client:google-http-client-bom to v1.39.2 ([#321](https://www.github.com/googleapis/java-shared-dependencies/issues/321)) ([273c66d](https://www.github.com/googleapis/java-shared-dependencies/commit/273c66d374f7cd6040aac2f302fd1c1dc0f4a1c0)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.6 ([#308](https://www.github.com/googleapis/java-shared-dependencies/issues/308)) ([b29dd05](https://www.github.com/googleapis/java-shared-dependencies/commit/b29dd0535f02b56607f64ba69e85d4d468902789)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.7 ([#316](https://www.github.com/googleapis/java-shared-dependencies/issues/316)) ([9c00d77](https://www.github.com/googleapis/java-shared-dependencies/commit/9c00d7753c1f7b963deb9ad69dcfe24ba28da5a2)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.8 ([#319](https://www.github.com/googleapis/java-shared-dependencies/issues/319)) ([15e5ae2](https://www.github.com/googleapis/java-shared-dependencies/commit/15e5ae2ef46eedcd790ffd8644677d36db5c63f9)) +* update dependency io.grpc:grpc-bom to v1.37.0 ([#313](https://www.github.com/googleapis/java-shared-dependencies/issues/313)) ([c599351](https://www.github.com/googleapis/java-shared-dependencies/commit/c5993511c7305e1ced42d73552a93a25dc5e1ac1)) +* update gax.version to v1.63.0 ([#318](https://www.github.com/googleapis/java-shared-dependencies/issues/318)) ([ba709da](https://www.github.com/googleapis/java-shared-dependencies/commit/ba709da6fb0e9bcfc83e663588336598737b46e4)) +* update google.core.version to v1.94.4 ([#305](https://www.github.com/googleapis/java-shared-dependencies/issues/305)) ([0d38f4c](https://www.github.com/googleapis/java-shared-dependencies/commit/0d38f4c9ffadcfd9446712b8bf0729399b0c9e91)) +* update google.core.version to v1.94.5 ([#320](https://www.github.com/googleapis/java-shared-dependencies/issues/320)) ([3439721](https://www.github.com/googleapis/java-shared-dependencies/commit/3439721da83a8b92d9c4b6ecfd158cfb1e1a0503)) +* update guava to 30.1.1-android ([#322](https://www.github.com/googleapis/java-shared-dependencies/issues/322)) ([a6b5d3b](https://www.github.com/googleapis/java-shared-dependencies/commit/a6b5d3b8ccfc352bf0d1678952ce3cd8b7a8361e)) +* update iam.version to v1.0.11 ([#304](https://www.github.com/googleapis/java-shared-dependencies/issues/304)) ([95a5264](https://www.github.com/googleapis/java-shared-dependencies/commit/95a526442b3d24c83782523d38dd3931e828d757)) + +### [0.20.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.20.0...v0.20.1) (2021-03-09) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.12.2 ([#301](https://www.github.com/googleapis/java-shared-dependencies/issues/301)) ([7c01eba](https://www.github.com/googleapis/java-shared-dependencies/commit/7c01ebabb6fd65b7404e56651b0ba27f505bb033)) +* update dependency com.google.api-client:google-api-client-bom to v1.31.3 ([#295](https://www.github.com/googleapis/java-shared-dependencies/issues/295)) ([a0774e9](https://www.github.com/googleapis/java-shared-dependencies/commit/a0774e9d62d00614142bc4c14214a83dda66d4ad)) +* update dependency com.google.api.grpc:grpc-google-iam-v1 to v1.0.10 ([#292](https://www.github.com/googleapis/java-shared-dependencies/issues/292)) ([b629789](https://www.github.com/googleapis/java-shared-dependencies/commit/b629789e3a1cc9a7308b829c034b09b06e24fc07)) +* update dependency com.google.auth:google-auth-library-bom to v0.24.1 ([#293](https://www.github.com/googleapis/java-shared-dependencies/issues/293)) ([d85ec34](https://www.github.com/googleapis/java-shared-dependencies/commit/d85ec347ccdd14dfdab10d365d2c2f8df3035e4d)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.3 ([#294](https://www.github.com/googleapis/java-shared-dependencies/issues/294)) ([58c01aa](https://www.github.com/googleapis/java-shared-dependencies/commit/58c01aa076e2c4954986185f913bac2c51a1e6fb)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.5 ([#302](https://www.github.com/googleapis/java-shared-dependencies/issues/302)) ([e9d5e6e](https://www.github.com/googleapis/java-shared-dependencies/commit/e9d5e6ee6039915da186315ceada673ac37b88d3)) +* update google.core.version to v1.94.2 ([#296](https://www.github.com/googleapis/java-shared-dependencies/issues/296)) ([af83b90](https://www.github.com/googleapis/java-shared-dependencies/commit/af83b901be0c03d507189999215d35345602fad7)) +* update google.core.version to v1.94.3 ([#300](https://www.github.com/googleapis/java-shared-dependencies/issues/300)) ([3e73176](https://www.github.com/googleapis/java-shared-dependencies/commit/3e73176af0b07dfe621163b301174b5b5820dfa2)) + +## [0.20.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.19.0...v0.20.0) (2021-02-25) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v0.24.0 ([#284](https://www.github.com/googleapis/java-shared-dependencies/issues/284)) ([5e4914c](https://www.github.com/googleapis/java-shared-dependencies/commit/5e4914cc4a8ccd41a219f150a7455da116d1594b)) +* update dependency com.google.http-client:google-http-client-bom to v1.39.0 ([#288](https://www.github.com/googleapis/java-shared-dependencies/issues/288)) ([70bb862](https://www.github.com/googleapis/java-shared-dependencies/commit/70bb862029b840fbd99ba0109fa2b8f585812793)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.1 ([#282](https://www.github.com/googleapis/java-shared-dependencies/issues/282)) ([44283bd](https://www.github.com/googleapis/java-shared-dependencies/commit/44283bdfdc9288b4a8d16b6ed3a61541792d147e)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.2 ([#287](https://www.github.com/googleapis/java-shared-dependencies/issues/287)) ([bdae560](https://www.github.com/googleapis/java-shared-dependencies/commit/bdae5600f9033219ef8beb6c4d1c521fb062eaec)) +* update dependency io.grpc:grpc-bom to v1.36.0 ([#285](https://www.github.com/googleapis/java-shared-dependencies/issues/285)) ([c59771b](https://www.github.com/googleapis/java-shared-dependencies/commit/c59771b2436ac1a4fbc92b48049900472dd6d3ff)) +* update gax.version to v1.62.0 ([#291](https://www.github.com/googleapis/java-shared-dependencies/issues/291)) ([66bd070](https://www.github.com/googleapis/java-shared-dependencies/commit/66bd0702bd3deb64e0f6c73635e0ffd51a4d637e)) +* update google.common-protos.version to v2.1.0 ([#289](https://www.github.com/googleapis/java-shared-dependencies/issues/289)) ([43c9f02](https://www.github.com/googleapis/java-shared-dependencies/commit/43c9f026b1fa82f38dcb93b902281c2559e82d8e)) +* update iam.version to v1.0.9 ([#281](https://www.github.com/googleapis/java-shared-dependencies/issues/281)) ([ee44d0b](https://www.github.com/googleapis/java-shared-dependencies/commit/ee44d0b41e101931ccf5de2561dfcfcc9ff88b88)) + +## [0.19.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.18.0...v0.19.0) (2021-02-19) + + +### Bug Fixes + +* update repo name ([#274](https://www.github.com/googleapis/java-shared-dependencies/issues/274)) ([4a98470](https://www.github.com/googleapis/java-shared-dependencies/commit/4a98470b7493c98137191b7bb3cabca23f98628f)) + + +### Dependencies + +* downgrade opencensus version back to 0.28.0 ([#265](https://www.github.com/googleapis/java-shared-dependencies/issues/265)) ([f37025c](https://www.github.com/googleapis/java-shared-dependencies/commit/f37025c70f951b1e34904ee983815c0ed8ec4086)) +* update dependency com.google.api-client:google-api-client-bom to v1.31.2 ([#254](https://www.github.com/googleapis/java-shared-dependencies/issues/254)) ([1b0b4a6](https://www.github.com/googleapis/java-shared-dependencies/commit/1b0b4a637cae0c22cd0336c527002025780317d5)) +* update dependency com.google.auth:google-auth-library-bom to v0.23.0 ([#261](https://www.github.com/googleapis/java-shared-dependencies/issues/261)) ([1c0b7bd](https://www.github.com/googleapis/java-shared-dependencies/commit/1c0b7bd60b3d73c16cc6c19ab90d8ccedece3706)) +* update dependency com.google.cloud:google-cloud-core to v1.94.1 ([#272](https://www.github.com/googleapis/java-shared-dependencies/issues/272)) ([44fd4c3](https://www.github.com/googleapis/java-shared-dependencies/commit/44fd4c3c6cae98bd514525f03462b830050828a8)) +* update dependency com.google.errorprone:error_prone_annotations to v2.5.1 ([#255](https://www.github.com/googleapis/java-shared-dependencies/issues/255)) ([6367023](https://www.github.com/googleapis/java-shared-dependencies/commit/63670233424e8f24c3924bba5e2cb6ca97525795)) +* update dependency com.google.http-client:google-http-client-bom to v1.38.1 ([#253](https://www.github.com/googleapis/java-shared-dependencies/issues/253)) ([ad87c74](https://www.github.com/googleapis/java-shared-dependencies/commit/ad87c74d9d893726042156d65850806d92e79952)) +* update dependency com.google.protobuf:protobuf-bom to v3.15.0 ([#278](https://www.github.com/googleapis/java-shared-dependencies/issues/278)) ([989efbd](https://www.github.com/googleapis/java-shared-dependencies/commit/989efbd29bcf4135f7abce49a697303df2cf1a60)) +* update dependency io.grpc:grpc-bom to v1.35.0 ([#248](https://www.github.com/googleapis/java-shared-dependencies/issues/248)) ([7a28c6e](https://www.github.com/googleapis/java-shared-dependencies/commit/7a28c6e7053c181993b1288adcae56de89312113)) +* update gax.version to v1.61.0 ([#277](https://www.github.com/googleapis/java-shared-dependencies/issues/277)) ([f1c3fb9](https://www.github.com/googleapis/java-shared-dependencies/commit/f1c3fb9295f2e1c130b9fc329faa60f4f8474ba6)) +* update iam.version to v1.0.7 ([#252](https://www.github.com/googleapis/java-shared-dependencies/issues/252)) ([5cb3ed9](https://www.github.com/googleapis/java-shared-dependencies/commit/5cb3ed906537269cd7f8d9ccf4b065754b5f5b48)) +* update iam.version to v1.0.8 ([#273](https://www.github.com/googleapis/java-shared-dependencies/issues/273)) ([4d5e7f7](https://www.github.com/googleapis/java-shared-dependencies/commit/4d5e7f720d847918b307a83c95cea10c244ba595)) + +## [0.18.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.17.1...v0.18.0) (2021-01-13) + + +### Features + +* add commons-codec to dependencyManagement ([#251](https://www.github.com/googleapis/java-shared-dependencies/issues/251)) ([4ee990d](https://www.github.com/googleapis/java-shared-dependencies/commit/4ee990d79c9207c81155f6ee9279308a2d4d0f9d)) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_annotations to v2.5.0 ([#247](https://www.github.com/googleapis/java-shared-dependencies/issues/247)) ([37c0861](https://www.github.com/googleapis/java-shared-dependencies/commit/37c0861cfb89f13a0682c98067c633b13b30b827)) + +### [0.17.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.17.0...v0.17.1) (2021-01-12) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.12.1 ([#245](https://www.github.com/googleapis/java-shared-dependencies/issues/245)) ([5ffc8a0](https://www.github.com/googleapis/java-shared-dependencies/commit/5ffc8a0d173ea0222ac9610ece0ac2aeb1d17f27)) + +## [0.17.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.16.1...v0.17.0) (2020-12-15) + + +### Dependencies + +* update dependency com.google.guava:guava-bom to v30.1-android ([#236](https://www.github.com/googleapis/java-shared-dependencies/issues/236)) ([78ebf7f](https://www.github.com/googleapis/java-shared-dependencies/commit/78ebf7fcec3ec0308ccd5103b719f02dde7ec6d8)) +* update dependency io.grpc:grpc-bom to v1.34.1 ([#238](https://www.github.com/googleapis/java-shared-dependencies/issues/238)) ([ee7e020](https://www.github.com/googleapis/java-shared-dependencies/commit/ee7e020a4631f2b288d1c6f5d681423d156e3c2d)) +* update iam.version to v1.0.5 ([#237](https://www.github.com/googleapis/java-shared-dependencies/issues/237)) ([bbe6be6](https://www.github.com/googleapis/java-shared-dependencies/commit/bbe6be650a93cf365f2439ae9c8bebf2ade83ddd)) + +### [0.16.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.16.0...v0.16.1) (2020-12-14) + + +### Dependencies + +* rollback gRPC to 1.33.1 ([#234](https://www.github.com/googleapis/java-shared-dependencies/issues/234)) ([67cc384](https://www.github.com/googleapis/java-shared-dependencies/commit/67cc384bacab8592d5bbc92db2469affee473eb7)) +* update dependency com.google.auth:google-auth-library-bom to v0.22.1 ([#229](https://www.github.com/googleapis/java-shared-dependencies/issues/229)) ([1c13161](https://www.github.com/googleapis/java-shared-dependencies/commit/1c13161fa289cd5f3923f389fd5b14f3b7b4a84d)) +* update dependency com.google.auth:google-auth-library-bom to v0.22.2 ([#235](https://www.github.com/googleapis/java-shared-dependencies/issues/235)) ([67434eb](https://www.github.com/googleapis/java-shared-dependencies/commit/67434eb4bb0789abcabb3055155672b2c2e70125)) +* update iam.version to v1.0.4 ([#231](https://www.github.com/googleapis/java-shared-dependencies/issues/231)) ([5edf99e](https://www.github.com/googleapis/java-shared-dependencies/commit/5edf99e0149a1b70eb52b8921e9eb04fb84d9160)) + +## [0.16.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.15.0...v0.16.0) (2020-12-02) + + +### Dependencies + +* update dependency com.fasterxml.jackson:jackson-bom to v2.12.0 ([#225](https://www.github.com/googleapis/java-shared-dependencies/issues/225)) ([b78a1ef](https://www.github.com/googleapis/java-shared-dependencies/commit/b78a1ef83ad946b0d29cd0dff46e48fbde44d120)) +* update dependency com.google.api-client:google-api-client-bom to v1.31.1 ([#215](https://www.github.com/googleapis/java-shared-dependencies/issues/215)) ([08d643a](https://www.github.com/googleapis/java-shared-dependencies/commit/08d643aaf289984b87d734274830712af82585b6)) +* update dependency com.google.protobuf:protobuf-bom to v3.14.0 ([#217](https://www.github.com/googleapis/java-shared-dependencies/issues/217)) ([01a9c64](https://www.github.com/googleapis/java-shared-dependencies/commit/01a9c6442906e8482a53712eba95ccc6f7040928)) +* update dependency io.grpc:grpc-bom to v1.34.0 ([#228](https://www.github.com/googleapis/java-shared-dependencies/issues/228)) ([425d1ea](https://www.github.com/googleapis/java-shared-dependencies/commit/425d1eab2a046c365f816f946576e4030e7c3696)) +* update gax.version to v1.60.1 ([#223](https://www.github.com/googleapis/java-shared-dependencies/issues/223)) ([84c75bd](https://www.github.com/googleapis/java-shared-dependencies/commit/84c75bdbd3f86ef7187373289ee08ad3a0c24719)) +* update google.core.version to v1.94.0 ([#212](https://www.github.com/googleapis/java-shared-dependencies/issues/212)) ([764ef5e](https://www.github.com/googleapis/java-shared-dependencies/commit/764ef5e9a2272cd9244a8fc5cc107ffacf9e9d5b)) + +## [0.15.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.14.1...v0.15.0) (2020-11-10) + + +### Dependencies + +* update dependency com.google.http-client:google-http-client-bom to v1.38.0 ([#207](https://www.github.com/googleapis/java-shared-dependencies/issues/207)) ([5e3198d](https://www.github.com/googleapis/java-shared-dependencies/commit/5e3198de5e1d0fe55c4d947b12984db7726059da)) +* update google.common-protos.version to v2.0.1 ([#205](https://www.github.com/googleapis/java-shared-dependencies/issues/205)) ([6b12417](https://www.github.com/googleapis/java-shared-dependencies/commit/6b1241737d34e99a55acdcd439aa71ad28d1e26c)) +* update iam.version to v1.0.3 ([#206](https://www.github.com/googleapis/java-shared-dependencies/issues/206)) ([94a4e31](https://www.github.com/googleapis/java-shared-dependencies/commit/94a4e31634718a206ef0f5ff1a8801dc7be4c5c5)) + +### [0.14.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.14.0...v0.14.1) (2020-10-31) + + +### Dependencies + +* update google.core.version to v1.93.10 ([#200](https://www.github.com/googleapis/java-shared-dependencies/issues/200)) ([2d73dc1](https://www.github.com/googleapis/java-shared-dependencies/commit/2d73dc152469d175c74f85c5c76dcc67993c9783)) + +## [0.14.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.13.0...v0.14.0) (2020-10-31) + + +### Dependencies + +* update dependency io.grpc:grpc-bom to v1.33.1 ([#192](https://www.github.com/googleapis/java-shared-dependencies/issues/192)) ([b29384d](https://www.github.com/googleapis/java-shared-dependencies/commit/b29384dc40c812f1848f00695228d5437556f029)) +* update dependency org.threeten:threetenbp to v1.5.0 ([#196](https://www.github.com/googleapis/java-shared-dependencies/issues/196)) ([825a6fa](https://www.github.com/googleapis/java-shared-dependencies/commit/825a6fa375d12f1caa0a515b784ffde182bac98d)) +* update iam.version to v1.0.2 ([#194](https://www.github.com/googleapis/java-shared-dependencies/issues/194)) ([5c57239](https://www.github.com/googleapis/java-shared-dependencies/commit/5c572399a1b453f4dc5f6ef8d8850a35be2aef75)) + +## [0.13.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.12.1...v0.13.0) (2020-10-20) + + +### Features + +* add jackson-core to the list of managed dependencies ([#190](https://www.github.com/googleapis/java-shared-dependencies/issues/190)) ([b37035e](https://www.github.com/googleapis/java-shared-dependencies/commit/b37035ed9b0beeb5e07d6e1c121154eece1a2c87)) + + +### Dependencies + +* update dependency com.google.guava:guava-bom to v30 ([#181](https://www.github.com/googleapis/java-shared-dependencies/issues/181)) ([bdb1e58](https://www.github.com/googleapis/java-shared-dependencies/commit/bdb1e582288d06a872e36ac8b778563f2d088468)) +* update gax.version to v1.60.0 ([#187](https://www.github.com/googleapis/java-shared-dependencies/issues/187)) ([8a8adf7](https://www.github.com/googleapis/java-shared-dependencies/commit/8a8adf7745d563c449bf095aad63b5e4a94e1a7d)) +* update google.common-protos.version to v2 ([#174](https://www.github.com/googleapis/java-shared-dependencies/issues/174)) ([3f7e3ff](https://www.github.com/googleapis/java-shared-dependencies/commit/3f7e3ffd5e07d2f11f0aa981dae2bdf5381e429f)) + +### [0.12.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.12.0...v0.12.1) (2020-10-16) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.10.1 ([#180](https://www.github.com/googleapis/java-shared-dependencies/issues/180)) ([b1f2d5d](https://www.github.com/googleapis/java-shared-dependencies/commit/b1f2d5dfde24fcf683eeb5600fce7f51190ecce8)) + +## [0.12.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.11.0...v0.12.0) (2020-10-15) + + +### Dependencies + +* update dependency com.google.api-client:google-api-client-bom to v1.30.11 ([#169](https://www.github.com/googleapis/java-shared-dependencies/issues/169)) ([a1b18d1](https://www.github.com/googleapis/java-shared-dependencies/commit/a1b18d1838c2ceca882615d574ab5d0245794820)) +* update dependency com.google.auth:google-auth-library-bom to v0.22.0 ([#171](https://www.github.com/googleapis/java-shared-dependencies/issues/171)) ([0c7635a](https://www.github.com/googleapis/java-shared-dependencies/commit/0c7635a82d922971ae6aac18dc2ee1879e017516)) + +## [0.11.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.10.2...v0.11.0) (2020-10-13) + + +### Dependencies + +* update dependency com.google.http-client:google-http-client-bom to v1.37.0 ([#166](https://www.github.com/googleapis/java-shared-dependencies/issues/166)) ([5721225](https://www.github.com/googleapis/java-shared-dependencies/commit/572122574ce8452b6a0fc6df919e9ce2d8ffd2ce)) +* update dependency io.grpc:grpc-bom to v1.32.2 ([#165](https://www.github.com/googleapis/java-shared-dependencies/issues/165)) ([b70ddb0](https://www.github.com/googleapis/java-shared-dependencies/commit/b70ddb00a3be97536cdd80bd57fe6bca1b0973e2)) + +### [0.10.2](https://www.github.com/googleapis/java-shared-dependencies/compare/0.10.1...v0.10.2) (2020-10-08) + + +### Dependencies + +* update dependency org.threeten:threetenbp to v1.4.5 ([#162](https://www.github.com/googleapis/java-shared-dependencies/issues/162)) ([54eccb5](https://www.github.com/googleapis/java-shared-dependencies/commit/54eccb533353ddfe537a7e069a696a3f0f70f211)) + +### [0.10.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.10.0...v0.10.1) (2020-10-06) + + +### Dependencies + +* update gax.version to v1.59.1 ([#159](https://www.github.com/googleapis/java-shared-dependencies/issues/159)) ([7c84443](https://www.github.com/googleapis/java-shared-dependencies/commit/7c84443db92e1d910590fa89c2e35b14613e7eba)) + +## [0.10.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.9.1...v0.10.0) (2020-09-23) + + +### Features + +* manage error-prone version ([#147](https://www.github.com/googleapis/java-shared-dependencies/issues/147)) ([0fb3108](https://www.github.com/googleapis/java-shared-dependencies/commit/0fb3108c96abcdef83b5051e842530e6c9934c37)) + + +### Dependencies + +* update google.core.version to v1.93.9 ([#148](https://www.github.com/googleapis/java-shared-dependencies/issues/148)) ([b2a680e](https://www.github.com/googleapis/java-shared-dependencies/commit/b2a680ec9297136dceb622463672cc554359ba5b)) + +### [0.9.1](https://www.github.com/googleapis/java-shared-dependencies/compare/0.9.0...v0.9.1) (2020-09-23) + + +### Dependencies + +* update dependency io.grpc:grpc-bom to v1.32.1 ([#133](https://www.github.com/googleapis/java-shared-dependencies/issues/133)) ([cde0463](https://www.github.com/googleapis/java-shared-dependencies/commit/cde0463dd15c2a510085a3d5e3ac7b418c2fc3d4)) +* update iam.version to v1.0.1 ([#136](https://www.github.com/googleapis/java-shared-dependencies/issues/136)) ([162e2bd](https://www.github.com/googleapis/java-shared-dependencies/commit/162e2bda35fc3427ce571c6747aae4c9eb5866f6)) + +## [0.9.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.8.6...v0.9.0) (2020-08-31) + + +### Bug Fixes + +* temporarily disable reporting to unblock releases ([#129](https://www.github.com/googleapis/java-shared-dependencies/issues/129)) ([7fff6f2](https://www.github.com/googleapis/java-shared-dependencies/commit/7fff6f2c94a19ba998d8cd47e8be5a6333808df8)) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.13.0 ([#126](https://www.github.com/googleapis/java-shared-dependencies/issues/126)) ([908063f](https://www.github.com/googleapis/java-shared-dependencies/commit/908063f9b820dd3195b15537189e45be0d4acbbb)) +* update dependency io.grpc:grpc-bom to v1.31.1 ([#124](https://www.github.com/googleapis/java-shared-dependencies/issues/124)) ([553a339](https://www.github.com/googleapis/java-shared-dependencies/commit/553a3393f5bede0e90e16e2d0d87daa2b936ab32)) +* update google.common-protos.version to v1.18.1 ([#119](https://www.github.com/googleapis/java-shared-dependencies/issues/119)) ([05ad27e](https://www.github.com/googleapis/java-shared-dependencies/commit/05ad27e35fe082e148d377315b10943b187b5670)) +* update google.core.version to v1.93.8 ([f72cef3](https://www.github.com/googleapis/java-shared-dependencies/commit/f72cef3d78a036e2b2434bf08b0a75d57b2fa139)) +* update iam.version to v0.15.0 ([#118](https://www.github.com/googleapis/java-shared-dependencies/issues/118)) ([1409a16](https://www.github.com/googleapis/java-shared-dependencies/commit/1409a16826d3fd4a5d9cbcbe46ea4b4af8687a5c)) +* update iam.version to v1 (major) ([#120](https://www.github.com/googleapis/java-shared-dependencies/issues/120)) ([a6243a0](https://www.github.com/googleapis/java-shared-dependencies/commit/a6243a02129e42fec804b5769fb8e3f334ba84ce)) + +### [0.8.6](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.8.5...v0.8.6) (2020-08-07) + + +### Dependencies + +* update gax to v1.58.2 ([#115](https://www.github.com/googleapis/java-shared-dependencies/issues/115)) ([84b48b4](https://www.github.com/googleapis/java-shared-dependencies/commit/84b48b4e77a4b5b4a2db6030609abe241d5ee2e1)) + +### [0.8.5](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.8.4...v0.8.5) (2020-08-07) + + +### Dependencies + +* update gax to v1.58.1 ([#111](https://www.github.com/googleapis/java-shared-dependencies/issues/111)) ([93a1691](https://www.github.com/googleapis/java-shared-dependencies/commit/93a16915b863a610ffdabe0e23aec58c4ae5f4f1)) + +### [0.8.4](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.8.3...v0.8.4) (2020-08-04) + + +### Dependencies + +* update core dependencies ([#104](https://www.github.com/googleapis/java-shared-dependencies/issues/104)) ([5046818](https://www.github.com/googleapis/java-shared-dependencies/commit/504681803d2bba888404acffe9a8853746501358)) +* update dependency com.google.api:api-common to v1.10.0 ([#101](https://www.github.com/googleapis/java-shared-dependencies/issues/101)) ([6472fac](https://www.github.com/googleapis/java-shared-dependencies/commit/6472face89700e3f2f982c04a5e88801876580be)) +* update dependency com.google.protobuf:protobuf-bom to v3.12.4 ([#103](https://www.github.com/googleapis/java-shared-dependencies/issues/103)) ([885bd0e](https://www.github.com/googleapis/java-shared-dependencies/commit/885bd0ef3c9e344bd1fc60e0f3264995064001d9)) + +### [0.8.3](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.8.2...v0.8.3) (2020-07-09) + + +### Dependencies + +* update core dependencies ([#96](https://www.github.com/googleapis/java-shared-dependencies/issues/96)) ([978e69e](https://www.github.com/googleapis/java-shared-dependencies/commit/978e69e9b5999630354ea204c034be2d6b8a2d80)) +* update dependency com.google.api-client:google-api-client-bom to v1.30.10 ([#99](https://www.github.com/googleapis/java-shared-dependencies/issues/99)) ([65c9cce](https://www.github.com/googleapis/java-shared-dependencies/commit/65c9ccea34275fa6f9599043d6e06df169bc433a)) +* update dependency com.google.api:api-common to v1.9.3 ([#91](https://www.github.com/googleapis/java-shared-dependencies/issues/91)) ([2a23a50](https://www.github.com/googleapis/java-shared-dependencies/commit/2a23a50ee5c73b581a02171048e20b14f999949f)) + +### [0.8.2](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.8.1...v0.8.2) (2020-07-01) + + +### Dependencies + +* update dependency com.google.auth:google-auth-library-bom to v0.21.0 ([#86](https://www.github.com/googleapis/java-shared-dependencies/issues/86)) ([dc9d717](https://www.github.com/googleapis/java-shared-dependencies/commit/dc9d717fdec4f0962141ba34e98f5737ec3bc57a)) +* update dependency com.google.http-client:google-http-client-bom to v1.36.0 ([#89](https://www.github.com/googleapis/java-shared-dependencies/issues/89)) ([12437d7](https://www.github.com/googleapis/java-shared-dependencies/commit/12437d7392a430299c3372d18d2650b62be60eaf)) +* update dependency io.grpc:grpc-bom to v1.30.1 ([#82](https://www.github.com/googleapis/java-shared-dependencies/issues/82)) ([a5199a0](https://www.github.com/googleapis/java-shared-dependencies/commit/a5199a02d5bde75e86349b37c1efae64a6379a40)) +* update dependency io.grpc:grpc-bom to v1.30.2 ([#85](https://www.github.com/googleapis/java-shared-dependencies/issues/85)) ([084d18d](https://www.github.com/googleapis/java-shared-dependencies/commit/084d18daab010c6b0be04e67b42ca8ab8ba5f3d5)) + +### [0.8.1](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.8.0...v0.8.1) (2020-06-13) + + +### Reverts + +* Revert "feat: mark javax annotations scope as provided (#70)" (#75) ([d2f23ec](https://www.github.com/googleapis/java-shared-dependencies/commit/d2f23ecae56a1ec07b1217f0fca5347dd0f0406b)), closes [#70](https://www.github.com/googleapis/java-shared-dependencies/issues/70) [#75](https://www.github.com/googleapis/java-shared-dependencies/issues/75) + +## [0.8.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.7.0...v0.8.0) (2020-06-12) + + +### Features + +* mark javax annotations scope as provided ([#70](https://www.github.com/googleapis/java-shared-dependencies/issues/70)) ([7bc7057](https://www.github.com/googleapis/java-shared-dependencies/commit/7bc70579a01ab761b52f8eef3d0a184b5eec26ae)) + + +### Dependencies + +* update core dependencies to v1.93.6 ([#74](https://www.github.com/googleapis/java-shared-dependencies/issues/74)) ([791639e](https://www.github.com/googleapis/java-shared-dependencies/commit/791639e805b2dcaf9b8e2c04a0428f74c029f94f)) +* update dependency com.google.api:api-common to v1.9.2 ([#63](https://www.github.com/googleapis/java-shared-dependencies/issues/63)) ([ee92a0e](https://www.github.com/googleapis/java-shared-dependencies/commit/ee92a0eb45595fa229cd6fa745f9f3cfa74bb65c)) +* update dependency io.grpc:grpc-bom to v1.30.0 ([#68](https://www.github.com/googleapis/java-shared-dependencies/issues/68)) ([ccf2310](https://www.github.com/googleapis/java-shared-dependencies/commit/ccf23106d29871855511cba0d4e704e4186347f5)) +* update gax to v1.57.0 ([#73](https://www.github.com/googleapis/java-shared-dependencies/issues/73)) ([b0ae1eb](https://www.github.com/googleapis/java-shared-dependencies/commit/b0ae1ebc7a6d4ca90ee50e3a827fcbcea06cfcf1)) + +## [0.7.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.6.0...v0.7.0) (2020-05-28) + + +### Features + +* add core test classifier (needed by BQ) ([#59](https://www.github.com/googleapis/java-shared-dependencies/issues/59)) ([a634d18](https://www.github.com/googleapis/java-shared-dependencies/commit/a634d1886072793f3143f8c5af51008a6d9c857e)) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.12.2 ([#57](https://www.github.com/googleapis/java-shared-dependencies/issues/57)) ([751f170](https://www.github.com/googleapis/java-shared-dependencies/commit/751f1709b9f6bca6e5a22bf42feadc7373bceef7)) + +## [0.6.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.5.0...v0.6.0) (2020-05-27) + + +### Features + +* add grpc-iam-v1 to keep version consistent w proto-iam-v1 ([#55](https://www.github.com/googleapis/java-shared-dependencies/issues/55)) ([0fe26dd](https://www.github.com/googleapis/java-shared-dependencies/commit/0fe26dd73e7c3ada31e53c5f5a84ef4d3c4f3956)) + + +### Dependencies + +* update core dependencies to v1.93.5 ([#53](https://www.github.com/googleapis/java-shared-dependencies/issues/53)) ([9d8d4d6](https://www.github.com/googleapis/java-shared-dependencies/commit/9d8d4d602128e6e32486288cbbec117b80f3fbc6)) +* update dependency com.google.api:api-common to v1.9.1 ([#51](https://www.github.com/googleapis/java-shared-dependencies/issues/51)) ([40276df](https://www.github.com/googleapis/java-shared-dependencies/commit/40276df393e34fb72eead8499968792852a880c7)) + +## [0.5.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.4.0...v0.5.0) (2020-05-26) + + +### ⚠ BREAKING CHANGES + +* remove certain test deps and autovalue (#49) +* remove mockito-core (#44) + +### Features + +* remove certain test deps and autovalue ([#49](https://www.github.com/googleapis/java-shared-dependencies/issues/49)) ([0bcf1a0](https://www.github.com/googleapis/java-shared-dependencies/commit/0bcf1a064ab37e1fbb304640f714ad841762949c)) +* remove mockito-core ([#44](https://www.github.com/googleapis/java-shared-dependencies/issues/44)) ([b690f8d](https://www.github.com/googleapis/java-shared-dependencies/commit/b690f8d742cb954744fdb394e3978407561179ca)) + + +### Bug Fixes + +* remove grpc-testing since it's in grpc-bom ([#50](https://www.github.com/googleapis/java-shared-dependencies/issues/50)) ([d7df346](https://www.github.com/googleapis/java-shared-dependencies/commit/d7df346f8f54301c6113f4bb997b84df5d4f45c7)) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.12.1 ([#48](https://www.github.com/googleapis/java-shared-dependencies/issues/48)) ([d367a31](https://www.github.com/googleapis/java-shared-dependencies/commit/d367a3122b94ec33f804200c38067ae0eac6ddc0)) + +## [0.4.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.3.1...v0.4.0) (2020-05-18) + + +### Features + +* add more shared dependencies ([#40](https://www.github.com/googleapis/java-shared-dependencies/issues/40)) ([34d7e2a](https://www.github.com/googleapis/java-shared-dependencies/commit/34d7e2a4bba3cc03d256de78cb2bf8543811742d)) + + +### Dependencies + +* update dependency com.google.protobuf:protobuf-bom to v3.12.0 ([#38](https://www.github.com/googleapis/java-shared-dependencies/issues/38)) ([155653b](https://www.github.com/googleapis/java-shared-dependencies/commit/155653b52f32e917a1aa970a8c5a716f57c7e190)) + +### [0.3.1](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.3.0...v0.3.1) (2020-05-13) + + +### Dependencies + +* update autovalue.version to v1.7.2 ([#35](https://www.github.com/googleapis/java-shared-dependencies/issues/35)) ([50a1511](https://www.github.com/googleapis/java-shared-dependencies/commit/50a1511a47362a2de5cce26de0f0fbd6ea31c7cb)) + + +### Documentation + +* update CONTRIBUTING.md to include code formatting ([#534](https://www.github.com/googleapis/java-shared-dependencies/issues/534)) ([#34](https://www.github.com/googleapis/java-shared-dependencies/issues/34)) ([c916354](https://www.github.com/googleapis/java-shared-dependencies/commit/c91635446a457e01aa38e2cc384d3fd5d43c1b3b)) + +## [0.3.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.2.0...v0.3.0) (2020-05-05) + + +### Features + +* add grpc-testing, mockito and truth extensions ([#25](https://www.github.com/googleapis/java-shared-dependencies/issues/25)) ([e906514](https://www.github.com/googleapis/java-shared-dependencies/commit/e9065147889ec42ac7350e2559fabae9abf335a9)) + + +### Dependencies + +* update autovalue.version to v1.7.1 ([#29](https://www.github.com/googleapis/java-shared-dependencies/issues/29)) ([c9e80f8](https://www.github.com/googleapis/java-shared-dependencies/commit/c9e80f8e990d42ab4ebace439da2abe93d33afcb)) +* update dependency com.google.http-client:google-http-client-bom to v1.35.0 ([#23](https://www.github.com/googleapis/java-shared-dependencies/issues/23)) ([e1775c2](https://www.github.com/googleapis/java-shared-dependencies/commit/e1775c253b7ef1fdd306b30a6e7698a9370bbf81)) +* update dependency org.mockito:mockito-core to v3.3.3 ([#27](https://www.github.com/googleapis/java-shared-dependencies/issues/27)) ([8dfa3a5](https://www.github.com/googleapis/java-shared-dependencies/commit/8dfa3a5cc8c6a9e2477b63c2174d501a2bdec58a)) +* update dependency org.threeten:threetenbp to v1.4.4 ([#22](https://www.github.com/googleapis/java-shared-dependencies/issues/22)) ([4734794](https://www.github.com/googleapis/java-shared-dependencies/commit/47347943605ad7fdc3340a1a7691c500bbdf1fa2)) +* update google.common-protos.version to v1.18.0 ([#30](https://www.github.com/googleapis/java-shared-dependencies/issues/30)) ([6cb6cc1](https://www.github.com/googleapis/java-shared-dependencies/commit/6cb6cc1304f105307d60c013eaa1604a7537e17a)) + +## [0.2.0](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.1.1...v0.2.0) (2020-04-22) + + +### Features + +* add truth as a managed test scope dependency ([#19](https://www.github.com/googleapis/java-shared-dependencies/issues/19)) ([36167bf](https://www.github.com/googleapis/java-shared-dependencies/commit/36167bfc19475425416316ede28e72db4d683db1)) +* import google-cloud-core-bom to include all google-cloud-core-* artifacts ([#18](https://www.github.com/googleapis/java-shared-dependencies/issues/18)) ([ed3850c](https://www.github.com/googleapis/java-shared-dependencies/commit/ed3850c6a6ea491b570c461a2108c124c9ef71da)) +* import protobuf-bom to manage all protobuf artifacts ([#21](https://www.github.com/googleapis/java-shared-dependencies/issues/21)) ([dc0f1e0](https://www.github.com/googleapis/java-shared-dependencies/commit/dc0f1e0be1be33f5bdf0426cad1cc2df45f5d10a)) + + +### Dependencies + +* update dependency io.grpc:grpc-bom to v1.29.0 ([#16](https://www.github.com/googleapis/java-shared-dependencies/issues/16)) ([eac0d44](https://www.github.com/googleapis/java-shared-dependencies/commit/eac0d448b0701a3dd5788321ed0494eb2a618f9e)) + +### [0.1.1](https://www.github.com/googleapis/java-shared-dependencies/compare/v0.1.0...v0.1.1) (2020-04-14) + + +### Dependencies + +* update core dependencies ([#2](https://www.github.com/googleapis/java-shared-dependencies/issues/2)) ([5589285](https://www.github.com/googleapis/java-shared-dependencies/commit/5589285e105ccd4746e3e194f959c72f17705d45)) +* update dependency com.google.cloud:google-cloud-core to v1.93.4 ([#9](https://www.github.com/googleapis/java-shared-dependencies/issues/9)) ([882cdd6](https://www.github.com/googleapis/java-shared-dependencies/commit/882cdd63f2948de1b29119b36032c45cb4887913)) +* update dependency com.google.guava:guava-bom to v29 ([#12](https://www.github.com/googleapis/java-shared-dependencies/issues/12)) ([9f844c4](https://www.github.com/googleapis/java-shared-dependencies/commit/9f844c4b86cfd5e228a1d3b215726d632c21abf6)) +* update dependency org.threeten:threetenbp to v1.4.3 ([#7](https://www.github.com/googleapis/java-shared-dependencies/issues/7)) ([cd8d481](https://www.github.com/googleapis/java-shared-dependencies/commit/cd8d4812c34568599c79edac45db5bc973eace0a)) + +## 0.1.0 (2020-03-30) + + +### Features + +* initial generation ([d4cec70](https://www.github.com/googleapis/java-shared-dependencies/commit/d4cec70fef2f22df1215e96793fe9f79b644d3b1)) + + +### Dependencies + +* update dependency com.google.api:api-common to v1.9.0 ([#3](https://www.github.com/googleapis/java-shared-dependencies/issues/3)) ([4f6896a](https://www.github.com/googleapis/java-shared-dependencies/commit/4f6896ac883557ad2e61d0fc66567948ae6622d1)) +* update dependency org.threeten:threetenbp to v1.4.2 ([#4](https://www.github.com/googleapis/java-shared-dependencies/issues/4)) ([9446245](https://www.github.com/googleapis/java-shared-dependencies/commit/944624527027f4386d9e3ab82c64655998a17d7a)) diff --git a/java-shared-dependencies/README.md b/java-shared-dependencies/README.md new file mode 100644 index 000000000000..82f2ebe93e03 --- /dev/null +++ b/java-shared-dependencies/README.md @@ -0,0 +1,48 @@ +# Google Cloud Shared Dependencies + +Shared Maven dependencies for Google Cloud Java client libraries. + +[![Maven][maven-version-image]][maven-version-link] + +## Quickstart + +[//]: # ({x-version-update-start:google-cloud-shared-dependencies:released}) +If you are using Maven, add this to the `dependencyManagement` section. +```xml + + + + com.google.cloud + google-cloud-shared-dependencies + 2.6.0 + pom + import + + + +``` +[//]: # ({x-version-update-end}) + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +## Contributing + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING.md][contributing] documentation for more information on how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-shared-dependencies.svg +[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-shared-dependencies&core=gav +[contributing]: https://github.com/googleapis/java-shared-dependencies/blob/main/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/java-shared-dependencies/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[license]: https://github.com/googleapis/java-shared-dependencies/blob/main/LICENSE diff --git a/java-shared-dependencies/dependency-convergence-check/README.md b/java-shared-dependencies/dependency-convergence-check/README.md new file mode 100644 index 000000000000..d593196eceaf --- /dev/null +++ b/java-shared-dependencies/dependency-convergence-check/README.md @@ -0,0 +1,6 @@ +# Dependency Convergence Check + +This project includes a test case for dependency convergence for some (not all) +artifacts in the Google Cloud Shared Dependencies BOM. + +This project is not meant to be used by end-users or published to Maven Central. diff --git a/java-shared-dependencies/dependency-convergence-check/pom.xml b/java-shared-dependencies/dependency-convergence-check/pom.xml new file mode 100644 index 000000000000..167e7c729340 --- /dev/null +++ b/java-shared-dependencies/dependency-convergence-check/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + com.google.cloud + shared-dependencies-dependency-convergence-test + 3.1.3-SNAPSHOT + Dependency convergence test for certain artifacts in Google Cloud Shared Dependencies + + An dependency convergence test case for the shared dependencies BOM. A failure of this test case means + the shared dependencies BOM has outdated dependencies; there are newer version of artifacts + appearing in the dependency tree. + + + + UTF-8 + 1.8 + 1.8 + + + + + + + + + + com.google.guava + guava + 31.0.1-jre + test + + + com.google.cloud.tools + dependencies + 1.5.13 + test + + + junit + junit + test + + + diff --git a/java-shared-dependencies/dependency-convergence-check/src/test/java/com/google/cloud/DependencyConvergenceTest.java b/java-shared-dependencies/dependency-convergence-check/src/test/java/com/google/cloud/DependencyConvergenceTest.java new file mode 100644 index 000000000000..66bf3d753eb7 --- /dev/null +++ b/java-shared-dependencies/dependency-convergence-check/src/test/java/com/google/cloud/DependencyConvergenceTest.java @@ -0,0 +1,114 @@ +/* + * Copyright 2022 Google LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud; + +import static org.junit.Assert.assertTrue; + +import com.google.cloud.tools.opensource.classpath.ClassPathBuilder; +import com.google.cloud.tools.opensource.classpath.ClassPathEntry; +import com.google.cloud.tools.opensource.classpath.ClassPathResult; +import com.google.cloud.tools.opensource.classpath.DependencyMediation; +import com.google.cloud.tools.opensource.dependencies.Bom; +import com.google.cloud.tools.opensource.dependencies.DependencyPath; +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Set; +import org.eclipse.aether.artifact.Artifact; +import org.junit.Test; + +/** + * Test to ensure that certain artifacts in the dependency tree of each entry of the shared + * dependencies BOM have the same version. + */ +public class DependencyConvergenceTest { + + @Test + public void testGrpcConvergence() throws Exception { + // There were cases where the gRPC version set in the shared dependencies BOM and the gRPC + // version declared in gax-grpc's dependency broke the build of downstream projects. Two + // artifacts were using version range to specify exact gRPC versions. + // https://github.com/googleapis/java-shared-dependencies/pull/595 + Bom bom = Bom.readBom(Paths.get("../pom.xml")); + assertConvergence( + bom, + "io.grpc", + "grpc-netty-shaded", + ImmutableSet.of( + // Because OpenCensus's gRPC version does not use version range notation, it does not + // break downstream build + "opencensus-exporter-trace-stackdriver", + "opencensus-exporter-stats-stackdriver", + // Because grpc-gcp's gRPC version does not use version range notation, it does not + // break downstream build + "grpc-gcp", + // Because native-image-support's gRPC dependency is provided scope, it does not bring + // inconsistent gRPC artifacts to users' class paths. + "native-image-support")); + } + + /** + * Asserts the artifact specified at {@code groupId} and {@code artifactId} have the same version + * across the dependency trees of the managed dependencies of {@code bom}. + * + *

Use {@code excludingArtifactIds} to ignore certain artifacts. + */ + private void assertConvergence( + Bom bom, String groupId, String artifactId, Set excludingArtifactIds) + throws Exception { + ImmutableList managedDependencies = bom.getManagedDependencies(); + + Set foundPaths = new HashSet<>(); + Set foundVersions = new HashSet<>(); + for (Artifact managedDependency : managedDependencies) { + if (excludingArtifactIds.contains(managedDependency.getArtifactId())) { + continue; + } + + ClassPathBuilder classPathBuilder = new ClassPathBuilder(); + ClassPathResult result = + classPathBuilder.resolve( + ImmutableList.of(managedDependency), false, DependencyMediation.MAVEN); + ImmutableList classPath = result.getClassPath(); + for (ClassPathEntry entry : classPath) { + Artifact artifact = entry.getArtifact(); + if (artifactId.equals(artifact.getArtifactId()) && groupId.equals(artifact.getGroupId())) { + ImmutableList dependencyPaths = result.getDependencyPaths(entry); + foundPaths.add(dependencyPaths.get(0)); + foundVersions.add(artifact.getVersion()); + } + } + } + + assertTrue( + "There should be at least one version in the graph but empty; " + + "please check the assertion is using correct groupID and artifactID.", + foundVersions.size() >= 1); + + // Duplicate versions found in the dependency trees + assertTrue( + "The version for " + + groupId + + ":" + + artifactId + + " should be one but there are multiple of them: " + + Joiner.on(", ").join(foundPaths), + foundVersions.size() <= 1); + } +} diff --git a/java-shared-dependencies/first-party-dependencies/java.header b/java-shared-dependencies/first-party-dependencies/java.header new file mode 100644 index 000000000000..d0970ba7d375 --- /dev/null +++ b/java-shared-dependencies/first-party-dependencies/java.header @@ -0,0 +1,15 @@ +^/\*$ +^ \* Copyright \d\d\d\d,? Google (Inc\.|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\.$ +^ \*/$ diff --git a/java-shared-dependencies/first-party-dependencies/license-checks.xml b/java-shared-dependencies/first-party-dependencies/license-checks.xml new file mode 100644 index 000000000000..6597fced808e --- /dev/null +++ b/java-shared-dependencies/first-party-dependencies/license-checks.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/java-shared-dependencies/first-party-dependencies/pom.xml b/java-shared-dependencies/first-party-dependencies/pom.xml new file mode 100644 index 000000000000..0bf109d6dabd --- /dev/null +++ b/java-shared-dependencies/first-party-dependencies/pom.xml @@ -0,0 +1,98 @@ + + + 4.0.0 + com.google.cloud + first-party-dependencies + pom + 3.1.3-SNAPSHOT + Google Cloud First-party Shared Dependencies + + Shared first-party dependencies for Google Cloud Java libraries. + + + + com.google.cloud + google-cloud-shared-config + 1.5.5 + + + + UTF-8 + ${project.artifactId} + 2.14.0 + 1.3.2 + 2.10.1 + 1.42.3 + 1.34.1 + 2.1.2 + + + + + + + + com.google.api + gapic-generator-java-bom + ${gapic-generator-java-bom.version} + pom + import + + + com.google.cloud + grpc-gcp + ${grpc-gcp.version} + + + com.google.code.gson + gson + ${gson.version} + + + com.google.cloud + google-cloud-core-bom + 2.9.5-SNAPSHOT + pom + import + + + com.google.http-client + google-http-client-bom + ${google.http-client.version} + pom + import + + + com.google.oauth-client + google-oauth-client-bom + ${google.oauth-client.version} + pom + import + + + com.google.api-client + google-api-client-bom + ${google.api-client.version} + pom + import + + + + + + com.google.cloud + google-cloud-core + 2.9.5-SNAPSHOT + test-jar + + + com.google.cloud + google-cloud-core + 2.9.5-SNAPSHOT + tests + + + + diff --git a/java-shared-dependencies/pom.xml b/java-shared-dependencies/pom.xml new file mode 100644 index 000000000000..9f08e2d3f25b --- /dev/null +++ b/java-shared-dependencies/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + com.google.cloud + google-cloud-shared-dependencies + pom + 3.1.3-SNAPSHOT + + first-party-dependencies + third-party-dependencies + + Google Cloud Shared Dependencies + + Shared build configuration for Google Cloud Java libraries. + + + + com.google.cloud + google-cloud-pom-parent + 1.4.0-SNAPSHOT + ../google-cloud-pom-parent/pom.xml + + + + UTF-8 + ${project.artifactId} + + + + + + com.google.cloud + first-party-dependencies + 3.1.3-SNAPSHOT + pom + import + + + com.google.cloud + third-party-dependencies + 3.1.3-SNAPSHOT + pom + import + + + + diff --git a/java-shared-dependencies/synth.metadata b/java-shared-dependencies/synth.metadata new file mode 100644 index 000000000000..57d8d055d1fb --- /dev/null +++ b/java-shared-dependencies/synth.metadata @@ -0,0 +1,86 @@ +{ + "sources": [ + { + "git": { + "name": ".", + "remote": "https://github.com/googleapis/java-shared-dependencies.git", + "sha": "8a7d227f2a1dab9ff23d247a4e6131c817804c36" + } + }, + { + "git": { + "name": "synthtool", + "remote": "https://github.com/googleapis/synthtool.git", + "sha": "a4be3384ccb92364795d981f2863f6986fcee620" + } + } + ], + "generatedFiles": [ + ".github/CODEOWNERS", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/blunderbuss.yml", + ".github/generated-files-bot.yml", + ".github/release-trigger.yml", + ".github/snippet-bot.yml", + ".github/sync-repo-settings.yaml", + ".github/trusted-contribution.yml", + ".github/workflows/approve-readme.yaml", + ".github/workflows/ci.yaml", + ".kokoro/build.bat", + ".kokoro/build.sh", + ".kokoro/coerce_logs.sh", + ".kokoro/common.cfg", + ".kokoro/common.sh", + ".kokoro/continuous/common.cfg", + ".kokoro/continuous/java8.cfg", + ".kokoro/dependencies.sh", + ".kokoro/nightly/common.cfg", + ".kokoro/nightly/integration.cfg", + ".kokoro/nightly/java11.cfg", + ".kokoro/nightly/java7.cfg", + ".kokoro/nightly/java8-osx.cfg", + ".kokoro/nightly/java8-win.cfg", + ".kokoro/nightly/java8.cfg", + ".kokoro/nightly/samples.cfg", + ".kokoro/populate-secrets.sh", + ".kokoro/presubmit/clirr.cfg", + ".kokoro/presubmit/common.cfg", + ".kokoro/presubmit/dependencies.cfg", + ".kokoro/presubmit/integration.cfg", + ".kokoro/presubmit/java11.cfg", + ".kokoro/presubmit/java7.cfg", + ".kokoro/presubmit/java8-osx.cfg", + ".kokoro/presubmit/java8-win.cfg", + ".kokoro/presubmit/java8.cfg", + ".kokoro/presubmit/linkage-monitor.cfg", + ".kokoro/presubmit/lint.cfg", + ".kokoro/presubmit/samples.cfg", + ".kokoro/readme.sh", + ".kokoro/release/bump_snapshot.cfg", + ".kokoro/release/common.cfg", + ".kokoro/release/common.sh", + ".kokoro/release/drop.cfg", + ".kokoro/release/drop.sh", + ".kokoro/release/promote.cfg", + ".kokoro/release/promote.sh", + ".kokoro/release/publish_javadoc.cfg", + ".kokoro/release/publish_javadoc.sh", + ".kokoro/release/publish_javadoc11.cfg", + ".kokoro/release/publish_javadoc11.sh", + ".kokoro/release/snapshot.cfg", + ".kokoro/release/snapshot.sh", + ".kokoro/release/stage.cfg", + ".kokoro/release/stage.sh", + ".kokoro/trampoline.sh", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "codecov.yaml", + "java.header", + "license-checks.xml" + ] +} \ No newline at end of file diff --git a/java-shared-dependencies/third-party-dependencies/java.header b/java-shared-dependencies/third-party-dependencies/java.header new file mode 100644 index 000000000000..d0970ba7d375 --- /dev/null +++ b/java-shared-dependencies/third-party-dependencies/java.header @@ -0,0 +1,15 @@ +^/\*$ +^ \* Copyright \d\d\d\d,? Google (Inc\.|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\.$ +^ \*/$ diff --git a/java-shared-dependencies/third-party-dependencies/license-checks.xml b/java-shared-dependencies/third-party-dependencies/license-checks.xml new file mode 100644 index 000000000000..6597fced808e --- /dev/null +++ b/java-shared-dependencies/third-party-dependencies/license-checks.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/java-shared-dependencies/third-party-dependencies/pom.xml b/java-shared-dependencies/third-party-dependencies/pom.xml new file mode 100644 index 000000000000..7d31b83e416d --- /dev/null +++ b/java-shared-dependencies/third-party-dependencies/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + com.google.cloud + third-party-dependencies + pom + 3.1.3-SNAPSHOT + Google Cloud Third-party Shared Dependencies + + Shared third-party dependencies for Google Cloud Java libraries. + + + + com.google.cloud + google-cloud-shared-config + 1.5.5 + + + + UTF-8 + ${project.artifactId} + + 1.6.5 + 1.3.2 + 1.22 + 0.31.1 + 3.0.2 + 2.18.0 + 2.14.1 + 1.15 + 4.4.16 + 4.5.14 + + 3.29.0 + 0.26.0 + + + + + + org.apache.httpcomponents + httpcore + ${httpcomponents.httpcore.version} + + + org.apache.httpcomponents + httpclient + ${httpcomponents.httpclient.version} + + + org.threeten + threetenbp + ${threeten.version} + + + javax.annotation + javax.annotation-api + ${javax.annotations.version} + compile + + + org.codehaus.mojo + animal-sniffer-annotations + ${animal-sniffer.version} + + + com.google.code.findbugs + jsr305 + ${findbugs.version} + + + com.google.errorprone + error_prone_annotations + ${errorprone.version} + + + com.fasterxml.jackson + jackson-bom + ${jackson.version} + pom + import + + + commons-codec + commons-codec + ${codec.version} + + + + + io.opencensus + opencensus-api + ${opencensus.version} + + + io.opencensus + opencensus-contrib-grpc-util + ${opencensus.version} + + + io.opencensus + opencensus-contrib-http-util + ${opencensus.version} + + + io.opencensus + opencensus-contrib-zpages + ${opencensus.version} + + + io.opencensus + opencensus-exporter-stats-stackdriver + ${opencensus.version} + + + io.opencensus + opencensus-exporter-trace-stackdriver + ${opencensus.version} + + + io.opencensus + opencensus-impl + ${opencensus.version} + + + io.opencensus + opencensus-impl-core + ${opencensus.version} + + + org.checkerframework + checker-qual + ${checker-qual.version} + + + + \ No newline at end of file diff --git a/java-shared-dependencies/upper-bound-check/pom.xml b/java-shared-dependencies/upper-bound-check/pom.xml new file mode 100644 index 000000000000..76f4a01220c6 --- /dev/null +++ b/java-shared-dependencies/upper-bound-check/pom.xml @@ -0,0 +1,231 @@ + + + 4.0.0 + com.google.cloud + shared-dependencies-upper-bound-test + pom + 3.1.3-SNAPSHOT + Upper bound test for Google Cloud Shared Dependencies + + An upper bound test case for the shared dependencies BOM. A failure of this test case means + the shared dependencies BOM has outdated dependencies; there are newer version of artifacts + appearing in the dependency tree. + + + + com.google.cloud + + google-cloud-shared-config + 1.5.5 + + + + UTF-8 + ${project.artifactId} + + + + + + + + + + + io.grpc + grpc-alts + + + io.grpc + grpc-api + + + io.grpc + grpc-auth + + + io.grpc + grpc-benchmarks + + + io.grpc + grpc-census + + + io.grpc + grpc-context + + + io.grpc + grpc-core + + + io.grpc + grpc-grpclb + + + io.grpc + grpc-netty + + + io.grpc + grpc-netty-shaded + + + io.grpc + grpc-okhttp + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-rls + + + io.grpc + grpc-services + + + io.grpc + grpc-stub + + + io.grpc + grpc-testing-proto + + + io.grpc + grpc-xds + + + com.google.api + gax + + + com.google.api + gax + + + com.google.api + gax-grpc + + + com.google.api + gax-httpjson + + + com.google.cloud + grpc-gcp + + + com.google.guava + guava + + + com.google.protobuf + protobuf-java + + + com.google.protobuf + protobuf-java-util + + + com.google.api + api-common + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + grpc-google-common-protos + + + com.google.cloud + google-cloud-core + + + com.google.cloud + google-cloud-core-grpc + + + com.google.cloud + google-cloud-core-http + + + com.google.auth + google-auth-library-credentials + + + com.google.auth + google-auth-library-oauth2-http + + + com.google.auth + google-auth-library-appengine + + + + com.google.http-client + google-http-client + + + com.google.http-client + google-http-client-android + + + com.google.http-client + google-http-client-apache-v2 + + + com.google.http-client + google-http-client-appengine + + + com.google.http-client + google-http-client-gson + + + com.google.http-client + google-http-client-jackson2 + + + com.google.http-client + google-http-client-protobuf + + + com.google.http-client + google-http-client-xml + + + + com.google.oauth-client + google-oauth-client + + + com.google.api-client + google-api-client + + + com.google.api-client + google-api-client-android + + + com.google.api.grpc + proto-google-iam-v1 + + + com.google.api.grpc + grpc-google-iam-v1 + + + diff --git a/pom.xml b/pom.xml index 40afd5668d3b..c1be8df05483 100644 --- a/pom.xml +++ b/pom.xml @@ -55,6 +55,7 @@ java-containeranalysis java-container java-contentwarehouse + java-core java-datacatalog java-dataflow java-dataform @@ -92,6 +93,7 @@ java-gsuite-addons java-iam-admin java-iamcredentials + java-iam java-ids java-iot java-kms @@ -137,6 +139,7 @@ java-servicedirectory java-service-management java-service-usage + java-shared-dependencies java-shell java-speech java-storage-transfer diff --git a/versions.txt b/versions.txt index 8c99f5448ec9..c9771941681a 100644 --- a/versions.txt +++ b/versions.txt @@ -603,3 +603,6 @@ grpc-google-cloud-tpu-v2:2.10.0:2.11.0-SNAPSHOT google-cloud-datalineage:0.1.0:0.2.0-SNAPSHOT proto-google-cloud-datalineage-v1:0.1.0:0.2.0-SNAPSHOT grpc-google-cloud-datalineage-v1:0.1.0:0.2.0-SNAPSHOT +google-cloud-shared-dependencies:3.1.2:3.1.3-SNAPSHOT +google-cloud-core:2.9.4:2.9.5-SNAPSHOT +google-iam-policy:1.7.0:1.7.1-SNAPSHOT