aws-iot-device-sdk-v2
Version:
NodeJS API for the AWS IoT service
231 lines • 9.21 kB
JavaScript
;
/*
* 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.IotJobsClientv2 = 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 jobs service can be used to define a set of remote operations that are sent to and executed on one or more devices connected to AWS IoT.
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#jobs-mqtt-api
*
* @category IotJobs
*/
class IotJobsClientv2 {
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 IotJobsClientv2(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 IotJobsClientv2(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();
}
/**
* Gets detailed information about a job execution.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-describejobexecution
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotJobs
*/
describeJobExecution(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "describeJobExecution",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Gets the list of all jobs for a thing that are not in a terminal state.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-getpendingjobexecutions
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotJobs
*/
getPendingJobExecutions(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "getPendingJobExecutions",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Gets and starts the next pending job execution for a thing (status IN_PROGRESS or QUEUED).
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-startnextpendingjobexecution
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotJobs
*/
startNextPendingJobExecution(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "startNextPendingJobExecution",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Updates the status of a job execution. You can optionally create a step timer by setting a value for the stepTimeoutInMinutes property. If you don't update the value of this property by running UpdateJobExecution again, the job execution times out when the step timer expires.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-updatejobexecution
*
* @param request operation to perform
*
* @return Promise which resolves into the response to the request
*
* @category IotJobs
*/
updateJobExecution(request) {
return __awaiter(this, void 0, void 0, function* () {
let config = {
operationName: "updateJobExecution",
serviceModel: this.serviceModel,
client: this.rrClient,
request: request
};
return yield mqtt_request_response_utils.doRequestResponse(config);
});
}
/**
* Creates a stream of JobExecutionsChanged notifications for a given IoT thing.
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-jobexecutionschanged
*
* @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 IotJobs
*/
createJobExecutionsChangedStream(config) {
let streamingOperationConfig = {
operationName: "createJobExecutionsChangedStream",
serviceModel: this.serviceModel,
client: this.rrClient,
modelConfig: config,
};
return mqtt_request_response.StreamingOperation.create(streamingOperationConfig);
}
/**
*
*
*
* AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/jobs-api.html#mqtt-nextjobexecutionchanged
*
* @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 IotJobs
*/
createNextJobExecutionChangedStream(config) {
let streamingOperationConfig = {
operationName: "createNextJobExecutionChangedStream",
serviceModel: this.serviceModel,
client: this.rrClient,
modelConfig: config,
};
return mqtt_request_response.StreamingOperation.create(streamingOperationConfig);
}
}
exports.IotJobsClientv2 = IotJobsClientv2;
//# sourceMappingURL=iotjobsclientv2.js.map