Skip to content

Commit 45a218a

Browse files
authored
Add skip backup parameter to delete folder api
1 parent a9e77cd commit 45a218a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,10 @@ public ApiResponse updateResourcesAccessModeByTag(String accessMode, String tag,
660660
* @throws Exception When the folder isn't empty or doesn't exist.
661661
*/
662662
public ApiResponse deleteFolder(String folder, Map options) throws Exception {
663+
if (options == null || options.isEmpty()) options = ObjectUtils.asMap();
663664
List<String> uri = Arrays.asList("folders", folder);
664-
return callApi(HttpMethod.DELETE, uri, Collections.<String, Object>emptyMap(), options);
665+
Map params = ObjectUtils.only(options, "skip_backup");
666+
return callApi(HttpMethod.DELETE, uri, params, options);
665667
}
666668

667669
/**

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,17 @@ public void testSubFolderWithParams() throws Exception {
8585
ApiResponse result = api.deleteFolder(rootFolderName, null);
8686
assertTrue(((List) result.get("deleted")).contains(rootFolderName));
8787
}
88+
89+
@Test
90+
public void testDeleteFolderWithSkipBackup() throws Exception {
91+
//Create
92+
String rootFolderName = "deleteFolderWithSkipBackup" + SUFFIX;
93+
assertTrue((Boolean) api.createFolder(rootFolderName, null).get("success"));
94+
95+
//Delete
96+
ApiResponse result = api.deleteFolder(rootFolderName, ObjectUtils.asMap("skip_backup", "true"));
97+
assertTrue(((List) result.get("deleted")).contains(rootFolderName));
98+
99+
100+
}
88101
}

0 commit comments

Comments
 (0)