diff --git a/src/Amazon.Core/Models/AwsClient.cs b/src/Amazon.Core/Models/AwsClient.cs index 4dabb4cb..fa510b60 100755 --- a/src/Amazon.Core/Models/AwsClient.cs +++ b/src/Amazon.Core/Models/AwsClient.cs @@ -16,12 +16,24 @@ public abstract class AwsClient protected readonly IAwsCredential credential; public AwsClient(AwsService service, AwsRegion region, IAwsCredential credential) + : this(service, region, credential, (string?)null) { } + + public AwsClient(AwsService service, AwsRegion region, IAwsCredential credential, HttpClient httpClient) + : this(service, region, credential, httpClient, null) { } + + public AwsClient(AwsService service, AwsRegion region, IAwsCredential credential, HttpClient httpClient, string? endpoint) + : this(service, region, credential, endpoint) + { + this.httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); + } + + public AwsClient(AwsService service, AwsRegion region, IAwsCredential credential, string? endpoint) { this.service = service ?? throw new ArgumentNullException(nameof(service)); Region = region ?? throw new ArgumentNullException(nameof(region)); this.credential = credential ?? throw new ArgumentNullException(nameof(credential)); - Endpoint = $"https://{service.Name}.{region.Name}.amazonaws.com/"; + Endpoint = endpoint ?? $"https://{service.Name}.{region.Name}.amazonaws.com/"; this.httpClient = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip @@ -33,15 +45,7 @@ public AwsClient(AwsService service, AwsRegion region, IAwsCredential credential }; } - public AwsClient(AwsService service, AwsRegion region, IAwsCredential credential, HttpClient httpClient) - { - this.service = service ?? throw new ArgumentNullException(nameof(service)); - Region = region ?? throw new ArgumentNullException(nameof(region)); - this.credential = credential ?? throw new ArgumentNullException(nameof(credential)); - this.httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); - - Endpoint = $"https://{service.Name}.{region.Name}.amazonaws.com/"; - } + public string Endpoint { get; } diff --git a/src/Amazon.DynamoDb/DynamoDbClient.cs b/src/Amazon.DynamoDb/DynamoDbClient.cs index 79bf5bb7..e41f9877 100755 --- a/src/Amazon.DynamoDb/DynamoDbClient.cs +++ b/src/Amazon.DynamoDb/DynamoDbClient.cs @@ -19,7 +19,10 @@ public sealed class DynamoDbClient : AwsClient }; public DynamoDbClient(AwsRegion region, IAwsCredential credential) - : base(AwsService.DynamoDb, region, credential) + : this(region, credential, null) { } + + public DynamoDbClient(AwsRegion region, IAwsCredential credential, string? endpoint) + : base(AwsService.DynamoDb, region, credential, endpoint) { httpClient.Timeout = TimeSpan.FromSeconds(10); }