Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.listDatabaseInstances = void 0;
  4. const api_1 = require("../api");
  5. const apiv2_1 = require("../apiv2");
  6. const logger_1 = require("../logger");
  7. const utils = require("../utils");
  8. function _handleErrorResponse(response) {
  9. if (response.body && response.body.error) {
  10. return utils.reject(response.body.error, { code: 2 });
  11. }
  12. logger_1.logger.debug("[firedata] error:", response.status, response.body);
  13. return utils.reject("Unexpected error encountered with FireData.", {
  14. code: 2,
  15. });
  16. }
  17. async function listDatabaseInstances(projectNumber) {
  18. const client = new apiv2_1.Client({ urlPrefix: api_1.firedataOrigin, apiVersion: "v1" });
  19. const response = await client.get(`/projects/${projectNumber}/databases`, {
  20. resolveOnHTTPError: true,
  21. });
  22. if (response.status === 200) {
  23. return response.body.instance;
  24. }
  25. return _handleErrorResponse(response);
  26. }
  27. exports.listDatabaseInstances = listDatabaseInstances;