Beispiel #1
0
        internal FtpClientProxy(IFtpClientProxyConfig config, IFlurlClientFactory client, TokenProvider tokenProvider, string host, NetworkCredential credentials)
        {
            this._config     = config;
            _tokenProvider   = tokenProvider;
            this.Host        = host;
            this.Credentials = credentials;

            _client = client.Get(_config.FtpProxyWebInterfaceBaseUri)
                      .Configure(c =>
            {
                c.HttpClientFactory      = new UntrustedCertClientFactory();
                c.ConnectionLeaseTimeout = TimeSpan.FromMinutes(30);
            })
                      .WithHeader("Accept", "application/json, text/json")
                      .WithHeader("Accept-Encoding", "gzip, deflate")
                      .WithTimeout(TimeSpan.FromMinutes(20))
                      .AllowHttpStatus(HttpStatusCode.NotFound)
            ;

            _client.BaseUrl = _config.FtpProxyWebInterfaceBaseUri.ToString();

            _connectionInfo = new ConnectionInfo
            {
                Host     = this.Host,
                Username = this.Credentials.UserName,
                Password = this.Credentials.Password,
            };
        }
Beispiel #2
0
 public WipeCloudflareCacheCommandHandler(
     IOptionsMonitor <CloudflareOptions> cloudflareCacheOptionsMonitor,
     IFlurlClientFactory flurlClientFactory)
 {
     this.cloudflareCacheOptionsMonitor = cloudflareCacheOptionsMonitor;
     this.flurlClient = flurlClientFactory.Get("https://api.cloudflare.com");
 }
        public WebRequest(string resource, string serviceKey, IServiceDiscovery serviceDiscovery,
                          IFlurlClientFactory flurlClientFactory, DefaultFlurlHttpSettings defaultFlurlHttpSettings)
        {
            if (serviceKey == null)
            {
                throw new ArgumentNullException(nameof(serviceKey));
            }

            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }

            this.flurlClientFactory       = flurlClientFactory;
            this.defaultFlurlHttpSettings = defaultFlurlHttpSettings;

            url = serviceDiscovery.ResolveServiceUrl(serviceKey).AbsoluteUri.AppendPathSegment(resource);

            retryPolicy = Policy.Handle <CommunicationException>()
                          .RetryAsync((exception, retryCount) =>
            {
                Log.Warning(exception, $"Communication exception occured to {serviceKey} - {url.Path}");

                var serviceUri = serviceDiscovery.ResolveServiceUrl(serviceKey);
                url            = new UriBuilder(Url.Decode(url, false))
                {
                    Host = serviceUri.Host, Port = serviceUri.Port
                }.Uri;

                Log.Warning($"A new url to {serviceKey} was resolved on retry - {url.Path}");
            });
        }
 public ManagementApiClientFactory(
     IFlurlClientFactory flurlClientFactory,
     IOptionsMonitor <Auth0Options> auth0OptionsMonitor)
 {
     this.flurlClient         = flurlClientFactory.Get("https://dogger.eu.auth0.com/oauth/token");
     this.auth0OptionsMonitor = auth0OptionsMonitor;
 }
 public InternalRequestFactory(
     string serviceKey,
     IServiceDiscovery serviceDiscovery,
     IFlurlClientFactory flurlClientFactory,
     DefaultFlurlHttpSettings defaultFlurlHttpSettings)
     : base(serviceKey, serviceDiscovery, flurlClientFactory, defaultFlurlHttpSettings)
 {
 }
Beispiel #6
0
 public GeocodeService(IFlurlClientFactory flurlClientFac,
                       IEnderecoRepository enderecoRepository,
                       IGeoLocationRepository geoLocationRepository)
 {
     this._flurlClient           = flurlClientFac.Get(_URL);
     this._enderecoRepository    = enderecoRepository;
     this._geoLocationRepository = geoLocationRepository;
 }
