getBucketInventory.ts 801 B

123456789101112131415161718192021222324
  1. import { checkBucketName } from '../utils/checkBucketName';
  2. import { formatInventoryConfig } from '../utils/formatInventoryConfig';
  3. /**
  4. * getBucketInventory
  5. * @param {String} bucketName - bucket name
  6. * @param {String} inventoryId
  7. * @param {Object} options
  8. */
  9. export async function getBucketInventory(this: any, bucketName: string, inventoryId: string, options: any = {}) {
  10. const subres: any = Object.assign({ inventory: '', inventoryId }, options.subres);
  11. checkBucketName(bucketName);
  12. const params = this._bucketRequestParams('GET', bucketName, subres, options);
  13. params.successStatuses = [200];
  14. params.xmlResponse = true;
  15. const result = await this.request(params);
  16. return {
  17. status: result.status,
  18. res: result.res,
  19. inventory: formatInventoryConfig(result.data)
  20. };
  21. }