Skip to content

Commit 1064e26

Browse files
committed
generated shadow update
1 parent f1471cc commit 1064e26

3 files changed

Lines changed: 32 additions & 54 deletions

File tree

shadow/include/aws/iotshadow/IotShadowClient.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,21 @@ namespace Aws
9393
std::function<void(Aws::Iotshadow::ErrorResponse *, int ioErr)>;
9494

9595
/**
96+
* @deprecated We strongly recommend using IotShadowClientV2. There are no current plans to
97+
* fully deprecate IotShadowClient but it is highly recommended customers migrate to IotShadowClientV2
98+
* More details can be found in the GitHub Repo FAQ
9699
* The AWS IoT Device Shadow service adds shadows to AWS IoT thing objects. Shadows are a simple data store for
97100
* device properties and state. Shadows can make a device’s state available to apps and other services whether
98101
* the device is connected to AWS IoT or not.
99102
*
100103
* https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html
101104
*
102105
*/
103-
class AWS_IOTSHADOW_API IotShadowClient final
104-
{
106+
class AWS_IOTSHADOW_API AWS_CRT_SOFT_DEPRECATED(
107+
"We strongly recommend using IotShadowClientV2. There are no current plans to fully "
108+
"deprecate IotShadowClient but it is highly recommended customers migrate to "
109+
"IotShadowClientV2 More details can be found in the GitHub Repo FAQ" IotShadowClient final
110+
{
105111
public:
106112
IotShadowClient(const std::shared_ptr<Aws::Crt::Mqtt::MqttConnection> &connection);
107113
IotShadowClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client);
@@ -649,7 +655,7 @@ namespace Aws
649655

650656
private:
651657
std::shared_ptr<Aws::Crt::Mqtt::MqttConnection> m_connection;
652-
};
658+
};
653659

654660
} // namespace Iotshadow
655661

