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.
-
.config(options = {}) ⇒ Cloudinary::Api::Response
Retrieves account configuration details.
-
.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.
-
.prepare_metadata_field_params(field) ⇒ Object
Prepares optional parameters for add/update_metadata_field API calls.
-
.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.
1039 1040 1041 |
# File 'lib/cloudinary/api.rb', line 1039 def self.(field, = {}) (:post, [], (field), ) end |
.add_metadata_rule(rule, options = {}) ⇒ Cloudinary::Api::Response
Creates a new metadata rule definition.
1218 1219 1220 1221 1222 |
# File 'lib/cloudinary/api.rb', line 1218 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.
442 443 444 445 446 447 448 |
# File 'lib/cloudinary/api.rb', line 442 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.
460 461 462 463 464 |
# File 'lib/cloudinary/api.rb', line 460 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.
1272 1273 1274 1275 1276 1277 1278 1279 1280 |
# File 'lib/cloudinary/api.rb', line 1272 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 |
.config(options = {}) ⇒ Cloudinary::Api::Response
Retrieves account configuration details.
26 27 28 29 30 31 |
# File 'lib/cloudinary/api.rb', line 26 def self.config(={}) uri = "config" params = only(, :settings) call_api(:get, uri, params, ) end |
.create_folder(folder_name, options = {}) ⇒ Cloudinary::Api::Response
Creates a new empty folder.
746 747 748 |
# File 'lib/cloudinary/api.rb', line 746 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.
857 858 859 860 861 862 863 864 |
# File 'lib/cloudinary/api.rb', line 857 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.
603 604 605 606 607 608 609 610 |
# File 'lib/cloudinary/api.rb', line 603 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.
838 839 840 841 842 |
# File 'lib/cloudinary/api.rb', line 838 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.
682 683 684 685 |
# File 'lib/cloudinary/api.rb', line 682 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.
367 368 369 370 371 372 |
# File 'lib/cloudinary/api.rb', line 367 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.
1106 1107 1108 1109 1110 1111 |
# File 'lib/cloudinary/api.rb', line 1106 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.
421 422 423 424 425 426 427 428 429 |
# File 'lib/cloudinary/api.rb', line 421 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.
406 407 408 409 |
# File 'lib/cloudinary/api.rb', line 406 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.
732 733 734 |
# File 'lib/cloudinary/api.rb', line 732 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.
1085 1086 1087 1088 1089 |
# File 'lib/cloudinary/api.rb', line 1085 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).
1257 1258 1259 1260 1261 |
# File 'lib/cloudinary/api.rb', line 1257 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.
477 478 479 480 481 482 483 |
# File 'lib/cloudinary/api.rb', line 477 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.
495 496 497 498 499 |
# File 'lib/cloudinary/api.rb', line 495 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.
327 328 329 330 331 332 |
# File 'lib/cloudinary/api.rb', line 327 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.
348 349 350 351 352 353 |
# File 'lib/cloudinary/api.rb', line 348 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.
387 388 389 390 391 |
# File 'lib/cloudinary/api.rb', line 387 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.
892 893 894 |
# File 'lib/cloudinary/api.rb', line 892 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.
566 567 568 |
# File 'lib/cloudinary/api.rb', line 566 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.
806 807 808 |
# File 'lib/cloudinary/api.rb', line 806 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.
652 653 654 |
# File 'lib/cloudinary/api.rb', line 652 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.
989 990 991 992 993 994 995 996 997 998 |
# File 'lib/cloudinary/api.rb', line 989 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.
906 907 908 |
# File 'lib/cloudinary/api.rb', line 906 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.
1009 1010 1011 |
# File 'lib/cloudinary/api.rb', line 1009 def self.( = {}) (:get, [], {}, ) end |
.list_metadata_rules(options = {}) ⇒ Cloudinary::Api::Response
Lists all metadata rules definitions.
1203 1204 1205 |
# File 'lib/cloudinary/api.rb', line 1203 def self.( = {}) (:get, [], {}, ) end |
.list_streaming_profiles ⇒ Cloudinary::Api::Response
Lists streaming profiles including built-in and custom profiles.
873 874 875 |
# File 'lib/cloudinary/api.rb', line 873 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.
1023 1024 1025 1026 1027 |
# File 'lib/cloudinary/api.rb', line 1023 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 |
.prepare_metadata_field_params(field) ⇒ Object
Prepares optional parameters for add/update_metadata_field API calls.
1065 1066 1067 1068 1069 1070 |
# File 'lib/cloudinary/api.rb', line 1065 def self.(field) only(field, :type, :external_id, :label, :mandatory, :restrictions, :default_value, :default_disabled, :validation, :datasource, :allow_dynamic_list_values ) end |
.rename_folder(from_path, to_path, options = {}) ⇒ Cloudinary::Api::Response
Renames existing asset folder.
761 762 763 |
# File 'lib/cloudinary/api.rb', line 761 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.
1171 1172 1173 1174 1175 1176 |
# File 'lib/cloudinary/api.rb', line 1171 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.
1187 1188 1189 1190 1191 1192 |
# File 'lib/cloudinary/api.rb', line 1187 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.
230 231 232 233 234 235 |
# File 'lib/cloudinary/api.rb', line 230 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.
249 250 251 252 |
# File 'lib/cloudinary/api.rb', line 249 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.
66 67 68 |
# File 'lib/cloudinary/api.rb', line 66 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
82 83 84 85 86 87 88 |
# File 'lib/cloudinary/api.rb', line 82 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.
196 197 198 199 |
# File 'lib/cloudinary/api.rb', line 196 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.
180 181 182 183 |
# File 'lib/cloudinary/api.rb', line 180 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.
145 146 147 148 149 |
# File 'lib/cloudinary/api.rb', line 145 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.
162 163 164 165 166 167 |
# File 'lib/cloudinary/api.rb', line 162 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.
123 124 125 126 127 |
# File 'lib/cloudinary/api.rb', line 123 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.
103 104 105 106 107 |
# File 'lib/cloudinary/api.rb', line 103 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.
266 267 268 269 270 271 |
# File 'lib/cloudinary/api.rb', line 266 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.
1154 1155 1156 1157 1158 1159 |
# File 'lib/cloudinary/api.rb', line 1154 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.
697 698 699 700 |
# File 'lib/cloudinary/api.rb', line 697 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.
715 716 717 718 |
# File 'lib/cloudinary/api.rb', line 715 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.
511 512 513 514 515 |
# File 'lib/cloudinary/api.rb', line 511 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.
544 545 546 547 548 |
# File 'lib/cloudinary/api.rb', line 544 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.
527 528 529 |
# File 'lib/cloudinary/api.rb', line 527 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.
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/cloudinary/api.rb', line 287 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.
1056 1057 1058 1059 1060 |
# File 'lib/cloudinary/api.rb', line 1056 def self.(field_external_id, field, = {}) uri = [field_external_id] (:put, uri, (field), ) 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.
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 |
# File 'lib/cloudinary/api.rb', line 1129 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.
1237 1238 1239 1240 1241 1242 |
# File 'lib/cloudinary/api.rb', line 1237 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.
972 973 974 |
# File 'lib/cloudinary/api.rb', line 972 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.
942 943 944 |
# File 'lib/cloudinary/api.rb', line 942 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.
957 958 959 |
# File 'lib/cloudinary/api.rb', line 957 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.
923 924 925 926 927 928 929 |
# File 'lib/cloudinary/api.rb', line 923 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.
584 585 586 587 588 589 |
# File 'lib/cloudinary/api.rb', line 584 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).
821 822 823 824 825 |
# File 'lib/cloudinary/api.rb', line 821 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.
667 668 669 670 |
# File 'lib/cloudinary/api.rb', line 667 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.
792 793 794 |
# File 'lib/cloudinary/api.rb', line 792 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).
775 776 777 778 |
# File 'lib/cloudinary/api.rb', line 775 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.
638 639 640 |
# File 'lib/cloudinary/api.rb', line 638 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.
622 623 624 |
# File 'lib/cloudinary/api.rb', line 622 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.
47 48 49 50 51 52 53 54 |
# File 'lib/cloudinary/api.rb', line 47 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.
208 209 210 211 212 213 |
# File 'lib/cloudinary/api.rb', line 208 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 |