Skip to content
Open
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
24 changes: 14 additions & 10 deletions src/Amazon.Core/Models/AwsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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; }

Expand Down
5 changes: 4 additions & 1 deletion src/Amazon.DynamoDb/DynamoDbClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down