Skip to content

Commit 8b636db

Browse files
feat: Adds TPC support (#2362)
* feat: Adds TPC support * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Add tracking bug * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 13c9aee commit 8b636db

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies:
5050
If you are using Gradle 5.x or later, add this to your dependencies:
5151

5252
```Groovy
53-
implementation platform('com.google.cloud:libraries-bom:26.30.0')
53+
implementation platform('com.google.cloud:libraries-bom:26.31.0')
5454
5555
implementation 'com.google.cloud:google-cloud-storage'
5656
```

google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,17 @@ public HttpStorageRpcFactory() {}
323323
public ServiceRpc create(StorageOptions options) {
324324
if (options instanceof HttpStorageOptions) {
325325
HttpStorageOptions httpStorageOptions = (HttpStorageOptions) options;
326+
// todo: In the future, this step will be done automatically, and the getResolvedApiaryHost
327+
// helper method will
328+
// be removed. When that happens, delete the following block.
329+
// https://github.com/googleapis/google-api-java-client-services/issues/19286
330+
if (httpStorageOptions.getUniverseDomain() != null) {
331+
httpStorageOptions =
332+
httpStorageOptions
333+
.toBuilder()
334+
.setHost(httpStorageOptions.getResolvedApiaryHost("storage"))
335+
.build();
336+
}
326337
return new HttpStorageRpc(httpStorageOptions);
327338
} else {
328339
throw new IllegalArgumentException("Only HttpStorageOptions supported");

google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ final class StorageImpl extends BaseService<StorageOptions> implements Storage {
101101
/** Signed URLs are only supported through the GCS XML API endpoint. */
102102
private static final String STORAGE_XML_URI_SCHEME = "https";
103103

104-
private static final String STORAGE_XML_URI_HOST_NAME = "storage.googleapis.com";
104+
// TODO: in the future, this can be replaced by getOptions().getHost()
105+
private final String STORAGE_XML_URI_HOST_NAME =
106+
getOptions()
107+
.getResolvedApiaryHost("storage")
108+
.replaceFirst("http(s)?://", "")
109+
.replace("/", "");
105110

106111
private static final int DEFAULT_BUFFER_SIZE = 15 * 1024 * 1024;
107112
private static final int MIN_BUFFER_SIZE = 256 * 1024;
@@ -1048,7 +1053,8 @@ private SignatureInfo buildSignatureInfo(
10481053
"host",
10491054
slashlessBucketNameFromBlobInfo(blobInfo) + "." + getBaseStorageHostName(optionMap));
10501055
} else if (optionMap.containsKey(SignUrlOption.Option.HOST_NAME)
1051-
|| optionMap.containsKey(SignUrlOption.Option.BUCKET_BOUND_HOST_NAME)) {
1056+
|| optionMap.containsKey(SignUrlOption.Option.BUCKET_BOUND_HOST_NAME)
1057+
|| getOptions().getUniverseDomain() != null) {
10521058
extHeadersBuilder.put("host", getBaseStorageHostName(optionMap));
10531059
}
10541060
}
@@ -1576,7 +1582,16 @@ public boolean deleteNotification(final String bucket, final String notification
15761582

15771583
@Override
15781584
public HttpStorageOptions getOptions() {
1579-
return (HttpStorageOptions) super.getOptions();
1585+
HttpStorageOptions options = (HttpStorageOptions) super.getOptions();
1586+
/**
1587+
* TODO: In the future, this should happen automatically, and this block will be deleted
1588+
* https://github.com/googleapis/google-api-java-client-services/issues/19286
1589+
*/
1590+
if (options.getUniverseDomain() != null) {
1591+
1592+
return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build();
1593+
}
1594+
return options;
15801595
}
15811596

15821597
private Blob internalGetBlob(BlobId blob, Map<StorageRpc.Option, ?> optionsMap) {

0 commit comments

Comments
 (0)