getACL.js 736 B

123456789101112131415161718192021222324252627282930
  1. const proto = exports;
  2. /*
  3. * Get object's ACL
  4. * @param {String} name the object key
  5. * @param {Object} options
  6. * @return {Object}
  7. */
  8. proto.getACL = async function getACL(name, options = {}) {
  9. options.subres = Object.assign({ acl: '' }, options.subres);
  10. if (options.versionId) {
  11. options.subres.versionId = options.versionId;
  12. }
  13. name = this._objectName(name);
  14. const params = this._objectRequestParams('GET', name, options);
  15. params.successStatuses = [200];
  16. params.xmlResponse = true;
  17. const result = await this.request(params);
  18. return {
  19. acl: result.data.AccessControlList.Grant,
  20. owner: {
  21. id: result.data.Owner.ID,
  22. displayName: result.data.Owner.DisplayName
  23. },
  24. res: result.res
  25. };
  26. };