elastic-enterprise-search 7.13.0 → 7.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.ci/make.sh +162 -0
  3. data/.ci/test-matrix.yml +1 -1
  4. data/.github/check_license_headers.rb +33 -0
  5. data/.github/license-header.txt +16 -0
  6. data/.github/workflows/license.yml +13 -0
  7. data/.github/workflows/testing.yml +1 -1
  8. data/Rakefile +1 -0
  9. data/docs/guide/app-search-api.asciidoc +28 -0
  10. data/docs/guide/release_notes/712.asciidoc +12 -0
  11. data/docs/guide/release_notes/714.asciidoc +21 -0
  12. data/docs/guide/release_notes/index.asciidoc +2 -0
  13. data/docs/guide/workplace-search-api.asciidoc +55 -0
  14. data/lib/elastic/app-search/api/api_key.rb +51 -0
  15. data/lib/elastic/app-search/api/create_api_key.rb +49 -0
  16. data/lib/elastic/app-search/api/delete_api_key.rb +51 -0
  17. data/lib/elastic/app-search/api/list_api_keys.rb +49 -0
  18. data/lib/elastic/app-search/api/put_api_key.rb +52 -0
  19. data/lib/elastic/enterprise-search/version.rb +1 -1
  20. data/lib/elastic/workplace-search/api/command_sync_jobs.rb +53 -0
  21. data/lib/elastic/workplace-search/api/create_analytics_event.rb +7 -7
  22. data/lib/elastic/workplace-search/api/create_batch_synonym_sets.rb +50 -0
  23. data/lib/elastic/workplace-search/api/create_content_source.rb +4 -2
  24. data/lib/elastic/workplace-search/api/create_external_identity.rb +3 -3
  25. data/lib/elastic/workplace-search/api/current_user.rb +47 -0
  26. data/lib/elastic/workplace-search/api/delete_documents_by_query.rb +50 -0
  27. data/lib/elastic/workplace-search/api/delete_synonym_set.rb +51 -0
  28. data/lib/elastic/workplace-search/api/document.rb +1 -1
  29. data/lib/elastic/workplace-search/api/list_synonym_sets.rb +51 -0
  30. data/lib/elastic/workplace-search/api/put_content_source.rb +6 -4
  31. data/lib/elastic/workplace-search/api/put_content_source_icons.rb +53 -0
  32. data/lib/elastic/workplace-search/api/put_external_identity.rb +3 -3
  33. data/lib/elastic/workplace-search/api/put_synonym_set.rb +53 -0
  34. data/lib/elastic/workplace-search/api/search.rb +1 -1
  35. data/lib/elastic/workplace-search/api/synonym_set.rb +51 -0
  36. data/rake_tasks/unified_release_tasks.rake +46 -0
  37. data/spec/app-search/api_apikey_spec.rb +92 -0
  38. data/spec/app-search/api_spec_helper.rb +16 -0
  39. data/spec/fixtures/vcr/app_search/create_api_key.yml +52 -0
  40. data/spec/fixtures/vcr/app_search/delete_api_key.yml +52 -0
  41. data/spec/fixtures/vcr/app_search/get_api_key.yml +52 -0
  42. data/spec/fixtures/vcr/app_search/list_api_keys.yml +52 -0
  43. data/spec/fixtures/vcr/app_search/put_api_key.yml +52 -0
  44. data/spec/integration/icon.png +0 -0
  45. data/spec/integration/workplace_search_spec.rb +122 -0
  46. data/spec/webmock_requires.rb +16 -0
  47. metadata +30 -3
@@ -1,3 +1,19 @@
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.
1
17
  # frozen_string_literal: true
2
18
 
