listBucketInventory.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import { checkBucketName } from '../utils/checkBucketName';
  2. import { formatInventoryConfig } from '../utils/formatInventoryConfig';
  3. /**
  4. * listBucketInventory
  5. * @param {String} bucketName - bucket name
  6. * @param {String} inventoryId
  7. * @param {Object} options
  8. */
  9. export async function listBucketInventory(this: any, bucketName: string, options: any = {}) {
  10. const { continuationToken } = options;
  11. const subres: any = Object.assign(
  12. { inventory: '' },
  13. continuationToken && { 'continuation-token': continuationToken },
  14. options.subres
  15. );
  16. checkBucketName(bucketName);
  17. const params = this._bucketRequestParams('GET', bucketName, subres, options);
  18. params.successStatuses = [200];
  19. params.xmlResponse = true;
  20. const result = await this.request(params);
  21. const { data, res, status } = result;
  22. return {
  23. isTruncated: data.IsTruncated === 'true',
  24. nextContinuationToken: data.NextContinuationToken,
  25. inventoryList: formatInventoryConfig(data.InventoryConfiguration, true),
  26. status,
  27. res
  28. };
  29. }