Encapsulates an IConnection that works with AWS's Elasticsearch service.
Наследование: HttpConnection
Пример #1
0
 public void NestPing_should_work()
 {
     var httpConnection = new AwsHttpConnection(TestConfig.AwsSettings);
     var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
     var config = new Nest.ConnectionSettings(pool, httpConnection);
     var client = new Nest.ElasticClient(config);
     var response = client.Ping();
     Assert.AreEqual(true, response.IsValid);
 }
Пример #2
0
 public void Ping_should_work()
 {
     var httpConnection = new AwsHttpConnection(TestConfig.AwsSettings);
     var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
     var config = new ConnectionConfiguration(pool, httpConnection);
     var client = new ElasticLowLevelClient(config);
     var response = client.Ping<object>();
     Assert.AreEqual(200, response.HttpStatusCode.GetValueOrDefault(-1));
 }
Пример #3
0
 public void Asterisk_encoded_url_should_work()
 {
     var httpConnection = new AwsHttpConnection(TestConfig.AwsSettings);
     var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
     var config = new ConnectionConfiguration(pool, httpConnection);
     var client = new ElasticLowLevelClient(config);
     var response = client.Get<Stream>("index*", "type", "id");
     Assert.AreEqual(404, response.HttpStatusCode.GetValueOrDefault(-1));
 }
Пример #4
0
 public void Random_encoded_url_should_work()
 {
     var randomString = Guid.NewGuid().ToString("N");
     var httpConnection = new AwsHttpConnection(TestConfig.AwsSettings);
     var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
     var config = new ConnectionConfiguration(pool, httpConnection);
     var client = new ElasticLowLevelClient(config);
     var response = client.Get<Stream>(randomString, string.Join(",", Enumerable.Repeat(randomString, 2)), randomString);
     Assert.AreEqual(404, response.HttpStatusCode.GetValueOrDefault(-1));
 }
Пример #5
-4
        /// <summary>
        /// Connects to server.
        /// </summary>
        protected override void ConnectToServer()
        {
            if ( GetAttributeValue( "NodeUrl" ).IsNotNullOrWhitespace() )
            {
                try {
                    var node = new Uri( GetAttributeValue( "NodeUrl" ) );
                    var region = GetAttributeValue( "Region" );
                    var accessKey = GetAttributeValue( "AccessKey" );
                    var secretKey = GetAttributeValue( "SecretKey" );

                    var httpConnection = new AwsHttpConnection( new AwsSettings
                    {
                        AccessKey = accessKey,
                        SecretKey = secretKey,
                        Region = region,
                    } );

                    var pool = new SingleNodeConnectionPool( node );
                    var config = new ConnectionSettings( pool, httpConnection );
                    _client = new ElasticClient( config );
                }
                catch { }
            }
        }