Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds Universe Domain support #2362

Merged
merged 7 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a tracking bug to know when this will be addressed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

// 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
Loading