Нема описа
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.

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.listBillingAccounts = exports.setBillingAccount = exports.checkBillingEnabled = void 0;
  4. const api_1 = require("../api");
  5. const apiv2_1 = require("../apiv2");
  6. const utils = require("../utils");
  7. const API_VERSION = "v1";
  8. const client = new apiv2_1.Client({ urlPrefix: api_1.cloudbillingOrigin, apiVersion: API_VERSION });
  9. async function checkBillingEnabled(projectId) {
  10. const res = await client.get(utils.endpoint(["projects", projectId, "billingInfo"]), { retryCodes: [500, 503] });
  11. return res.body.billingEnabled;
  12. }
  13. exports.checkBillingEnabled = checkBillingEnabled;
  14. async function setBillingAccount(projectId, billingAccountName) {
  15. const res = await client.put(utils.endpoint(["projects", projectId, "billingInfo"]), {
  16. billingAccountName: billingAccountName,
  17. }, { retryCodes: [500, 503] });
  18. return res.body.billingEnabled;
  19. }
  20. exports.setBillingAccount = setBillingAccount;
  21. async function listBillingAccounts() {
  22. const res = await client.get(utils.endpoint(["billingAccounts"]), { retryCodes: [500, 503] });
  23. return res.body.billingAccounts || [];
  24. }
  25. exports.listBillingAccounts = listBillingAccounts;