|
| 1 | +using System.IO; |
| 2 | +using System.Threading; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using BaGet.Protocol.Models; |
| 5 | +using NuGet.Versioning; |
| 6 | + |
| 7 | +namespace BaGet.Core.Content |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// The Package Content resource, used to download NuGet packages and to fetch other metadata. |
| 11 | + /// |
| 12 | + /// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource |
| 13 | + /// </summary> |
| 14 | + public interface IPackageContentService |
| 15 | + { |
| 16 | + /// <summary> |
| 17 | + /// Get a package's versions, or null if the package does not exist. |
| 18 | + /// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#enumerate-package-versions |
| 19 | + /// </summary> |
| 20 | + /// <param name="packageId">The package ID.</param> |
| 21 | + /// <param name="cancellationToken">A token to cancel the task.</param> |
| 22 | + /// <returns>The package's versions, or null if the package does not exist.</returns> |
| 23 | + Task<PackageVersionsResponse> GetPackageVersionsOrNullAsync( |
| 24 | + string packageId, |
| 25 | + CancellationToken cancellationToken = default); |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// Download a package, or null if the package does not exist. |
| 29 | + /// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-content-nupkg |
| 30 | + /// </summary> |
| 31 | + /// <param name="packageId">The package ID.</param> |
| 32 | + /// <param name="packageVersion">The package's version.</param> |
| 33 | + /// <param name="cancellationToken">A token to cancel the task.</param> |
| 34 | + /// <returns> |
| 35 | + /// The package's content stream, or null if the package does not exist. The stream may not be seekable. |
| 36 | + /// </returns> |
| 37 | + Task<Stream> GetPackageContentStreamOrNullAsync( |
| 38 | + string packageId, |
| 39 | + NuGetVersion packageVersion, |
| 40 | + CancellationToken cancellationToken = default); |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Download a package's manifest (nuspec), or null if the package does not exist. |
| 44 | + /// See: https://docs.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec |
| 45 | + /// </summary> |
| 46 | + /// <param name="packageId">The package id.</param> |
| 47 | + /// <param name="packageVersion">The package's version.</param> |
| 48 | + /// <param name="cancellationToken">A token to cancel the task.</param> |
| 49 | + /// <returns> |
| 50 | + /// The package's manifest stream, or null if the package does not exist. The stream may not be seekable. |
| 51 | + /// </returns> |
| 52 | + Task<Stream> GetPackageManifestStreamOrNullAsync( |
| 53 | + string packageId, |
| 54 | + NuGetVersion packageVersion, |
| 55 | + CancellationToken cancellationToken = default); |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Download a package's readme, or null if the package or readme does not exist. |
| 59 | + /// </summary> |
| 60 | + /// <param name="id">The package id.</param> |
| 61 | + /// <param name="version">The package's version.</param> |
| 62 | + /// <param name="cancellationToken">A token to cancel the task.</param> |
| 63 | + /// <returns> |
| 64 | + /// The package's readme stream, or null if the package or readme does not exist. The stream may not be seekable. |
| 65 | + /// </returns> |
| 66 | + Task<Stream> GetPackageReadmeStreamOrNullAsync( |
| 67 | + string id, |
| 68 | + NuGetVersion version, |
| 69 | + CancellationToken cancellationToken = default); |
| 70 | + } |
| 71 | +} |
0 commit comments