Beispiel #7
0
 public BiliBiliHelp(AppSettings appSettings, IFlurlClientFactory flurlClientFac,
                     CacheLiteDb cache)
 {
     _flurlClient   = flurlClientFac.Get(BilibiliApiBaseUrl);
     _caching       = cache;
     _setting       = appSettings.BiliBiliSetting;
     _canGetHistory = !string.IsNullOrEmpty(_setting.Cookie);
 }
Beispiel #8
0
        public BaseRepository(IFlurlClientFactory flurlFac, IConfig configuration)
        {
            _flurlClient = flurlFac.Get(configuration.UrlBase);

            _timeOut = configuration.TimeOut;

            _headers = configuration.Headers;
        }
Beispiel #9
0
 public Currency(AppSettings settings, IFlurlClientFactory flurlFactory, IAppCache cache)
 {
     _command = new ExchangeRatesCommand(new BlobServiceConfig()
     {
         ConnectionString = settings.BlobSettings.ConnectionString,
         Container        = settings.BlobSettings.ContainerNameExchangeRates
     }, flurlFactory, cache);
 }
Beispiel #10
0
        /// <summary>
        /// Provides thread-safe access to a specific IFlurlClient, typically to configure settings and default headers.
        /// The URL is used to find the client, but keep in mind that the same client will be used in all calls to the same host by default.
        /// </summary>
        /// <param name="factory">This IFlurlClientFactory.</param>
        /// <param name="url">the URL used to find the IFlurlClient.</param>
        /// <param name="configAction">the action to perform against the IFlurlClient.</param>
        public static IFlurlClientFactory ConfigureClient(this IFlurlClientFactory factory, string url, Action <IFlurlClient> configAction)
        {
            var client = factory.Get(url);

            lock (_clientLocks.GetOrCreateValue(client)) {
                configAction(client);
            }
            return(factory);
        }
Beispiel #11
0
 public RequestFactory(
     ISdkClient client,
     IServiceDiscovery serviceDiscovery,
     IFlurlClientFactory flurlClientFactory,
     IEnumerable <ISdkConfig> configProvider,
     DefaultFlurlHttpSettings defaultFlurlHttpSettings)
     : base(client, serviceDiscovery, flurlClientFactory, configProvider, defaultFlurlHttpSettings)
 {
 }
Beispiel #12
0
 public AirportsApplicationService(IApplicationModuleSettings applicationModuleSettings,
                                   IFlurlClientFactory flurlClientFactory,
                                   IIndex <DistanceUnit, IMetersConverterApplicationService> converterServices)
 {
     this.airportDetailsApiUrl = (applicationModuleSettings ?? throw new ArgumentNullException(nameof(applicationModuleSettings)))
                                 .AirportDetailsApiUrl ?? throw new ArgumentException($"{nameof(applicationModuleSettings.AirportDetailsApiUrl)} is required");
     this.flurlClient       = (flurlClientFactory ?? throw new ArgumentNullException(nameof(flurlClient))).Get(this.airportDetailsApiUrl);
     this.converterServices = converterServices;
 }
        protected BaseRequestFactory(string serviceKey, IServiceDiscovery serviceDiscovery,
                                     IFlurlClientFactory flurlClientFactory, DefaultFlurlHttpSettings defaultFlurlHttpSettings)
        {
            this.serviceKey = serviceKey;

            this.serviceDiscovery         = serviceDiscovery;
            this.flurlClientFactory       = flurlClientFactory;
            this.defaultFlurlHttpSettings = defaultFlurlHttpSettings;
        }
        protected BaseRequestFactory(ISdkClient client, IServiceDiscovery serviceDiscovery,
                                     IFlurlClientFactory flurlClientFactory, IEnumerable <ISdkConfig> configProvider,
                                     DefaultFlurlHttpSettings defaultFlurlHttpSettings)
        {
            serviceKey = configProvider.GetServiceKey(client.GetType());

            this.serviceDiscovery         = serviceDiscovery;
            this.flurlClientFactory       = flurlClientFactory;
            this.defaultFlurlHttpSettings = defaultFlurlHttpSettings;
        }
