add ability to validate and download packages

This commit is contained in:
sbwalker
2023-09-02 14:08:21 -04:00
parent 1f4ae5dbfb
commit 9966fc4651
13 changed files with 169 additions and 51 deletions

View File

@ -39,11 +39,10 @@ namespace Oqtane.Services
Task<List<Package>> GetPackagesAsync(string type, string search, string price, string package, string sort);
/// <summary>
/// Returns a list of packages matching the list of package names
/// Returns a list of packages based on installationid
/// </summary>
/// <param name="names"></param>
/// <returns></returns>
Task<List<Package>> GetPackagesAsync(List<string> packagenames);
Task<List<Package>> GetPackageUpdatesAsync(string type);
/// <summary>
/// Returns a specific package
@ -51,7 +50,7 @@ namespace Oqtane.Services
/// <param name="packageId"></param>
/// <param name="version"></param>
/// <returns></returns>
Task<Package> GetPackageAsync(string packageId, string version);
Task<Package> GetPackageAsync(string packageId, string version, bool download);
/// <summary>
/// Downloads a specific package as .nupkg file
@ -60,7 +59,7 @@ namespace Oqtane.Services
/// <param name="version"></param>
/// <param name="folder"></param>
/// <returns></returns>
Task DownloadPackageAsync(string packageId, string version, string folder);
Task DownloadPackageAsync(string packageId, string version);
/// <summary>
/// Installs all packages located in //TODO: 2dm where?

View File

@ -31,19 +31,19 @@ namespace Oqtane.Services
return await GetJsonAsync<List<Package>>($"{Apiurl}?type={type}&search={WebUtility.UrlEncode(search)}&price={price}&package={package}&sort={sort}");
}
public async Task<List<Package>> GetPackagesAsync(List<string> packagenames)
public async Task<List<Package>> GetPackageUpdatesAsync(string type)
{
return await GetJsonAsync<List<Package>>($"{Apiurl}/list/?names={string.Join(",", packagenames)}");
return await GetJsonAsync<List<Package>>($"{Apiurl}/updates/?type={type}");
}
public async Task<Package> GetPackageAsync(string packageId, string version)
public async Task<Package> GetPackageAsync(string packageId, string version, bool download)
{
return await PostJsonAsync<Package>($"{Apiurl}?packageid={packageId}&version={version}", null);
return await PostJsonAsync<Package>($"{Apiurl}?packageid={packageId}&version={version}&download={download}&install=false", null);
}
public async Task DownloadPackageAsync(string packageId, string version, string folder)
public async Task DownloadPackageAsync(string packageId, string version)
{
await PostAsync($"{Apiurl}?packageid={packageId}&version={version}&folder={folder}");
await PostAsync($"{Apiurl}?packageid={packageId}&version={version}&download=true&install=true");
}
public async Task InstallPackagesAsync()