Skip to content

Commit

Permalink
Enabled Sentinel-2 download from Google Cloud Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
floeschau committed Apr 19, 2024
1 parent 9efbb40 commit faad63f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/Stars.Data/Suppliers/DataHubSourceSupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public DataHubSourceSupplier(ILogger<DataHubSourceSupplier> logger,
this.credentialsManager = credentialsManager;
_s3ClientFactory = s3ClientFactory;
SupplierPluginOption supplierPluginOption = pluginOption as SupplierPluginOption;
ConfigureWrapper(new Uri(supplierPluginOption.ServiceUrl));
ConfigureWrapper(supplierPluginOption);
}

public override string Id => wrapper.Name;
Expand All @@ -47,11 +47,12 @@ public DataHubSourceSupplier(ILogger<DataHubSourceSupplier> logger,

public IDataHubSourceWrapper Wrapper => wrapper;

public void ConfigureWrapper(Uri serviceUrl)
public void ConfigureWrapper(SupplierPluginOption pluginOption)
{
if (pluginOption == null)
throw new ArgumentNullException("pluginOption");

if (serviceUrl == null)
throw new ArgumentNullException("serviceUrl");
Uri serviceUrl = new Uri(pluginOption.ServiceUrl);

var target_uri = serviceUrl;
var target_creds = credentialsManager;
Expand Down Expand Up @@ -125,13 +126,22 @@ public void ConfigureWrapper(Uri serviceUrl)

if (target_uri.Host.EndsWith("googleapis.com") || target_uri.Host.EndsWith("google.com"))
{
wrapper = new GoogleWrapper(null, null, target_creds, "https://cloud.google.com");
wrapper = new GoogleWrapper(pluginOption.AccountFile, pluginOption.ProjectId, target_creds, "https://cloud.google.com");
}

this.openSearchable = wrapper.CreateOpenSearchable(new OpenSearchableFactorySettings(this.opensearchEngine));

}

[Obsolete("Method kept for backward compatibility")]
public void ConfigureWrapper(Uri serviceUrl)
{
if (serviceUrl == null)
throw new ArgumentNullException("serviceUrl");

ConfigureWrapper(new SupplierPluginOption() { ServiceUrl = serviceUrl.AbsoluteUri });
}

internal static NetworkCredential GetNetworkCredentials(IConfigurationSection credentials)
{
if (credentials == null)
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Data/Terradue.Stars.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="Terradue.MetadataExtractor" Version="1.3.0" />
<PackageReference Include="ProjNet" Version="2.0.0" />
<PackageReference Include="MimeTypes" Version="2.0.2" />
<PackageReference Include="Terradue.OpenSearch.SciHub" Version="1.40.*"/>
<PackageReference Include="Terradue.OpenSearch.SciHub" Version="1.41.*"/>
<PackageReference Include="Terradue.OpenSearch.Asf" Version="1.4.*" />
<PackageReference Include="Terradue.OpenSearch.Usgs" Version="1.7.*" />
<PackageReference Include="Terradue.OpenSearch.GeoJson" Version="1.4.5" />
Expand Down
4 changes: 4 additions & 0 deletions src/Stars.Services/Plugins/PluginsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,9 @@ public PluginOption()
public class SupplierPluginOption : PluginOption
{
public string ServiceUrl { get; set; }

public string AccountFile { get; set; }

public string ProjectId { get; set; }
}
}

0 comments on commit faad63f

Please sign in to comment.