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

fix: Apiary Host returns user set host if set #2455

Merged
merged 4 commits into from
Feb 9, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -851,17 +851,24 @@ public String getResolvedHost(String serviceName) {
}

/**
* Temporarily used for BigQuery and Storage Apiary Wrapped Libraries. To be removed in the future
* when Apiary clients can resolve their endpoints. Returns the host to be used as the rootUrl.
* Returns a host value to be used for BigQuery and Storage Apiary Wrapped Libraries. To be
* removed in the future when Apiary clients can resolve their endpoints. Returns the host to be
* used as the rootUrl.
*
* <p>The resolved host will be in `https://{serviceName}.{resolvedUniverseDomain}/` format. The
* resolvedUniverseDomain will be set to `googleapis.com` if universeDomain is null.
*
* <p>The host value is set to DEFAULT_HOST if the user didn't configure a host. Returns the host
* value the user set, otherwise constructs the host for the user.
*
* @see <a
* href="https://github.com/googleapis/google-api-java-client/blob/76765d5f9689be9d266a7d62fa6ffb4cabf701f5/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClient.java#L49">rootUrl</a>
*/
@InternalApi
public String getResolvedApiaryHost(String serviceName) {
if (!DEFAULT_HOST.equals(host)) {
return host;
}
String resolvedUniverseDomain =
universeDomain != null ? universeDomain : Credentials.GOOGLE_DEFAULT_UNIVERSE;
return "https://" + serviceName + "." + resolvedUniverseDomain + "/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,10 @@ public void testGetResolvedApiaryHost_customUniverseDomain_customHost() {
TestServiceOptions options =
TestServiceOptions.newBuilder()
.setUniverseDomain("test.com")
.setHost("https://service.random.com")
.setHost("https://service.random.com/")
.setProjectId("project-id")
.build();
assertThat(options.getResolvedApiaryHost("service")).isEqualTo("https://service.test.com/");
assertThat(options.getResolvedApiaryHost("service")).isEqualTo("https://service.random.com/");
}

// No User Configuration = GDU, Default Credentials = GDU
Expand Down