Skip to content

Commit 6d1217b

Browse files
author
awstools
committed
feat(client-iot-data-plane): This release adds support for MQTT5 properties to AWS IoT HTTP Publish API.
1 parent fabc6b1 commit 6d1217b

File tree

3 files changed

+359
-209
lines changed

3 files changed

+359
-209
lines changed

clients/client-iot-data-plane/src/models/models_0.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// smithy-typescript generated code
2-
import { ExceptionOptionType as __ExceptionOptionType } from "@aws-sdk/smithy-client";
2+
import {
3+
ExceptionOptionType as __ExceptionOptionType,
4+
LazyJsonString as __LazyJsonString,
5+
} from "@aws-sdk/smithy-client";
36

47
import { IoTDataPlaneServiceException as __BaseException } from "./IoTDataPlaneServiceException";
58

@@ -345,6 +348,11 @@ export interface ListRetainedMessagesResponse {
345348
nextToken?: string;
346349
}
347350

351+
export enum PayloadFormatIndicator {
352+
UNSPECIFIED_BYTES = "UNSPECIFIED_BYTES",
353+
UTF8_DATA = "UTF8_DATA",
354+
}
355+
348356
/**
349357
* <p>The input for the Publish operation.</p>
350358
*/
@@ -355,7 +363,7 @@ export interface PublishRequest {
355363
topic: string | undefined;
356364

357365
/**
358-
* <p>The Quality of Service (QoS) level.</p>
366+
* <p>The Quality of Service (QoS) level. The default QoS level is 0.</p>
359367
*/
360368
qos?: number;
361369

@@ -375,6 +383,51 @@ export interface PublishRequest {
375383
* <code>true</code> deletes the retained message identified by <b>topic</b> from Amazon Web Services IoT Core.</p>
376384
*/
377385
payload?: Uint8Array;
386+
387+
/**
388+
* <p>A JSON string that contains an array of JSON objects. If you don’t use Amazon Web Services SDK or CLI,
389+
* you must encode the JSON string to base64 format before adding it to the HTTP header.
390+
* <code>userProperties</code> is an HTTP header value in the API.</p>
391+
* <p>The following example <code>userProperties</code> parameter is a JSON string which
392+
* represents two User Properties. Note that it needs to be base64-encoded:</p>
393+
* <p>
394+
* <code>[{"deviceName": "alpha"}, {"deviceCnt": "45"}]</code>
395+
* </p>
396+
*/
397+
userProperties?: __LazyJsonString | string;
398+
399+
/**
400+
* <p>An <code>Enum</code> string value that indicates whether the payload is formatted as
401+
* UTF-8. <code>payloadFormatIndicator</code> is an HTTP header value in the API.</p>
402+
*/
403+
payloadFormatIndicator?: PayloadFormatIndicator | string;
404+
405+
/**
406+
* <p>A UTF-8 encoded string that describes the content of the publishing message.</p>
407+
*/
408+
contentType?: string;
409+
410+
/**
411+
* <p>A UTF-8 encoded string that's used as the topic name for a response message. The response
412+
* topic is used to describe the topic which the receiver should publish to as part of the
413+
* request-response flow. The topic must not contain wildcard characters.</p>
414+
*/
415+
responseTopic?: string;
416+
417+
/**
418+
* <p>The base64-encoded binary data used by the sender of the request message to identify which
419+
* request the response message is for when it's received. <code>correlationData</code> is an
420+
* HTTP header value in the API.</p>
421+
*/
422+
correlationData?: string;
423+
424+
/**
425+
* <p>A user-defined integer value that represents the message expiry interval in seconds. If
426+
* absent, the message doesn't expire. For more information about the limits of
427+
* <code>messageExpiry</code>, see <a href="https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits">Amazon Web Services IoT Core message broker and
428+
* protocol limits and quotas </a> from the Amazon Web Services Reference Guide.</p>
429+
*/
430+
messageExpiry?: number;
378431
}
379432

380433
/**

clients/client-iot-data-plane/src/protocols/Aws_restJson1.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
expectObject as __expectObject,
99
expectString as __expectString,
1010
extendedEncodeURIComponent as __extendedEncodeURIComponent,
11+
LazyJsonString as __LazyJsonString,
1112
map as __map,
1213
resolvedPath as __resolvedPath,
1314
throwDefaultError,
@@ -172,14 +173,23 @@ export const serializeAws_restJson1PublishCommand = async (
172173
context: __SerdeContext
173174
): Promise<__HttpRequest> => {
174175
const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
175-
const headers: any = {
176+
const headers: any = map({}, isSerializableHeaderValue, {
176177
"content-type": "application/octet-stream",
177-
};
178+
"x-amz-mqtt5-user-properties": [
179+
() => isSerializableHeaderValue(input.userProperties),
180+
() => context.base64Encoder(Buffer.from(__LazyJsonString.fromObject(input.userProperties!))),
181+
],
182+
"x-amz-mqtt5-payload-format-indicator": input.payloadFormatIndicator!,
183+
"x-amz-mqtt5-correlation-data": input.correlationData!,
184+
});
178185
let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/topics/{topic}";
179186
resolvedPath = __resolvedPath(resolvedPath, input, "topic", () => input.topic!, "{topic}", false);
180187
const query: any = map({
181188
qos: [() => input.qos !== void 0, () => input.qos!.toString()],
182189
retain: [() => input.retain !== void 0, () => input.retain!.toString()],
190+
contentType: [, input.contentType!],
191+
responseTopic: [, input.responseTopic!],
192+
messageExpiry: [() => input.messageExpiry !== void 0, () => input.messageExpiry!.toString()],
183193
});
184194
let body: any;
185195
if (input.payload !== undefined) {
@@ -572,6 +582,9 @@ const deserializeAws_restJson1PublishCommandError = async (
572582
case "MethodNotAllowedException":
573583
case "com.amazonaws.iotdataplane#MethodNotAllowedException":
574584
throw await deserializeAws_restJson1MethodNotAllowedExceptionResponse(parsedOutput, context);
585+
case "ThrottlingException":
586+
case "com.amazonaws.iotdataplane#ThrottlingException":
587+
throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context);
575588
case "UnauthorizedException":
576589
case "com.amazonaws.iotdataplane#UnauthorizedException":
577590
throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context);

0 commit comments

Comments
 (0)