elastic-workplace-search 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +68 -0
  3. data/.gitignore +10 -0
  4. data/.travis.yml +15 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +201 -0
  7. data/NOTICE.txt +3 -0
  8. data/README.md +171 -0
  9. data/Rakefile +1 -0
  10. data/elastic-workplace-search.gemspec +23 -0
  11. data/lib/data/ca-bundle.crt +3554 -0
  12. data/lib/elastic-workplace-search.rb +1 -0
  13. data/lib/elastic/workplace-search.rb +7 -0
  14. data/lib/elastic/workplace-search/client.rb +53 -0
  15. data/lib/elastic/workplace-search/client/content_source_documents.rb +45 -0
  16. data/lib/elastic/workplace-search/client/permissions.rb +29 -0
  17. data/lib/elastic/workplace-search/configuration.rb +54 -0
  18. data/lib/elastic/workplace-search/exceptions.rb +11 -0
  19. data/lib/elastic/workplace-search/request.rb +113 -0
  20. data/lib/elastic/workplace-search/utils.rb +15 -0
  21. data/lib/elastic/workplace-search/version.rb +5 -0
  22. data/spec/client/content_source_documents_spec.rb +55 -0
  23. data/spec/client/permissions_spec.rb +75 -0
  24. data/spec/configuration_spec.rb +19 -0
  25. data/spec/fixtures/vcr/add_user_permissions.yml +55 -0
  26. data/spec/fixtures/vcr/async_create_or_update_document_success.yml +51 -0
  27. data/spec/fixtures/vcr/destroy_documents_success.yml +51 -0
  28. data/spec/fixtures/vcr/get_user_permissions.yml +55 -0
  29. data/spec/fixtures/vcr/list_all_permissions.yml +55 -0
  30. data/spec/fixtures/vcr/list_all_permissions_with_paging.yml +55 -0
  31. data/spec/fixtures/vcr/remove_user_permissions.yml +55 -0
  32. data/spec/fixtures/vcr/update_user_permissions.yml +55 -0
  33. data/spec/spec_helper.rb +28 -0
  34. metadata +143 -0
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Configuration' do
4
+ context '.endpoint' do
5
+ context 'with a trailing /' do
6
+ it 'adds / to the end of of the URL' do
7
+ Elastic::WorkplaceSearch.endpoint = 'https://api.swiftype.com/api/ws/v1'
8
+ expect(Elastic::WorkplaceSearch.endpoint).to eq('https://api.swiftype.com/api/ws/v1/')
9
+ end
10
+ end
11
+
12
+ context 'with a trailing /' do
13
+ it 'leaves the URL alone' do
14
+ Elastic::WorkplaceSearch.endpoint = 'https://api.swiftype.com/api/ws/v1/'
15
+ expect(Elastic::WorkplaceSearch.endpoint).to eq('https://api.swiftype.com/api/ws/v1/')
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:3002/api/ws/v1/sources/5d96387b75444bf49532c24a/permissions/enterprise_search/add
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"permissions":["permission1"]}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json
18
+ X-Swiftype-Client:
19
+ - elastic-workplace-search-ruby
20
+ X-Swiftype-Client-Version:
21
+ - 0.4.0
22
+ Authorization:
23
+ - Bearer xyT3mm3ecPsPuYxd_6fX
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"6cb0d74ff26d6f74253df3ee283a38dd"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _st_frito_togo_session=KzdUM3ZvN3Z3aUIvRHNudUF0ZzJaT01EK2tNUk53akxDNVBlNWZxYVVDd3o4YlhqZXVUWjA3MWlqSlZnNzB0eFJrRW5RaUZBRFdHeVdtRnBtWUs5bWc9PS0tcEhjSk0xekxrOGRrcXNsWE83dlJrUT09--6f1c0da2f24a45042ff4492d5bac3ae214cd3731;
43
+ path=/; expires=Mon, 08 Oct 2029 18:04:32 -0000; HttpOnly
44
+ X-Request-Id:
45
+ - 616a8613-11c8-4031-8767-16f3ff735170
46
+ X-Runtime:
47
+ - '0.310198'
48
+ Transfer-Encoding:
49
+ - chunked
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"user":"enterprise_search","permissions":["permission1"]}'
53
+ http_version:
54
+ recorded_at: Tue, 08 Oct 2019 18:04:32 GMT
55
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:3002/api/ws/v1/sources/59542d332139de0acacc7dd4/documents/bulk_create.json
6
+ body:
7
+ encoding: UTF-8
8
+ string: '[{"id":"INscMGmhmX4","url":"http://www.youtube.com/watch?v=v1uyQZNg2vE","title":"The
9
+ Original Grumpy Cat","body":"this is a test"},{"id":"JNDFojsd02","url":"http://www.youtube.com/watch?v=tsdfhk2j","title":"Another
10
+ Grumpy Cat","body":"this is also a test"}]'
11
+ headers:
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ Content-Type:
17
+ - application/json
18
+ Authorization:
19
+ - Bearer cGUN-vBokevBhhzyA669
20
+ response:
21
+ status:
22
+ code: 202
23
+ message: Accepted
24
+ headers:
25
+ X-Frame-Options:
26
+ - SAMEORIGIN
27
+ X-Xss-Protection:
28
+ - 1; mode=block
29
+ X-Content-Type-Options:
30
+ - nosniff
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Cache-Control:
34
+ - no-cache
35
+ Set-Cookie:
36
+ - _st_main_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJWE4NGIxMjQ0YjgzNzYwOWU2NzljZGYyMjkwYzM2ODA4BjsAVA%3D%3D--d0ca869176aa0b9f3d57baf66152897d305fabae;
37
+ path=/; expires=Mon, 05 Jul 2027 17:52:09 -0000; HttpOnly
38
+ X-Request-Id:
39
+ - '09b779a9-1704-46e7-991d-9e92e67b0001'
40
+ X-Runtime:
41
+ - '0.115497'
42
+ Connection:
43
+ - close
44
+ Server:
45
+ - thin 1.5.0 codename Knife
46
+ body:
47
+ encoding: UTF-8
48
+ string: '[{"id":null,"id":"1234","errors":[]},{"id":null,"id":"1235","errors":[]}]'
49
+ http_version:
50
+ recorded_at: Wed, 05 Jul 2017 17:52:09 GMT
51
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:3002/api/ws/v1/sources/59542d332139de0acacc7dd4/documents/bulk_destroy.json
6
+ body:
7
+ encoding: UTF-8
8
+ string: '["INscMGmhmX4"]'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ Content-Type:
15
+ - application/json
16
+ Authorization:
17
+ - Bearer cGUN-vBokevBhhzyA669
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ X-Frame-Options:
24
+ - SAMEORIGIN
25
+ X-Xss-Protection:
26
+ - 1; mode=block
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Etag:
32
+ - W/"ab494a471abdde82a270b9d9562b7bb9"
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - _st_main_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTQ5ZGE4NjY4ZjZmY2Q2OTM2MGM0OTIyMDFkNmRmMzFlBjsAVA%3D%3D--75e0f9002e5f32100e4814a9dc015ffd43a5b6eb;
37
+ path=/; expires=Mon, 05 Jul 2027 17:52:12 -0000; HttpOnly
38
+ X-Request-Id:
39
+ - ec1754ea-5fa3-474f-87ba-e754e4c62553
40
+ X-Runtime:
41
+ - '1.367282'
42
+ Connection:
43
+ - close
44
+ Server:
45
+ - thin 1.5.0 codename Knife
46
+ body:
47
+ encoding: UTF-8
48
+ string: '[{"id":"INscMGmhmX4","success":true}]'
49
+ http_version:
50
+ recorded_at: Wed, 05 Jul 2017 17:52:12 GMT
51
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3002/api/ws/v1/sources/5d96387b75444bf49532c24a/permissions/enterprise_search
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json
18
+ X-Swiftype-Client:
19
+ - elastic-workplace-search-ruby
20
+ X-Swiftype-Client-Version:
21
+ - 0.4.0
22
+ Authorization:
23
+ - Bearer xyT3mm3ecPsPuYxd_6fX
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"6cb0d74ff26d6f74253df3ee283a38dd"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _st_frito_togo_session=NFJOYW80dHcxSGVmMTZTYUJaSTN4aUhKZjhtNmRhUVowN29zV3doakdJOHpyUDdzRnhoMlJJeE9nd1RvWWh0R1E1Zk1lUnhvTzNvajNUbXpmWnZIcVE9PS0tbENURG5USHgwYTZOUlcxS3lNUkdtQT09--e15485e53d7c2a3aa83288a815d1dcdfe6b9788a;
43
+ path=/; expires=Mon, 08 Oct 2029 18:04:48 -0000; HttpOnly
44
+ X-Request-Id:
45
+ - 67442386-136f-4f13-8f8e-0ac1b9ac10ce
46
+ X-Runtime:
47
+ - '0.303674'
48
+ Transfer-Encoding:
49
+ - chunked
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"user":"enterprise_search","permissions":["permission1"]}'
53
+ http_version:
54
+ recorded_at: Tue, 08 Oct 2019 18:04:48 GMT
55
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3002/api/ws/v1/sources/5d96387b75444bf49532c24a/permissions?page%5Bcurrent%5D=1&page%5Bsize%5D=25
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json
18
+ X-Swiftype-Client:
19
+ - elastic-workplace-search-ruby
20
+ X-Swiftype-Client-Version:
21
+ - 0.4.0
22
+ Authorization:
23
+ - Bearer xyT3mm3ecPsPuYxd_6fX
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"5c7f433cb2ebcb5549f57098f3ceab57"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _st_frito_togo_session=UFpRY1dUSldpNXhOdVUxVGlGaUl3c20ybGFkVGZFemhJZGFqVjNHcDhGWWdjVVpBVDVIWENNQkVWVXJXYnRKcmxqSm1TdHY0WjRoMDNmczJvT2Yzamc9PS0tcDkzWmV3MXN4Z0labTNxMXJrbitMdz09--ed529bc01c2d5cc98d6272fa033a876b1a7e689c;
43
+ path=/; expires=Mon, 08 Oct 2029 17:56:03 -0000; HttpOnly
44
+ X-Request-Id:
45
+ - 9bee4837-355a-4486-a35f-a92d5f13f389
46
+ X-Runtime:
47
+ - '0.230366'
48
+ Transfer-Encoding:
49
+ - chunked
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"meta":{"page":{"current":1,"total_pages":1,"total_results":2,"size":25}},"results":[{"user":"elastic","permissions":[]},{"user":"enterprise_search","permissions":[]}]}'
53
+ http_version:
54
+ recorded_at: Tue, 08 Oct 2019 17:56:03 GMT
55
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:3002/api/ws/v1/sources/5d96387b75444bf49532c24a/permissions?page%5Bcurrent%5D=2&page%5Bsize%5D=5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json
18
+ X-Swiftype-Client:
19
+ - elastic-workplace-search-ruby
20
+ X-Swiftype-Client-Version:
21
+ - 0.4.0
22
+ Authorization:
23
+ - Bearer xyT3mm3ecPsPuYxd_6fX
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"701f9ddd65c2586e892ac7f10050825f"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _st_frito_togo_session=ZXVYWkI5SFNTSm94Z29MY2thQTQvcmx4aStDenhUWkFWOVNyUWFCYWZaL3NJcDI2N21BcXJzK2h5dzNHNjd3NUdDYUNMYmgwYkNVczhjUmQ1dkd6Y2c9PS0tM3B5ciswcGlxek1QVXVjMUFsbFdPdz09--cea9576c7338c79cbd06216fe476cb63a9f6364f;
43
+ path=/; expires=Mon, 08 Oct 2029 17:58:09 -0000; HttpOnly
44
+ X-Request-Id:
45
+ - 1f924257-ed83-4715-a2f3-88be62d7d3c5
46
+ X-Runtime:
47
+ - '0.211862'
48
+ Transfer-Encoding:
49
+ - chunked
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"meta":{"page":{"current":2,"total_pages":1,"total_results":2,"size":5}},"results":[]}'
53
+ http_version:
54
+ recorded_at: Tue, 08 Oct 2019 17:58:09 GMT
55
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:3002/api/ws/v1/sources/5d96387b75444bf49532c24a/permissions/enterprise_search/remove
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"permissions":["permission2"]}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json
18
+ X-Swiftype-Client:
19
+ - elastic-workplace-search-ruby
20
+ X-Swiftype-Client-Version:
21
+ - 0.4.0
22
+ Authorization:
23
+ - Bearer xyT3mm3ecPsPuYxd_6fX
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"eaf0aef29a99d5f9dda5844986aa3880"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _st_frito_togo_session=aGhGT0VyRUVVZDIzMEJMTkpjR3U5TURLR01MVFIvajlqUmtEVG85My9ZWlk3dU1OdC9nWVVnNFhIRGlTdC9Ddks4dzNoeGx6d20raFVjSUI4d0Q5NWc9PS0tT2hwcXNkZnA1T2gyUUVDcUZIWEtrUT09--0e523f810425ee9c2b201bef99048a24b7f4e5d0;
43
+ path=/; expires=Mon, 08 Oct 2029 18:04:32 -0000; HttpOnly
44
+ X-Request-Id:
45
+ - 32583732-daf1-4153-9978-f2567862b21d
46
+ X-Runtime:
47
+ - '0.295464'
48
+ Transfer-Encoding:
49
+ - chunked
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"user":"enterprise_search","permissions":[]}'
53
+ http_version:
54
+ recorded_at: Tue, 08 Oct 2019 18:04:32 GMT
55
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:3002/api/ws/v1/sources/5d96387b75444bf49532c24a/permissions/enterprise_search
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"permissions":["permission2"]}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Content-Type:
17
+ - application/json
18
+ X-Swiftype-Client:
19
+ - elastic-workplace-search-ruby
20
+ X-Swiftype-Client-Version:
21
+ - 0.4.0
22
+ Authorization:
23
+ - Bearer xyT3mm3ecPsPuYxd_6fX
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Content-Type:
36
+ - application/json; charset=utf-8
37
+ Etag:
38
+ - W/"d9b34b6591f5971aeb0f3d706560e171"
39
+ Cache-Control:
40
+ - max-age=0, private, must-revalidate
41
+ Set-Cookie:
42
+ - _st_frito_togo_session=VXFPc0pKQitCSkcvb2c4Wjl3ZEx2YXRTL1NXWW5KbHVwdHhIcEVpd3lJS3orVVM3eVV0UVo1bTJ5MGFxQXhMQjZCM3VOZmV3bDl5NHl1a3ZkV2UxOHc9PS0tc2Nma0NRR0FmcWs0S0tJdFBxUXF3UT09--97d427ee534c30c51d1770571623a1d361b61b6f;
43
+ path=/; expires=Mon, 08 Oct 2029 18:04:31 -0000; HttpOnly
44
+ X-Request-Id:
45
+ - 9404a936-7a58-4412-8ab8-e08f71a0380c
46
+ X-Runtime:
47
+ - '0.388014'
48
+ Transfer-Encoding:
49
+ - chunked
50
+ body:
51
+ encoding: UTF-8
52
+ string: '{"user":"enterprise_search","permissions":["permission2"]}'
53
+ http_version:
54
+ recorded_at: Tue, 08 Oct 2019 18:04:31 GMT
55
+ recorded_with: VCR 3.0.3