Ingen beskrivning
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

pubsub.js 1.0KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.deleteTopic = exports.updateTopic = exports.getTopic = exports.createTopic = void 0;
  4. const apiv2_1 = require("../apiv2");
  5. const api_1 = require("../api");
  6. const proto = require("./proto");
  7. const API_VERSION = "v1";
  8. const client = new apiv2_1.Client({
  9. urlPrefix: api_1.pubsubOrigin,
  10. auth: true,
  11. apiVersion: API_VERSION,
  12. });
  13. async function createTopic(topic) {
  14. const result = await client.put(topic.name, topic);
  15. return result.body;
  16. }
  17. exports.createTopic = createTopic;
  18. async function getTopic(name) {
  19. const result = await client.get(name);
  20. return result.body;
  21. }
  22. exports.getTopic = getTopic;
  23. async function updateTopic(topic) {
  24. const queryParams = {
  25. updateMask: proto.fieldMasks(topic).join(","),
  26. };
  27. const result = await client.patch(topic.name, topic, { queryParams });
  28. return result.body;
  29. }
  30. exports.updateTopic = updateTopic;
  31. async function deleteTopic(name) {
  32. await client.delete(name);
  33. }
  34. exports.deleteTopic = deleteTopic;