Beispiel #15
0
        internal FtpClientProxy(IFtpClientProxyConfig config, IFlurlClientFactory client, TokenProvider tokenProvider, FtpConfig ftpConfig)
        {
            _init(config, null, ftpConfig);

            _tokenProvider = tokenProvider;

            _client = _initClient(client);

            _connectionInfo = _initConnectionInfo();
        }
Beispiel #16
0
        public GitHubClientFactory(
            IGitHubClient gitHubClient,
            IFlurlClientFactory flurlClientFactory,
            IOptionsMonitor <GitHubOptions> gitHubOptionsMonitor)
        {
            this.gitHubClient         = gitHubClient;
            this.gitHubOptionsMonitor = gitHubOptionsMonitor;

            this.flurlClient = flurlClientFactory.Get("https://github.com/login/oauth/access_token");
        }
        public FlurlWrapperClient(IFlurlClientFactory clientFactory, IOptions <FlurlWrapperClientSettings> appSettings, string url)
        {
            _client = clientFactory.Get(url);

            _circuitBreaker = Policy
                              .Handle <FlurlHttpException>()
                              .Or <FlurlHttpTimeoutException>()
                              .CircuitBreakerAsync(
                exceptionsAllowedBeforeBreaking: appSettings.Value.PollyCircuitBreakExceptionCount,
                durationOfBreak: TimeSpan.FromSeconds(appSettings.Value.PollyCircuitBreakDurationInSeconds));
        }
Beispiel #18
0
 public FinApiService(IOptions <FinApiClientSettings> settings, IFlurlClientFactory flurlClientFactory,
                      IHttpContextAccessor httpContextAccessor, DatabaseContext databaseContext,
                      IEasyCachingProvider cachingProvider, ILogger <FinApiService> logger, CachingService cachingService)
 {
     _flurlClientFactory  = flurlClientFactory;
     _httpContextAccessor = httpContextAccessor;
     _databaseContext     = databaseContext;
     _cachingProvider     = cachingProvider;
     _logger         = logger;
     _cachingService = cachingService;
     _settings       = settings.Value;
 }
Beispiel #19
0
        internal FtpClientProxy(IFtpClientProxyConfig config, IFlurlClientFactory client, TokenProvider tokenProvider, Uri uri, NetworkCredential credentials)
        {
            //In here we can dispose the FtpConfig because has no 'Certificate'
            using var ftpConfig = new FtpConfig(uri, credentials);

            _init(config, null, ftpConfig);

            _tokenProvider = tokenProvider;

            _client = _initClient(client);

            _connectionInfo = _initConnectionInfo();
        }
Beispiel #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NasaClient"/> class
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="flurlClientFactory"></param>
        public NasaClient(IOptions <AppSettings> settings, IFlurlClientFactory flurlClientFactory)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (flurlClientFactory == null)
            {
                throw new ArgumentNullException(nameof(flurlClientFactory));
            }

            _settings    = settings.Value;
            _flurlClient = flurlClientFactory.Get(_settings.NasaServices.Endpoints.BaseUrl);
        }
        public FootballDataOrgImporter(FootballImportServiceConfiguration cfg,
                                       IFlurlClientFactory flurlClientFactory,
                                       IMapper mapper,
                                       ILeagueManager leagueManager)
        {
            _client = flurlClientFactory.Get(cfg.FootballDataOrgApiUrl);
            _client.Headers.Add("X-Auth-Token", cfg.FootballDataOrgApiKey);
            _client.Headers.Add("X-Requests-Available-Minute", "");
            _client.BaseUrl = cfg.FootballDataOrgApiUrl;

            _configuration = cfg;
            _mapper        = mapper;
            _leagueManager = leagueManager;
        }