3
19
  require 'spec_helper'
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:3002/api/as/v1/credentials/
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"my-api-key","type":"private","read":true,"write":true,"access_all_engines":true}'
9
+ headers:
10
+ X-Elastic-Client-Meta:
11
+ - ent=8.0.0,rb=3.0.1,t=7.13.3,fd=1.5.1,nh=0.1.1
12
+ User-Agent:
13
+ - 'elastic-enteprise-search-ruby/8.0.0 (RUBY_VERSION: 3.0.1; linux x86_64; elasticsearch-transport:
14
+ 7.13.3)'
15
+ Content-Type:
16
+ - application/json
17
+ Authorization:
18
+ - Bearer api_key
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ Accept:
22
+ - "*/*"
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ X-App-Search-Version:
29
+ - 7.14.0
30
+ Content-Type:
31
+ - application/json;charset=utf-8
32
+ Vary:
33
+ - Accept-Encoding, User-Agent
34
+ - Origin
35
+ Etag:
36
+ - W/"cb88f57feab926c9f2fc911133296c96--gzip"
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - aa3678b1-f5cb-4b6a-b699-076420dd908d
41
+ X-Runtime:
42
+ - '0.124357'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Server:
46
+ - Jetty(9.4.33.v20201020)
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: '{"id":"loco_moco_account_id:60ed920e613281f096273599|name:my-api-key","key":"private-q1fom1cnf2cdsr2wa91vpqs4","name":"my-api-key","type":"private","read":true,"write":true,"access_all_engines":true}'
50
+ http_version:
51
+ recorded_at: Tue, 13 Jul 2021 13:30:34 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://localhost:3002/api/as/v1/credentials/my-api-key/?api_key_name=my-api-key
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ X-Elastic-Client-Meta:
11
+ - ent=8.0.0,rb=3.0.1,t=7.13.3,fd=1.5.1,nh=0.1.1
12
+ User-Agent:
13
+ - 'elastic-enteprise-search-ruby/8.0.0 (RUBY_VERSION: 3.0.1; linux x86_64; elasticsearch-transport:
14
+ 7.13.3)'
15
+ Content-Type:
16
+ - application/json
17
+ Authorization:
18
+ - Bearer api_key
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ Accept:
22
+ - "*/*"
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ X-App-Search-Version:
29
+ - 7.14.0
30
+ Content-Type:
31
+ - application/json;charset=utf-8
32
+ Vary:
33
+ - Accept-Encoding, User-Agent
34
+ - Origin
35
+ Etag:
36
+ - W/"1b70b1c98c544d975c39049311ab1d24--gzip"
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 977b3790-757e-4f78-be0d-a09c7fc7ae4b
41
+ X-Runtime:
42
+ - '0.093760'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Server:
46
+ - Jetty(9.4.33.v20201020)
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: '{"deleted":true}'
50
+ http_version:
51
+ recorded_at: Tue, 13 Jul 2021 15:01:55 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3002/api/as/v1/credentials/my-api-key/?api_key_name=my-api-key
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ X-Elastic-Client-Meta:
11
+ - ent=8.0.0,rb=3.0.1,t=7.13.3,fd=1.5.1,nh=0.1.1
12
+ User-Agent:
13
+ - 'elastic-enteprise-search-ruby/8.0.0 (RUBY_VERSION: 3.0.1; linux x86_64; elasticsearch-transport:
14
+ 7.13.3)'
15
+ Content-Type:
16
+ - application/json
17
+ Authorization:
18
+ - Bearer api_key
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ Accept:
22
+ - "*/*"
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ X-App-Search-Version:
29
+ - 7.14.0
30
+ Content-Type:
31
+ - application/json;charset=utf-8
32
+ Vary:
33
+ - Accept-Encoding, User-Agent
34
+ - Origin
35
+ Etag:
36
+ - W/"cb88f57feab926c9f2fc911133296c96--gzip"
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 54dd3deb-d236-4fdd-adaa-7790230fb55e
41
+ X-Runtime:
42
+ - '0.064862'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Server:
46
+ - Jetty(9.4.33.v20201020)
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: '{"id":"loco_moco_account_id:60ed920e613281f096273599|name:my-api-key","key":"private-q1fom1cnf2cdsr2wa91vpqs4","name":"my-api-key","type":"private","read":true,"write":true,"access_all_engines":true}'
50
+ http_version:
51
+ recorded_at: Tue, 13 Jul 2021 13:36:10 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3002/api/as/v1/credentials/
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ X-Elastic-Client-Meta:
11
+ - ent=8.0.0,rb=3.0.1,t=7.13.3,fd=1.5.1,nh=0.1.1
12
+ User-Agent:
13
+ - 'elastic-enteprise-search-ruby/8.0.0 (RUBY_VERSION: 3.0.1; linux x86_64; elasticsearch-transport:
14
+ 7.13.3)'
15
+ Content-Type:
16
+ - application/json
17
+ Authorization:
18
+ - Bearer api_key
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ Accept:
22
+ - "*/*"
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ X-App-Search-Version:
29
+ - 7.14.0
30
+ Content-Type:
31
+ - application/json;charset=utf-8
32
+ Vary:
33
+ - Accept-Encoding, User-Agent
34
+ - Origin
35
+ Etag:
36
+ - W/"939fc16d42c5831cfe117f2a95d945cd--gzip"
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 0e178874-067a-43d9-855e-b5a310e8a818
41
+ X-Runtime:
42
+ - '0.029724'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Server:
46
+ - Jetty(9.4.33.v20201020)
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: '{"meta":{"page":{"current":1,"total_pages":1,"total_results":4,"size":25}},"results":[{"id":"loco_moco_account_id:60ed920e613281f096273599|name:my-api-key","key":"private-q1fom1cnf2cdsr2wa91vpqs4","name":"my-api-key","type":"private","read":true,"write":true,"access_all_engines":true},{"id":"loco_moco_account_id:60ed920e613281f096273599|name:private-key","key":"private-593eojp3t6bhqrgtkv31iifg","name":"private-key","type":"private","read":true,"write":true,"access_all_engines":true},{"id":"loco_moco_account_id:60ed920e613281f096273599|name:search-key","key":"search-frunn74mzsf6fz222gupq24i","name":"search-key","type":"search","access_all_engines":true},{"id":"loco_moco_account_id:60ed920e613281f096273599|name:test","key":"api_key","name":"test","type":"admin"}]}'
50
+ http_version:
51
+ recorded_at: Tue, 13 Jul 2021 13:38:17 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://localhost:3002/api/as/v1/credentials/my-api-key/?api_key_name=my-api-key
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"my-api-key","type":"private","read":true,"write":true,"engines":["test"]}'
9
+ headers:
10
+ X-Elastic-Client-Meta:
11
+ - ent=8.0.0,rb=3.0.1,t=7.13.3,fd=1.5.1,nh=0.1.1
12
+ User-Agent:
13
+ - 'elastic-enteprise-search-ruby/8.0.0 (RUBY_VERSION: 3.0.1; linux x86_64; elasticsearch-transport:
14
+ 7.13.3)'
15
+ Content-Type:
16
+ - application/json
17
+ Authorization:
18
+ - Bearer api_key
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ Accept:
22
+ - "*/*"
23
+ response:
24
+ status:
25
+ code: 200
26
+ message: OK
27
+ headers:
28
+ X-App-Search-Version:
29
+ - 7.14.0
30
+ Content-Type:
31
+ - application/json;charset=utf-8
32
+ Vary:
33
+ - Accept-Encoding, User-Agent
34
+ - Origin
35
+ Etag:
36
+ - W/"4b2fa3ed1c59fd1267877524d95fdcae--gzip"
37
+ Cache-Control:
38
+ - max-age=0, private, must-revalidate
39
+ X-Request-Id:
40
+ - 1ef1e1d7-4d4a-4eed-b4c5-4116ba6a29bf
41
+ X-Runtime:
42
+ - '0.093023'
43
+ Transfer-Encoding:
44
+ - chunked
45
+ Server:
46
+ - Jetty(9.4.33.v20201020)
47
+ body:
48
+ encoding: ASCII-8BIT
49
+ string: '{"id":"loco_moco_account_id:60ed920e613281f096273599|name:my-api-key","key":"private-q1fom1cnf2cdsr2wa91vpqs4","name":"my-api-key","type":"private","read":true,"write":true,"engines":["test"]}'
50
+ http_version:
51
+ recorded_at: Tue, 13 Jul 2021 14:58:36 GMT
52
+ recorded_with: VCR 3.0.3
Binary file
@@ -18,6 +18,7 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  require 'spec_helper'
21
+ require 'base64'
21
22
 
