Skip to content

Commit 91701d0

Browse files
Add support for rename_folder Admin API
1 parent d36b7dc commit 91701d0

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lib/cloudinary/api.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,21 @@ def self.create_folder(folder_name, options={})
731731
call_api(:post, "folders/#{folder_name}", {}, options)
732732
end
733733

734+
# Renames existing asset folder.
735+
#
736+
# @param [String] from_path The full path of an existing asset folder.
737+
# @param [String] to_path The full path of the new asset folder.
738+
# @param [Hash] options The optional parameters.
739+
#
740+
# @return [Cloudinary::Api::Response]
741+
#
742+
# @raise [Cloudinary::Api::Error]
743+
#
744+
# @see https://cloudinary.com/documentation/admin_api#rename_folder
745+
def self.rename_folder(from_path, to_path, options={})
746+
call_api(:put, "folders/#{from_path}", {:to_folder => to_path}, options)
747+
end
748+
734749
# Lists upload mappings by folder and its mapped template (URL).
735750
#
736751
# @param [Hash] options The optional parameters. See the

spec/api_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,15 @@
741741
res = @mock_api.create_folder(UNIQUE_TEST_FOLDER)
742742
expect(res).to have_deep_hash_values_of(expected)
743743
end
744+
it 'should rename folder' do
745+
expected = {
746+
[:url] => /.*\/folders\/#{UNIQUE_TEST_FOLDER}$/,
747+
[:method] => :put,
748+
[:payload, :to_folder] => UNIQUE_TEST_FOLDER + "_new",
749+
}
750+
res = @mock_api.rename_folder(UNIQUE_TEST_FOLDER, UNIQUE_TEST_FOLDER + "_new")
751+
expect(res).to have_deep_hash_values_of(expected)
752+
end
744753
it "should support listing folders" do
745754
res = @mock_api.root_folders
746755
expect(res).to have_deep_hash_values_of([:url] => /.*\/folders$/, [:method] => :get)

0 commit comments

Comments
 (0)