Beispiel #22
0
        public ReplController(
            IFlurlClientFactory flurlClientFactory,
            IHostEnvironment hostEnvironment)
        {
            var url = GetReplUrl(hostEnvironment);

            this.client = flurlClientFactory.Get(url).Configure(settings =>
            {
                settings.JsonSerializer = new NewtonsoftJsonSerializer(
                    new JsonSerializerSettings()
                {
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });
            });
        }
Beispiel #23
0
        public GameService(
            IOptions <GameSettings> settings,
            IFlurlClientFactory clientFactory,
            ILogger <GameService> logger)
        {
            _settings = settings.Value;

            if (!_settings.IsValid)
            {
                throw new SettingsNotValidException(_settings);
            }

            _game          = new Game();
            _clientFactory = clientFactory;
            _logger        = logger;
        }
Beispiel #24
0
        private IFlurlClient _initClient(IFlurlClientFactory client)
        {
            var flurlClient = client.Get(_config.FtpProxyWebInterfaceBaseUri)
                              .Configure(c =>
            {
                c.HttpClientFactory      = new UntrustedCertClientFactory();
                c.ConnectionLeaseTimeout = TimeSpan.FromMinutes(30);
            })
                              .WithHeader("Accept", "application/json, text/json")
                              .WithHeader("Accept-Encoding", "gzip, deflate")
                              .WithTimeout(TimeSpan.FromMinutes(20))
                              .AllowHttpStatus(HttpStatusCode.NotFound)
            ;

            flurlClient.BaseUrl = _config.FtpProxyWebInterfaceBaseUri.ToString();

            return(flurlClient);
        }
Beispiel #25
0
        public FtpClientProxy(IFtpClientProxyConfig config, IFlurlClientFactory client, string host, NetworkCredential credentials)
        {
            this._config     = config;
            this.Host        = host;
            this.Credentials = credentials;

            _client = client.Get(_config.FtpProxyWebInterfaceBaseUri)
                      .Configure(c =>
            {
                c.HttpClientFactory      = new UntrustedCertClientFactory();
                c.ConnectionLeaseTimeout = TimeSpan.FromMinutes(30);
            })
                      .WithHeader("Accept", "application/json, text/json")
                      .WithHeader("Accept-Encoding", "gzip, deflate")
                      .WithTimeout(TimeSpan.FromMinutes(20))
                      .AllowHttpStatus(HttpStatusCode.NotFound)
            ;

            _client.BaseUrl = _config.FtpProxyWebInterfaceBaseUri.ToString();

            if (_config.UseAuth0)
            {
                _auth0 = new AuthenticationApiClientCachingDecorator(new AuthenticationApiClient(_config.TenantID));
            }
            else
            {
                _adal = new AuthenticationContext("https://login.microsoftonline.com/" + this._config.TenantID);
            }

            _connectionInfo = new ConnectionInfo
            {
                Host     = this.Host,
                Username = this.Credentials.UserName,
                Password = this.Credentials.Password,
            };
        }
Beispiel #26
0
 public ZohoClient(ZohoClientConfig config, IFlurlClientFactory flurlFactory)
 {
     _flurlFactory = flurlFactory;
     Config        = config;
     InitResources();
 }
Beispiel #27
0
 public ZohoClient(IFlurlClientFactory flurlFactory)
 {
     _flurlFactory = flurlFactory;
 }
Beispiel #28
0
 public CommonClient(ClientOptions clientOptions, IFlurlClientFactory flurlClientFac)
 {
     this.clientOptions = clientOptions;
     flurlClient        = flurlClientFac.Get(this.clientOptions.InvoiceServiceUrl).SetDefaultSettings();
 }
 public OrderRepository(IFlurlClientFactory flurlFactory, IConfiguration configuration)
 {
     this.client = flurlFactory.Get(new Url(configuration.GetValue(typeof(String), "BASE_URL").ToString()));
 }
Beispiel #30
0
 public PlayerInstance(PlayerSettings settings, IFlurlClientFactory clientFactory)
 {
     _settings = settings;
     _client = clientFactory.Get(_settings.BaseUrl);
 }