scanii-ruby 1.3.1 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9fddc91c85da53168797a052626eb0fe200d675267b0752ff2d9e40e08c977e
4
- data.tar.gz: 1438bf8d7cd1aa58747a898a6aed657cca75b5108b5ba0f4090511725e39d861
3
+ metadata.gz: 8b7caeccb8435e1085c555d60e2c0000ed7c57713fce50087be9d4fa33f6e4d1
4
+ data.tar.gz: e37e050290e8d7e38605861b317040cde9819eda9088e6b0289e836372053e64
5
5
  SHA512:
6
- metadata.gz: 69e26e752018a0792cf7f8dcb9bf0b49667c454186967f7193668dc5e24f12808c6f7c1ddf131b570f1045005d9b212233e74a22b1dd6b06417571cb71007b1a
7
- data.tar.gz: a235aef9683b29e8111235cfbe11787c94594e897a0536703a1cfb7f546f7502c4355b1ccfa2254115af2495075a678c3e99a911f6263e20dd748752d51a0bc3
6
+ metadata.gz: ae9ced99eb6909f3fa06840a519d953ff77ca729b84ee4a35273dd7bdaaf406c2853b09ba68111a395705bb9a8f7ccd16893eb17b3c86d2844cfc6afddbb8cb1
7
+ data.tar.gz: 8117f19a3d7e78d1451b01ca9a0e12bf1d2716b43fb664362a6edce5323022aec3742a1ae24f59f99cc824c74dff8476c58513936a44b3658a6b6b98c3b460ee
data/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to `scanii-ruby` are documented here. Versions follow [SemVer](https://semver.org).
4
4
 
5
+ ## [1.4.0] — split result and trace deletion
6
+
7
+ ### Added
8
+
9
+ - `Scanii::Client#delete(id)` — deletes a previously processed file result
10
+ (`DELETE /files/{id}`). Returns `true` on 204; the processing trace is left intact.
11
+ - `Scanii::Client#delete_trace(id)` — deletes the processing trace separately
12
+ (`DELETE /files/{id}/trace`). Returns `true` on 204; the processing result is left intact.
13
+
14
+ The two resources are independent: deleting one does not remove the other.
15
+ To erase a scan entirely, call both.
16
+
17
+ ### Changed
18
+
19
+ - Dropped the "v2.2 preview" designation from `retrieve_trace` and `process_from_url`
20
+ in the README and RDoc. Neither is marked preview in the API contract; the methods
21
+ themselves are unchanged.
22
+
23
+ ### Fixed
24
+
25
+ - Path segments are now encoded with `URI.encode_uri_component` rather than
26
+ `URI.encode_www_form_component`, which rendered a space as `+`. Inside a path a
27
+ `+` is a literal plus, so an id containing a space reached the server corrupted.
28
+ Affects every id-taking method. Scanii-issued ids are hex, so this was not
29
+ reachable in practice with server-generated ids.
30
+
5
31
  ## [1.3.1] — dependency refresh
6
32
 
7
33
  ### Changed
data/README.md CHANGED
@@ -60,15 +60,21 @@ puts "findings: #{result.findings.inspect}"
60
60
  | `process_file(path, metadata:, callback:)` | `POST /files` | `Scanii::ProcessingResult` |
61
61
  | `process_async(io, filename:, content_type:, metadata:, callback:)` | `POST /files/async` | `Scanii::PendingResult` |
62
62
  | `process_async_file(path, metadata:, callback:)` | `POST /files/async` | `Scanii::PendingResult` |
63
- | `process_from_url(location, callback:, metadata:)` | `POST /files` | `Scanii::ProcessingResult` (v2.2 preview) |
63
+ | `process_from_url(location, callback:, metadata:)` | `POST /files` | `Scanii::ProcessingResult` |
64
64
  | `fetch(url, metadata:, callback:)` | `POST /files/fetch` | `Scanii::PendingResult` |
65
65
  | `retrieve(id)` | `GET /files/{id}` | `Scanii::ProcessingResult` |
66
- | `retrieve_trace(id)` | `GET /files/{id}/trace` | `Scanii::TraceResult` or `nil` (v2.2 preview) |
66
+ | `retrieve_trace(id)` | `GET /files/{id}/trace` | `Scanii::TraceResult` or `nil` |
67
+ | `delete(id)` | `DELETE /files/{id}` | `true` |
68
+ | `delete_trace(id)` | `DELETE /files/{id}/trace` | `true` |
67
69
  | `ping` | `GET /ping` | `true` |
68
70
  | `create_auth_token(timeout_seconds)` | `POST /auth/tokens` | `Scanii::AuthToken` |
69
71
  | `retrieve_auth_token(id)` | `GET /auth/tokens/{id}` | `Scanii::AuthToken` |
70
72
  | `delete_auth_token(id)` | `DELETE /auth/tokens/{id}` | `true` |
71
73
 
74
+ `delete` and `delete_trace` act on independent resources: deleting a scan result
75
+ leaves its trace readable, and deleting a trace leaves the result readable. To erase
76
+ a scan entirely, call both.
77
+
72
78
  Full API reference: <https://scanii.github.io/openapi/v22/>.
73
79
 
74
80
  ## Regional endpoints
data/lib/scanii/client.rb CHANGED
@@ -202,9 +202,6 @@ module Scanii
202
202
  #
203
203
  # Returns nil when no trace exists for the given id (HTTP 404).
204
204
  #
205
- # This is a v2.2 preview surface; the API shape may shift before it is
206
- # marked stable.
207
- #
208
205
  # @param id [String] processing id returned by process or process_file
209
206
  # @see https://scanii.github.io/openapi/v22/ GET /files/{id}/trace
210
207
  # @return [Scanii::TraceResult, nil]
@@ -218,6 +215,41 @@ module Scanii
218
215
  TraceResult.from_response(resp_body, headers)
219
216
  end
220
217
 
218
+ # Delete a previously processed file result.
219
+ #
220
+ # The processing trace is a separate resource and is *not* removed by this
221
+ # call — it stays readable via {#retrieve_trace} until you delete it with
222
+ # {#delete_trace}. To erase a scan entirely, call both.
223
+ #
224
+ # @param id [String] processing id returned by {#process} or {#process_file}
225
+ # @see https://scanii.github.io/openapi/v22/ DELETE /files/{id}
226
+ # @return [Boolean] true on 204
227
+ # @raise [Scanii::Error] when no result exists for the id (HTTP 404), which is
228
+ # also what a repeated delete of the same id returns
229
+ def delete(id)
230
+ raise ArgumentError, "id must not be empty" if id.nil? || id.empty?
231
+
232
+ status, resp_body, headers = request("DELETE", "/files/#{url_encode(id)}")
233
+ raise_for_status(status, resp_body, headers) unless status == 204
234
+ true
235
+ end
236
+
237
+ # Delete the processing trace for a previously processed file, leaving the
238
+ # processing result itself untouched.
239
+ #
240
+ # @param id [String] processing id returned by {#process} or {#process_file}
241
+ # @see https://scanii.github.io/openapi/v22/ DELETE /files/{id}/trace
242
+ # @return [Boolean] true on 204
243
+ # @raise [Scanii::Error] when no trace exists for the id (HTTP 404), which is
244
+ # also what a repeated delete of the same id returns
245
+ def delete_trace(id)
246
+ raise ArgumentError, "id must not be empty" if id.nil? || id.empty?
247
+
248
+ status, resp_body, headers = request("DELETE", "/files/#{url_encode(id)}/trace")
249
+ raise_for_status(status, resp_body, headers) unless status == 204
250
+ true
251
+ end
252
+
221
253
  # Submit a remote URL for synchronous scanning.
222
254
  #
223
255
  # Sends the URL as a +location+ field in a multipart/form-data POST to
@@ -228,9 +260,6 @@ module Scanii
228
260
  # +location+ must be a String URL. This matches the existing {#fetch}
229
261
  # String-URL convention and the Java reference (processFromUrl(String)).
230
262
  #
231
- # This is a v2.2 preview surface; the API shape may shift before it is
232
- # marked stable.
233
- #
234
263
  # @param location [String] URL of the content to scan
235
264
  # @param callback [String, nil] URL to POST the result to on completion
236
265
  # @param metadata [Hash{String=>String}, nil] arbitrary key/value pairs attached to the result
@@ -431,8 +460,11 @@ module Scanii
431
460
  body
432
461
  end
433
462
 
463
+ # Path-segment encoding. NOT encode_www_form_component, which renders a
464
+ # space as "+" — correct for form bodies, wrong inside a path, where "+"
465
+ # is a literal plus and the id would arrive corrupted.
434
466
  def url_encode(value)
435
- URI.encode_www_form_component(value)
467
+ URI.encode_uri_component(value)
436
468
  end
437
469
  end
438
470
  end
@@ -3,9 +3,6 @@ require "json"
3
3
  module Scanii
4
4
  # Result of Client#retrieve_trace — ordered processing events for a scan.
5
5
  #
6
- # This is a v2.2 preview surface; the API shape may shift before it is
7
- # marked stable.
8
- #
9
6
  # @see https://scanii.github.io/openapi/v22/
10
7
  class TraceResult
11
8
  attr_reader :id, :events, :request_id, :host_id, :raw_response
@@ -1,3 +1,3 @@
1
1
  module Scanii
2
- VERSION = "1.3.1".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scanii-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scanii