From 24a170fa767f512c876d407d02047f50b0cdb49f Mon Sep 17 00:00:00 2001 From: Jesse Lovelace Date: Thu, 18 Jan 2024 16:56:13 -0800 Subject: [PATCH 1/5] feat: Adds TPC support --- .../google/cloud/storage/HttpStorageOptions.java | 5 +++++ .../com/google/cloud/storage/StorageImpl.java | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java index f21860e7f7..90f7099b0a 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java @@ -323,6 +323,11 @@ public HttpStorageRpcFactory() {} public ServiceRpc create(StorageOptions options) { if (options instanceof HttpStorageOptions) { HttpStorageOptions httpStorageOptions = (HttpStorageOptions) options; + // todo: In the future, this step will be done automatically, and the getResolvedApiaryHost helper method will + // be removed. When that happens, delete the following block. + if (httpStorageOptions.getUniverseDomain() != null) { + httpStorageOptions = httpStorageOptions.toBuilder().setHost(httpStorageOptions.getResolvedApiaryHost("storage")).build(); + } return new HttpStorageRpc(httpStorageOptions); } else { throw new IllegalArgumentException("Only HttpStorageOptions supported"); diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index 94b3387768..ded8952b5e 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -101,7 +101,8 @@ final class StorageImpl extends BaseService implements Storage { /** Signed URLs are only supported through the GCS XML API endpoint. */ private static final String STORAGE_XML_URI_SCHEME = "https"; - private static final String STORAGE_XML_URI_HOST_NAME = "storage.googleapis.com"; + // TODO: in the future, this can be replaced by getOptions().getHost() + private final String STORAGE_XML_URI_HOST_NAME = getOptions().getResolvedApiaryHost("storage").replaceFirst("http(s)?://", "").replace("/", ""); private static final int DEFAULT_BUFFER_SIZE = 15 * 1024 * 1024; private static final int MIN_BUFFER_SIZE = 256 * 1024; @@ -1048,7 +1049,8 @@ private SignatureInfo buildSignatureInfo( "host", slashlessBucketNameFromBlobInfo(blobInfo) + "." + getBaseStorageHostName(optionMap)); } else if (optionMap.containsKey(SignUrlOption.Option.HOST_NAME) - || optionMap.containsKey(SignUrlOption.Option.BUCKET_BOUND_HOST_NAME)) { + || optionMap.containsKey(SignUrlOption.Option.BUCKET_BOUND_HOST_NAME) + || getOptions().getUniverseDomain() != null) { extHeadersBuilder.put("host", getBaseStorageHostName(optionMap)); } } @@ -1576,7 +1578,14 @@ public boolean deleteNotification(final String bucket, final String notification @Override public HttpStorageOptions getOptions() { - return (HttpStorageOptions) super.getOptions(); + HttpStorageOptions options = (HttpStorageOptions) super.getOptions(); + /** + * TODO: In the future, this should happen automatically, and this block will be deleted + */ + if(options.getUniverseDomain() != null) { + return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build(); + } + return options; } private Blob internalGetBlob(BlobId blob, Map optionsMap) { From eb98fff89c004f15c49be99814a7bb6dee27a80c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 19 Jan 2024 01:02:25 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 2 +- .../com/google/cloud/storage/HttpStorageOptions.java | 9 +++++++-- .../java/com/google/cloud/storage/StorageImpl.java | 12 +++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d7ce7e14e6..48074507a9 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.29.0') +implementation platform('com.google.cloud:libraries-bom:26.30.0') implementation 'com.google.cloud:google-cloud-storage' ``` diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java index 90f7099b0a..0d8997d6ae 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java @@ -323,10 +323,15 @@ public HttpStorageRpcFactory() {} public ServiceRpc create(StorageOptions options) { if (options instanceof HttpStorageOptions) { HttpStorageOptions httpStorageOptions = (HttpStorageOptions) options; - // todo: In the future, this step will be done automatically, and the getResolvedApiaryHost helper method will + // todo: In the future, this step will be done automatically, and the getResolvedApiaryHost + // helper method will // be removed. When that happens, delete the following block. if (httpStorageOptions.getUniverseDomain() != null) { - httpStorageOptions = httpStorageOptions.toBuilder().setHost(httpStorageOptions.getResolvedApiaryHost("storage")).build(); + httpStorageOptions = + httpStorageOptions + .toBuilder() + .setHost(httpStorageOptions.getResolvedApiaryHost("storage")) + .build(); } return new HttpStorageRpc(httpStorageOptions); } else { diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index ded8952b5e..f7f3243e04 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -102,7 +102,11 @@ final class StorageImpl extends BaseService implements Storage { private static final String STORAGE_XML_URI_SCHEME = "https"; // TODO: in the future, this can be replaced by getOptions().getHost() - private final String STORAGE_XML_URI_HOST_NAME = getOptions().getResolvedApiaryHost("storage").replaceFirst("http(s)?://", "").replace("/", ""); + private final String STORAGE_XML_URI_HOST_NAME = + getOptions() + .getResolvedApiaryHost("storage") + .replaceFirst("http(s)?://", "") + .replace("/", ""); private static final int DEFAULT_BUFFER_SIZE = 15 * 1024 * 1024; private static final int MIN_BUFFER_SIZE = 256 * 1024; @@ -1579,10 +1583,8 @@ public boolean deleteNotification(final String bucket, final String notification @Override public HttpStorageOptions getOptions() { HttpStorageOptions options = (HttpStorageOptions) super.getOptions(); - /** - * TODO: In the future, this should happen automatically, and this block will be deleted - */ - if(options.getUniverseDomain() != null) { + /** TODO: In the future, this should happen automatically, and this block will be deleted */ + if (options.getUniverseDomain() != null) { return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build(); } return options; From 64a5bc52be1a747011ca7295927d5d21381a9e07 Mon Sep 17 00:00:00 2001 From: Jesse Lovelace Date: Tue, 23 Jan 2024 13:33:26 -0800 Subject: [PATCH 3/5] Add tracking bug --- .../main/java/com/google/cloud/storage/HttpStorageOptions.java | 1 + .../src/main/java/com/google/cloud/storage/StorageImpl.java | 1 + 2 files changed, 2 insertions(+) diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java index 90f7099b0a..8b03021cf3 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java @@ -325,6 +325,7 @@ public ServiceRpc create(StorageOptions options) { HttpStorageOptions httpStorageOptions = (HttpStorageOptions) options; // todo: In the future, this step will be done automatically, and the getResolvedApiaryHost helper method will // be removed. When that happens, delete the following block. + // https://github.com/googleapis/google-api-java-client-services/issues/19286 if (httpStorageOptions.getUniverseDomain() != null) { httpStorageOptions = httpStorageOptions.toBuilder().setHost(httpStorageOptions.getResolvedApiaryHost("storage")).build(); } diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index ded8952b5e..171d0cbd53 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -1581,6 +1581,7 @@ public HttpStorageOptions getOptions() { HttpStorageOptions options = (HttpStorageOptions) super.getOptions(); /** * TODO: In the future, this should happen automatically, and this block will be deleted + * https://github.com/googleapis/google-api-java-client-services/issues/19286 */ if(options.getUniverseDomain() != null) { return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build(); From 669e54df4d11c7e9649af179f9cd1a7faff1d7c5 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 23 Jan 2024 21:36:33 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 6 +++--- .../src/main/java/com/google/cloud/storage/StorageImpl.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 48074507a9..de09f729fc 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-storage' If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-storage:2.31.0' +implementation 'com.google.cloud:google-cloud-storage:2.32.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.31.0" +libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.32.0" ``` @@ -428,7 +428,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-storage/java11.html [stability-image]: https://img.shields.io/badge/stability-stable-green [maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-storage.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-storage/2.31.0 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-storage/2.32.0 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index c518aee5e8..9af54fee20 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -1587,7 +1587,7 @@ public HttpStorageOptions getOptions() { * TODO: In the future, this should happen automatically, and this block will be deleted * https://github.com/googleapis/google-api-java-client-services/issues/19286 */ - if(options.getUniverseDomain() != null) { + if (options.getUniverseDomain() != null) { return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build(); } From 27fa34aea0863cb9c6d88dc32999ea619f2a2e99 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 31 Jan 2024 18:28:56 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2394ea3bee..6d2bb70810 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.30.0') +implementation platform('com.google.cloud:libraries-bom:26.31.0') implementation 'com.google.cloud:google-cloud-storage' ```