shadow/include/aws/iotshadow/IotShadowClientV2.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ namespace Aws
214214
* AWS documentation:
215215
* https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-delta-pub-sub-topic
216216
*
217-
* @param request Modeled streaming operation subscription configuration.
218-
* @param options Configuration options for the streaming operation.
217+
* @param request modeled streaming operation subscription configuration
218+
* @param options
219219
*
220-
* @return A streaming operation which will emit a modeled event every time a message is received on the
221-
* associated MQTT topic.
220+
* @return a streaming operation which will emit a modeled event every time a message is received on the
221+
* associated MQTT topic
222222
*/
223223
virtual std::shared_ptr<Aws::Iot::RequestResponse::IStreamingOperation> CreateNamedShadowDeltaUpdatedStream(
224224
const NamedShadowDeltaUpdatedSubscriptionRequest &request,
@@ -231,11 +231,11 @@ namespace Aws
231231
* AWS documentation:
232232
* https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-documents-pub-sub-topic
233233
*
234-
* @param request Modeled streaming operation subscription configuration.
235-
* @param options Configuration options for the streaming operation.
234+
* @param request modeled streaming operation subscription configuration
235+
* @param options
236236
*
237-
* @return A streaming operation which will emit a modeled event every time a message is received on the
238-
* associated MQTT topic.
237+
* @return a streaming operation which will emit a modeled event every time a message is received on the
238+
* associated MQTT topic
239239
*/
240240
virtual std::shared_ptr<Aws::Iot::RequestResponse::IStreamingOperation> CreateNamedShadowUpdatedStream(
241241
const NamedShadowUpdatedSubscriptionRequest &request,
@@ -248,11 +248,11 @@ namespace Aws
248248
* AWS documentation:
249249
* https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-delta-pub-sub-topic
250250
*
251-
* @param request Modeled streaming operation subscription configuration.
252-
* @param options Configuration options for the streaming operation.
251+
* @param request modeled streaming operation subscription configuration
252+
* @param options
253253
*
254-
* @return A streaming operation which will emit a modeled event every time a message is received on the
255-
* associated MQTT topic.
254+
* @return a streaming operation which will emit a modeled event every time a message is received on the
255+
* associated MQTT topic
256256
*/
257257
virtual std::shared_ptr<Aws::Iot::RequestResponse::IStreamingOperation> CreateShadowDeltaUpdatedStream(
258258
const ShadowDeltaUpdatedSubscriptionRequest &request,
@@ -265,11 +265,11 @@ namespace Aws
265265
* AWS documentation:
266266
* https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html#update-documents-pub-sub-topic
267267
*
268-
* @param request Modeled streaming operation subscription configuration.
269-
* @param options Configuration options for the streaming operation.
268+
* @param request modeled streaming operation subscription configuration
269+
* @param options
270270
*
271-
* @return A streaming operation which will emit a modeled event every time a message is received on the
272-
* associated MQTT topic.
271+
* @return a streaming operation which will emit a modeled event every time a message is received on the
272+
* associated MQTT topic
273273
*/
274274
virtual std::shared_ptr<Aws::Iot::RequestResponse::IStreamingOperation> CreateShadowUpdatedStream(
275275
const ShadowUpdatedSubscriptionRequest &request,

shadow/source/IotShadowClientV2.cpp

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -748,38 +748,6 @@ namespace Aws
748748
return submitResult == AWS_OP_SUCCESS;
749749
}
750750

751-
static bool s_initModeledEvent(
752-
const Aws::Iot::RequestResponse::IncomingPublishEvent &publishEvent,
753-
ShadowUpdatedEvent &modeledEvent)
754-
{
755-
const auto &payload = publishEvent.GetPayload();
756-
Aws::Crt::String objectStr(reinterpret_cast<char *>(payload.ptr), payload.len);
757-
Aws::Crt::JsonObject jsonObject(objectStr);
758-
if (!jsonObject.WasParseSuccessful())
759-
{
760-
return false;
761-
}
762-
763-
modeledEvent = ShadowUpdatedEvent(jsonObject);
764-
return true;
765-
}
766-
767-
static bool s_initModeledEvent(
768-
const Aws::Iot::RequestResponse::IncomingPublishEvent &publishEvent,
769-
ShadowDeltaUpdatedEvent &modeledEvent)
770-
{
771-
const auto &payload = publishEvent.GetPayload();
772-
Aws::Crt::String objectStr(reinterpret_cast<char *>(payload.ptr), payload.len);
773-
Aws::Crt::JsonObject jsonObject(objectStr);
774-
if (!jsonObject.WasParseSuccessful())
775-
{
776-
return false;
777-
}
778-
779-
modeledEvent = ShadowDeltaUpdatedEvent(jsonObject);
780-
return true;
781-
}
782-
783751
template <typename T> class ServiceStreamingOperation : public Aws::Iot::RequestResponse::IStreamingOperation
784752
{
785753
public:
@@ -796,13 +764,17 @@ namespace Aws
796764
{
797765

798766
std::function<void(Aws::Iot::RequestResponse::IncomingPublishEvent &&)> unmodeledHandler =
799-
[options](Aws::Iot::RequestResponse::IncomingPublishEvent &&publishEvent)
767+
[options](Aws::Iot::RequestResponse::IncomingPublishEvent &&event)
800768
{
801-
T modeledEvent;
802-
if (!s_initModeledEvent(publishEvent, modeledEvent))
769+
const auto &payload = event.GetPayload();
770+
Aws::Crt::String objectStr(reinterpret_cast<char *>(payload.ptr), payload.len);
771+
Aws::Crt::JsonObject jsonObject(objectStr);
772+
if (!jsonObject.WasParseSuccessful())
803773
{
804774
return;
805775
}
776+
777+
T modeledEvent(jsonObject);
806778
options.GetStreamHandler()(std::move(modeledEvent));
807779
};
808780

0 commit comments

Comments
 (0)