Skip to content

Commit

Permalink
feat: Universe domain support for Discovery based libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda-tarafa committed Feb 22, 2024
1 parent 200eac2 commit b43bae5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Google.Api.Gax.Rest.IntegrationTests/ClientBuilderBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public async Task BaseUri()
await ValidateResultAsync(builder, initializer => Assert.Equal(uri, initializer.BaseUri));
}

[Fact]
public async Task UniverseDomain()
{
string universeDomain = "custom.domain";
var builder = new SampleClientBuilder { UniverseDomain = universeDomain };
await ValidateResultAsync(builder, initializer => Assert.Equal(universeDomain, initializer.UniverseDomain));
}

[Fact]
public async Task ApplicationNameUnspecified()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public void UseSelfSignedJwts_DisabledByDefault()
{
var builder = new DefaultsTestBuilder();
Assert.False(builder.UseJwtAccessWithScopes);
Assert.Null(builder.UniverseDomain);
}

/// <summary>
Expand Down
20 changes: 20 additions & 0 deletions Google.Api.Gax.Rest/ClientBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ public abstract class ClientBuilderBase<TClient>
/// </summary>
public string BaseUri { get; set; }

/// <summary>
/// The universe domain to connect to, or null to use the default universe domain.
/// </summary>
/// <remarks>
/// <para>
/// <see cref="UniverseDomain"/> is used to build the base URI to connect to, unless <see cref="BaseUri"/>
/// is set, in which case <see cref="BaseUri"/> will be used without further modification.
/// </para>
/// <para>
/// If default credentials or one of <see cref="GoogleCredential"/>, <see cref="CredentialsPath"/> or <see cref="JsonCredentials"/>
/// is used, <see cref="GoogleCredential.GetUniverseDomain"/> should be:
/// <list type="bullet">
/// <item>The same as <see cref="UniverseDomain"/> if <see cref="UniverseDomain"/> has been set.</item>
/// <item>The default universe domain otherwise.</item>
/// </list>
/// </para>
/// </remarks>
public string UniverseDomain { get; set; }

/// <summary>
/// The credential to use for authentication. This cannot be specified alongside other authentication properties.
/// Note that scopes are not automatically applied to this credential; if a scoped credential is required, the
Expand Down Expand Up @@ -165,6 +184,7 @@ private BaseClientService.Initializer CreateServiceInitializerImpl(IConfigurable
ApiKey = ApiKey,
ApplicationName = ApplicationName ?? GetDefaultApplicationName(),
BaseUri = BaseUri,
UniverseDomain = UniverseDomain,
HttpClientFactory = HttpClientFactory
};
initializer.VersionHeaderBuilder
Expand Down

0 comments on commit b43bae5

Please sign in to comment.