elasticsearch 7.17.1 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -10
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.md +70 -31
- data/bin/elastic_ruby_console +0 -18
- data/elasticsearch.gemspec +14 -14
- data/lib/elasticsearch/version.rb +1 -1
- data/lib/elasticsearch.rb +100 -30
- data/spec/integration/characters_escaping_spec.rb +11 -11
- data/spec/integration/client_integration_spec.rb +10 -4
- data/spec/spec_helper.rb +8 -3
- data/spec/unit/api_key_spec.rb +101 -0
- data/spec/unit/cloud_credentials_spec.rb +167 -0
- data/spec/unit/custom_transport_implementation_spec.rb +43 -0
- data/spec/unit/elasticsearch_product_validation_spec.rb +53 -217
- data/spec/unit/headers_spec.rb +55 -0
- data/spec/unit/opaque_id_spec.rb +48 -0
- data/spec/unit/wrapper_gem_spec.rb +4 -10
- metadata +28 -20
- data/spec/integration/validation_integration_spec.rb +0 -30
@@ -0,0 +1,55 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
require 'spec_helper'
|
18
|
+
require 'ostruct'
|
19
|
+
|
20
|
+
describe Elasticsearch::Client do
|
21
|
+
context 'when a header is set on an endpoint request' do
|
22
|
+
let(:client) { described_class.new }
|
23
|
+
let(:headers) { { 'user-agent' => 'my ruby app' } }
|
24
|
+
|
25
|
+
it 'performs the request with the header' do
|
26
|
+
allow(client).to receive(:perform_request) { OpenStruct.new(body: '') }
|
27
|
+
expect { client.search(headers: headers) }.not_to raise_error
|
28
|
+
expect(client).to have_received(:perform_request)
|
29
|
+
.with('GET', '_search', {}, nil, headers)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when a header is set on an endpoint request and on initialization' do
|
34
|
+
let!(:client) do
|
35
|
+
described_class.new(
|
36
|
+
host: 'http://localhost:9200',
|
37
|
+
transport_options: { headers: instance_headers }
|
38
|
+
).tap do |client|
|
39
|
+
client.instance_variable_set('@verified', true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
let(:instance_headers) { { set_in_instantiation: 'header value' } }
|
43
|
+
let(:param_headers) { { 'user-agent' => 'My Ruby Tests', 'set-on-method-call' => 'header value' } }
|
44
|
+
|
45
|
+
it 'performs the request with the header' do
|
46
|
+
expected_headers = client.transport.connections.connections.first.connection.headers.merge(param_headers)
|
47
|
+
|
48
|
+
expect_any_instance_of(Faraday::Connection)
|
49
|
+
.to receive(:run_request)
|
50
|
+
.with(:get, 'http://localhost:9200/_search', nil, expected_headers) { OpenStruct.new(body: '') }
|
51
|
+
|
52
|
+
client.search(headers: param_headers)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
require 'spec_helper'
|
18
|
+
require 'ostruct'
|
19
|
+
|
20
|
+
describe Elasticsearch::Client do
|
21
|
+
let(:transport) { client.instance_variable_get('@transport') }
|
22
|
+
let(:client) { described_class.new.tap { |cl| cl.instance_variable_set('@verified', true) } }
|
23
|
+
|
24
|
+
before do
|
25
|
+
allow(transport).to receive(:perform_request) { OpenStruct.new(body: '') }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when x-opaque-id is set' do
|
29
|
+
it 'uses x-opaque-id on a request' do
|
30
|
+
client.search(opaque_id: '12345')
|
31
|
+
expect(transport).to have_received(:perform_request)
|
32
|
+
.with('GET', '_search', {}, nil, { 'X-Opaque-Id' => '12345' })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when an x-opaque-id prefix is set on initialization' do
|
37
|
+
let(:prefix) { 'elastic_cloud' }
|
38
|
+
let(:client) do
|
39
|
+
described_class.new(opaque_id_prefix: prefix).tap { |cl| cl.instance_variable_set('@verified', true) }
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'uses x-opaque-id on a request' do
|
43
|
+
expect { client.search(opaque_id: '12345') }.not_to raise_error
|
44
|
+
expect(transport).to have_received(:perform_request)
|
45
|
+
.with('GET', '_search', {}, nil, { 'X-Opaque-Id' => 'elastic_cloud12345' })
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -14,13 +14,13 @@
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
|
-
|
18
|
-
require '
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
19
|
|
20
20
|
describe 'Elasticsearch: wrapper gem' do
|
21
21
|
it 'requires all neccessary subgems' do
|
22
|
-
expect(defined?
|
23
|
-
expect(defined?
|
22
|
+
expect(defined? Elasticsearch::Client)
|
23
|
+
expect(defined? Elasticsearch::API)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'mixes the API into the client' do
|
@@ -30,10 +30,4 @@ describe 'Elasticsearch: wrapper gem' do
|
|
30
30
|
expect(client).to respond_to(:cluster)
|
31
31
|
expect(client).to respond_to(:indices)
|
32
32
|
end
|
33
|
-
|
34
|
-
it 'can access the client transport' do
|
35
|
-
client = Elasticsearch::Client.new
|
36
|
-
expect(client.transport).to be_a(Elasticsearch::Transport::Client)
|
37
|
-
expect(client.transport.transport).to be_a(Elasticsearch::Transport::Transport::HTTP::Faraday)
|
38
|
-
end
|
39
33
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: elastic-transport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 8.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 8.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: elasticsearch-api
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 8.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 8.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: require-prof
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,11 +188,11 @@ executables:
|
|
188
188
|
extensions: []
|
189
189
|
extra_rdoc_files:
|
190
190
|
- README.md
|
191
|
-
- LICENSE
|
191
|
+
- LICENSE.txt
|
192
192
|
files:
|
193
193
|
- ".gitignore"
|
194
194
|
- Gemfile
|
195
|
-
- LICENSE
|
195
|
+
- LICENSE.txt
|
196
196
|
- README.md
|
197
197
|
- Rakefile
|
198
198
|
- bin/elastic_ruby_console
|
@@ -202,17 +202,21 @@ files:
|
|
202
202
|
- lib/elasticsearch/version.rb
|
203
203
|
- spec/integration/characters_escaping_spec.rb
|
204
204
|
- spec/integration/client_integration_spec.rb
|
205
|
-
- spec/integration/validation_integration_spec.rb
|
206
205
|
- spec/spec_helper.rb
|
206
|
+
- spec/unit/api_key_spec.rb
|
207
|
+
- spec/unit/cloud_credentials_spec.rb
|
208
|
+
- spec/unit/custom_transport_implementation_spec.rb
|
207
209
|
- spec/unit/elasticsearch_product_validation_spec.rb
|
210
|
+
- spec/unit/headers_spec.rb
|
211
|
+
- spec/unit/opaque_id_spec.rb
|
208
212
|
- spec/unit/wrapper_gem_spec.rb
|
209
|
-
homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/
|
213
|
+
homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
|
210
214
|
licenses:
|
211
215
|
- Apache-2.0
|
212
216
|
metadata:
|
213
|
-
homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/
|
214
|
-
changelog_uri: https://github.com/elastic/elasticsearch-ruby/blob/
|
215
|
-
source_code_uri: https://github.com/elastic/elasticsearch-ruby/tree/
|
217
|
+
homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
|
218
|
+
changelog_uri: https://github.com/elastic/elasticsearch-ruby/blob/main/CHANGELOG.md
|
219
|
+
source_code_uri: https://github.com/elastic/elasticsearch-ruby/tree/main
|
216
220
|
bug_tracker_uri: https://github.com/elastic/elasticsearch-ruby/issues
|
217
221
|
post_install_message:
|
218
222
|
rdoc_options:
|
@@ -223,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
227
|
requirements:
|
224
228
|
- - ">="
|
225
229
|
- !ruby/object:Gem::Version
|
226
|
-
version: '2.
|
230
|
+
version: '2.5'
|
227
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
232
|
requirements:
|
229
233
|
- - ">="
|
@@ -237,7 +241,11 @@ summary: Ruby integrations for Elasticsearch
|
|
237
241
|
test_files:
|
238
242
|
- spec/integration/characters_escaping_spec.rb
|
239
243
|
- spec/integration/client_integration_spec.rb
|
240
|
-
- spec/integration/validation_integration_spec.rb
|
241
244
|
- spec/spec_helper.rb
|
245
|
+
- spec/unit/api_key_spec.rb
|
246
|
+
- spec/unit/cloud_credentials_spec.rb
|
247
|
+
- spec/unit/custom_transport_implementation_spec.rb
|
242
248
|
- spec/unit/elasticsearch_product_validation_spec.rb
|
249
|
+
- spec/unit/headers_spec.rb
|
250
|
+
- spec/unit/opaque_id_spec.rb
|
243
251
|
- spec/unit/wrapper_gem_spec.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
-
# license agreements. See the NOTICE file distributed with
|
3
|
-
# this work for additional information regarding copyright
|
4
|
-
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
-
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
-
# not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
12
|
-
# software distributed under the License is distributed on an
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
-
# KIND, either express or implied. See the License for the
|
15
|
-
# specific language governing permissions and limitations
|
16
|
-
# under the License.
|
17
|
-
require 'spec_helper'
|
18
|
-
require 'logger'
|
19
|
-
|
20
|
-
describe 'Elasticsearch validation integration' do
|
21
|
-
it 'Validates for Elasticsearch > 7.14' do
|
22
|
-
client = Elasticsearch::Client.new(
|
23
|
-
host: ELASTICSEARCH_URL,
|
24
|
-
logger: Logger.new($stderr)
|
25
|
-
)
|
26
|
-
expect(client.instance_variable_get('@verified')).to be false
|
27
|
-
client.count
|
28
|
-
expect(client.instance_variable_get('@verified')).to be true
|
29
|
-
end
|
30
|
-
end
|