aws-iot-device-sdk-v2
Version:
NodeJS API for the AWS IoT service
321 lines • 12.3 kB
JavaScript
"use strict";
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*
* This file is generated
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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.IotShadowClientv2 = void 0;
const aws_crt_1 = require("aws-crt");
const mqtt_request_response = __importStar(require("../mqtt_request_response"));
const mqtt_request_response_utils = __importStar(require("../mqtt_request_response_utils"));
const v2utils = __importStar(require("./v2utils"));
/**
* The AWS IoT Device Shadow service adds shadows to AWS IoT thing objects. Shadows are a simple data store for device properties and state. Shadows can make a device’s state available to apps and other services whether the device is connected to AWS IoT or not.
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html
*
* @category IotShadow
*/
class IotShadowClientv2 {
constructor(rrClient) {
this.rrClient = rrClient;
this.serviceModel = v2utils.makeServiceModel();
}
/**
* Creates a new service client that will use an SDK MQTT 311 client as transport.
*
* @param protocolClient the MQTT 311 client to use for transport
* @param options additional service client configuration options
*
* @return a new service client
*
*/
static newFromMqtt311(protocolClient, options) {
let rrClient = aws_crt_1.mqtt_request_response.RequestResponseClient.newFromMqtt311(protocolClient, options);
return new IotShadowClientv2(rrClient);
}
/**
* Creates a new service client that will use an SDK MQTT 5 client as transport.
*
* @param protocolClient the MQTT 5 client to use for transport
* @param options additional service client configuration options
*
* @return a new service client
*
*/
static newFromMqtt5(protocolClient, options) {
let rrClient = aws_crt_1.mqtt_request_response.RequestResponseClient.newFromMqtt5(protocolClient, options);
return new IotShadowClientv2(rrClient);
}
/**
* Triggers cleanup of all resources associated with the service client. Closing a client will fail
* all incomplete requests and close all unclosed streaming operations.
*
* This must be called when finished with a client; otherwise, native resources will leak.
*/
close() {
this.rrClient.close();
}
/**
* Deletes a named shadow for an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#delete-pub-sub-topic
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotShadow
*/
deleteNamedShadow(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "deleteNamedShadow",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Deletes the (classic) shadow for an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#delete-pub-sub-topic
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotShadow
*/
deleteShadow(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "deleteShadow",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Gets a named shadow for an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#get-pub-sub-topic
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotShadow
*/
getNamedShadow(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "getNamedShadow",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Gets the (classic) shadow for an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#get-pub-sub-topic
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotShadow
*/
getShadow(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "getShadow",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Update a named shadow for a device.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-pub-sub-topic
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotShadow
*/
updateNamedShadow(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "updateNamedShadow",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Update a device's (classic) shadow.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-pub-sub-topic
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotShadow
*/
updateShadow(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "updateShadow",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Create a stream for NamedShadowDelta events for a named shadow of an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-delta-pub-sub-topic
*
* @param config streaming operation configuration options
*
* @return a streaming operation which will emit an event every time a message is received on the
* associated MQTT topic
*
* @category IotShadow
*/
createNamedShadowDeltaUpdatedStream(config) {
let streamingOperationConfig = {
operationName: "createNamedShadowDeltaUpdatedStream",
serviceModel: this.serviceModel,
client: this.rrClient,
modelConfig: config,
};
return mqtt_request_response.StreamingOperation.create(streamingOperationConfig);
}
/**
* Create a stream for ShadowUpdated events for a named shadow of an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-documents-pub-sub-topic
*
* @param config streaming operation configuration options
*
* @return a streaming operation which will emit an event every time a message is received on the
* associated MQTT topic
*
* @category IotShadow
*/
createNamedShadowUpdatedStream(config) {
let streamingOperationConfig = {
operationName: "createNamedShadowUpdatedStream",
serviceModel: this.serviceModel,
client: this.rrClient,
modelConfig: config,
};
return mqtt_request_response.StreamingOperation.create(streamingOperationConfig);
}
/**
* Create a stream for ShadowDelta events for the (classic) shadow of an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-delta-pub-sub-topic
*
* @param config streaming operation configuration options
*
* @return a streaming operation which will emit an event every time a message is received on the
* associated MQTT topic
*
* @category IotShadow
*/
createShadowDeltaUpdatedStream(config) {
let streamingOperationConfig = {
operationName: "createShadowDeltaUpdatedStream",
serviceModel: this.serviceModel,
client: this.rrClient,
modelConfig: config,
};
return mqtt_request_response.StreamingOperation.create(streamingOperationConfig);
}
/**
* Create a stream for ShadowUpdated events for the (classic) shadow of an AWS IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-documents-pub-sub-topic
*
* @param config streaming operation configuration options
*
* @return a streaming operation which will emit an event every time a message is received on the
* associated MQTT topic
*
* @category IotShadow
*/
createShadowUpdatedStream(config) {
let streamingOperationConfig = {
operationName: "createShadowUpdatedStream",
serviceModel: this.serviceModel,
client: this.rrClient,
modelConfig: config,
};
return mqtt_request_response.StreamingOperation.create(streamingOperationConfig);
}
}
exports.IotShadowClientv2 = IotShadowClientv2;
//# sourceMappingURL=iotshadowclientv2.js.map