@mindconnect/mindconnect-nodejs
Version:
NodeJS Library for Siemens Insights Hub Connectivity - TypeScript SDK for Insights Hub and Industrial IoT - Command Line Interface - Insights Hub Development Proxy (Siemens Insights Hub was formerly known as MindSphere)
135 lines • 5.09 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageBrokerClient = void 0;
const sdk_client_1 = require("../common/sdk-client");
class MessageBrokerClient extends sdk_client_1.SdkClient {
constructor() {
super(...arguments);
this._baseUrl = "/api/messagebroker/v4";
}
/**
* * Subscribers
*
* Managing subscribers - create or update a subscription to the given topic.
*
* @param {string} id
* @param {string} versionId
* @param {string} topicId
*
* TopicId string
* pattern: mdsp\.[a-z0-9-_]+\.[a-z0-9-_]+\.v[0-9]+\.(pubsub|postbox)\.[a-z0-9-_.]+
* maxLength: 255
*
* @example: mdsp.core.am.v1.postbox.asset.deleted
* Id of the topic. Format: mdsp.{tenant}.{service}.v{version}.{type}.{additional}
*
* @param {MessageBrokerModels.SubscriberTopicInput} subscription
* @returns {Promise<MessageBrokerModels.SubscriberTopicInput>}
*
* @memberOf MessageBrokerClient
*/
PutSubscription(id, versionId, topicId, subscription) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.HttpAction({
verb: "PUT",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
body: subscription,
baseUrl: `${this._baseUrl}/subscribers/${id}/versions/${versionId}/topics/${topicId}`,
});
return result;
});
}
/**
* * Subscribers
*
* Get the subscription.
*
* @param {string} id
* @param {string} versionId
* @param {string} topicId
*
* TopicId string
* pattern: mdsp\.[a-z0-9-_]+\.[a-z0-9-_]+\.v[0-9]+\.(pubsub|postbox)\.[a-z0-9-_.]+
* maxLength: 255
*
* @example: mdsp.core.am.v1.postbox.asset.deleted
* Id of the topic. Format: mdsp.{tenant}.{service}.v{version}.{type}.{additional}
*
* @returns {Promise<MessageBrokerModels.SubscriberTopicInput>}
*
* @memberOf MessageBrokerClient
*/
GetSubscription(id, versionId, topicId) {
return __awaiter(this, void 0, void 0, function* () {
const result = yield this.HttpAction({
verb: "GET",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
baseUrl: `${this._baseUrl}/subscribers/${id}/versions/${versionId}/topics/${topicId}`,
});
return result;
});
}
/**
* * Subscribers
*
* Delete the subscription.
*
* @param {string} id
* @param {string} versionId
* @param {string} topicId
*
* TopicId string
* pattern: mdsp\.[a-z0-9-_]+\.[a-z0-9-_]+\.v[0-9]+\.(pubsub|postbox)\.[a-z0-9-_.]+
* maxLength: 255
* @example: mdsp.core.am.v1.postbox.asset.deleted
* Id of the topic. Format: mdsp.{tenant}.{service}.v{version}.{type}.{additional}
*
* @memberOf MessageBrokerClient
*/
DeleteSubscription(id, versionId, topicId) {
return __awaiter(this, void 0, void 0, function* () {
yield this.HttpAction({
verb: "DELETE",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
baseUrl: `${this._baseUrl}/subscribers/${id}/versions/${versionId}/topics/${topicId}`,
noResponse: true,
});
});
}
/**
* * Publishes new message to the given topic.
*
* @param {string} id
* Id of the topic. Format: mdsp.{tenant}.{service}.v{version}.{type}.{additional}
*
* @param {MessageBrokerModels.Messages} message
* Input for posting a message on given postbox topic only. The content is what the sender sends and is not modified.
*
* @memberOf MessageBrokerClient
*/
SendMessage(id, message) {
return __awaiter(this, void 0, void 0, function* () {
yield this.HttpAction({
verb: "GET",
gateway: this.GetGateway(),
authorization: yield this.GetToken(),
baseUrl: `${this._baseUrl}/topics/${id}/sendmessage`,
noResponse: true,
});
});
}
}
exports.MessageBrokerClient = MessageBrokerClient;
//# sourceMappingURL=messagebroker.js.map