publishing_platform_api_adapters 0.5.1 → 0.6.1
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/Rakefile +3 -3
- data/lib/publishing_platform_api/json_client.rb +1 -1
- data/lib/publishing_platform_api/publishing_api.rb +7 -7
- data/lib/publishing_platform_api/router.rb +63 -0
- data/lib/publishing_platform_api/version.rb +1 -1
- data/lib/publishing_platform_api.rb +22 -8
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba00f3fd59ac75e1c672ed3478d9db8503fbaa56ee682a4358620ff226e3cf6b
|
4
|
+
data.tar.gz: 190d8d347832fb1cab2df63a2b4dd49198e1c8fb147f4b593696755c31ae8490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9996d745a94433034e222944d6c30cd76d70a3fff86cbe36ab6ec69ebf945f04defbf18a8d9df9e812006f73c5502dc3c01102ade2eb20bcbff576be5577585
|
7
|
+
data.tar.gz: 9ea06ebd27980708823a44525c22221fe18e9eaea4eadcf5a23cd43a46b20d6cd2176b87667bbf182e20e024eb133629225506e9729a6de30ac1c520367af032
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
|
|
10
10
|
# Put a content item
|
11
11
|
#
|
12
12
|
# @param content_id [UUID]
|
13
|
-
# @param payload [Hash] A valid content item
|
13
|
+
# @param payload [Hash] A valid content item
|
14
14
|
def put_content(content_id, payload)
|
15
15
|
put_json(content_url(content_id), payload)
|
16
16
|
end
|
@@ -123,13 +123,13 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
|
|
123
123
|
# }
|
124
124
|
def get_links(content_id)
|
125
125
|
get_json(links_url(content_id))
|
126
|
-
end
|
126
|
+
end
|
127
127
|
|
128
128
|
# Get expanded links
|
129
129
|
#
|
130
130
|
# Return the expanded links of the item.
|
131
131
|
#
|
132
|
-
# @param content_id [UUID]
|
132
|
+
# @param content_id [UUID]
|
133
133
|
# @param with_drafts [Bool] Whether links to draft-only editions are returned, defaulting to `true`.
|
134
134
|
# @param generate [Bool] Whether to require publishing-api to generate the expanded links, which may be slow. Defaults to `false`.
|
135
135
|
#
|
@@ -155,14 +155,14 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
|
|
155
155
|
query = query_string(params)
|
156
156
|
validate_content_id(content_id)
|
157
157
|
get_json("#{endpoint}/expanded-links/#{content_id}#{query}")
|
158
|
-
end
|
158
|
+
end
|
159
159
|
|
160
160
|
# Patch the links of a content item
|
161
161
|
#
|
162
162
|
# @param content_id [UUID]
|
163
163
|
# @param params [Hash]
|
164
164
|
# @option params [Hash] links A "links hash"
|
165
|
-
# @option params [Integer] previous_version The previous version (returned by `get_links`). If this version is not the current version, the publishing-api will reject the change and return 409 Conflict. (optional)
|
165
|
+
# @option params [Integer] previous_version The previous version (returned by `get_links`). If this version is not the current version, the publishing-api will reject the change and return 409 Conflict. (optional)
|
166
166
|
# @example
|
167
167
|
#
|
168
168
|
# publishing_api.patch_links(
|
@@ -214,7 +214,7 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
|
|
214
214
|
end
|
215
215
|
|
216
216
|
get_json("#{endpoint}/linkables?document_type=#{document_type}")
|
217
|
-
end
|
217
|
+
end
|
218
218
|
|
219
219
|
# Reserves a path for a publishing application
|
220
220
|
#
|
@@ -278,4 +278,4 @@ private
|
|
278
278
|
def validate_content_id(content_id)
|
279
279
|
raise ArgumentError, "content_id cannot be nil" unless content_id
|
280
280
|
end
|
281
|
-
end
|
281
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
class PublishingPlatformApi::Router < PublishingPlatformApi::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, redirect_type = "permanent", 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
|
+
redirect_type:,
|
45
|
+
segments_mode: options[:segments_mode],
|
46
|
+
},
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_gone_route(path, type)
|
51
|
+
put_json(
|
52
|
+
"#{endpoint}/routes",
|
53
|
+
route: { incoming_path: path, route_type: type, handler: "gone" },
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete_route(path, hard_delete: false)
|
58
|
+
url = "#{endpoint}/routes?incoming_path=#{CGI.escape(path)}"
|
59
|
+
url += "&hard_delete=true" if hard_delete
|
60
|
+
|
61
|
+
delete_json(url)
|
62
|
+
end
|
63
|
+
end
|
@@ -1,11 +1,25 @@
|
|
1
1
|
require "addressable"
|
2
2
|
require "publishing_platform_location"
|
3
3
|
require "time"
|
4
|
-
require "publishing_platform_api/publishing_api"
|
5
4
|
require "publishing_platform_api/content_store"
|
5
|
+
require "publishing_platform_api/publishing_api"
|
6
|
+
require "publishing_platform_api/router"
|
6
7
|
|
7
8
|
# @api documented
|
8
9
|
module PublishingPlatformApi
|
10
|
+
# Creates a PublishingPlatformApi::ContentStore adapter
|
11
|
+
#
|
12
|
+
# This will set a bearer token if a CONTENT_STORE_BEARER_TOKEN environment
|
13
|
+
# variable is set
|
14
|
+
#
|
15
|
+
# @return [PublishingPlatformApi::ContentStore]
|
16
|
+
def self.content_store(options = {})
|
17
|
+
PublishingPlatformApi::ContentStore.new(
|
18
|
+
PublishingPlatformLocation.find("content-store"),
|
19
|
+
{ bearer_token: ENV["CONTENT_STORE_BEARER_TOKEN"] }.merge(options),
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
9
23
|
# Creates a PublishingPlatformApi::PublishingApi adapter
|
10
24
|
#
|
11
25
|
# This will set a bearer token if a PUBLISHING_API_BEARER_TOKEN environment
|
@@ -19,16 +33,16 @@ module PublishingPlatformApi
|
|
19
33
|
)
|
20
34
|
end
|
21
35
|
|
22
|
-
# Creates a PublishingPlatformApi::
|
36
|
+
# Creates a PublishingPlatformApi::Router adapter for communicating with Router API
|
23
37
|
#
|
24
|
-
# This will set a bearer token if a
|
38
|
+
# This will set a bearer token if a ROUTER_API_BEARER_TOKEN environment
|
25
39
|
# variable is set
|
26
40
|
#
|
27
|
-
# @return [PublishingPlatformApi::
|
28
|
-
def self.
|
29
|
-
PublishingPlatformApi::
|
30
|
-
PublishingPlatformLocation.find("
|
31
|
-
{ bearer_token: ENV["
|
41
|
+
# @return [PublishingPlatformApi::Router]
|
42
|
+
def self.router(options = {})
|
43
|
+
PublishingPlatformApi::Router.new(
|
44
|
+
PublishingPlatformLocation.find("router-api"),
|
45
|
+
{ bearer_token: ENV["ROUTER_API_BEARER_TOKEN"] }.merge(options),
|
32
46
|
)
|
33
47
|
end
|
34
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishing_platform_api_adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Publishing Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/publishing_platform_api/publishing_platform_headers.rb
|
114
114
|
- lib/publishing_platform_api/railtie.rb
|
115
115
|
- lib/publishing_platform_api/response.rb
|
116
|
+
- lib/publishing_platform_api/router.rb
|
116
117
|
- lib/publishing_platform_api/version.rb
|
117
118
|
- lib/publishing_platform_api_adapters.rb
|
118
119
|
homepage:
|
@@ -127,14 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
128
|
requirements:
|
128
129
|
- - ">="
|
129
130
|
- !ruby/object:Gem::Version
|
130
|
-
version: '3.
|
131
|
+
version: '3.1'
|
131
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
133
|
requirements:
|
133
134
|
- - ">="
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.5.23
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: Adapters to work with Publishing Platform APIs
|