Skip to content

Commit

Permalink
Update GeosquareService and AmazonCustomS3Config classes
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Feb 27, 2024
1 parent 2fa8281 commit c192cf0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Stars.Data/ThirdParty/Publication/GeosquareService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task<IPublicationState> PublishAsync(IPublicationModel publicationM
return state;
}

private HttpClient CreateClient(string catalogId)
public HttpClient CreateClient(string catalogId)
{
HttpClient client = httpClientFactory.CreateClient(catalogId);
if (client.BaseAddress == null)
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Services/Resources/AmazonCustomS3Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Terradue.Stars.Services.Resources
{
internal class AmazonCustomS3Config : AmazonS3Config
public class AmazonCustomS3Config : AmazonS3Config
{
private string _region;
private string _serviceURL;
Expand Down
1 change: 1 addition & 0 deletions src/Stars.Services/Resources/IS3ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface IS3ClientFactory
{
IAmazonS3 CreateS3Client(S3Url s3Url);
IAmazonS3 CreateS3Client(IAsset asset);
IAmazonS3 CreateS3Client(S3Configuration s3Config);
Task<IAmazonS3> CreateS3ClientAsync(S3Url url, IIdentityProvider identityProvider, string policy = null);
AWSCredentials GetConfiguredCredentials(S3Url s3Url, IIdentityProvider identityProvider = null);
IAmazonS3 CreateS3Client(string name);
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Services/Resources/S3ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public S3Configuration GetAmazonS3Config(S3Url s3Url)
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
private static AmazonCustomS3Config CreateS3Configuration(AWSOptions options)
public static AmazonCustomS3Config CreateS3Configuration(AWSOptions options)
{
AmazonCustomS3Config config = new AmazonCustomS3Config();

Expand Down
28 changes: 28 additions & 0 deletions src/Stars.Services/Resources/S3Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,34 @@ public S3Configuration(S3Configuration s3Configuration)
this.UseWebIdentity = s3Configuration == null ? false : s3Configuration.UseWebIdentity;
}

/// <summary>
/// Create a new S3Configuration from original AmazonS3Config and AWSCredentials
/// This is useful when you want to create a new S3Configuration from an existing AmazonS3Config and AWSCredentials
/// and leverage the modification to access a custom S3 service by using IS3ClientFactory
/// </summary>
/// <param name="amazonS3Config"></param>
/// <param name="awsCredentials"></param>
/// <returns></returns>
public static S3Configuration Create(AmazonS3Config amazonS3Config, AWSCredentials awsCredentials)
{
return new S3Configuration
{
AmazonS3Config = amazonS3Config,
AWSCredentials = awsCredentials,
UrlPattern = $".*", // match all
Region = amazonS3Config?.RegionEndpoint?.SystemName,
ServiceURL = amazonS3Config?.ServiceURL,
AccessKey = awsCredentials?.GetCredentials()?.AccessKey,
SecretKey = awsCredentials?.GetCredentials()?.SecretKey,
SessionToken = awsCredentials?.GetCredentials()?.Token,
AuthenticationRegion = amazonS3Config?.AuthenticationRegion,
UseHttp = amazonS3Config?.UseHttp ?? false,
ForcePathStyle = amazonS3Config?.ForcePathStyle ?? false,
TryAdaptRegion = true,
UseWebIdentity = false
};
}

public string UrlPattern { get; set; }
public string ServiceURL { get; set; }
public string AccessKey { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Services/Router/GenericCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public GenericCatalog(IEnumerable<IResource> routes, string id)

public string Title => id;

public ContentType ContentType => new ContentType("application/catalog");
public ContentType ContentType => new ContentType("application/atom+xml");

public Uri Uri => new Uri("stars://catalog");

Expand Down

0 comments on commit c192cf0

Please sign in to comment.