Skip to content

Commit

Permalink
feat: Adds TPC support (#2362)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
JesseLovelace and gcf-owl-bot[bot] authored Jan 31, 2024
1 parent 13c9aee commit 8b636db
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ 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.
// https://github.com/googleapis/google-api-java-client-services/issues/19286
if (httpStorageOptions.getUniverseDomain() != null) {
httpStorageOptions =
httpStorageOptions
.toBuilder()
.setHost(httpStorageOptions.getResolvedApiaryHost("storage"))
.build();
}
return new HttpStorageRpc(httpStorageOptions);
} else {
throw new IllegalArgumentException("Only HttpStorageOptions supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ final class StorageImpl extends BaseService<StorageOptions> 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;
Expand Down Expand Up @@ -1048,7 +1053,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));
}
}
Expand Down Expand Up @@ -1576,7 +1582,16 @@ 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
* https://github.com/googleapis/google-api-java-client-services/issues/19286
*/
if (options.getUniverseDomain() != null) {

return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build();
}
return options;
}

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

0 comments on commit 8b636db

Please sign in to comment.