listBucketInventory.ts 1017 B

12345678910111213141516171819202122232425262728
  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({ inventory: '' }, continuationToken && { 'continuation-token': continuationToken }, options.subres);
  12. checkBucketName(bucketName);
  13. const params = this._bucketRequestParams('GET', bucketName, subres, options);
  14. params.successStatuses = [200];
  15. params.xmlResponse = true;
  16. const result = await this.request(params);
  17. const { data, res, status } = result;
  18. return {
  19. isTruncated: data.IsTruncated === 'true',
  20. nextContinuationToken: data.NextContinuationToken,
  21. inventoryList: formatInventoryConfig(data.InventoryConfiguration, true),
  22. status,
  23. res,
  24. };
  25. }