/// <summary> /// Create a new ElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="innerMessageHandler">The HttpMessageHandler used to intercept network requests for testing.</param> /// <param name="endpoint">The URL endpoint of the Elasticsearch server.</param> /// <param name="userName">UserName to use to connect to the server (optional).</param> /// <param name="password">Password to use to connect to the server (optional).</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> internal ElasticConnection(HttpMessageHandler innerMessageHandler, Uri endpoint, string userName = null, string password = null, string index = null, TimeSpan?timeout = null, ElasticConnectionOptions options = null) { Argument.EnsureNotNull("endpoint", endpoint); if (timeout.HasValue) { Argument.EnsurePositive("value", timeout.Value); } if (index != null) { Argument.EnsureNotBlank("index", index); } this.endpoint = endpoint; this.index = index; this.options = options ?? new ElasticConnectionOptions(); this.timeout = timeout ?? defaultTimeout; var httpClientHandler = innerMessageHandler as HttpClientHandler; if (httpClientHandler != null && httpClientHandler.SupportsAutomaticDecompression) { httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip; } httpClient = new HttpClient(new ForcedAuthHandler(userName, password, innerMessageHandler), true); }
public ElasticNetConnection( IElasticsearchClient client, Uri endpoint, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) : base(endpoint, index, timeout, options) { this.client = client; }
/// <summary> /// Create a new BaseElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> protected BaseElasticConnection(string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) { if (timeout.HasValue) Argument.EnsurePositive("value", timeout.Value); if (index != null) Argument.EnsureNotBlank("index", index); this.index = index; this.options = options ?? new ElasticConnectionOptions(); this.timeout = timeout ?? defaultTimeout; }
/// <summary> /// Create a new ElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="innerMessageHandler">The HttpMessageHandler used to intercept network requests for testing.</param> /// <param name="endpoint">The URL endpoint of the Elasticsearch server.</param> /// <param name="userName">UserName to use to connect to the server (optional).</param> /// <param name="password">Password to use to connect to the server (optional).</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> internal ElasticConnection(HttpMessageHandler innerMessageHandler, Uri endpoint, string userName = null, string password = null, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) : base(index, timeout, options) { Argument.EnsureNotNull("endpoint", endpoint); this.endpoint = endpoint; var httpClientHandler = innerMessageHandler as HttpClientHandler; if (httpClientHandler != null && httpClientHandler.SupportsAutomaticDecompression) httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip; httpClient = new HttpClient(new ForcedAuthHandler(userName, password, innerMessageHandler), true); }
public static ElasticConnection GetNewConnection(string url, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) { var uri = new Uri(url); var username = ""; var password = ""; if (!string.IsNullOrWhiteSpace(uri.UserInfo)) { var upa = uri.UserInfo.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries); username = upa[0]; password = upa[1]; } var connection = new ElasticConnection(uri, username, password, timeout, index, options); return connection; }
/// <summary> /// Create a new BaseElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> protected BaseElasticConnection(string index = null, TimeSpan?timeout = null, ElasticConnectionOptions options = null) { if (timeout.HasValue) { Argument.EnsurePositive("value", timeout.Value); } if (index != null) { Argument.EnsureNotBlank("index", index); } this.index = index; this.options = options ?? new ElasticConnectionOptions(); this.timeout = timeout ?? defaultTimeout; }
/// <summary> /// Create a new ElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="innerMessageHandler">The HttpMessageHandler used to intercept network requests for testing.</param> /// <param name="endpoint">The URL endpoint of the Elasticsearch server.</param> /// <param name="userName">UserName to use to connect to the server (optional).</param> /// <param name="password">Password to use to connect to the server (optional).</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> internal ElasticConnection(HttpMessageHandler innerMessageHandler, Uri endpoint, string userName = null, string password = null, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null) { Argument.EnsureNotNull("endpoint", endpoint); if (timeout.HasValue) Argument.EnsurePositive("value", timeout.Value); if (index != null) Argument.EnsureNotBlank("index", index); this.endpoint = endpoint; this.index = index; this.options = options ?? new ElasticConnectionOptions(); this.timeout = timeout ?? defaultTimeout; var httpClientHandler = innerMessageHandler as HttpClientHandler; if (httpClientHandler != null && httpClientHandler.SupportsAutomaticDecompression) httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip; httpClient = new HttpClient(new ForcedAuthHandler(userName, password, innerMessageHandler), true); }
/// <summary> /// Create a new ElasticConnection with the given parameters defining its properties. /// </summary> /// <param name="endpoint">The URL endpoint of the Elasticsearch server.</param> /// <param name="userName">UserName to use to connect to the server (optional).</param> /// <param name="password">Password to use to connect to the server (optional).</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> public ElasticConnection(Uri endpoint, string userName = null, string password = null, TimeSpan? timeout = null, string index = null, ElasticConnectionOptions options = null) : this(new HttpClientHandler(), endpoint, userName, password, index, timeout, options) { }
/// <summary> /// Create a new ElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="innerMessageHandler">The HttpMessageHandler used to intercept network requests for testing.</param> /// <param name="endpoint">The URL endpoint of the Elasticsearch server.</param> /// <param name="userName">UserName to use to connect to the server (optional).</param> /// <param name="password">Password to use to connect to the server (optional).</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> internal ElasticConnection(HttpMessageHandler innerMessageHandler, Uri endpoint, string userName = null, string password = null, string index = null, TimeSpan?timeout = null, ElasticConnectionOptions options = null) : base(index, timeout, options) { Argument.EnsureNotNull(nameof(endpoint), endpoint); this.Endpoint = endpoint; var httpClientHandler = innerMessageHandler as HttpClientHandler; if (httpClientHandler != null && httpClientHandler.SupportsAutomaticDecompression) { httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip; } HttpClient = new HttpClient(new ForcedAuthHandler(userName, password, innerMessageHandler), true); }
/// <summary> /// Create a new ElasticConnection with the given parameters defining its properties. /// </summary> /// <param name="endpoint">The URL endpoint of the Elasticsearch server.</param> /// <param name="userName">UserName to use to connect to the server (optional).</param> /// <param name="password">Password to use to connect to the server (optional).</param> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> public ElasticConnection(Uri endpoint, string userName = null, string password = null, TimeSpan?timeout = null, string index = null, ElasticConnectionOptions options = null) : this(new HttpClientHandler(), endpoint, userName, password, index, timeout, options) { }
/// <summary> /// Create a new BaseElasticConnection with the given parameters for internal testing. /// </summary> /// <param name="timeout">TimeSpan to wait for network responses before failing (optional, defaults to 10 seconds).</param> /// <param name="index">Name of the index to use on the server (optional).</param> /// <param name="options">Additional options that specify how this connection should behave.</param> protected BaseElasticConnection(string index = null, TimeSpan?timeout = null, ElasticConnectionOptions options = null) { if (timeout.HasValue) { Argument.EnsurePositive(nameof(timeout), timeout.Value); } if (index != null) { Argument.EnsureNotBlank(nameof(index), index); } Index = index; Options = options ?? new ElasticConnectionOptions(); Timeout = timeout ?? defaultTimeout; }