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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cc2e318b07cdd179bf6a7817f3f35fbf0adb2ec2ea10c3a507b8f565605c469
4
- data.tar.gz: 51f43af7ba7cb51de03419f473cd20a3a39f42ff24542f8fb9a346bbbd8dc441
3
+ metadata.gz: 9655c1c4310b5c3d7b121b9984ba13eff6989deaf1056bfe3a0dd8b2c0ae493b
4
+ data.tar.gz: 4933a217789771803d88f9c6b92d09119846730ab61543e2789c9a1348796ef9
5
5
  SHA512:
6
- metadata.gz: 64283cf5dc2a5bb7089917f09de9b43bdccccf748c83be099002b8e9676d065988d64571d4d9f0b599049cee2fe19d8627d7ddf476489a1078caa62c2056ca29
7
- data.tar.gz: eb252a94732ac916de5496f8ad74f0c19005a1f15c9c4776105c20f2a53cf61a6ad7d1637fecdbe10efa30a5b9e8898f37288bfbd60a0d6b3d83fe887bae830a
6
+ metadata.gz: 0a348613279cf9cd9753561136bcebaae7729ff112ad20be435e966b62336a899da72fcd5fd736318103174442b1e931ba7c566b01fdcea876954a6a2e922785
7
+ data.tar.gz: 9f2504559bf4c6b7542ec50f649dbeb290a8fe8aa2add595a26a84ef45015d38801526a9d765ba7269a26f2f68f00373346951cbd3b165b684431c39383989ad
@@ -33,7 +33,7 @@ class DistributedPress
33
33
  validate_schema! schema
34
34
  validate_capabilities!
35
35
 
36
- client.delete(endpoint: "/v1/admin/#{schema[:id]}", schema: schema)
36
+ client.delete(endpoint: "/v1/admin/#{schema[:id]}")
37
37
  end
38
38
 
39
39
  private
@@ -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]}", schema: schema)
38
+ client.delete(endpoint: "/v1/auth/revoke/#{schema[:tokenId]}")
39
39
  end
40
40
 
41
41
  private
@@ -36,7 +36,7 @@ class DistributedPress
36
36
  validate_schema! schema
37
37
  validate_capabilities!
38
38
 
39
- client.delete(endpoint: "/v1/publisher/#{schema[:id]}", schema: schema)
39
+ client.delete(endpoint: "/v1/publisher/#{schema[:id]}")
40
40
  end
41
41
 
42
42
  private
@@ -65,7 +65,9 @@ class DistributedPress
65
65
  validate_capabilities!
66
66
  responses = []
67
67
 
68
- Open3.popen2('tar', '--to-stdout', '--create', '--gzip', '--dereference', '--directory', path,
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? &:success?
89
+ responses.all?(&:success?)
88
90
  end
89
91
 
90
- def delete
91
- raise NotImplementedError
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, timeout: timeout).tap do |response|
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:, schema:)
103
- self.class.delete(endpoint, body: schema.to_h.to_json, headers: headers).tap do |response|
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", "")}" unless response.ok?
141
+ raise Error, "#{endpoint}: #{response.code} #{response.to_s.tr("\n", '')}" unless response.ok?
141
142
  end
142
143
  end
143
144
  end
@@ -15,6 +15,7 @@ class DistributedPress
15
15
 
16
16
  # TODO: Validate domain name
17
17
  required(:domain).filled(:string)
18
+ required(:public).filled(:bool)
18
19
 
19
20
  required(:protocols).hash do
20
21
  required(:http).filled(:bool)
@@ -10,6 +10,7 @@ class DistributedPress
10
10
  class UpdateSite < Dry::Schema::JSON
11
11
  define do
12
12
  required(:id).filled(:string)
13
+ required(:public).filled(:bool)
13
14
 
14
15
  required(:protocols).hash do
15
16
  optional(:http).filled(:bool)
@@ -3,5 +3,5 @@
3
3
  # API client
4
4
  class DistributedPress
5
5
  # Version
6
- VERSION = '0.2.2'
6
+ VERSION = '0.2.4'
7
7
  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.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-02-08 00:00:00.000000000 Z
11
+ date: 2023-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable