diff --git a/lib/api.js b/lib/api.js index 5e5fdfe7..f6234245 100644 --- a/lib/api.js +++ b/lib/api.js @@ -150,6 +150,12 @@ exports.delete_resources = function delete_resources(public_ids, callback, optio }), callback, options); }; +exports.delete_resources_by_asset_ids = function delete_resources_by_asset_ids(asset_ids, callback, options = {}) { + return call_api("delete", "resources", deleteResourcesParams(options, { + "asset_ids[]": asset_ids + }), callback, options); +}; + exports.delete_resources_by_prefix = function delete_resources_by_prefix(prefix, callback, options = {}) { let resource_type, type, uri; resource_type = options.resource_type || "image"; diff --git a/test/integration/api/admin/api_spec.js b/test/integration/api/admin/api_spec.js index 227026c1..3bdf2f47 100644 --- a/test/integration/api/admin/api_spec.js +++ b/test/integration/api/admin/api_spec.js @@ -582,6 +582,26 @@ describe("api", function () { expect(error.http_code).to.eql(404); }); }); + it.only("should allow deleting resources by asset_ids", function () { + this.timeout(TIMEOUT.MEDIUM); + return uploadImage({ + public_id: PUBLIC_ID_3, + tags: UPLOAD_TAGS + }).then( + () => cloudinary.v2.api.resource(PUBLIC_ID_3) + ).then(function (resource) { + expect(resource).not.to.eql(void 0); + console.log(resource); + return cloudinary.v2.api.delete_resources_by_asset_ids([resource.asset_id]); + }).then( + () => cloudinary.v2.api.resource(PUBLIC_ID_3) + ).then(() => { + expect().fail(); + }).catch(function ({error}) { + expect(error).to.be.an(Object); + expect(error.http_code).to.eql(404); + }); + }); describe("delete_resources_by_prefix", function () { callReusableTest("accepts next_cursor", cloudinary.v2.api.delete_resources_by_prefix, "prefix_foobar"); return it("should allow deleting resources by prefix", function () {