public static string GetRequiredResourceUrl(this ServiceIndexResponse serviceIndex, string[] types, string resourceName) { // For more information on required resources, // see: https://docs.microsoft.com/en-us/nuget/api/overview#resources-and-schema var resourceUrl = serviceIndex.GetResourceUrl(types); if (string.IsNullOrEmpty(resourceUrl)) { throw new InvalidOperationException( $"The service index does not have a resource named '{resourceName}'"); } return(resourceUrl); }
public Task <ServiceIndexResponse> GetAsync(CancellationToken cancellationToken = default) { var resources = new List <ServiceIndexItem>(); resources.AddRange(BuildResource("PackagePublish", _url.GetPackagePublishResourceUrl(), "2.0.0")); resources.AddRange(BuildResource("SymbolPackagePublish", _url.GetSymbolPublishResourceUrl(), "4.9.0")); resources.AddRange(BuildResource("SearchQueryService", _url.GetSearchResourceUrl(), "", "3.0.0-beta", "3.0.0-rc")); resources.AddRange(BuildResource("RegistrationsBaseUrl", _url.GetPackageMetadataResourceUrl(), "", "3.0.0-rc", "3.0.0-beta")); resources.AddRange(BuildResource("PackageBaseAddress", _url.GetPackageContentResourceUrl(), "3.0.0")); resources.AddRange(BuildResource("SearchAutocompleteService", _url.GetAutocompleteResourceUrl(), "", "3.0.0-rc", "3.0.0-beta")); var result = new ServiceIndexResponse(new NuGetVersion("3.0.0"), resources); return(Task.FromResult(result)); }
public RawPublishClient(HttpClient httpClient, ServiceIndexResponse serviceIndex) { _httpClient = httpClient; _serviceIndex = serviceIndex; }
public static string GetSearchAutocompleteResourceUrl(this ServiceIndexResponse serviceIndex) { return(serviceIndex.GetResourceUrl(SearchAutocompleteService)); }
public static string GetResourceUrl(this ServiceIndexResponse serviceIndex, string[] types) { var resource = types.SelectMany(t => serviceIndex.Resources.Where(r => r.Type == t)).FirstOrDefault(); return(resource?.ResourceUrl.Trim('/')); }
public static string GetCatalogResourceUrl(this ServiceIndexResponse serviceIndex) { return(serviceIndex.GetResourceUrl(Catalog)); }
public static string GetSearchQueryResourceUrl(this ServiceIndexResponse serviceIndex) { return(serviceIndex.GetRequiredResourceUrl(SearchQueryService, nameof(SearchQueryService))); }
public static string GetPackageMetadataResourceUrl(this ServiceIndexResponse serviceIndex) { return(serviceIndex.GetRequiredResourceUrl(RegistrationsBaseUrl, nameof(RegistrationsBaseUrl))); }
public static string GetSymbolPublishResourceUrl(this ServiceIndexResponse serviceIndex) { return(serviceIndex.GetResourceUrl(SymbolPackagePublish)); }
public static string GetPackageContentResourceUrl(this ServiceIndexResponse serviceIndex) { return(serviceIndex.GetRequiredResourceUrl(PackageBaseAddress, nameof(PackageBaseAddress))); }