From c8f7dc145c8b66d6b1e9730d06f154243e09af64 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2019 15:26:17 -0700 Subject: [PATCH 01/16] chore: release 1.91.4-SNAPSHOT (#67) * updated versions.txt [ci skip] * updated google-cloud-core-bom/pom.xml [ci skip] * updated google-cloud-core-grpc/pom.xml [ci skip] * updated google-cloud-core-http/pom.xml [ci skip] * updated google-cloud-core/pom.xml [ci skip] * updated pom.xml [ci skip] --- google-cloud-core-bom/pom.xml | 8 ++++---- google-cloud-core-grpc/pom.xml | 4 ++-- google-cloud-core-http/pom.xml | 4 ++-- google-cloud-core/pom.xml | 4 ++-- pom.xml | 2 +- versions.txt | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/google-cloud-core-bom/pom.xml b/google-cloud-core-bom/pom.xml index fc33e94245..81e051bf33 100644 --- a/google-cloud-core-bom/pom.xml +++ b/google-cloud-core-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-bom - 1.91.3 + 1.91.4-SNAPSHOT pom com.google.cloud @@ -63,17 +63,17 @@ com.google.cloud google-cloud-core - 1.91.3 + 1.91.4-SNAPSHOT com.google.cloud google-cloud-core-grpc - 1.91.3 + 1.91.4-SNAPSHOT com.google.cloud google-cloud-core-http - 1.91.3 + 1.91.4-SNAPSHOT diff --git a/google-cloud-core-grpc/pom.xml b/google-cloud-core-grpc/pom.xml index f95e757971..a95967e501 100644 --- a/google-cloud-core-grpc/pom.xml +++ b/google-cloud-core-grpc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-grpc - 1.91.3 + 1.91.4-SNAPSHOT jar Google Cloud Core gRPC https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.91.3 + 1.91.4-SNAPSHOT google-cloud-core-grpc diff --git a/google-cloud-core-http/pom.xml b/google-cloud-core-http/pom.xml index f9df33bf3c..0117e21e40 100644 --- a/google-cloud-core-http/pom.xml +++ b/google-cloud-core-http/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-http - 1.91.3 + 1.91.4-SNAPSHOT jar Google Cloud Core HTTP https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.91.3 + 1.91.4-SNAPSHOT google-cloud-core-http diff --git a/google-cloud-core/pom.xml b/google-cloud-core/pom.xml index d0e53e22e1..1b97c97354 100644 --- a/google-cloud-core/pom.xml +++ b/google-cloud-core/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core - 1.91.3 + 1.91.4-SNAPSHOT jar Google Cloud Core https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.91.3 + 1.91.4-SNAPSHOT google-cloud-core diff --git a/pom.xml b/pom.xml index 1b025878cc..93a35500b6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-core-parent pom - 1.91.3 + 1.91.4-SNAPSHOT Google Cloud Core Parent https://github.com/googleapis/java-core diff --git a/versions.txt b/versions.txt index eaac9cb3af..beccab0bbb 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-core:1.91.3:1.91.3 \ No newline at end of file +google-cloud-core:1.91.3:1.91.4-SNAPSHOT \ No newline at end of file From 0f8aca59e6c9045952c34cd370c438abb1472982 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 29 Oct 2019 22:18:31 -0700 Subject: [PATCH 02/16] chore: clean up release config (#69) --- .kokoro/release/drop.cfg | 3 --- .kokoro/release/promote.cfg | 4 ---- synth.metadata | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.kokoro/release/drop.cfg b/.kokoro/release/drop.cfg index 211c014c2a..6590b0c133 100644 --- a/.kokoro/release/drop.cfg +++ b/.kokoro/release/drop.cfg @@ -4,6 +4,3 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/java-core/.kokoro/release/drop.sh" } - -# Download staging properties file. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java/releases/java-core" \ No newline at end of file diff --git a/.kokoro/release/promote.cfg b/.kokoro/release/promote.cfg index b3fc2015d6..800f0884e6 100644 --- a/.kokoro/release/promote.cfg +++ b/.kokoro/release/promote.cfg @@ -4,7 +4,3 @@ env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/java-core/.kokoro/release/promote.sh" } - -# Download staging properties file. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/java/releases/java-core" - diff --git a/synth.metadata b/synth.metadata index 3841938ac0..b015b61d61 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-10-19T07:59:22.603125Z", + "updateTime": "2019-10-26T08:01:40.057113Z", "sources": [ { "template": { From e1a4047fb470ea4f80459ca0bb399f4ab2c7decf Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 30 Oct 2019 07:27:20 +0200 Subject: [PATCH 03/16] deps: update dependency com.google.api-client:google-api-client-bom to v1.30.5 (#68) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 93a35500b6..4db929f821 100644 --- a/pom.xml +++ b/pom.xml @@ -157,7 +157,7 @@ 1.17.0 0.13.0 0.18.0 - 1.30.4 + 1.30.5 1.32.1 1.24.1 3.10.0 From 8f1e690611e98855d0eed26d7ef75120bccc862e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 13 Nov 2019 08:50:46 +0100 Subject: [PATCH 04/16] deps: update dependency com.google.http-client:google-http-client-bom to v1.33.0 (#71) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4db929f821..4f0916e487 100644 --- a/pom.xml +++ b/pom.xml @@ -158,7 +158,7 @@ 0.13.0 0.18.0 1.30.5 - 1.32.1 + 1.33.0 1.24.1 3.10.0 0.24.0 From 3a09fc7c4ce73a3c4f144d0cd4da6d29a1664b75 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 18 Nov 2019 22:39:35 +0100 Subject: [PATCH 05/16] deps: update dependency io.grpc:grpc-bom to v1.25.0 (#72) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4f0916e487..4627fb2b33 100644 --- a/pom.xml +++ b/pom.xml @@ -159,7 +159,7 @@ 0.18.0 1.30.5 1.33.0 - 1.24.1 + 1.25.0 3.10.0 0.24.0 1.3.2 From 69fe6e9eb66309e65cd40439c83515a17ab8c0a3 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 18 Nov 2019 22:40:12 +0100 Subject: [PATCH 06/16] chore(deps): update dependency com.google.cloud:google-cloud-shared-config to v0.3.0 (#75) --- google-cloud-core-bom/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google-cloud-core-bom/pom.xml b/google-cloud-core-bom/pom.xml index 81e051bf33..8c4ae2d821 100644 --- a/google-cloud-core-bom/pom.xml +++ b/google-cloud-core-bom/pom.xml @@ -8,7 +8,7 @@ com.google.cloud google-cloud-shared-config - 0.2.1 + 0.3.0 Google Cloud Core diff --git a/pom.xml b/pom.xml index 4627fb2b33..5b435d4360 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 0.2.1 + 0.3.0 From 3d5e6f34a73a207344b1353a3082261a15c564cf Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Mon, 18 Nov 2019 15:47:33 -0600 Subject: [PATCH 07/16] chore: fix distribution_name (#76) --- .repo-metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index e3e884930d..6f416a3b18 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -5,5 +5,5 @@ "language": "java", "repo": "googleapis/java-core", "repo_short": "java-core", - "distribution_name": "google-cloud-java" + "distribution_name": "com.google.cloud:google-cloud-core" } From f493b5bbe5945202af6a94fe01407f795014b4a1 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 18 Nov 2019 22:47:59 +0100 Subject: [PATCH 08/16] deps: update dependency com.google.api:gax-bom to v1.50.1 (#73) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b435d4360..8f0e3c5a20 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ github google-cloud-core-parent - 1.49.1 + 1.50.1 1.8.1 1.17.0 0.13.0 From d8af07a0546af9b6be7106639141554a744d2ed9 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 19 Nov 2019 12:32:49 -0800 Subject: [PATCH 09/16] chore: update common templates (#80) --- .github/release-please.yml | 1 + .kokoro/build.sh | 14 ++++++++++---- .kokoro/dependencies.sh | 6 +++++- synth.metadata | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/release-please.yml b/.github/release-please.yml index 8274468280..dce2c84509 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ releaseType: java-yoshi +bumpMinorPreMajor: true \ No newline at end of file diff --git a/.kokoro/build.sh b/.kokoro/build.sh index fa132f410d..dc2936ef76 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -27,6 +27,7 @@ echo ${JOB_TYPE} mvn install -B -V \ -DskipTests=true \ -Dclirr.skip=true \ + -Denforcer.skip=true \ -Dmaven.javadoc.skip=true \ -Dgcloud.download.skip=true \ -T 1C @@ -38,7 +39,7 @@ fi case ${JOB_TYPE} in test) - mvn test -B -Dclirr.skip=true + mvn test -B -Dclirr.skip=true -Denforcer.skip=true bash ${KOKORO_GFILE_DIR}/codecov.sh bash .kokoro/coerce_logs.sh ;; @@ -49,12 +50,17 @@ javadoc) mvn javadoc:javadoc javadoc:test-javadoc ;; integration) - mvn -B ${INTEGRATION_TEST_ARGS} -DtrimStackTrace=false -Dclirr.skip=true -fae verify + mvn -B ${INTEGRATION_TEST_ARGS} \ + -DtrimStackTrace=false \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -fae \ + verify bash .kokoro/coerce_logs.sh ;; clirr) - mvn -B clirr:check + mvn -B -Denforcer.skip=true clirr:check ;; *) ;; -esac \ No newline at end of file +esac diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index 51e976d441..3fc816b94c 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -23,5 +23,9 @@ echo $JOB_TYPE export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" -mvn install -DskipTests=true -B -V +# this should run maven enforcer +mvn install -B -V \ + -DskipTests=true \ + -Dclirr.skip=true + mvn -B dependency:analyze -DfailOnWarning=true diff --git a/synth.metadata b/synth.metadata index b015b61d61..6822849bef 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-10-26T08:01:40.057113Z", + "updateTime": "2019-11-19T20:08:48.618165Z", "sources": [ { "template": { From 5128bd45bae8cbb8540eccd683f5bba52783feef Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 4 Dec 2019 16:15:35 -0500 Subject: [PATCH 10/16] deps: update to threetenbp 1.4.0 (#89) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8f0e3c5a20..eeed533e41 100644 --- a/pom.xml +++ b/pom.xml @@ -168,7 +168,7 @@ 1.0 3.6 3.0.2 - 1.3.3 + 1.4.0 2.6 2.3.3 2.8.6 From 71d0de782432814971facb7cbb67acdec5e45f00 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Thu, 5 Dec 2019 23:54:02 +0100 Subject: [PATCH 11/16] deps: update dependency com.google.api:gax-bom to v1.51.0 (#85) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eeed533e41..b5e855af27 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ github google-cloud-core-parent - 1.50.1 + 1.51.0 1.8.1 1.17.0 0.13.0 From 9b4df8f839624dfb911935a6f712cd767bac6f10 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 9 Dec 2019 14:32:15 +0200 Subject: [PATCH 12/16] chore(deps): update dependency com.google.api-client:google-api-client-bom to v1.30.6 (#91) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b5e855af27..300314fd11 100644 --- a/pom.xml +++ b/pom.xml @@ -157,7 +157,7 @@ 1.17.0 0.13.0 0.18.0 - 1.30.5 + 1.30.6 1.33.0 1.25.0 3.10.0 From 09b327daf764403b7800180cab79ae3e38815075 Mon Sep 17 00:00:00 2001 From: Dominic Zippilli <35895831+domZippilli@users.noreply.github.com> Date: Fri, 13 Dec 2019 10:30:15 -0800 Subject: [PATCH 13/16] feat: increase DEFAULT_CHUNK_SIZE to reduce transfer overhead (#87) --- .../src/main/java/com/google/cloud/BaseWriteChannel.java | 4 ++-- .../src/test/java/com/google/cloud/BaseWriteChannelTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java b/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java index 865af88959..e45a5aead1 100644 --- a/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java +++ b/google-cloud-core/src/main/java/com/google/cloud/BaseWriteChannel.java @@ -36,8 +36,8 @@ public abstract class BaseWriteChannel< ServiceOptionsT extends ServiceOptions, EntityT extends Serializable> implements WriteChannel { - private static final int MIN_CHUNK_SIZE = 256 * 1024; - private static final int DEFAULT_CHUNK_SIZE = 8 * MIN_CHUNK_SIZE; + 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; diff --git a/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java b/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java index b5e5273420..3f539e5f64 100644 --- a/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java +++ b/google-cloud-core/src/test/java/com/google/cloud/BaseWriteChannelTest.java @@ -55,8 +55,8 @@ protected CustomServiceOptions( 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; - private static final int DEFAULT_CHUNK_SIZE = 8 * MIN_CHUNK_SIZE; + 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; From b465630023dc87537a02a34fb957be340aeb6078 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 14 Dec 2019 00:13:17 +0200 Subject: [PATCH 14/16] deps: update dependency com.google.auth:google-auth-library-bom to v0.19.0 (#93) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 300314fd11..cc83f647ff 100644 --- a/pom.xml +++ b/pom.xml @@ -156,7 +156,7 @@ 1.8.1 1.17.0 0.13.0 - 0.18.0 + 0.19.0 1.30.6 1.33.0 1.25.0 From 6aa4476441fd7636dd116516d3bf4b738cf8a8a9 Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Fri, 13 Dec 2019 16:37:16 -0700 Subject: [PATCH 15/16] feat: support setting ServiceOption for quota project (#92) --- .../cloud/http/HttpTransportOptions.java | 1 + .../java/com/google/cloud/ServiceOptions.java | 44 +++++++-- .../com/google/cloud/ServiceOptionsTest.java | 99 ++++++++++++++++--- pom.xml | 2 +- 4 files changed, 122 insertions(+), 24 deletions(-) diff --git a/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java b/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java index 2dbcb018f8..4bdfee3cca 100644 --- a/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java +++ b/google-cloud-core-http/src/main/java/com/google/cloud/http/HttpTransportOptions.java @@ -176,6 +176,7 @@ ApiClientHeaderProvider.Builder getInternalHeaderProviderBuilder( builder.setClientLibToken( ServiceOptions.getGoogApiClientLibName(), GaxProperties.getLibraryVersion(serviceOptions.getClass())); + builder.setQuotaProjectIdToken(serviceOptions.getQuotaProjectId()); return builder; } diff --git a/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java b/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java index 56f2d19595..792609f4b4 100644 --- a/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java +++ b/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java @@ -43,6 +43,7 @@ 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; @@ -102,6 +103,7 @@ public abstract class ServiceOptions< protected Credentials credentials; private final TransportOptions transportOptions; private final HeaderProvider headerProvider; + private final String quotaProjectId; private transient ServiceRpcFactory serviceRpcFactory; private transient ServiceFactory serviceFactory; @@ -132,6 +134,7 @@ public abstract static class Builder< 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() {} @@ -147,6 +150,7 @@ protected Builder(ServiceOptions options) { clock = options.clock; transportOptions = options.transportOptions; clientLibToken = options.clientLibToken; + quotaProjectId = options.quotaProjectId; } protected abstract ServiceOptions build(); @@ -212,6 +216,10 @@ public B setCredentials(Credentials credentials) { if (this.projectId == null && credentials instanceof ServiceAccountCredentials) { this.projectId = ((ServiceAccountCredentials) credentials).getProjectId(); } + + if (this.quotaProjectId == null && credentials instanceof QuotaProjectIdProvider) { + this.quotaProjectId = ((ServiceAccountCredentials) credentials).getQuotaProjectId(); + } return self(); } @@ -269,6 +277,17 @@ public B setClientLibToken(String 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; } @@ -305,6 +324,10 @@ protected ServiceOptions( firstNonNull(builder.transportOptions, serviceDefaults.getDefaultTransportOptions()); headerProvider = firstNonNull(builder.headerProvider, new NoHeaderProvider()); clientLibToken = builder.clientLibToken; + quotaProjectId = + builder.quotaProjectId != null + ? builder.quotaProjectId + : getValueFromCredentialsFile(System.getenv(CREDENTIAL_ENV_NAME), "quota_project_id"); } /** @@ -488,24 +511,24 @@ static boolean headerContainsMetadataFlavor(HttpResponse response) { } protected static String getServiceAccountProjectId() { - return getServiceAccountProjectId(System.getenv(CREDENTIAL_ENV_NAME)); + return getValueFromCredentialsFile(System.getenv(CREDENTIAL_ENV_NAME), "project_id"); } @InternalApi("Visible for testing") - static String getServiceAccountProjectId(String credentialsPath) { - String project = null; + static String getValueFromCredentialsFile(String credentialsPath, String key) { + String value = null; if (credentialsPath != null) { try (InputStream credentialsStream = new FileInputStream(credentialsPath)) { JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); JsonObjectParser parser = new JsonObjectParser(jsonFactory); GenericJson fileContents = parser.parseAndClose(credentialsStream, Charsets.UTF_8, GenericJson.class); - project = (String) fileContents.get("project_id"); + value = (String) fileContents.get(key); } catch (IOException e) { // ignore } } - return project; + return value; } /** @@ -664,7 +687,8 @@ protected int baseHashCode() { retrySettings, serviceFactoryClassName, serviceRpcFactoryClassName, - clock); + clock, + quotaProjectId); } protected boolean baseEquals(ServiceOptions other) { @@ -674,7 +698,8 @@ protected boolean baseEquals(ServiceOptions other) { && Objects.equals(retrySettings, other.retrySettings) && Objects.equals(serviceFactoryClassName, other.serviceFactoryClassName) && Objects.equals(serviceRpcFactoryClassName, other.serviceRpcFactoryClassName) - && Objects.equals(clock, clock); + && Objects.equals(clock, clock) + && Objects.equals(quotaProjectId, other.quotaProjectId); } private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { @@ -734,4 +759,9 @@ public static T getFromServiceLoader(Class clazz, T defaultInst 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/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java b/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java index 3ce9ffd543..8f8cab08b3 100644 --- a/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java +++ b/google-cloud-core/src/test/java/com/google/cloud/ServiceOptionsTest.java @@ -53,6 +53,10 @@ import org.junit.rules.ExpectedException; 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" @@ -80,16 +84,6 @@ public class ServiceOptionsTest { + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + " \"type\": \"service_account\"\n" + "}"; - private static GoogleCredentials credentials; - - static { - try { - InputStream keyStream = new ByteArrayInputStream(JSON_KEY.getBytes()); - credentials = GoogleCredentials.fromStream(keyStream); - } catch (IOException e) { - fail("Couldn't create fake JSON credentials."); - } - } private static final String JSON_KEY_PROJECT_ID = "{\n" @@ -119,15 +113,51 @@ public class ServiceOptionsTest { + " \"client_id\": \"someclientid.apps.googleusercontent.com\",\n" + " \"type\": \"service_account\"\n" + "}"; - private static GoogleCredentials credentialsWithProjectId; + + 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(JSON_KEY_PROJECT_ID.getBytes()); - credentialsWithProjectId = GoogleCredentials.fromStream(keyStream); + 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(); @@ -138,6 +168,7 @@ public class ServiceOptionsTest { .setHost("host") .setProjectId("project-id") .setRetrySettings(ServiceOptions.getNoRetrySettings()) + .setQuotaProjectId("quota-project-id") .build(); private static final TestServiceOptions OPTIONS_NO_CREDENTIALS = TestServiceOptions.newBuilder() @@ -146,6 +177,7 @@ public class ServiceOptionsTest { .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(); @@ -283,6 +315,39 @@ public void testBuilder() { 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()); @@ -293,6 +358,7 @@ public void testBuilderNoCredentials() { 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 @@ -372,7 +438,8 @@ public void testGetServiceAccountProjectId() throws Exception { Files.write("{\"project_id\":\"my-project-id\"}".getBytes(), credentialsFile); assertEquals( - "my-project-id", ServiceOptions.getServiceAccountProjectId(credentialsFile.getPath())); + "my-project-id", + ServiceOptions.getValueFromCredentialsFile(credentialsFile.getPath(), "project_id")); } @Test @@ -381,14 +448,14 @@ public void testGetServiceAccountProjectId_badJson() throws Exception { credentialsFile.deleteOnExit(); Files.write("asdfghj".getBytes(), credentialsFile); - assertNull(ServiceOptions.getServiceAccountProjectId(credentialsFile.getPath())); + assertNull(ServiceOptions.getValueFromCredentialsFile(credentialsFile.getPath(), "project_id")); } @Test public void testGetServiceAccountProjectId_nonExistentFile() throws Exception { File credentialsFile = new File("/doesnotexist"); - assertNull(ServiceOptions.getServiceAccountProjectId(credentialsFile.getPath())); + assertNull(ServiceOptions.getValueFromCredentialsFile(credentialsFile.getPath(), "project_id")); } @Test diff --git a/pom.xml b/pom.xml index cc83f647ff..5ef6385bc7 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ github google-cloud-core-parent - 1.51.0 + 1.52.0 1.8.1 1.17.0 0.13.0 From 0994384a89ebef036c5593c109dd267b5e99b4c0 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2019 16:45:58 -0700 Subject: [PATCH 16/16] chore: release 1.92.0 (#95) --- CHANGELOG.md | 19 +++++++++++++++++++ google-cloud-core-bom/pom.xml | 8 ++++---- google-cloud-core-grpc/pom.xml | 4 ++-- google-cloud-core-http/pom.xml | 4 ++-- google-cloud-core/pom.xml | 4 ++-- pom.xml | 2 +- versions.txt | 2 +- 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eb8233eb0..05107ed47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [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) diff --git a/google-cloud-core-bom/pom.xml b/google-cloud-core-bom/pom.xml index 8c4ae2d821..f9ce77ee26 100644 --- a/google-cloud-core-bom/pom.xml +++ b/google-cloud-core-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-bom - 1.91.4-SNAPSHOT + 1.92.0 pom com.google.cloud @@ -63,17 +63,17 @@ com.google.cloud google-cloud-core - 1.91.4-SNAPSHOT + 1.92.0 com.google.cloud google-cloud-core-grpc - 1.91.4-SNAPSHOT + 1.92.0 com.google.cloud google-cloud-core-http - 1.91.4-SNAPSHOT + 1.92.0 diff --git a/google-cloud-core-grpc/pom.xml b/google-cloud-core-grpc/pom.xml index a95967e501..431f8b0b36 100644 --- a/google-cloud-core-grpc/pom.xml +++ b/google-cloud-core-grpc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-grpc - 1.91.4-SNAPSHOT + 1.92.0 jar Google Cloud Core gRPC https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.91.4-SNAPSHOT + 1.92.0 google-cloud-core-grpc diff --git a/google-cloud-core-http/pom.xml b/google-cloud-core-http/pom.xml index 0117e21e40..3162fe68a4 100644 --- a/google-cloud-core-http/pom.xml +++ b/google-cloud-core-http/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core-http - 1.91.4-SNAPSHOT + 1.92.0 jar Google Cloud Core HTTP https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.91.4-SNAPSHOT + 1.92.0 google-cloud-core-http diff --git a/google-cloud-core/pom.xml b/google-cloud-core/pom.xml index 1b97c97354..d3f2f690a8 100644 --- a/google-cloud-core/pom.xml +++ b/google-cloud-core/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-core - 1.91.4-SNAPSHOT + 1.92.0 jar Google Cloud Core https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core @@ -13,7 +13,7 @@ com.google.cloud google-cloud-core-parent - 1.91.4-SNAPSHOT + 1.92.0 google-cloud-core diff --git a/pom.xml b/pom.xml index 5ef6385bc7..2718decfb9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-core-parent pom - 1.91.4-SNAPSHOT + 1.92.0 Google Cloud Core Parent https://github.com/googleapis/java-core diff --git a/versions.txt b/versions.txt index beccab0bbb..b6b09bca2f 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,4 @@ # Format: # module:released-version:current-version -google-cloud-core:1.91.3:1.91.4-SNAPSHOT \ No newline at end of file +google-cloud-core:1.92.0:1.92.0 \ No newline at end of file