public PackageRegistrationMetadataResourceV3( RegistrationResourceV3 registration, HttpSource client) { _registration = registration; _client = client; }
public PSAutoCompleteResourceV3(DataClient client, ServiceIndexResourceV3 serviceIndex, RegistrationResourceV3 regResource) : base() { _regResource = regResource; _serviceIndex = serviceIndex; _client = client; }
public UIMetadataResourceV3(DataClient client, RegistrationResourceV3 regResource, ReportAbuseResourceV3 reportAbuseResource) : base() { _regResource = regResource; _client = client; _reportAbuseResource = reportAbuseResource; }
protected override void Init(IDictionary <string, string> arguments, CancellationToken cancellationToken) { var gallery = arguments.GetOrThrow <string>(Arguments.Gallery); var index = arguments.GetOrThrow <string>(Arguments.Index); var packageBaseAddress = arguments.GetOrThrow <string>(Arguments.ContentBaseAddress); var source = arguments.GetOrThrow <string>(Arguments.Source); var requireSignature = arguments.GetOrDefault(Arguments.RequireSignature, false); var verbose = arguments.GetOrDefault(Arguments.Verbose, false); CommandHelpers.AssertAzureStorage(arguments); var monitoringStorageFactory = CommandHelpers.CreateStorageFactory(arguments, verbose); var auditingStorageFactory = CommandHelpers.CreateSuffixedStorageFactory("Auditing", arguments, verbose); var endpointInputs = CommandHelpers.GetEndpointFactoryInputs(arguments); var messageHandlerFactory = CommandHelpers.GetHttpMessageHandlerFactory(TelemetryService, verbose); Logger.LogInformation( "CONFIG gallery: {Gallery} index: {Index} storage: {Storage} auditingStorage: {AuditingStorage} endpoints: {Endpoints}", gallery, index, monitoringStorageFactory, auditingStorageFactory, string.Join(", ", endpointInputs.Select(e => e.Name))); _packageValidator = new PackageValidatorFactory(LoggerFactory) .Create(gallery, index, packageBaseAddress, auditingStorageFactory, endpointInputs, messageHandlerFactory, requireSignature, verbose); _queue = CommandHelpers.CreateStorageQueue <PackageValidatorContext>(arguments, PackageValidatorContext.Version); _statusService = CommandHelpers.GetPackageMonitoringStatusService(arguments, monitoringStorageFactory, LoggerFactory); _notificationService = new LoggerMonitoringNotificationService(LoggerFactory.CreateLogger <LoggerMonitoringNotificationService>()); _regResource = Repository.Factory.GetCoreV3(index).GetResource <RegistrationResourceV3>(cancellationToken); _client = new CollectorHttpClient(messageHandlerFactory()); }
private PackageMetadataResourceV3 GetPackageMetadataResource() { RegistrationResourceV3 regResource = _sourceRepository.GetResource <RegistrationResourceV3>(); ReportAbuseResourceV3 reportAbuseResource = _sourceRepository.GetResource <ReportAbuseResourceV3>(); var packageMetadataRes = new PackageMetadataResourceV3(_httpSource.HttpSource, regResource, reportAbuseResource); return(packageMetadataRes); }
public NuRepository(List <Lazy <INuGetResourceProvider> > providers, Uri repositoryUrl, Microsoft.Extensions.Logging.ILogger <NuGetClient> logger) { this.providers = providers; this.repositoryUrl = repositoryUrl; this._logger = logger; PackageSource packageSource = new PackageSource(repositoryUrl.AbsoluteUri); _sourceRepository = new SourceRepository(packageSource, providers); _cacheContext = new SourceCacheContext(); var httpSource = _sourceRepository.GetResource <HttpSourceResource>(); _regResource = _sourceRepository.GetResource <RegistrationResourceV3>(); ReportAbuseResourceV3 reportAbuseResource = _sourceRepository.GetResource <ReportAbuseResourceV3>(); _metadataSearch = new PackageMetadataResourceV3(httpSource.HttpSource, _regResource, reportAbuseResource); _versionSearch = new RemoteV3FindPackageByIdResource(_sourceRepository, httpSource.HttpSource); this._loggerAdapter = new NuGetLoggerAdapter <NuGetClient>(logger); }
public static async Task <long> PackageSize(this SourceRepository sourceRepository, PackageIdentity packageIdentity, CancellationToken cancellationToken) { if (null == sourceRepository || null == packageIdentity) { return(0); } using (SourceCacheContext cache = new SourceCacheContext { DirectDownload = true, NoCache = true }) { try { RegistrationResourceV3 registrationResource = await sourceRepository.GetResourceAsync <RegistrationResourceV3>(cancellationToken).ConfigureAwait(false); JObject packageMetadata = await registrationResource.GetPackageMetadata(packageIdentity, cache, NullLogger.Instance, cancellationToken).ConfigureAwait(false); if (null == packageMetadata) { throw new PackageNotFoundProtocolException(packageIdentity); } string catalogItemUrl = packageMetadata.Value <string>("@id"); HttpSourceResource httpSourceResource = await sourceRepository.GetResourceAsync <HttpSourceResource>(cancellationToken).ConfigureAwait(false); JObject catalogItem = await httpSourceResource.HttpSource.GetJObjectAsync(new HttpSourceRequest(catalogItemUrl, NullLogger.Instance), NullLogger.Instance, cancellationToken).ConfigureAwait(false); return(catalogItem.Value <long>("packageSize")); } catch (Exception ex) when(ex is FatalProtocolException || ex is HttpRequestException) { return(0); } } }