Class: Cloudinary::Api
Defined Under Namespace
Classes: AlreadyExists, AuthorizationRequired, BadRequest, Error, GeneralError, NotAllowed, NotFound, RateLimited, Response
Class Method Summary collapse
- .create_transformation(name, definition, options = {}) ⇒ Object
- .create_upload_preset(options = {}) ⇒ Object
- .delete_all_resources(options = {}) ⇒ Object
- .delete_derived_resources(derived_resource_ids, options = {}) ⇒ Object
- .delete_resources(public_ids, options = {}) ⇒ Object
- .delete_resources_by_prefix(prefix, options = {}) ⇒ Object
- .delete_resources_by_tag(tag, options = {}) ⇒ Object
- .delete_transformation(transformation, options = {}) ⇒ Object
- .delete_upload_preset(name, options = {}) ⇒ Object
- .ping(options = {}) ⇒ Object
- .resource(public_id, options = {}) ⇒ Object
- .resource_types(options = {}) ⇒ Object
- .resources(options = {}) ⇒ Object
- .resources_by_ids(public_ids, options = {}) ⇒ Object
- .resources_by_moderation(kind, status, options = {}) ⇒ Object
- .resources_by_tag(tag, options = {}) ⇒ Object
- .root_folders(options = {}) ⇒ Object
- .subfolders(of_folder_path, options = {}) ⇒ Object
- .tags(options = {}) ⇒ Object
- .transformation(transformation, options = {}) ⇒ Object
- .transformations(options = {}) ⇒ Object
- .update(public_id, options = {}) ⇒ Object
-
.update_transformation(transformation, updates, options = {}) ⇒ Object
updates - supports: “allowed_for_strict” boolean “unsafe_update” transformation params - updates a named transformation parameters without regenerating existing images.
- .update_upload_preset(name, options = {}) ⇒ Object
- .upload_preset(name, options = {}) ⇒ Object
-
.upload_presets(options = {}) ⇒ Object
upload presets.
- .usage(options = {}) ⇒ Object
Class Method Details
.create_transformation(name, definition, options = {}) ⇒ Object
148 149 150 |
# File 'lib/cloudinary/api.rb', line 148 def self.create_transformation(name, definition, ={}) call_api(:post, "transformations/#{name}", {:transformation=>transformation_string(definition)}, ) end |
.create_upload_preset(options = {}) ⇒ Object
170 171 172 173 |
# File 'lib/cloudinary/api.rb', line 170 def self.create_upload_preset(={}) params = Cloudinary::Uploader.build_upload_params() call_api(:post, "upload_presets", params.merge(only(, :name, :unsigned, :disallow_public_id)), ) end |
.delete_all_resources(options = {}) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/cloudinary/api.rb', line 103 def self.delete_all_resources(={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:delete, uri, {:all=>true}.merge(only(, :keep_original, :next_cursor, :invalidate)), ) end |
.delete_derived_resources(derived_resource_ids, options = {}) ⇒ Object
116 117 118 119 |
# File 'lib/cloudinary/api.rb', line 116 def self.delete_derived_resources(derived_resource_ids, ={}) uri = "derived_resources" call_api(:delete, uri, {:derived_resource_ids=>derived_resource_ids}, ) end |
.delete_resources(public_ids, options = {}) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/cloudinary/api.rb', line 89 def self.delete_resources(public_ids, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:delete, uri, {:public_ids=>public_ids}.merge(only(, :keep_original, :invalidate)), ) end |
.delete_resources_by_prefix(prefix, options = {}) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/cloudinary/api.rb', line 96 def self.delete_resources_by_prefix(prefix, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:delete, uri, {:prefix=>prefix}.merge(only(, :keep_original, :next_cursor, :invalidate)), ) end |
.delete_resources_by_tag(tag, options = {}) ⇒ Object
110 111 112 113 114 |
# File 'lib/cloudinary/api.rb', line 110 def self.delete_resources_by_tag(tag, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/tags/#{tag}" call_api(:delete, uri, only(, :keep_original, :next_cursor, :invalidate), ) end |
.delete_transformation(transformation, options = {}) ⇒ Object
135 136 137 |
# File 'lib/cloudinary/api.rb', line 135 def self.delete_transformation(transformation, ={}) call_api(:delete, "transformations/#{transformation_string(transformation)}", {}, ) end |
.delete_upload_preset(name, options = {}) ⇒ Object
161 162 163 |
# File 'lib/cloudinary/api.rb', line 161 def self.delete_upload_preset(name, ={}) call_api(:delete, "upload_presets/#{name}", {}, ) end |
.ping(options = {}) ⇒ Object
22 23 24 |
# File 'lib/cloudinary/api.rb', line 22 def self.ping(={}) call_api(:get, "ping", {}, ) end |
.resource(public_id, options = {}) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/cloudinary/api.rb', line 61 def self.resource(public_id, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}/#{public_id}" call_api(:get, uri, only(, :colors, :exif, :faces, :image_metadata, :pages, :phash, :coordinates, :max_results), ) end |
.resource_types(options = {}) ⇒ Object
30 31 32 |
# File 'lib/cloudinary/api.rb', line 30 def self.resource_types(={}) call_api(:get, "resources", {}, ) end |
.resources(options = {}) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/cloudinary/api.rb', line 34 def self.resources(={}) resource_type = [:resource_type] || "image" type = [:type] uri = "resources/#{resource_type}" uri += "/#{type}" if !type.blank? call_api(:get, uri, only(, :next_cursor, :max_results, :prefix, :tags, :context, :moderations, :direction, :start_at), ) end |
.resources_by_ids(public_ids, options = {}) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/cloudinary/api.rb', line 54 def self.resources_by_ids(public_ids, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:get, uri, only(, :tags, :context, :moderations).merge(:public_ids => public_ids), ) end |
.resources_by_moderation(kind, status, options = {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/cloudinary/api.rb', line 48 def self.resources_by_moderation(kind, status, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/moderations/#{kind}/#{status}" call_api(:get, uri, only(, :next_cursor, :max_results, :tags, :context, :moderations, :direction), ) end |
.resources_by_tag(tag, options = {}) ⇒ Object
42 43 44 45 46 |
# File 'lib/cloudinary/api.rb', line 42 def self.resources_by_tag(tag, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/tags/#{tag}" call_api(:get, uri, only(, :next_cursor, :max_results, :tags, :context, :moderations, :direction), ) end |
.root_folders(options = {}) ⇒ Object
175 176 177 |
# File 'lib/cloudinary/api.rb', line 175 def self.root_folders(={}) call_api(:get, "folders", {}, ) end |
.subfolders(of_folder_path, options = {}) ⇒ Object
179 180 181 |
# File 'lib/cloudinary/api.rb', line 179 def self.subfolders(of_folder_path, ={}) call_api(:get, "folders/#{of_folder_path}", {}, ) end |
.tags(options = {}) ⇒ Object
121 122 123 124 125 |
# File 'lib/cloudinary/api.rb', line 121 def self.(={}) resource_type = [:resource_type] || "image" uri = "tags/#{resource_type}" call_api(:get, uri, only(, :next_cursor, :max_results, :prefix), ) end |
.transformation(transformation, options = {}) ⇒ Object
131 132 133 |
# File 'lib/cloudinary/api.rb', line 131 def self.transformation(transformation, ={}) call_api(:get, "transformations/#{transformation_string(transformation)}", only(, :max_results), ) end |
.transformations(options = {}) ⇒ Object
127 128 129 |
# File 'lib/cloudinary/api.rb', line 127 def self.transformations(={}) call_api(:get, "transformations", only(, :next_cursor, :max_results), ) end |
.update(public_id, options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cloudinary/api.rb', line 68 def self.update(public_id, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}/#{public_id}" = { :tags => [:tags] && Cloudinary::Utils.build_array([:tags]).join(","), :context => Cloudinary::Utils.encode_hash([:context]), :face_coordinates => Cloudinary::Utils.encode_double_array([:face_coordinates]), :custom_coordinates => Cloudinary::Utils.encode_double_array([:custom_coordinates]), :moderation_status => [:moderation_status], :raw_convert => [:raw_convert], :ocr => [:ocr], :categorization => [:categorization], :detection => [:detection], :similarity_search => [:similarity_search], :background_removal => [:background_removal], :auto_tagging => [:auto_tagging] && [:auto_tagging].to_f } call_api(:post, uri, , ) end |
.update_transformation(transformation, updates, options = {}) ⇒ Object
updates - supports:
"allowed_for_strict" boolean
"unsafe_update" transformation params - updates a named transformation parameters without existing images
142 143 144 145 146 |
# File 'lib/cloudinary/api.rb', line 142 def self.update_transformation(transformation, updates, ={}) params = only(updates, :allowed_for_strict) params[:unsafe_update] = transformation_string(updates[:unsafe_update]) if updates[:unsafe_update] call_api(:put, "transformations/#{transformation_string(transformation)}", params, ) end |
.update_upload_preset(name, options = {}) ⇒ Object
165 166 167 168 |
# File 'lib/cloudinary/api.rb', line 165 def self.update_upload_preset(name, ={}) params = Cloudinary::Uploader.build_upload_params() call_api(:put, "upload_presets/#{name}", params.merge(only(, :unsigned, :disallow_public_id)), ) end |
.upload_preset(name, options = {}) ⇒ Object
157 158 159 |
# File 'lib/cloudinary/api.rb', line 157 def self.upload_preset(name, ={}) call_api(:get, "upload_presets/#{name}", only(, :max_results), ) end |
.upload_presets(options = {}) ⇒ Object
upload presets
153 154 155 |
# File 'lib/cloudinary/api.rb', line 153 def self.upload_presets(={}) call_api(:get, "upload_presets", only(, :next_cursor, :max_results), ) end |
.usage(options = {}) ⇒ Object
26 27 28 |
# File 'lib/cloudinary/api.rb', line 26 def self.usage(={}) call_api(:get, "usage", {}, ) end |