Class: Cloudinary::Api
- Extended by:
- BaseApi
- Defined in:
- lib/cloudinary/api.rb
Class Method Summary collapse
-
.add_metadata_field(field, options = {}) ⇒ Cloudinary::Api::Response
Creates a new metadata field definition.
-
.add_metadata_rule(rule, options = {}) ⇒ Cloudinary::Api::Response
Creates a new metadata rule definition.
-
.add_related_assets(public_id, assets_to_relate, options = {}) ⇒ Cloudinary::Api::Response
Relates an asset to other assets by public IDs.
-
.add_related_assets_by_asset_ids(asset_id, assets_to_relate, options = {}) ⇒ Cloudinary::Api::Response
Relates an asset to other assets by asset IDs.
-
.analyze(input_type, analysis_type, options = {}) ⇒ Cloudinary::Api::Response
Analyzes an asset with the requested analysis type.
-
.create_folder(folder_name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new empty folder.
-
.create_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new, custom streaming profile.
-
.create_transformation(name, definition, options = {}) ⇒ Cloudinary::Api::Response
Creates a named transformation.
-
.create_upload_mapping(name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new upload mapping.
-
.create_upload_preset(options = {}) ⇒ Cloudinary::Api::Response
Creates a new upload preset.
-
.delete_all_resources(options = {}) ⇒ Cloudinary::Api::Response
Deletes all assets of the specified asset and delivery type, including their derived assets.
-
.delete_datasource_entries(field_external_id, entries_external_id, options = {}) ⇒ Cloudinary::Api::Response
Deletes entries in a metadata single or multi-select field’s datasource.
-
.delete_derived_by_transformation(public_ids, transformations, options = {}) ⇒ Cloudinary::Api::Response
Deletes derived assets identified by transformation and public_ids.
-
.delete_derived_resources(derived_resource_ids, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified derived assets by derived asset ID.
-
.delete_folder(path, options = {}) ⇒ Cloudinary::Api::Response
Deletes an empty folder.
-
.delete_metadata_field(field_external_id, options = {}) ⇒ Cloudinary::Api::Response
Deletes a metadata field definition by external ID.
-
.delete_metadata_rule(external_id, options = {}) ⇒ Cloudinary::Api::Response
Deletes a metadata rule definition by external ID.
-
.delete_related_assets(public_id, assets_to_unrelate, options = {}) ⇒ Cloudinary::Api::Response
Unrelates an asset from other assets by public IDs.
-
.delete_related_assets_by_asset_ids(asset_id, assets_to_unrelate, options = {}) ⇒ Cloudinary::Api::Response
Unrelates an asset from other assets by asset IDs.
-
.delete_resources(public_ids, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified assets.
-
.delete_resources_by_prefix(prefix, options = {}) ⇒ Cloudinary::Api::Response
Deletes assets by prefix.
-
.delete_resources_by_tag(tag, options = {}) ⇒ Cloudinary::Api::Response
Deletes assets with the specified tag, including their derived assets.
-
.delete_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Deletes or reverts the specified streaming profile.
-
.delete_transformation(transformation, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified stored transformation.
-
.delete_upload_mapping(name, options = {}) ⇒ Cloudinary::Api::Response
Deletes an upload mapping.
-
.delete_upload_preset(name, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified upload preset.
-
.get_breakpoints(public_id, options) ⇒ Cloudinary::Api::Response
Gets the breakpoints.
-
.get_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Gets details of a single streaming profile by name.
-
.list_metadata_fields(options = {}) ⇒ Cloudinary::Api::Response
Lists all metadata field definitions.
-
.list_metadata_rules(options = {}) ⇒ Cloudinary::Api::Response
Lists all metadata rules definitions.
-
.list_streaming_profiles ⇒ Cloudinary::Api::Response
Lists streaming profiles including built-in and custom profiles.
-
.metadata_field_by_field_id(field_external_id, options = {}) ⇒ Cloudinary::Api::Response
Gets a single metadata field definition by external ID.
-
.ping(options = {}) ⇒ Cloudinary::Api::Response
Tests the reachability of the Cloudinary API.
-
.rename_folder(from_path, to_path, options = {}) ⇒ Cloudinary::Api::Response
Renames existing asset folder.
-
.reorder_metadata_field_datasource(field_external_id, order_by, direction = nil, options = {}) ⇒ Cloudinary::Api::Response
Reorders metadata field datasource.
-
.reorder_metadata_fields(order_by, direction = nil, options = {}) ⇒ Cloudinary::Api::Response
Reorders metadata fields.
-
.resource(public_id, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of the specified asset and all its derived assets.
-
.resource_by_asset_id(asset_id, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of the specified asset and all its derived assets by asset id.
-
.resource_types(options = {}) ⇒ Cloudinary::Api::Response
Lists all uploaded assets filtered by any specified options.
-
.resources(options = {}) ⇒ Cloudinary::Api::Response
Lists all uploaded assets filtered by any specified options.
-
.resources_by_asset_folder(asset_folder, options = {}) ⇒ Cloudinary::Api::Response
Returns all assets stored directly in a specified asset folder, regardless of the public ID paths of those assets.
-
.resources_by_asset_ids(asset_ids, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified asset IDs.
-
.resources_by_context(key, value = nil, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified contextual metadata.
-
.resources_by_ids(public_ids, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified public IDs.
-
.resources_by_moderation(kind, status, options = {}) ⇒ Cloudinary::Api::Response
Lists assets currently in the specified moderation queue and status.
-
.resources_by_tag(tag, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified tag.
-
.restore(public_ids, options = {}) ⇒ Cloudinary::Api::Response
Reverts to the latest backed up version of the specified deleted assets.
-
.restore_metadata_field_datasource(field_external_id, entries_external_ids, options = {}) ⇒ Cloudinary::Api::Response
Restore entries in a metadata field datasource.
-
.root_folders(options = {}) ⇒ Cloudinary::Api::Response
Lists all root folders.
-
.subfolders(of_folder_path, options = {}) ⇒ Cloudinary::Api::Response
Lists sub-folders.
-
.tags(options = {}) ⇒ Cloudinary::Api::Response
Lists all the tags currently used for a specified asset type.
-
.transformation(transformation, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of a single transformation.
-
.transformations(options = {}) ⇒ Cloudinary::Api::Response
Lists stored transformations.
-
.update(public_id, options = {}) ⇒ Cloudinary::Api::Response
Updates details of an existing asset.
-
.update_metadata_field(field_external_id, field, options = {}) ⇒ Cloudinary::Api::Response
Updates a metadata field by external ID.
-
.update_metadata_field_datasource(field_external_id, entries_external_id, options = {}) ⇒ Cloudinary::Api::Response
Updates a metadata field datasource.
-
.update_metadata_rule(external_id, rule, options = {}) ⇒ Cloudinary::Api::Response
Updates a metadata rule by external ID.
-
.update_resources_access_mode_by_ids(access_mode, public_ids, options = {}) ⇒ Cloudinary::Api::Response
Update resources access mode.
-
.update_resources_access_mode_by_prefix(access_mode, prefix, options = {}) ⇒ Cloudinary::Api::Response
Update resources access mode.
-
.update_resources_access_mode_by_tag(access_mode, tag, options = {}) ⇒ Cloudinary::Api::Response
Update resources access mode.
-
.update_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Updates an existing streaming profile.
-
.update_transformation(transformation, updates, options = {}) ⇒ Cloudinary::Api::Response
Updates the specified transformation.
-
.update_upload_mapping(name, options = {}) ⇒ Cloudinary::Api::Response
Updates an existing upload mapping with a new template (URL).
-
.update_upload_preset(name, options = {}) ⇒ Cloudinary::Api::Response
Updates the specified upload preset.
-
.upload_mapping(name = nil, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of the specified upload mapping.
-
.upload_mappings(options = {}) ⇒ Cloudinary::Api::Response
Lists upload mappings by folder and its mapped template (URL).
-
.upload_preset(name, options = {}) ⇒ Cloudinary::Api::Response
Retrieves the details of the specified upload preset.
-
.upload_presets(options = {}) ⇒ Cloudinary::Api::Response
Lists existing upload presets.
-
.usage(options = {}) ⇒ Cloudinary::Api::Response
Gets cloud usage details.
-
.visual_search(options = {}) ⇒ Cloudinary::Api::Response
Find images based on their visual content.
Methods included from BaseApi
Class Method Details
.add_metadata_field(field, options = {}) ⇒ Cloudinary::Api::Response
Creates a new metadata field definition.
1023 1024 1025 1026 1027 |
# File 'lib/cloudinary/api.rb', line 1023 def self.(field, = {}) params = only(field, :type, :external_id, :label, :mandatory, :default_value, :validation, :datasource) (:post, [], params, ) end |
.add_metadata_rule(rule, options = {}) ⇒ Cloudinary::Api::Response
Creates a new metadata rule definition.
1195 1196 1197 1198 1199 |
# File 'lib/cloudinary/api.rb', line 1195 def self.(rule, = {}) params = only(rule, :metadata_field_id, :condition, :result, :name) (:post, [], params, ) end |
.add_related_assets(public_id, assets_to_relate, options = {}) ⇒ Cloudinary::Api::Response
Relates an asset to other assets by public IDs.
426 427 428 429 430 431 432 |
# File 'lib/cloudinary/api.rb', line 426 def self.(public_id, assets_to_relate, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/related_assets/#{resource_type}/#{type}/#{public_id}" params = {:assets_to_relate => Cloudinary::Utils.build_array(assets_to_relate)} call_api(:post, uri, params, ) end |
.add_related_assets_by_asset_ids(asset_id, assets_to_relate, options = {}) ⇒ Cloudinary::Api::Response
Relates an asset to other assets by asset IDs.
444 445 446 447 448 |
# File 'lib/cloudinary/api.rb', line 444 def self.(asset_id, assets_to_relate, ={}) uri = "resources/related_assets/#{asset_id}" params = {:assets_to_relate => Cloudinary::Utils.build_array(assets_to_relate)} call_api(:post, uri, params, ) end |
.analyze(input_type, analysis_type, options = {}) ⇒ Cloudinary::Api::Response
Analyzes an asset with the requested analysis type.
1249 1250 1251 1252 1253 1254 1255 1256 1257 |
# File 'lib/cloudinary/api.rb', line 1249 def self.analyze(input_type, analysis_type, = {}) api_uri = ["analysis", "analyze", input_type] params = only(, :uri, :parameters) params["analysis_type"] = analysis_type [:api_version] = 'v2' call_api(:post, api_uri, params, ) end |
.create_folder(folder_name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new empty folder.
730 731 732 |
# File 'lib/cloudinary/api.rb', line 730 def self.create_folder(folder_name, ={}) call_api(:post, "folders/#{folder_name}", {}, ) end |
.create_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new, custom streaming profile.
841 842 843 844 845 846 847 848 |
# File 'lib/cloudinary/api.rb', line 841 def self.create_streaming_profile(name, ={}) params = only(, :display_name, :representations) params[:representations] = params[:representations].map do |r| {:transformation => Cloudinary::Utils.generate_transformation_string(r[:transformation])} end.to_json params[:name] = name call_api(:post, 'streaming_profiles', params, ) end |
.create_transformation(name, definition, options = {}) ⇒ Cloudinary::Api::Response
Creates a named transformation.
587 588 589 590 591 592 593 594 |
# File 'lib/cloudinary/api.rb', line 587 def self.create_transformation(name, definition, ={}) params = { :name => name, :transformation => Cloudinary::Utils.build_eager(definition) } call_api(:post, "transformations", params, ) end |
.create_upload_mapping(name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new upload mapping.
822 823 824 825 826 |
# File 'lib/cloudinary/api.rb', line 822 def self.create_upload_mapping(name, ={}) params = only(, :template) params[:folder] = name call_api(:post, 'upload_mappings', params, ) end |
.create_upload_preset(options = {}) ⇒ Cloudinary::Api::Response
Creates a new upload preset.
666 667 668 669 |
# File 'lib/cloudinary/api.rb', line 666 def self.create_upload_preset(={}) params = Cloudinary::Uploader.build_upload_params(, true) call_api(:post, "upload_presets", params.merge(only(, :name, :unsigned, :disallow_public_id, :live)), ) end |
.delete_all_resources(options = {}) ⇒ Cloudinary::Api::Response
Deletes all assets of the specified asset and delivery type, including their derived assets.
Supports deleting up to a maximum of 1000 original assets in a single call.
351 352 353 354 355 356 |
# File 'lib/cloudinary/api.rb', line 351 def self.delete_all_resources(={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:delete, uri, delete_resource_params(, :all => true ), ) end |
.delete_datasource_entries(field_external_id, entries_external_id, options = {}) ⇒ Cloudinary::Api::Response
Deletes entries in a metadata single or multi-select field’s datasource.
Deletes (blocks) the datasource (list) entries from the specified metadata field definition. Sets the state of the entries to inactive. This is a soft delete. The entries still exist in the database and can be reactivated using the restoreDatasourceEntries method.
1083 1084 1085 1086 1087 1088 |
# File 'lib/cloudinary/api.rb', line 1083 def self.delete_datasource_entries(field_external_id, entries_external_id, = {}) uri = [field_external_id, "datasource"] params = {:external_ids => entries_external_id } (:delete, uri, params, ) end |
.delete_derived_by_transformation(public_ids, transformations, options = {}) ⇒ Cloudinary::Api::Response
Deletes derived assets identified by transformation and public_ids.
405 406 407 408 409 410 411 412 413 |
# File 'lib/cloudinary/api.rb', line 405 def self.delete_derived_by_transformation(public_ids, transformations, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" params = {:public_ids => public_ids}.merge(only(, :invalidate)) params[:keep_original] = true params[:transformations] = Cloudinary::Utils.build_eager(transformations) call_api(:delete, uri, params, ) end |
.delete_derived_resources(derived_resource_ids, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified derived assets by derived asset ID.
The derived asset IDs for a particular original asset are returned when calling the resource method to return the details of a single asset.
390 391 392 393 |
# File 'lib/cloudinary/api.rb', line 390 def self.delete_derived_resources(derived_resource_ids, ={}) uri = "derived_resources" call_api(:delete, uri, { :derived_resource_ids => derived_resource_ids }, ) end |
.delete_folder(path, options = {}) ⇒ Cloudinary::Api::Response
Deletes an empty folder.
The specified folder cannot contain any assets, but can have empty descendant sub-folders.
716 717 718 |
# File 'lib/cloudinary/api.rb', line 716 def self.delete_folder(path, ={}) call_api(:delete, "folders/#{path}", {}, ) end |
.delete_metadata_field(field_external_id, options = {}) ⇒ Cloudinary::Api::Response
Deletes a metadata field definition by external ID.
The external ID is immutable. Therefore, once deleted, the field’s external ID can no longer be used for future purposes.
1062 1063 1064 1065 1066 |
# File 'lib/cloudinary/api.rb', line 1062 def self.(field_external_id, = {}) uri = [field_external_id] (:delete, uri, {}, ) end |
.delete_metadata_rule(external_id, options = {}) ⇒ Cloudinary::Api::Response
Deletes a metadata rule definition by external ID.
The rule should no longer be considered a valid candidate for all other endpoints (it will not show up in the list of rules, etc).
1234 1235 1236 1237 1238 |
# File 'lib/cloudinary/api.rb', line 1234 def self.(external_id, = {}) uri = [external_id] (:delete, uri, {}, ) end |
.delete_related_assets(public_id, assets_to_unrelate, options = {}) ⇒ Cloudinary::Api::Response
Unrelates an asset from other assets by public IDs.
461 462 463 464 465 466 467 |
# File 'lib/cloudinary/api.rb', line 461 def self.(public_id, assets_to_unrelate, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/related_assets/#{resource_type}/#{type}/#{public_id}" params = {:assets_to_unrelate => Cloudinary::Utils.build_array(assets_to_unrelate)} call_api(:delete, uri, params, ) end |
.delete_related_assets_by_asset_ids(asset_id, assets_to_unrelate, options = {}) ⇒ Cloudinary::Api::Response
Unrelates an asset from other assets by asset IDs.
479 480 481 482 483 |
# File 'lib/cloudinary/api.rb', line 479 def self.(asset_id, assets_to_unrelate, ={}) uri = "resources/related_assets/#{asset_id}" params = {:assets_to_unrelate => Cloudinary::Utils.build_array(assets_to_unrelate)} call_api(:delete, uri, params, ) end |
.delete_resources(public_ids, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified assets.
311 312 313 314 315 316 |
# File 'lib/cloudinary/api.rb', line 311 def self.delete_resources(public_ids, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:delete, uri, delete_resource_params(, :public_ids => public_ids ), ) end |
.delete_resources_by_prefix(prefix, options = {}) ⇒ Cloudinary::Api::Response
Deletes assets by prefix.
Delete up to 1000 original assets, along with their derived assets, where the public ID starts with the specified prefix.
332 333 334 335 336 337 |
# File 'lib/cloudinary/api.rb', line 332 def self.delete_resources_by_prefix(prefix, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:delete, uri, delete_resource_params(, :prefix => prefix), ) end |
.delete_resources_by_tag(tag, options = {}) ⇒ Cloudinary::Api::Response
Deletes assets with the specified tag, including their derived assets.
Supports deleting up to a maximum of 1000 original assets in a single call.
Admin API documentation.
371 372 373 374 375 |
# File 'lib/cloudinary/api.rb', line 371 def self.delete_resources_by_tag(tag, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/tags/#{tag}" call_api(:delete, uri, delete_resource_params(), ) end |
.delete_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Deletes or reverts the specified streaming profile.
For custom streaming profiles, deletes the specified profile. For built-in streaming profiles, if the built-in profile was modified, reverts the profile to the original settings. For built-in streaming profiles that have not been modified, the Delete method returns an error.
876 877 878 |
# File 'lib/cloudinary/api.rb', line 876 def self.delete_streaming_profile(name, ={}) call_api(:delete, "streaming_profiles/#{name}", {}, ) end |
.delete_transformation(transformation, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified stored transformation.
Deleting a transformation also deletes all the stored derived assets based on this transformation (up to 1000). The method returns an error if there are more than 1000 derived assets based on this transformation.
550 551 552 |
# File 'lib/cloudinary/api.rb', line 550 def self.delete_transformation(transformation, ={}) call_api(:delete, "transformations", {:transformation => Cloudinary::Utils.build_eager(transformation)}, ) end |
.delete_upload_mapping(name, options = {}) ⇒ Cloudinary::Api::Response
Deletes an upload mapping.
790 791 792 |
# File 'lib/cloudinary/api.rb', line 790 def self.delete_upload_mapping(name, ={}) call_api(:delete, 'upload_mappings', { :folder => name }, ) end |
.delete_upload_preset(name, options = {}) ⇒ Cloudinary::Api::Response
Deletes the specified upload preset.
636 637 638 |
# File 'lib/cloudinary/api.rb', line 636 def self.delete_upload_preset(name, ={}) call_api(:delete, "upload_presets/#{name}", {}, ) end |
.get_breakpoints(public_id, options) ⇒ Cloudinary::Api::Response
Gets the breakpoints.
Returns breakpoints if defined, otherwise checks the cache(if configured), otherwise fall backs to static calculation.
973 974 975 976 977 978 979 980 981 982 |
# File 'lib/cloudinary/api.rb', line 973 def self.get_breakpoints(public_id, ) = .clone base_transformation = Cloudinary::Utils.generate_transformation_string() srcset = [:srcset] breakpoints = [:min_width, :max_width, :bytes_step, :max_images].map {|k| srcset[k]}.join('_') [:transformation] = [base_transformation, width: "auto:breakpoints_#{breakpoints}:json"] json_url = Cloudinary::Utils.cloudinary_url public_id, call_json_api('GET', json_url, {}, 60, {}) end |
.get_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Gets details of a single streaming profile by name.
890 891 892 |
# File 'lib/cloudinary/api.rb', line 890 def self.get_streaming_profile(name, ={}) call_api(:get, "streaming_profiles/#{name}", {}, ) end |
.list_metadata_fields(options = {}) ⇒ Cloudinary::Api::Response
Lists all metadata field definitions.
993 994 995 |
# File 'lib/cloudinary/api.rb', line 993 def self.( = {}) (:get, [], {}, ) end |
.list_metadata_rules(options = {}) ⇒ Cloudinary::Api::Response
Lists all metadata rules definitions.
1180 1181 1182 |
# File 'lib/cloudinary/api.rb', line 1180 def self.( = {}) (:get, [], {}, ) end |
.list_streaming_profiles ⇒ Cloudinary::Api::Response
Lists streaming profiles including built-in and custom profiles.
857 858 859 |
# File 'lib/cloudinary/api.rb', line 857 def self.list_streaming_profiles call_api(:get, 'streaming_profiles', {}, {}) end |
.metadata_field_by_field_id(field_external_id, options = {}) ⇒ Cloudinary::Api::Response
Gets a single metadata field definition by external ID.
1007 1008 1009 1010 1011 |
# File 'lib/cloudinary/api.rb', line 1007 def self.(field_external_id, = {}) uri = [field_external_id] (:get, uri, {}, ) end |
.ping(options = {}) ⇒ Cloudinary::Api::Response
Tests the reachability of the Cloudinary API.
13 14 15 |
# File 'lib/cloudinary/api.rb', line 13 def self.ping(={}) call_api(:get, "ping", {}, ) end |
.rename_folder(from_path, to_path, options = {}) ⇒ Cloudinary::Api::Response
Renames existing asset folder.
745 746 747 |
# File 'lib/cloudinary/api.rb', line 745 def self.rename_folder(from_path, to_path, ={}) call_api(:put, "folders/#{from_path}", {:to_folder => to_path}, ) end |
.reorder_metadata_field_datasource(field_external_id, order_by, direction = nil, options = {}) ⇒ Cloudinary::Api::Response
Reorders metadata field datasource. Currently supports only value.
1148 1149 1150 1151 1152 1153 |
# File 'lib/cloudinary/api.rb', line 1148 def self.(field_external_id, order_by, direction = nil, = {}) uri = [field_external_id, "datasource", "order"] params = { :order_by => order_by, :direction => direction } (:post, uri, params, ) end |
.reorder_metadata_fields(order_by, direction = nil, options = {}) ⇒ Cloudinary::Api::Response
Reorders metadata fields.
1164 1165 1166 1167 1168 1169 |
# File 'lib/cloudinary/api.rb', line 1164 def self.(order_by, direction = nil, = {}) uri = ["order"] params = { :order_by => order_by, :direction => direction } (:put, uri, params, ) end |
.resource(public_id, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of the specified asset and all its derived assets.
Note that if you only need details about the original asset, you can also use the Uploader::upload or Uploader::explicit methods, which return the same information and are not rate limited.
214 215 216 217 218 219 |
# File 'lib/cloudinary/api.rb', line 214 def self.resource(public_id, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}/#{public_id}" call_api(:get, uri, prepare_resource_details_params(), ) end |
.resource_by_asset_id(asset_id, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of the specified asset and all its derived assets by asset id.
Note that if you only need details about the original asset, you can also use the Uploader::upload or Uploader::explicit methods, which return the same information and are not rate limited.
233 234 235 236 |
# File 'lib/cloudinary/api.rb', line 233 def self.resource_by_asset_id(asset_id, ={}) uri = "resources/#{asset_id}" call_api(:get, uri, prepare_resource_details_params(), ) end |
.resource_types(options = {}) ⇒ Cloudinary::Api::Response
Lists all uploaded assets filtered by any specified options.
50 51 52 |
# File 'lib/cloudinary/api.rb', line 50 def self.resource_types(={}) call_api(:get, "resources", {}, ) end |
.resources(options = {}) ⇒ Cloudinary::Api::Response
Lists all uploaded assets filtered by any specified options.
see cloudinary.com/documentation/admin_api#get_resources Get all images
66 67 68 69 70 71 72 |
# File 'lib/cloudinary/api.rb', line 66 def self.resources(={}) resource_type = [:resource_type] || "image" type = [:type] uri = "resources/#{resource_type}" uri += "/#{type}" unless type.blank? call_api(:get, uri, list_resources_params().merge(only(, :prefix, :start_at)), ) end |
.resources_by_asset_folder(asset_folder, options = {}) ⇒ Cloudinary::Api::Response
Returns all assets stored directly in a specified asset folder, regardless of the public ID paths of those assets.
<a href=cloudinary.com/documentation/dynamic_folders#new_admin_api_endpoints target=“_blank”> Admin API</a> documentation.
180 181 182 183 |
# File 'lib/cloudinary/api.rb', line 180 def self.resources_by_asset_folder(asset_folder, ={}) uri = "resources/by_asset_folder" call_api(:get, uri, list_resources_params(, :asset_folder => asset_folder), ) end |
.resources_by_asset_ids(asset_ids, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified asset IDs.
<a href=cloudinary.com/documentation/admin_api#get_resources target=“_blank”> Admin API</a> documentation.
164 165 166 167 |
# File 'lib/cloudinary/api.rb', line 164 def self.resources_by_asset_ids(asset_ids, ={}) uri = "resources/by_asset_ids" call_api(:get, uri, resources_params(, :asset_ids => asset_ids), ) end |
.resources_by_context(key, value = nil, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified contextual metadata.
This method does not return matching deleted assets, even if they have been backed up.
129 130 131 132 133 |
# File 'lib/cloudinary/api.rb', line 129 def self.resources_by_context(key, value=nil, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/context" call_api(:get, uri, list_resources_params(, :key => key, :value => value), ) end |
.resources_by_ids(public_ids, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified public IDs.
146 147 148 149 150 151 |
# File 'lib/cloudinary/api.rb', line 146 def self.resources_by_ids(public_ids, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}" call_api(:get, uri, resources_params(, :public_ids => public_ids), ) end |
.resources_by_moderation(kind, status, options = {}) ⇒ Cloudinary::Api::Response
Lists assets currently in the specified moderation queue and status.
107 108 109 110 111 |
# File 'lib/cloudinary/api.rb', line 107 def self.resources_by_moderation(kind, status, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/moderations/#{kind}/#{status}" call_api(:get, uri, list_resources_params(), ) end |
.resources_by_tag(tag, options = {}) ⇒ Cloudinary::Api::Response
Lists assets with the specified tag.
This method does not return matching deleted assets, even if they have been backed up.
87 88 89 90 91 |
# File 'lib/cloudinary/api.rb', line 87 def self.resources_by_tag(tag, ={}) resource_type = [:resource_type] || "image" uri = "resources/#{resource_type}/tags/#{tag}" call_api(:get, uri, list_resources_params(), ) end |
.restore(public_ids, options = {}) ⇒ Cloudinary::Api::Response
Reverts to the latest backed up version of the specified deleted assets.
250 251 252 253 254 255 |
# File 'lib/cloudinary/api.rb', line 250 def self.restore(public_ids, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}/restore" call_api(:post, uri, { :public_ids => public_ids, :versions => [:versions] }, ) end |
.restore_metadata_field_datasource(field_external_id, entries_external_ids, options = {}) ⇒ Cloudinary::Api::Response
Restore entries in a metadata field datasource.
Restores (unblocks) any previously deleted datasource entries for a specified metadata field definition. Sets the state of the entries to active.
1131 1132 1133 1134 1135 1136 |
# File 'lib/cloudinary/api.rb', line 1131 def self.(field_external_id, entries_external_ids, = {}) uri = [field_external_id, "datasource_restore"] params = {:external_ids => entries_external_ids } (:post, uri, params, ) end |
.root_folders(options = {}) ⇒ Cloudinary::Api::Response
Lists all root folders.
681 682 683 684 |
# File 'lib/cloudinary/api.rb', line 681 def self.root_folders(={}) params = only(, :max_results, :next_cursor) call_api(:get, "folders", params, ) end |
.subfolders(of_folder_path, options = {}) ⇒ Cloudinary::Api::Response
Lists sub-folders.
Returns the name and path of all the sub-folders of a specified parent folder. Limited to 2000 results.
699 700 701 702 |
# File 'lib/cloudinary/api.rb', line 699 def self.subfolders(of_folder_path, ={}) params = only(, :max_results, :next_cursor) call_api(:get, "folders/#{of_folder_path}", params, ) end |
.tags(options = {}) ⇒ Cloudinary::Api::Response
Lists all the tags currently used for a specified asset type.
495 496 497 498 499 |
# File 'lib/cloudinary/api.rb', line 495 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 = {}) ⇒ Cloudinary::Api::Response
Returns the details of a single transformation.
528 529 530 531 532 |
# File 'lib/cloudinary/api.rb', line 528 def self.transformation(transformation, ={}) params = only(, :next_cursor, :max_results) params[:transformation] = Cloudinary::Utils.build_eager(transformation) call_api(:get, "transformations", params, ) end |
.transformations(options = {}) ⇒ Cloudinary::Api::Response
Lists stored transformations.
511 512 513 |
# File 'lib/cloudinary/api.rb', line 511 def self.transformations(={}) call_api(:get, "transformations", only(, :named, :next_cursor, :max_results), ) end |
.update(public_id, options = {}) ⇒ Cloudinary::Api::Response
Updates details of an existing asset.
Update one or more of the attributes associated with a specified asset. Note that you can also update most attributes of an existing asset using the Uploader::explicit method, which is not rate limited.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/cloudinary/api.rb', line 271 def self.update(public_id, ={}) resource_type = [:resource_type] || "image" type = [:type] || "upload" uri = "resources/#{resource_type}/#{type}/#{public_id}" = { :access_control => Cloudinary::Utils.json_array_param([:access_control]), :asset_folder => [:asset_folder], :auto_tagging => [:auto_tagging] && [:auto_tagging].to_f, :background_removal => [:background_removal], :categorization => [:categorization], :context => Cloudinary::Utils.encode_context([:context]), :custom_coordinates => Cloudinary::Utils.encode_double_array([:custom_coordinates]), :detection => [:detection], :display_name => [:display_name], :face_coordinates => Cloudinary::Utils.encode_double_array([:face_coordinates]), :metadata => Cloudinary::Utils.encode_context([:metadata]), :moderation_status => [:moderation_status], :notification_url => [:notification_url], :quality_override => [:quality_override], :ocr => [:ocr], :raw_convert => [:raw_convert], :similarity_search => [:similarity_search], :tags => [:tags] && Cloudinary::Utils.build_array([:tags]).join(","), :clear_invalid => Cloudinary::Utils.as_safe_bool([:clear_invalid]), :unique_display_name=> [:unique_display_name] } call_api(:post, uri, , ) end |
.update_metadata_field(field_external_id, field, options = {}) ⇒ Cloudinary::Api::Response
Updates a metadata field by external ID.
Updates a metadata field definition (partially, no need to pass the entire object) passed as JSON data.
1042 1043 1044 1045 1046 1047 |
# File 'lib/cloudinary/api.rb', line 1042 def self.(field_external_id, field, = {}) uri = [field_external_id] params = only(field, :label, :mandatory, :default_value, :validation) (:put, uri, params, ) end |
.update_metadata_field_datasource(field_external_id, entries_external_id, options = {}) ⇒ Cloudinary::Api::Response
Updates a metadata field datasource.
Updates the datasource of a supported field type (currently enum or set), passed as JSON data. The update is partial: datasource entries with an existing external_id will be updated and entries with new external_id’s (or without external_id’s) will be appended.
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
# File 'lib/cloudinary/api.rb', line 1106 def self.(field_external_id, entries_external_id, = {}) uri = [field_external_id, "datasource"] params = entries_external_id.each_with_object({:values => [] }) do |item, hash| item = only(item, :external_id, :value) hash[:values ] << item if item.present? end (:put, uri, params, ) end |
.update_metadata_rule(external_id, rule, options = {}) ⇒ Cloudinary::Api::Response
Updates a metadata rule by external ID.
Updates an existing metadata rule definition. Expects a JSON object which defines the updated rule.
1214 1215 1216 1217 1218 1219 |
# File 'lib/cloudinary/api.rb', line 1214 def self.(external_id, rule, = {}) uri = [external_id] params = only(rule, :metadata_field_id, :condition, :result, :name, :state) (:put, uri, params, ) end |
.update_resources_access_mode_by_ids(access_mode, public_ids, options = {}) ⇒ Cloudinary::Api::Response
Update resources access mode. Resources are selected by the provided public_ids.
956 957 958 |
# File 'lib/cloudinary/api.rb', line 956 def self.update_resources_access_mode_by_ids(access_mode, public_ids, = {}) update_resources_access_mode(access_mode, :public_ids, public_ids, ) end |
.update_resources_access_mode_by_prefix(access_mode, prefix, options = {}) ⇒ Cloudinary::Api::Response
Update resources access mode. Resources are selected by the prefix.
926 927 928 |
# File 'lib/cloudinary/api.rb', line 926 def self.update_resources_access_mode_by_prefix(access_mode, prefix, = {}) update_resources_access_mode(access_mode, :prefix, prefix, ) end |
.update_resources_access_mode_by_tag(access_mode, tag, options = {}) ⇒ Cloudinary::Api::Response
Update resources access mode. Resources are selected by the tag.
941 942 943 |
# File 'lib/cloudinary/api.rb', line 941 def self.update_resources_access_mode_by_tag(access_mode, tag, = {}) update_resources_access_mode(access_mode, :tag, tag, ) end |
.update_streaming_profile(name, options = {}) ⇒ Cloudinary::Api::Response
Updates an existing streaming profile.
You can update both custom and built-in profiles. The specified list of representations replaces the previous list.
Admin API documentation.
907 908 909 910 911 912 913 |
# File 'lib/cloudinary/api.rb', line 907 def self.update_streaming_profile(name, ={}) params = only(, :display_name, :representations) params[:representations] = params[:representations].map do |r| {:transformation => Cloudinary::Utils.generate_transformation_string(r[:transformation])} end.to_json call_api(:put, "streaming_profiles/#{name}", params, ) end |
.update_transformation(transformation, updates, options = {}) ⇒ Cloudinary::Api::Response
Updates the specified transformation.
568 569 570 571 572 573 |
# File 'lib/cloudinary/api.rb', line 568 def self.update_transformation(transformation, updates, ={}) params = only(updates, :allowed_for_strict) params[:unsafe_update] = Cloudinary::Utils.build_eager(updates[:unsafe_update]) if updates[:unsafe_update] params[:transformation] = Cloudinary::Utils.build_eager(transformation) call_api(:put, "transformations", params, ) end |
.update_upload_mapping(name, options = {}) ⇒ Cloudinary::Api::Response
Updates an existing upload mapping with a new template (URL).
805 806 807 808 809 |
# File 'lib/cloudinary/api.rb', line 805 def self.update_upload_mapping(name, ={}) params = only(, :template) params[:folder] = name call_api(:put, 'upload_mappings', params, ) end |
.update_upload_preset(name, options = {}) ⇒ Cloudinary::Api::Response
Updates the specified upload preset.
Admin API documentation.
651 652 653 654 |
# File 'lib/cloudinary/api.rb', line 651 def self.update_upload_preset(name, ={}) params = Cloudinary::Uploader.build_upload_params(, true) call_api(:put, "upload_presets/#{name}", params.merge(only(, :unsigned, :disallow_public_id, :live)), ) end |
.upload_mapping(name = nil, options = {}) ⇒ Cloudinary::Api::Response
Returns the details of the specified upload mapping.
Retrieve the mapped template (URL) of a specified upload mapping folder.
776 777 778 |
# File 'lib/cloudinary/api.rb', line 776 def self.upload_mapping(name=nil, ={}) call_api(:get, 'upload_mappings', { :folder => name }, ) end |
.upload_mappings(options = {}) ⇒ Cloudinary::Api::Response
Lists upload mappings by folder and its mapped template (URL).
759 760 761 762 |
# File 'lib/cloudinary/api.rb', line 759 def self.upload_mappings(={}) params = only(, :next_cursor, :max_results) call_api(:get, :upload_mappings, params, ) end |
.upload_preset(name, options = {}) ⇒ Cloudinary::Api::Response
Retrieves the details of the specified upload preset.
622 623 624 |
# File 'lib/cloudinary/api.rb', line 622 def self.upload_preset(name, ={}) call_api(:get, "upload_presets/#{name}", only(, :max_results), ) end |
.upload_presets(options = {}) ⇒ Cloudinary::Api::Response
Lists existing upload presets.
606 607 608 |
# File 'lib/cloudinary/api.rb', line 606 def self.upload_presets(={}) call_api(:get, "upload_presets", only(, :next_cursor, :max_results), ) end |
.usage(options = {}) ⇒ Cloudinary::Api::Response
Gets cloud usage details.
Returns a report detailing your current Cloudinary cloud usage details, including storage, bandwidth, requests, number of assets, and add-on usage. Note that numbers are updated periodically.
31 32 33 34 35 36 37 38 |
# File 'lib/cloudinary/api.rb', line 31 def self.usage(={}) uri = 'usage' date = [:date] uri += "/#{Cloudinary::Utils.to_usage_api_date_format(date)}" unless date.nil? call_api(:get, uri, {}, ) end |
.visual_search(options = {}) ⇒ Cloudinary::Api::Response
Find images based on their visual content.
192 193 194 195 196 197 |
# File 'lib/cloudinary/api.rb', line 192 def self.visual_search( = {}) uri = "resources/visual_search" params = only(, :image_url, :image_asset_id, :text, :image_file) params[:image_file] = Cloudinary::Utils.handle_file_param(params[:image_file]) if params.has_key?(:image_file) call_api(:post, uri, params, ) end |