Class: Uploadcare::Api::Rest::FileTags
- Inherits:
-
Object
- Object
- Uploadcare::Api::Rest::FileTags
- Defined in:
- lib/uploadcare/api/rest/file_tags.rb
Overview
REST API endpoint for per-file tag operations.
Instance Attribute Summary collapse
-
#rest ⇒ Uploadcare::Api::Rest
readonly
Parent REST client.
Instance Method Summary collapse
-
#initialize(rest:) ⇒ FileTags
constructor
A new instance of FileTags.
-
#list(uuid:, request_options: {}) ⇒ Uploadcare::Result
(also: #index)
Get the ordered list of tags for a file.
-
#replace(uuid:, tags:, request_options: {}) ⇒ Uploadcare::Result
Replace all tags for a file.
-
#update(uuid:, add: nil, delete: nil, request_options: {}) ⇒ Uploadcare::Result
Atomically add and delete tags for a file.
Constructor Details
#initialize(rest:) ⇒ FileTags
Returns a new instance of FileTags.
13 14 15 |
# File 'lib/uploadcare/api/rest/file_tags.rb', line 13 def initialize(rest:) @rest = rest end |
Instance Attribute Details
#rest ⇒ Uploadcare::Api::Rest (readonly)
Returns Parent REST client.
10 11 12 |
# File 'lib/uploadcare/api/rest/file_tags.rb', line 10 def rest @rest end |
Instance Method Details
#list(uuid:, request_options: {}) ⇒ Uploadcare::Result Also known as: index
Get the ordered list of tags for a file.
22 23 24 |
# File 'lib/uploadcare/api/rest/file_tags.rb', line 22 def list(uuid:, request_options: {}) rest.get(path: (uuid), params: {}, headers: {}, request_options: ) end |
#replace(uuid:, tags:, request_options: {}) ⇒ Uploadcare::Result
Replace all tags for a file.
33 34 35 36 37 |
# File 'lib/uploadcare/api/rest/file_tags.rb', line 33 def replace(uuid:, tags:, request_options: {}) rest.put( path: (uuid), params: { tags: }, headers: {}, request_options: ) end |
#update(uuid:, add: nil, delete: nil, request_options: {}) ⇒ Uploadcare::Result
Atomically add and delete tags for a file.
Deletions are applied before additions by the API.
48 49 50 51 52 53 54 |
# File 'lib/uploadcare/api/rest/file_tags.rb', line 48 def update(uuid:, add: nil, delete: nil, request_options: {}) params = {} params[:add] = add unless add.nil? || add.empty? params[:delete] = delete unless delete.nil? || delete.empty? body = params.empty? ? {}.to_json : params rest.patch(path: (uuid), params: body, headers: {}, request_options: ) end |