Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cloudinary-core/src/main/java/com/cloudinary/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,18 @@ public ApiResponse deleteDatasourceEntries(String fieldExternalId, List<String>
return callApi(HttpMethod.DELETE, uri, Collections.singletonMap("external_ids", entriesExternalId), Collections.emptyMap());
}

/**
* Restore deleted data source entries for a given field
* @param fieldExternalId The id of the field to operate
* @param entriesExternalId The ids of all the entries to restore from the data source
* @return The datasource entries state after restore
* @throws Exception
*/
public ApiResponse restoreDatasourceEntries(String fieldExternalId, List<String> entriesExternalId) throws Exception {
List<String> uri = Arrays.asList("metadata_fields", fieldExternalId, "datasource_restore");
return callApi(HttpMethod.POST, uri, Collections.singletonMap("external_ids", entriesExternalId), Collections.singletonMap("content_type", "json"));
}

/**
* Delete a field definition.
* @param fieldExternalId The id of the field to delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ public void testDeleteDatasourceEntries() throws Exception {
assertNotNull(result);
}

@Test
public void testRestoreDatasourceEntries() throws Exception {
SetMetadataField setField = createSetField("testRestoreDatasourceEntries");
ApiResponse fieldResult = addFieldToAccount(setField);
String fieldExternalId = fieldResult.get("external_id").toString();
api.deleteDatasourceEntries(fieldExternalId, Collections.singletonList("id1"));
ApiResponse result = api.restoreDatasourceEntries(fieldExternalId, Collections.singletonList("id1"));
assertNotNull(result);
}

@Test
public void testUploadWithMetadata() throws Exception {
StringMetadataField field = newFieldInstance("testUploadWithMetadata");
Expand Down