Skip to content

Commit 65fd1e3

Browse files
authored
Get the details of a single resource by asset_id
1 parent c287a62 commit 65fd1e3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ public ApiResponse resourcesByContext(String key, String value, Map options) thr
115115
return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, "context"), params, options);
116116
}
117117

118+
public ApiResponse resourceByAssetID(String assetId, Map options) throws Exception {
119+
if (options == null) options = ObjectUtils.emptyMap();
120+
Map params = ObjectUtils.only(options, "tags", "context", "moderations");
121+
ApiResponse response = callApi(HttpMethod.GET, Arrays.asList("resources", assetId), params, options);
122+
return response;
123+
}
118124
public ApiResponse resourcesByAssetIDs(Iterable<String> assetIds, Map options) throws Exception {
119125
if (options == null) options = ObjectUtils.emptyMap();
120126
Map params = ObjectUtils.only(options, "public_ids", "tags", "context", "moderations");

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ public void testResourcesByAssetIds() throws Exception {
280280
assertNotNull(findByAttr(resources, "public_id", API_TEST_1));
281281
}
282282

283+
@Test
284+
public void testResourceByAssetId() throws Exception {
285+
Map result = api.resourceByAssetID(assetId1, ObjectUtils.asMap("tags", true, "context", true));
286+
assertEquals(API_TEST, result.get("public_id").toString());
287+
}
288+
283289
@Test
284290
public void testResourcesByPublicIds() throws Exception {
285291
// should allow listing resources by public ids

0 commit comments

Comments
 (0)