distributed-press-api-client 0.2.2 → 0.2.4
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/distributed_press/v1/client/admin.rb +1 -1
- data/lib/distributed_press/v1/client/auth.rb +1 -1
- data/lib/distributed_press/v1/client/publisher.rb +1 -1
- data/lib/distributed_press/v1/client/site.rb +13 -4
- data/lib/distributed_press/v1/client.rb +5 -4
- data/lib/distributed_press/v1/schemas/site.rb +1 -0
- data/lib/distributed_press/v1/schemas/update_site.rb +1 -0
- data/lib/distributed_press/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9655c1c4310b5c3d7b121b9984ba13eff6989deaf1056bfe3a0dd8b2c0ae493b
|
4
|
+
data.tar.gz: 4933a217789771803d88f9c6b92d09119846730ab61543e2789c9a1348796ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a348613279cf9cd9753561136bcebaae7729ff112ad20be435e966b62336a899da72fcd5fd736318103174442b1e931ba7c566b01fdcea876954a6a2e922785
|
7
|
+
data.tar.gz: 9f2504559bf4c6b7542ec50f649dbeb290a8fe8aa2add595a26a84ef45015d38801526a9d765ba7269a26f2f68f00373346951cbd3b165b684431c39383989ad
|
@@ -35,7 +35,7 @@ class DistributedPress
|
|
35
35
|
|
36
36
|
raise TokenCapabilityMissingError, 'Only admins can revoke tokens' unless client.token.admin?
|
37
37
|
|
38
|
-
client.delete(endpoint: "/v1/auth/revoke/#{schema[:tokenId]}"
|
38
|
+
client.delete(endpoint: "/v1/auth/revoke/#{schema[:tokenId]}")
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
@@ -65,7 +65,9 @@ class DistributedPress
|
|
65
65
|
validate_capabilities!
|
66
66
|
responses = []
|
67
67
|
|
68
|
-
Open3.popen2('tar', '--to-stdout', '--create', '--gzip',
|
68
|
+
Open3.popen2('tar', '--to-stdout', '--create', '--gzip',
|
69
|
+
'--dereference', '--exclude="*.gz"',
|
70
|
+
'--exclude="*.br"', '--directory', path,
|
69
71
|
'.') do |_, stdout, thread|
|
70
72
|
stream, body = IO.pipe
|
71
73
|
multipart = Multipart.new
|
@@ -84,11 +86,18 @@ class DistributedPress
|
|
84
86
|
responses << thread.value
|
85
87
|
end
|
86
88
|
|
87
|
-
responses.all?
|
89
|
+
responses.all?(&:success?)
|
88
90
|
end
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
+
# Deletes a website
|
93
|
+
#
|
94
|
+
# @param schema [DistributedPress::V1::Schemas::Site]
|
95
|
+
# @return [Boolean]
|
96
|
+
def delete(schema)
|
97
|
+
validate_schema! schema
|
98
|
+
validate_capabilities!
|
99
|
+
|
100
|
+
client.delete(endpoint: "/v1/sites/#{schema[:id]}")
|
92
101
|
end
|
93
102
|
|
94
103
|
private
|
@@ -83,7 +83,8 @@ class DistributedPress
|
|
83
83
|
multipart_headers['Content-Type'] = "multipart/form-data; boundary=#{boundary}"
|
84
84
|
multipart_headers['Transfer-Encoding'] = 'chunked'
|
85
85
|
|
86
|
-
self.class.put(endpoint, body_stream: io, headers: multipart_headers, max_retries: 0,
|
86
|
+
self.class.put(endpoint, body_stream: io, headers: multipart_headers, max_retries: 0,
|
87
|
+
timeout: timeout).tap do |response|
|
87
88
|
process_response_errors! endpoint, response
|
88
89
|
end
|
89
90
|
end
|
@@ -99,8 +100,8 @@ class DistributedPress
|
|
99
100
|
# @param endpoint [String]
|
100
101
|
# @param schema [Dry::Schema::Result]
|
101
102
|
# @return [Boolean]
|
102
|
-
def delete(endpoint
|
103
|
-
self.class.delete(endpoint,
|
103
|
+
def delete(endpoint:)
|
104
|
+
self.class.delete(endpoint, headers: headers).tap do |response|
|
104
105
|
process_response_errors! endpoint, response
|
105
106
|
end.ok?
|
106
107
|
end
|
@@ -137,7 +138,7 @@ class DistributedPress
|
|
137
138
|
# @param response [HTTParty::Response]
|
138
139
|
def process_response_errors!(endpoint, response)
|
139
140
|
raise TokenUnauthorizedError if response.unauthorized?
|
140
|
-
raise Error, "#{endpoint}: #{response.code} #{response.to_s.tr("\n",
|
141
|
+
raise Error, "#{endpoint}: #{response.code} #{response.to_s.tr("\n", '')}" unless response.ok?
|
141
142
|
end
|
142
143
|
end
|
143
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distributed-press-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|