22
23
  describe Elastic::EnterpriseSearch::WorkplaceSearch::Client do
23
24
  let(:host) { ENV['ELASTIC_ENTERPRISE_HOST'] || 'http://localhost:3002' }
@@ -92,6 +93,28 @@ describe Elastic::EnterpriseSearch::WorkplaceSearch::Client do
92
93
  expect(response.status).to eq 200
93
94
  expect(response.body['name']) == new_name
94
95
  end
96
+
97
+ it 'syncs jobs' do
98
+ response = client.create_content_source(name: 'sync_jobs_test')
99
+ expect(response.status).to eq 200
100
+ id = response.body['id']
101
+
102
+ response = client.command_sync_jobs(id, body: { command: 'interrupt' })
103
+ expect(response.status).to eq 200
104
+ expect(response.body['results'].keys).to eq ['interrupted']
105
+ end
106
+
107
+ context 'Icons' do
108
+ let(:content_source_id) { client.create_content_source(name: 'with-icon').body['id'] }
109
+
110
+ it 'puts an icon' do
111
+ path = File.expand_path("#{File.dirname(__FILE__)}/icon.png")
112
+ icon = Base64.strict_encode64(File.read(path))
113
+ response = client.put_content_source_icons(content_source_id, main_icon: icon, alt_icon: icon)
114
+ expect(response.status).to eq 200
115
+ expect(response.body['results']).to eq({ 'main_icon' => 'success', 'alt_icon' => 'success' })
116
+ end
117
+ end
95
118
  end
96
119
 
97
120
  context 'Documents' do
