uploadcare-ruby 5.0.0 → 5.1.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 +4 -4
- data/.github/workflows/gem-push.yml +3 -1
- data/CHANGELOG.md +18 -0
- data/MIGRATING_V5.md +2 -1
- data/README.md +108 -6
- data/api_examples/README.md +9 -5
- data/api_examples/rest_api/get_files_uuid_tags.rb +4 -0
- data/api_examples/rest_api/patch_files_uuid_tags.rb +4 -0
- data/api_examples/rest_api/post_files_search.rb +4 -0
- data/api_examples/rest_api/put_files_uuid_tags.rb +4 -0
- data/api_examples/support/example_helper.rb +17 -1
- data/api_examples/support/run_rest_example.rb +30 -0
- data/api_examples/support/run_upload_example.rb +8 -2
- data/context7.json +3 -1
- data/docs/release-notes-5.1.0.md +33 -0
- data/examples/README.md +4 -0
- data/examples/file_search.rb +33 -0
- data/examples/file_tags.rb +37 -0
- data/lib/uploadcare/api/rest/file_tags.rb +62 -0
- data/lib/uploadcare/api/rest/files.rb +18 -1
- data/lib/uploadcare/api/rest.rb +37 -12
- data/lib/uploadcare/api/upload/files.rb +18 -5
- data/lib/uploadcare/api/upload.rb +2 -1
- data/lib/uploadcare/client/file_tags_accessor.rb +44 -0
- data/lib/uploadcare/client/files_accessor.rb +17 -0
- data/lib/uploadcare/client.rb +7 -0
- data/lib/uploadcare/collections/file_search_result.rb +45 -0
- data/lib/uploadcare/collections/paginated.rb +7 -1
- data/lib/uploadcare/internal/file_tag_normalizer.rb +62 -0
- data/lib/uploadcare/internal/upload_params_generator.rb +16 -2
- data/lib/uploadcare/internal/user_agent.rb +1 -1
- data/lib/uploadcare/operations/file_search.rb +43 -0
- data/lib/uploadcare/operations/multipart_upload.rb +1 -1
- data/lib/uploadcare/operations/upload_router.rb +2 -2
- data/lib/uploadcare/resources/file.rb +23 -15
- data/lib/uploadcare/resources/file_tags.rb +92 -0
- data/lib/uploadcare/version.rb +1 -1
- data/lib/uploadcare.rb +2 -0
- metadata +14 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Resource for reading and changing the ordered tag list associated with a file.
|
|
4
|
+
#
|
|
5
|
+
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File-tags
|
|
6
|
+
class Uploadcare::Resources::FileTags < Uploadcare::Resources::BaseResource
|
|
7
|
+
attr_accessor :uuid, :tags, :added, :deleted
|
|
8
|
+
|
|
9
|
+
def initialize(attributes = {}, client_or_config = nil)
|
|
10
|
+
@tags = []
|
|
11
|
+
@added = []
|
|
12
|
+
@deleted = []
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Fetch the current tags.
|
|
17
|
+
#
|
|
18
|
+
# @param request_options [Hash] Request options
|
|
19
|
+
# @return [self]
|
|
20
|
+
def list(request_options: {})
|
|
21
|
+
response = Uploadcare::Result.unwrap(
|
|
22
|
+
client.api.rest.file_tags.list(uuid: uuid, request_options: request_options)
|
|
23
|
+
)
|
|
24
|
+
self.tags = response.fetch('tags', [])
|
|
25
|
+
self.added = []
|
|
26
|
+
self.deleted = []
|
|
27
|
+
self
|
|
28
|
+
end
|
|
29
|
+
alias index list
|
|
30
|
+
|
|
31
|
+
# Replace the complete tag list. An empty array clears all tags.
|
|
32
|
+
#
|
|
33
|
+
# @param tags [Array<String>]
|
|
34
|
+
# @param request_options [Hash] Request options
|
|
35
|
+
# @return [self]
|
|
36
|
+
def replace(tags:, request_options: {})
|
|
37
|
+
normalized = Uploadcare::Internal::FileTagNormalizer.call(tags)
|
|
38
|
+
response = Uploadcare::Result.unwrap(
|
|
39
|
+
client.api.rest.file_tags.replace(uuid: uuid, tags: normalized, request_options: request_options)
|
|
40
|
+
)
|
|
41
|
+
assign_attributes(response)
|
|
42
|
+
self
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Atomically add and delete tags. Deletions are applied first.
|
|
46
|
+
#
|
|
47
|
+
# @param add [Array<String>] Tags to add
|
|
48
|
+
# @param delete [Array<String>] Tags to delete
|
|
49
|
+
# @param request_options [Hash] Request options
|
|
50
|
+
# @return [self]
|
|
51
|
+
def update(add: [], delete: [], request_options: {})
|
|
52
|
+
normalized_add = Uploadcare::Internal::FileTagNormalizer.call(add)
|
|
53
|
+
normalized_delete = Uploadcare::Internal::FileTagNormalizer.call(delete, max_count: nil)
|
|
54
|
+
response = Uploadcare::Result.unwrap(
|
|
55
|
+
client.api.rest.file_tags.update(
|
|
56
|
+
uuid: uuid, add: normalized_add, delete: normalized_delete, request_options: request_options
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
assign_attributes(response)
|
|
60
|
+
self
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Get the current tag list for a file.
|
|
64
|
+
#
|
|
65
|
+
# @return [Array<String>]
|
|
66
|
+
def self.list(uuid:, client: nil, config: Uploadcare.configuration, request_options: {})
|
|
67
|
+
resolved_client = resolve_client(client: client, config: config)
|
|
68
|
+
new({ uuid: uuid }, resolved_client).list(request_options: request_options).tags.dup
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class << self
|
|
72
|
+
alias index list
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Replace the complete tag list for a file.
|
|
76
|
+
#
|
|
77
|
+
# @return [Uploadcare::Resources::FileTags]
|
|
78
|
+
def self.replace(uuid:, tags:, client: nil, config: Uploadcare.configuration, request_options: {})
|
|
79
|
+
resolved_client = resolve_client(client: client, config: config)
|
|
80
|
+
new({ uuid: uuid }, resolved_client).replace(tags: tags, request_options: request_options)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Atomically add and delete tags for a file.
|
|
84
|
+
#
|
|
85
|
+
# @return [Uploadcare::Resources::FileTags]
|
|
86
|
+
def self.update(uuid:, add: [], delete: [], client: nil, config: Uploadcare.configuration, request_options: {})
|
|
87
|
+
resolved_client = resolve_client(client: client, config: config)
|
|
88
|
+
new({ uuid: uuid }, resolved_client).update(
|
|
89
|
+
add: add, delete: delete, request_options: request_options
|
|
90
|
+
)
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/uploadcare/version.rb
CHANGED
data/lib/uploadcare.rb
CHANGED
|
@@ -79,6 +79,8 @@ module Uploadcare
|
|
|
79
79
|
Webhook = Resources::Webhook
|
|
80
80
|
# Alias for the file metadata resource.
|
|
81
81
|
FileMetadata = Resources::FileMetadata
|
|
82
|
+
# Alias for the file tags resource.
|
|
83
|
+
FileTags = Resources::FileTags
|
|
82
84
|
# Alias for the add-on execution resource.
|
|
83
85
|
AddonExecution = Resources::AddonExecution
|
|
84
86
|
# Alias for the document conversion resource.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uploadcare-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)"
|
|
@@ -119,10 +119,12 @@ files:
|
|
|
119
119
|
- api_examples/rest_api/get_files_uuid.rb
|
|
120
120
|
- api_examples/rest_api/get_files_uuid_metadata.rb
|
|
121
121
|
- api_examples/rest_api/get_files_uuid_metadata_key.rb
|
|
122
|
+
- api_examples/rest_api/get_files_uuid_tags.rb
|
|
122
123
|
- api_examples/rest_api/get_groups.rb
|
|
123
124
|
- api_examples/rest_api/get_groups_uuid.rb
|
|
124
125
|
- api_examples/rest_api/get_project.rb
|
|
125
126
|
- api_examples/rest_api/get_webhooks.rb
|
|
127
|
+
- api_examples/rest_api/patch_files_uuid_tags.rb
|
|
126
128
|
- api_examples/rest_api/post_addons_aws_rekognition_detect_labels_execute.rb
|
|
127
129
|
- api_examples/rest_api/post_addons_aws_rekognition_detect_moderation_labels_execute.rb
|
|
128
130
|
- api_examples/rest_api/post_addons_remove_bg_execute.rb
|
|
@@ -131,10 +133,12 @@ files:
|
|
|
131
133
|
- api_examples/rest_api/post_convert_video.rb
|
|
132
134
|
- api_examples/rest_api/post_files_local_copy.rb
|
|
133
135
|
- api_examples/rest_api/post_files_remote_copy.rb
|
|
136
|
+
- api_examples/rest_api/post_files_search.rb
|
|
134
137
|
- api_examples/rest_api/post_webhooks.rb
|
|
135
138
|
- api_examples/rest_api/put_files_storage.rb
|
|
136
139
|
- api_examples/rest_api/put_files_uuid_metadata_key.rb
|
|
137
140
|
- api_examples/rest_api/put_files_uuid_storage.rb
|
|
141
|
+
- api_examples/rest_api/put_files_uuid_tags.rb
|
|
138
142
|
- api_examples/rest_api/put_webhooks_id.rb
|
|
139
143
|
- api_examples/support/example_helper.rb
|
|
140
144
|
- api_examples/support/run_rest_example.rb
|
|
@@ -152,8 +156,11 @@ files:
|
|
|
152
156
|
- bin/setup
|
|
153
157
|
- context7.json
|
|
154
158
|
- docs/release-notes-5.0.0.md
|
|
159
|
+
- docs/release-notes-5.1.0.md
|
|
155
160
|
- examples/README.md
|
|
156
161
|
- examples/batch_upload.rb
|
|
162
|
+
- examples/file_search.rb
|
|
163
|
+
- examples/file_tags.rb
|
|
157
164
|
- examples/group_creation.rb
|
|
158
165
|
- examples/large_file_upload.rb
|
|
159
166
|
- examples/simple_upload.rb
|
|
@@ -164,6 +171,7 @@ files:
|
|
|
164
171
|
- lib/uploadcare/api/rest/addons.rb
|
|
165
172
|
- lib/uploadcare/api/rest/document_conversions.rb
|
|
166
173
|
- lib/uploadcare/api/rest/file_metadata.rb
|
|
174
|
+
- lib/uploadcare/api/rest/file_tags.rb
|
|
167
175
|
- lib/uploadcare/api/rest/files.rb
|
|
168
176
|
- lib/uploadcare/api/rest/groups.rb
|
|
169
177
|
- lib/uploadcare/api/rest/project.rb
|
|
@@ -178,6 +186,7 @@ files:
|
|
|
178
186
|
- lib/uploadcare/client/conversions_accessor.rb
|
|
179
187
|
- lib/uploadcare/client/document_conversions_accessor.rb
|
|
180
188
|
- lib/uploadcare/client/file_metadata_accessor.rb
|
|
189
|
+
- lib/uploadcare/client/file_tags_accessor.rb
|
|
181
190
|
- lib/uploadcare/client/files_accessor.rb
|
|
182
191
|
- lib/uploadcare/client/groups_accessor.rb
|
|
183
192
|
- lib/uploadcare/client/project_accessor.rb
|
|
@@ -185,6 +194,7 @@ files:
|
|
|
185
194
|
- lib/uploadcare/client/webhooks_accessor.rb
|
|
186
195
|
- lib/uploadcare/cname_generator.rb
|
|
187
196
|
- lib/uploadcare/collections/batch_result.rb
|
|
197
|
+
- lib/uploadcare/collections/file_search_result.rb
|
|
188
198
|
- lib/uploadcare/collections/paginated.rb
|
|
189
199
|
- lib/uploadcare/configuration.rb
|
|
190
200
|
- lib/uploadcare/exception/auth_error.rb
|
|
@@ -201,11 +211,13 @@ files:
|
|
|
201
211
|
- lib/uploadcare/exception/upload_timeout_error.rb
|
|
202
212
|
- lib/uploadcare/internal/authenticator.rb
|
|
203
213
|
- lib/uploadcare/internal/error_handler.rb
|
|
214
|
+
- lib/uploadcare/internal/file_tag_normalizer.rb
|
|
204
215
|
- lib/uploadcare/internal/signature_generator.rb
|
|
205
216
|
- lib/uploadcare/internal/throttle_handler.rb
|
|
206
217
|
- lib/uploadcare/internal/upload_io.rb
|
|
207
218
|
- lib/uploadcare/internal/upload_params_generator.rb
|
|
208
219
|
- lib/uploadcare/internal/user_agent.rb
|
|
220
|
+
- lib/uploadcare/operations/file_search.rb
|
|
209
221
|
- lib/uploadcare/operations/multipart_upload.rb
|
|
210
222
|
- lib/uploadcare/operations/upload_router.rb
|
|
211
223
|
- lib/uploadcare/resources/addon_execution.rb
|
|
@@ -213,6 +225,7 @@ files:
|
|
|
213
225
|
- lib/uploadcare/resources/document_conversion.rb
|
|
214
226
|
- lib/uploadcare/resources/file.rb
|
|
215
227
|
- lib/uploadcare/resources/file_metadata.rb
|
|
228
|
+
- lib/uploadcare/resources/file_tags.rb
|
|
216
229
|
- lib/uploadcare/resources/group.rb
|
|
217
230
|
- lib/uploadcare/resources/project.rb
|
|
218
231
|
- lib/uploadcare/resources/video_conversion.rb
|