Skip to content
Open
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
35 changes: 35 additions & 0 deletions javascript/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,41 @@ ee.data.getAssetAcl = function(assetId, opt_callback) {
};


/**
* Tests whether the caller has the specified permissions on a Cloud asset ID.
* If the asset ID does not exist, this will return an empty object, not a
* NOT_FOUND error.
*
* Example permissions:
*
* - earthengine.assets.create
* - earthengine.assets.delete
* - earthengine.assets.get
* - earthengine.assets.getIamPolicy
* - earthengine.assets.list
* - earthengine.assets.setIamPolicy
* - earthengine.assets.update
*
* @param {string} assetId The ID of the Cloud asset to check (e.g.
* projects/project-id/assets/asset-id).
* @param {!Array<string>} permissions The list of permissions to check on the
* asset.
* @param {function(?ee.api.TestIamPermissionsResponse, string=)=} opt_callback
* An optional callback with two parameters: the response object containing
* "permissions" or empty if none found, and an error message. If not
* supplied, the call is made synchronously.
* @return {?ee.api.TestIamPermissionsResponse}
* @export
*/
ee.data.testIamPermissions = function(assetId, permissions, opt_callback) {
const resource = ee.rpc_convert.assetIdToAssetName(assetId);
const request = new ee.api.TestIamPermissionsRequest({permissions});
const call = new ee.apiclient.Call(opt_callback);
return call.handle(call.assets().testIamPermissions(
resource, request, {prettyPrint: false}));
};


/**
* Returns the access control list of the asset with the given ID.
*
Expand Down
Loading