@@ -124,6 +147,26 @@ describe Elastic::EnterpriseSearch::WorkplaceSearch::Client do
124
147
  response = client.delete_all_documents(content_source_id)
125
148
  expect(response.status).to eq 200
126
149
  end
150
+
151
+ it 'Deletes documents by query' do
152
+ content_source_id = client.create_content_source(name: 'asimov').body['id']
153
+ documents = [
154
+ { title: 'Foundation', year: 1951 },
155
+ { title: 'Foundation and Empire', year: 1952 },
156
+ { title: 'Second Foundation', year: 1953 }
157
+ ]
158
+ response = client.index_documents(content_source_id, documents: documents)
159
+
160
+ expect(response.status).to eq 200
161
+ expect(response.body['results'].count).to eq 3
162
+
163
+ # Give time to index the documents so we can delete them:
164
+ sleep 2
165
+
166
+ response = client.delete_documents_by_query(content_source_id, query: 'Foundation')
167
+ expect(response.status).to eq 200
168
+ expect(response.body).to eq({ 'total' => 3, 'deleted' => 3, 'failures' => [] })
169
+ end
127
170
  end
128
171
 
129
172
  context 'External Identities' do
@@ -250,4 +293,83 @@ describe Elastic::EnterpriseSearch::WorkplaceSearch::Client do
250
293
  expect(response.body).to eq({ 'user' => 'enterprise_search', 'permissions' => [] })
251
294
  end
252
295
  end
296
+
297
+ context 'Synonym sets' do
298
+ let(:body) do
299
+ {
300
+ synonym_sets: [
301
+ { 'synonyms' => ['house', 'home', 'abode'] },
302
+ { 'synonyms' => ['cat', 'feline', 'kitty'] },
303
+ { 'synonyms' => ['mouses', 'mice'] }
304
+ ]
305
+ }
306
+ end
307
+
308
+ it 'creates and deletes a batch synonym set' do
309
+ response = client.create_batch_synonym_sets(body: body)
310
+
311
+ expect(response.status).to eq 200
312
+ expect(response.body['has_errors']).to eq false
313
+ expect(response.body['synonym_sets'].count).to eq 3
314
+
315
+ response.body['synonym_sets'].map { |s| client.delete_synonym_set(synonym_set_id: s['id']) }
316
+ end
317
+
318
+ it 'lists synonym sets' do
319
+ client.create_batch_synonym_sets(body: body)
320
+ response = client.list_synonym_sets
321
+
322
+ expect(response.status).to eq 200
323
+ expect(response.body['results'].count).to eq 3
324
+
325
+ response.body['results'].map { |syn| client.delete_synonym_set(synonym_set_id: syn['id']) }
326
+ end
327
+
328
+ it 'gets a single synonym set' do
329
+ id = client.create_batch_synonym_sets(
330
+ body: {
331
+ synonym_sets: [
332
+ { 'synonyms' => ['house', 'home', 'abode'] }
333
+ ]
334
+ }
335
+ ).body['synonym_sets'].first['id']
336
+
337
+ response = client.synonym_set(synonym_set_id: id)
338
+ expect(response.status).to eq 200
339
+ expect(response.body['id']).to eq id
340
+ expect(response.body['synonyms']).to eq ['house', 'home', 'abode']
341
+ client.delete_synonym_set(synonym_set_id: id)
342
+ end
343
+
344
+ it 'updates a synonym set' do
345
+ id = client.create_batch_synonym_sets(
346
+ body: {
347
+ synonym_sets: [
348
+ { 'synonyms' => ['mouses', 'mice'] }
349
+ ]
350
+ }
351
+ ).body['synonym_sets'].first['id']
352
+ body = { synonyms: ['mouses', 'mice', 'luch'] }
353
+
354
+ response = client.put_synonym_set(synonym_set_id: id, body: body)
355
+
356
+ expect(response.status).to eq 200
357
+ expect(response.body).to eq({ 'id' => id, 'synonyms' => ['mouses', 'mice', 'luch'] })
358
+ client.delete_synonym_set(synonym_set_id: id)
359
+ end
360
+ end
361
+
362
+ context 'Users' do
363
+ it 'gets the current user' do
364
+ response = client.current_user
365
+ expect(response.status).to eq 200
366
+ expect(response.body.keys).to eq ['email', 'username']
367
+ end
368
+
369
+ it 'gets the current user with an access token' do
370
+ response = client.current_user(get_token: true)
371
+ expect(response.status).to eq 200
372
+ expect(response.body.keys).to eq ['email', 'username', 'access_token']
373
+ end
374
+ end
253
375
  end
@@ -1,3 +1,19 @@
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.
1
17
  # frozen_string_literal: true
2
18
 
3
19
  require 'webmock'