Skip to content

Commit 40941ec

Browse files
authored
Add rename folder api support
1 parent f09aacb commit 40941ec

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

cloudinary-core/src/main/java/com/cloudinary/Api.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,18 @@ public ApiResponse analyze(String inputType, String analysisType, String uri, Ma
790790
return callApi(HttpMethod.POST, url, params, options);
791791
}
792792

793+
public ApiResponse renameFolder(String path, String toPath, Map options) throws Exception {
794+
if (options == null || options.isEmpty()) options = ObjectUtils.asMap();
795+
List<String> url = Arrays.asList("folder_operations", "rename");
796+
797+
final Map params = new HashMap();
798+
params.put("path", path);
799+
params.put("to_path", toPath);
800+
801+
return callApi(HttpMethod.PUT, url, params, options);
802+
803+
}
804+
793805
private Map<String, ?> extractParams(Map options, List<String> keys) {
794806
Map<String, Object> result = new HashMap<String, Object>();
795807
for (String key : keys) {

cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractApiTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,4 +1267,15 @@ public void testVisualSearch() {
12671267
Util.processWriteParameters(options, params);
12681268
assertEquals(true, params.get("visual_search"));
12691269
}
1270+
1271+
@Test
1272+
@Ignore("Skip test till FD is enabled for test accounts")
1273+
public void testRenameFolder() throws Exception {
1274+
Map result = api.createFolder("apTestCreateFolder", null);
1275+
assertNotNull(result);
1276+
1277+
String folderName = (String) result.get("path");
1278+
Map response = api.renameFolder(folderName, "newFolderName", ObjectUtils.emptyMap());
1279+
assertNotNull(response);
1280+
}
12701281
}

0 commit comments

Comments
 (0)