gds-api-adapters 97.6.0 → 98.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/publishing_api.rb +18 -0
- data/lib/gds_api/version.rb +1 -1
- data/lib/gds_api.rb +0 -14
- metadata +3 -8
- data/lib/gds_api/router.rb +0 -62
- data/lib/gds_api/test_helpers/router.rb +0 -94
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4713a40baf4587862f28d5ab412bff34567eb2be929f81bf9f9946d119a978a3
|
4
|
+
data.tar.gz: 6c924fb31cdcc61d690f948b372d6c29b25cccd622431803b784755b5d89a138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c40c6142acf029075d1e2fb0438a53d62bde1a6ea7f3d4ab48c1e3381b444b2448cd3929f41e090bc96b9ffae7043e65f8cdb843b232a893191076177ad084a
|
7
|
+
data.tar.gz: b15571c36e56b8722eae8deb09562184b88e1b9dc626108517929d982cb91c3aaef8d75dd9a5237cddcfd8c8184994c6ef88b23c5eecbb852f0b8c5db6e833dd
|
@@ -378,6 +378,24 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
378
378
|
get_host_content_for_content_id(content_id, params)
|
379
379
|
end
|
380
380
|
|
381
|
+
# Get events for a specific content_id
|
382
|
+
#
|
383
|
+
# @param content_id [UUID]
|
384
|
+
# @param params [Hash]
|
385
|
+
#
|
386
|
+
# publishing_api.get_events_for_content_id(
|
387
|
+
# "7ac47b33-c09c-4c1d-a9a7-0cfef99081ac",
|
388
|
+
# { action: "PutContent", from: "2023-01-01T00:00:00Z", to: "2023-01-05T10:00:00Z" }
|
389
|
+
# )
|
390
|
+
#
|
391
|
+
# @return [GdsApi::Response] A response containing a list of events for that content ID
|
392
|
+
#
|
393
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_idevents
|
394
|
+
def get_events_for_content_id(content_id, params = {})
|
395
|
+
query = query_string(params)
|
396
|
+
get_json("#{endpoint}/v2/content/#{content_id}/events#{query}")
|
397
|
+
end
|
398
|
+
|
381
399
|
# Returns an Enumerator of content items for the provided
|
382
400
|
# query string parameters.
|
383
401
|
#
|
data/lib/gds_api/version.rb
CHANGED
data/lib/gds_api.rb
CHANGED
@@ -14,7 +14,6 @@ require "gds_api/locations_api"
|
|
14
14
|
require "gds_api/maslow"
|
15
15
|
require "gds_api/organisations"
|
16
16
|
require "gds_api/publishing_api"
|
17
|
-
require "gds_api/router"
|
18
17
|
require "gds_api/search"
|
19
18
|
require "gds_api/search_api_v2"
|
20
19
|
require "gds_api/support"
|
@@ -155,19 +154,6 @@ module GdsApi
|
|
155
154
|
)
|
156
155
|
end
|
157
156
|
|
158
|
-
# Creates a GdsApi::Router adapter for communicating with Router API
|
159
|
-
#
|
160
|
-
# This will set a bearer token if a ROUTER_API_BEARER_TOKEN environment
|
161
|
-
# variable is set
|
162
|
-
#
|
163
|
-
# @return [GdsApi::Router]
|
164
|
-
def self.router(options = {})
|
165
|
-
GdsApi::Router.new(
|
166
|
-
Plek.find("router-api"),
|
167
|
-
{ bearer_token: ENV["ROUTER_API_BEARER_TOKEN"] }.merge(options),
|
168
|
-
)
|
169
|
-
end
|
170
|
-
|
171
157
|
# Creates a GdsApi::Search adapter to access via a search.* hostname
|
172
158
|
#
|
173
159
|
# @return [GdsApi::Search]
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 98.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
10
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: addressable
|
@@ -351,7 +350,6 @@ files:
|
|
351
350
|
- lib/gds_api/publishing_api/special_route_publisher.rb
|
352
351
|
- lib/gds_api/railtie.rb
|
353
352
|
- lib/gds_api/response.rb
|
354
|
-
- lib/gds_api/router.rb
|
355
353
|
- lib/gds_api/search.rb
|
356
354
|
- lib/gds_api/search_api_v2.rb
|
357
355
|
- lib/gds_api/support.rb
|
@@ -371,7 +369,6 @@ files:
|
|
371
369
|
- lib/gds_api/test_helpers/organisations.rb
|
372
370
|
- lib/gds_api/test_helpers/places_manager.rb
|
373
371
|
- lib/gds_api/test_helpers/publishing_api.rb
|
374
|
-
- lib/gds_api/test_helpers/router.rb
|
375
372
|
- lib/gds_api/test_helpers/search.rb
|
376
373
|
- lib/gds_api/test_helpers/support_api.rb
|
377
374
|
- lib/gds_api/test_helpers/worldwide.rb
|
@@ -387,7 +384,6 @@ files:
|
|
387
384
|
homepage: http://github.com/alphagov/gds-api-adapters
|
388
385
|
licenses: []
|
389
386
|
metadata: {}
|
390
|
-
post_install_message:
|
391
387
|
rdoc_options: []
|
392
388
|
require_paths:
|
393
389
|
- lib
|
@@ -402,8 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
402
398
|
- !ruby/object:Gem::Version
|
403
399
|
version: '0'
|
404
400
|
requirements: []
|
405
|
-
rubygems_version: 3.
|
406
|
-
signing_key:
|
401
|
+
rubygems_version: 3.6.0
|
407
402
|
specification_version: 4
|
408
403
|
summary: Adapters to work with GDS APIs
|
409
404
|
test_files: []
|
data/lib/gds_api/router.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require_relative "base"
|
2
|
-
|
3
|
-
class GdsApi::Router < GdsApi::Base
|
4
|
-
### Backends
|
5
|
-
|
6
|
-
def get_backend(id)
|
7
|
-
get_json("#{endpoint}/backends/#{CGI.escape(id)}")
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_backend(id, url)
|
11
|
-
put_json("#{endpoint}/backends/#{CGI.escape(id)}", backend: { backend_url: url })
|
12
|
-
end
|
13
|
-
|
14
|
-
def delete_backend(id)
|
15
|
-
delete_json("#{endpoint}/backends/#{CGI.escape(id)}")
|
16
|
-
end
|
17
|
-
|
18
|
-
### Routes
|
19
|
-
|
20
|
-
def get_route(path)
|
21
|
-
get_json("#{endpoint}/routes?incoming_path=#{CGI.escape(path)}")
|
22
|
-
end
|
23
|
-
|
24
|
-
def add_route(path, type, backend_id)
|
25
|
-
put_json(
|
26
|
-
"#{endpoint}/routes",
|
27
|
-
route: {
|
28
|
-
incoming_path: path,
|
29
|
-
route_type: type,
|
30
|
-
handler: "backend",
|
31
|
-
backend_id:,
|
32
|
-
},
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_redirect_route(path, type, destination, options = {})
|
37
|
-
put_json(
|
38
|
-
"#{endpoint}/routes",
|
39
|
-
route: {
|
40
|
-
incoming_path: path,
|
41
|
-
route_type: type,
|
42
|
-
handler: "redirect",
|
43
|
-
redirect_to: destination,
|
44
|
-
segments_mode: options[:segments_mode],
|
45
|
-
},
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
def add_gone_route(path, type)
|
50
|
-
put_json(
|
51
|
-
"#{endpoint}/routes",
|
52
|
-
route: { incoming_path: path, route_type: type, handler: "gone" },
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
def delete_route(path, hard_delete: false)
|
57
|
-
url = "#{endpoint}/routes?incoming_path=#{CGI.escape(path)}"
|
58
|
-
url += "&hard_delete=true" if hard_delete
|
59
|
-
|
60
|
-
delete_json(url)
|
61
|
-
end
|
62
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "gds_api/test_helpers/json_client_helper"
|
2
|
-
|
3
|
-
module GdsApi
|
4
|
-
module TestHelpers
|
5
|
-
module Router
|
6
|
-
ROUTER_API_ENDPOINT = Plek.find("router-api")
|
7
|
-
|
8
|
-
def stub_router_has_route(path, route, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"])
|
9
|
-
stub_get_route(path, bearer_token).to_return(
|
10
|
-
status: 200,
|
11
|
-
body: route.to_json,
|
12
|
-
headers: { "Content-Type" => "application/json" },
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
def stub_router_doesnt_have_route(path, bearer_token = ENV["ROUTER_API_BEARER_TOKEN"])
|
17
|
-
stub_get_route(path, bearer_token).to_return(status: 404)
|
18
|
-
end
|
19
|
-
|
20
|
-
def stub_router_has_backend_route(path, backend_id:, route_type: "exact", disabled: false)
|
21
|
-
stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:)
|
22
|
-
end
|
23
|
-
|
24
|
-
def stub_router_has_redirect_route(path, redirect_to:, route_type: "exact", disabled: false)
|
25
|
-
stub_router_has_route(path, handler: "redirect", redirect_to:, disabled:, route_type:)
|
26
|
-
end
|
27
|
-
|
28
|
-
def stub_router_has_gone_route(path, route_type: "exact", disabled: false)
|
29
|
-
stub_router_has_route(path, handler: "gone", route_type:, disabled:)
|
30
|
-
end
|
31
|
-
|
32
|
-
def stub_all_router_registration
|
33
|
-
stub_request(:put, %r{\A#{ROUTER_API_ENDPOINT}/backends/[a-z0-9-]+\z})
|
34
|
-
stub_request(:put, "#{ROUTER_API_ENDPOINT}/routes")
|
35
|
-
end
|
36
|
-
|
37
|
-
def stub_router_backend_registration(backend_id, backend_url)
|
38
|
-
backend = { "backend" => { "backend_url" => backend_url } }
|
39
|
-
stub_http_request(:put, "#{ROUTER_API_ENDPOINT}/backends/#{backend_id}")
|
40
|
-
.with(body: backend.to_json)
|
41
|
-
.to_return(status: 201)
|
42
|
-
end
|
43
|
-
|
44
|
-
def stub_route_registration(path, type, backend_id)
|
45
|
-
stub_route_put({
|
46
|
-
route: {
|
47
|
-
incoming_path: path,
|
48
|
-
route_type: type,
|
49
|
-
handler: "backend",
|
50
|
-
backend_id:,
|
51
|
-
},
|
52
|
-
})
|
53
|
-
end
|
54
|
-
|
55
|
-
def stub_redirect_registration(path, type, destination, segments_mode = nil)
|
56
|
-
stub_route_put({
|
57
|
-
route: {
|
58
|
-
incoming_path: path,
|
59
|
-
route_type: type,
|
60
|
-
handler: "redirect",
|
61
|
-
redirect_to: destination,
|
62
|
-
segments_mode:,
|
63
|
-
},
|
64
|
-
})
|
65
|
-
end
|
66
|
-
|
67
|
-
def stub_gone_route_registration(path, type)
|
68
|
-
stub_route_put({
|
69
|
-
route: {
|
70
|
-
incoming_path: path,
|
71
|
-
route_type: type,
|
72
|
-
handler: "gone",
|
73
|
-
},
|
74
|
-
})
|
75
|
-
end
|
76
|
-
|
77
|
-
private
|
78
|
-
|
79
|
-
def stub_get_route(path, bearer_token)
|
80
|
-
stub_http_request(:get, "#{ROUTER_API_ENDPOINT}/routes")
|
81
|
-
.with(
|
82
|
-
query: { "incoming_path" => path },
|
83
|
-
headers: { "Authorization" => "Bearer #{bearer_token}" },
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
def stub_route_put(route)
|
88
|
-
stub_http_request(:put, "#{ROUTER_API_ENDPOINT}/routes")
|
89
|
-
.with(body: route.to_json)
|
90
|
-
.to_return(status: 201)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|