gds-api-adapters 33.2.2 → 34.0.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/lib/gds_api/rummager.rb +21 -16
- data/lib/gds_api/test_helpers/rummager.rb +45 -16
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31508a987b6157626ddc9dd154b5458db554ea2
|
4
|
+
data.tar.gz: 43b17d83043656ccdd24b88fcb6d07c74d9c19cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f4709932906aca95ba97ea7343bbc9896953be06c57871e7ab9e93c3ce45f4b3f73bb093a14844d6cd37e44c0030457cbf1d1013b978f26eb0467b19febc66
|
7
|
+
data.tar.gz: 634deb28aee00f3ca3050ab8cea2b41eabd31bead3207ecd9ba98a8306dea9edd1dc7a260de634a511932f1b099600f3ce7d7bfc3718230a42077f72ceda032e
|
data/lib/gds_api/rummager.rb
CHANGED
@@ -4,9 +4,7 @@ require 'rack/utils'
|
|
4
4
|
module GdsApi
|
5
5
|
class Rummager < Base
|
6
6
|
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# Perform a search
|
7
|
+
# Perform a search.
|
10
8
|
#
|
11
9
|
# @param query [Hash] A valid search query. See Rummager documentation for options.
|
12
10
|
#
|
@@ -16,7 +14,7 @@ module GdsApi
|
|
16
14
|
get_json!(request_url)
|
17
15
|
end
|
18
16
|
|
19
|
-
# Advanced search
|
17
|
+
# Advanced search.
|
20
18
|
#
|
21
19
|
# @deprecated Only in use by Whitehall. Use the `unified_search` method.
|
22
20
|
def advanced_search(args)
|
@@ -25,9 +23,12 @@ module GdsApi
|
|
25
23
|
get_json!(request_path)
|
26
24
|
end
|
27
25
|
|
28
|
-
# Add a document
|
26
|
+
# Add a document to the search index.
|
29
27
|
#
|
30
|
-
#
|
28
|
+
# @param type [String] The rummager/elasticsearch document type.
|
29
|
+
# @param id [String] The rummager/elasticsearch id. Typically the same as the `link` field, but this is not strictly enforced.
|
30
|
+
# @param document [Hash] The document to add. Must match the rummager schema matchin the `type` parameter and contain a `link` field.
|
31
|
+
# @return [GdsApi::Response] A status code of 202 indicates the document has been successfully queued.
|
31
32
|
#
|
32
33
|
# @see https://github.com/alphagov/rummager/blob/master/docs/documents.md
|
33
34
|
def add_document(type, id, document)
|
@@ -40,9 +41,11 @@ module GdsApi
|
|
40
41
|
)
|
41
42
|
end
|
42
43
|
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
44
|
+
# Delete a content-document from the index by base path.
|
45
|
+
#
|
46
|
+
# Content documents are pages on GOV.UK that have a base path and are
|
47
|
+
# returned in searches. This excludes best bets, recommended-links,
|
48
|
+
# and contacts, which may be deleted with `delete_document`.
|
46
49
|
#
|
47
50
|
# @param base_path Base path of the page on GOV.UK.
|
48
51
|
# @see https://github.com/alphagov/rummager/blob/master/docs/content-api.md
|
@@ -51,8 +54,11 @@ module GdsApi
|
|
51
54
|
delete_json!(request_url)
|
52
55
|
end
|
53
56
|
|
54
|
-
#
|
55
|
-
#
|
57
|
+
# Retrieve a content-document from the index.
|
58
|
+
#
|
59
|
+
# Content documents are pages on GOV.UK that have a base path and are
|
60
|
+
# returned in searches. This excludes best bets, recommended-links,
|
61
|
+
# and contacts.
|
56
62
|
#
|
57
63
|
# @param base_path [String] Base path of the page on GOV.UK.
|
58
64
|
# @see https://github.com/alphagov/rummager/blob/master/docs/content-api.md
|
@@ -61,13 +67,12 @@ module GdsApi
|
|
61
67
|
get_json!(request_url)
|
62
68
|
end
|
63
69
|
|
64
|
-
#
|
70
|
+
# Delete a non-content document from the search index.
|
65
71
|
#
|
66
|
-
#
|
67
|
-
# needs a type, but can be used to delete non-content documents from the
|
68
|
-
# index.
|
72
|
+
# For example, best bets, recommended links, or contacts.
|
69
73
|
#
|
70
|
-
# @
|
74
|
+
# @param type [String] The rummager/elasticsearch document type.
|
75
|
+
# @param id [String] The rummager/elasticsearch id. Typically the same as the `link` field.
|
71
76
|
def delete_document(type, id)
|
72
77
|
delete_json!(
|
73
78
|
"#{documents_url}/#{id}",
|
@@ -6,18 +6,31 @@ module GdsApi
|
|
6
6
|
module Rummager
|
7
7
|
RUMMAGER_ENDPOINT = Plek.current.find('rummager')
|
8
8
|
|
9
|
-
def stub_any_rummager_post
|
10
|
-
|
9
|
+
def stub_any_rummager_post(index: nil)
|
10
|
+
if index
|
11
|
+
stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/#{index}/documents})
|
12
|
+
.to_return(status: [202, "Accepted"])
|
13
|
+
else
|
14
|
+
stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents})
|
15
|
+
.to_return(status: [202, "Accepted"])
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def stub_any_rummager_post_with_queueing_enabled
|
20
|
+
warn "stub_any_rummager_post_with_queueing_enabled is deprecated: use stub_any_rummager_post instead"
|
21
|
+
|
14
22
|
stub_request(:post, %r{#{RUMMAGER_ENDPOINT}/documents}) \
|
15
23
|
.to_return(status: [202, "Accepted"])
|
16
24
|
end
|
17
25
|
|
18
|
-
def assert_rummager_posted_item(attributes)
|
19
|
-
|
20
|
-
|
26
|
+
def assert_rummager_posted_item(attributes, index: nil, **options)
|
27
|
+
if index
|
28
|
+
url = RUMMAGER_ENDPOINT + "/#{index}/documents"
|
29
|
+
else
|
30
|
+
url = RUMMAGER_ENDPOINT + "/documents"
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_requested(:post, url, **options) do |req|
|
21
34
|
data = JSON.parse(req.body)
|
22
35
|
attributes.to_a.all? do |key, value|
|
23
36
|
data[key.to_s] == value
|
@@ -25,28 +38,44 @@ module GdsApi
|
|
25
38
|
end
|
26
39
|
end
|
27
40
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
41
|
+
def stub_any_rummager_delete(index: nil)
|
42
|
+
if index
|
43
|
+
stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/#{index}/documents/.*})
|
44
|
+
else
|
45
|
+
# use rummager's default index
|
46
|
+
stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/documents/.*})
|
47
|
+
end
|
32
48
|
end
|
33
49
|
|
34
50
|
def stub_any_rummager_delete_content
|
35
51
|
stub_request(:delete, %r{#{RUMMAGER_ENDPOINT}/content.*})
|
36
52
|
end
|
37
53
|
|
38
|
-
|
39
|
-
def assert_rummager_deleted_item(id)
|
40
|
-
warn "assert_rummager_deleted_item stub is deprecated, instead use: assert_rummager_deleted_content"
|
41
|
-
|
54
|
+
def assert_rummager_deleted_item(id, index: nil, **options)
|
42
55
|
if id =~ %r{^/}
|
43
56
|
raise ArgumentError, 'Rummager id must not start with a slash'
|
44
57
|
end
|
45
|
-
|
58
|
+
if index
|
59
|
+
assert_requested(
|
60
|
+
:delete,
|
61
|
+
%r{#{RUMMAGER_ENDPOINT}/#{index}/documents/#{id}},
|
62
|
+
**options
|
63
|
+
)
|
64
|
+
else
|
65
|
+
assert_requested(
|
66
|
+
:delete,
|
67
|
+
%r{#{RUMMAGER_ENDPOINT}/documents/#{id}},
|
68
|
+
**options
|
69
|
+
)
|
70
|
+
end
|
46
71
|
end
|
47
72
|
|
48
|
-
def assert_rummager_deleted_content(base_path)
|
49
|
-
assert_requested(
|
73
|
+
def assert_rummager_deleted_content(base_path, **options)
|
74
|
+
assert_requested(
|
75
|
+
:delete,
|
76
|
+
%r{#{RUMMAGER_ENDPOINT}/content.*#{base_path}},
|
77
|
+
**options
|
78
|
+
)
|
50
79
|
end
|
51
80
|
|
52
81
|
def rummager_has_services_and_info_data_for_organisation
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 34.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|