From d0614128f1c5aeb71b9ecbd87e2c4170f56a00bd Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 12:04:27 -0700 Subject: [PATCH 01/11] Add Telemetry APIs --- .../core/DigitalTwinsAsyncClient.java | 105 ++++++++++++++++++ .../digitaltwins/core/DigitalTwinsClient.java | 30 +++++ .../core/util/TelemetryOptions.java | 62 +++++++++++ 3 files changed, 197 insertions(+) create mode 100644 sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index dafbced7a6f1a..522a890b6ba8d 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1338,4 +1338,109 @@ Mono> listEventRoutesNextPage(String nextLink, Context } //endregion Event Route APIs + + //region Telemetry APIs + + /** + * Publishes telemetry from a digital twin + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @return An empty mono. + */ + public Mono publishTelemetry(String digitalTwinId, String payload) { + TelemetryOptions telemetryOptions = new TelemetryOptions(); + return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context)) + .flatMap(voidResponse -> Mono.empty()); + } + + /** + * Publishes telemetry from a digital twin + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @return An empty mono. + */ + public Mono publishTelemetry(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { + return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context)) + .flatMap(voidResponse -> Mono.empty()); + } + + /** + * Publishes telemetry from a digital twin + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @return A {@link Response} containing an empty mono. + */ + public Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { + return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context)); + } + + Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions, Context context) { + return protocolLayer.getDigitalTwins().sendTelemetryWithResponseAsync( + digitalTwinId, + telemetryOptions.getMessageId(), + payload, + telemetryOptions.getTimeStamp().toString(), + context); + } + + /** + * Publishes telemetry from a digital twin's component + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @return An empty mono. + */ + public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { + TelemetryOptions telemetryOptions = new TelemetryOptions(); + return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context)) + .flatMap(voidResponse -> Mono.empty()); + } + + /** + * Publishes telemetry from a digital twin's component + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @return An empty mono. + */ + public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { + return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context)) + .flatMap(voidResponse -> Mono.empty()); + } + + /** + * Publishes telemetry from a digital twin's component + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @return A {@link Response} containing an empty mono. + */ + public Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { + return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context)); + } + + Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions, Context context) { + return protocolLayer.getDigitalTwins().sendComponentTelemetryWithResponseAsync( + digitalTwinId, + componentName, + telemetryOptions.getMessageId(), + payload, + telemetryOptions.getTimeStamp().toString(), + context); + } + + //endregion Telemetry APIs } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index 7596847d933e4..fa52bbbba7e63 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -768,4 +768,34 @@ public PagedIterable listEventRoutes(EventRoutesListOptions options, } //endregion Event Route APIs + + //region Telemetry APIs + + public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { + TelemetryOptions telemetryOptions = new TelemetryOptions(); + publishComponentTelemetry(digitalTwinId, componentName, payload, telemetryOptions); + } + + public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { + publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, Context.NONE); + } + + public Response publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions, Context context) { + return digitalTwinsAsyncClient.publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context).block(); + } + + public void publishTelemetry(String digitalTwinId, String payload) { + TelemetryOptions telemetryOptions = new TelemetryOptions(); + publishTelemetry(digitalTwinId, payload, telemetryOptions); + } + + public void publishTelemetry(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { + publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, Context.NONE); + } + + public Response publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions, Context context) { + return digitalTwinsAsyncClient.publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context).block(); + } + + //endregion TelemetryAPIs } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java new file mode 100644 index 0000000000000..65fe37dc9919b --- /dev/null +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java @@ -0,0 +1,62 @@ +package com.azure.digitaltwins.core.util; + +import com.azure.core.annotation.Fluent; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.UUID; + +/** + * The additional information to be used when processing a telemetry request. + */ +@Fluent +public final class TelemetryOptions { + + /** + * A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. + * Defaults to a random guid. + */ + private String messageId = UUID.randomUUID().toString(); + + /** + * An RFC 3339 timestamp that identifies the time the telemetry was measured. + * It defaults to the current date/time UTC. + */ + private OffsetDateTime timeStamp = OffsetDateTime.now(ZoneOffset.UTC); + + /** + * Gets the message Id. + * @return A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. + */ + public String getMessageId() { + return this.messageId; + } + + /** + * Gets the timestamp. + * @return The timestamp that identifies the time the telemetry was measured. + */ + public OffsetDateTime getTimeStamp() { + return this.timeStamp; + } + + /** + * Set the message Id + * @param messageId A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. + * @return The TelemetryOption object itself. + */ + public TelemetryOptions setMessageId(String messageId) { + this.messageId = messageId; + return this; + } + + /** + * Set the timestamp + * @param timeStamp The timestamp that identifies the time the telemetry was measured. + * @return The TelemetryOption object itself. + */ + public TelemetryOptions setTimeStamp(OffsetDateTime timeStamp) { + this.timeStamp = timeStamp; + return this; + } +} From d827eef4632b80caf11411bf6e8925ff48cc1786 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 12:11:02 -0700 Subject: [PATCH 02/11] Update API comments --- .../core/DigitalTwinsAsyncClient.java | 3 + .../digitaltwins/core/DigitalTwinsClient.java | 77 ++++++++++++++++--- 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index 522a890b6ba8d..e75249d6f256f 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1396,6 +1396,7 @@ Mono> publishTelemetryWithResponse(String digitalTwinId, String p * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. + * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. * @return An empty mono. */ @@ -1410,6 +1411,7 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. + * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. * @param telemetryOptions The additional information to be used when processing a telemetry request. * @return An empty mono. @@ -1424,6 +1426,7 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. + * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. * @param telemetryOptions The additional information to be used when processing a telemetry request. * @return A {@link Response} containing an empty mono. diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index fa52bbbba7e63..a041698fe78f0 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -771,30 +771,83 @@ public PagedIterable listEventRoutes(EventRoutesListOptions options, //region Telemetry APIs - public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { + /** + * Publishes telemetry from a digital twin + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + */ + public void publishTelemetry(String digitalTwinId, String payload) { TelemetryOptions telemetryOptions = new TelemetryOptions(); - publishComponentTelemetry(digitalTwinId, componentName, payload, telemetryOptions); + publishTelemetry(digitalTwinId, payload, telemetryOptions); } - public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { - publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, Context.NONE); + /** + * Publishes telemetry from a digital twin + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + */ + public void publishTelemetry(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { + publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, Context.NONE); } - public Response publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions, Context context) { - return digitalTwinsAsyncClient.publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context).block(); + /** + * Publishes telemetry from a digital twin + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link Response}. + */ + public Response publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions, Context context) { + return digitalTwinsAsyncClient.publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context).block(); } - public void publishTelemetry(String digitalTwinId, String payload) { + /** + * Publishes telemetry from a digital twin's component + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param componentName The name of the DTDL component. + * @param payload The application/json telemetry payload to be sent. + */ + public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { TelemetryOptions telemetryOptions = new TelemetryOptions(); - publishTelemetry(digitalTwinId, payload, telemetryOptions); + publishComponentTelemetry(digitalTwinId, componentName, payload, telemetryOptions); } - public void publishTelemetry(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { - publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, Context.NONE); + /** + * Publishes telemetry from a digital twin's component + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param componentName The name of the DTDL component. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + */ + public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { + publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, Context.NONE); } - public Response publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions, Context context) { - return digitalTwinsAsyncClient.publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context).block(); + /** + * Publishes telemetry from a digital twin's component + * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} + * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. + * @param digitalTwinId The Id of the digital twin. + * @param componentName The name of the DTDL component. + * @param payload The application/json telemetry payload to be sent. + * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link Response}. + */ + public Response publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions, Context context) { + return digitalTwinsAsyncClient.publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context).block(); } //endregion TelemetryAPIs From affaa952135c2ad3ad136f5d6152826d14080b1f Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 12:29:01 -0700 Subject: [PATCH 03/11] Address comments --- .../core/DigitalTwinsAsyncClient.java | 44 +++++++++---------- .../digitaltwins/core/DigitalTwinsClient.java | 32 +++++++------- ...va => PublishTelemetryRequestOptions.java} | 20 ++++----- 3 files changed, 48 insertions(+), 48 deletions(-) rename sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/{TelemetryOptions.java => PublishTelemetryRequestOptions.java} (70%) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index e75249d6f256f..6beeabd0bb4ca 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1350,8 +1350,8 @@ Mono> listEventRoutesNextPage(String nextLink, Context * @return An empty mono. */ public Mono publishTelemetry(String digitalTwinId, String payload) { - TelemetryOptions telemetryOptions = new TelemetryOptions(); - return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context)) + PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); + return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context)) .flatMap(voidResponse -> Mono.empty()); } @@ -1361,11 +1361,11 @@ public Mono publishTelemetry(String digitalTwinId, String payload) { * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @return An empty mono. */ - public Mono publishTelemetry(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { - return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context)) + public Mono publishTelemetry(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { + return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context)) .flatMap(voidResponse -> Mono.empty()); } @@ -1375,19 +1375,19 @@ public Mono publishTelemetry(String digitalTwinId, String payload, Telemet * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @return A {@link Response} containing an empty mono. */ - public Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { - return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context)); + public Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { + return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context)); } - Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions, Context context) { + Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { return protocolLayer.getDigitalTwins().sendTelemetryWithResponseAsync( digitalTwinId, - telemetryOptions.getMessageId(), + publishTelemetryRequestOptions.getMessageId(), payload, - telemetryOptions.getTimeStamp().toString(), + publishTelemetryRequestOptions.getTimestamp().toString(), context); } @@ -1401,8 +1401,8 @@ Mono> publishTelemetryWithResponse(String digitalTwinId, String p * @return An empty mono. */ public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { - TelemetryOptions telemetryOptions = new TelemetryOptions(); - return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context)) + PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); + return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context)) .flatMap(voidResponse -> Mono.empty()); } @@ -1413,11 +1413,11 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @return An empty mono. */ - public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { - return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context)) + public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { + return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context)) .flatMap(voidResponse -> Mono.empty()); } @@ -1428,20 +1428,20 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @return A {@link Response} containing an empty mono. */ - public Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { - return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context)); + public Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { + return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context)); } - Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions, Context context) { + Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { return protocolLayer.getDigitalTwins().sendComponentTelemetryWithResponseAsync( digitalTwinId, componentName, - telemetryOptions.getMessageId(), + publishTelemetryRequestOptions.getMessageId(), payload, - telemetryOptions.getTimeStamp().toString(), + publishTelemetryRequestOptions.getTimestamp().toString(), context); } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index a041698fe78f0..d897158f9b911 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -779,8 +779,8 @@ public PagedIterable listEventRoutes(EventRoutesListOptions options, * @param payload The application/json telemetry payload to be sent. */ public void publishTelemetry(String digitalTwinId, String payload) { - TelemetryOptions telemetryOptions = new TelemetryOptions(); - publishTelemetry(digitalTwinId, payload, telemetryOptions); + PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); + publishTelemetry(digitalTwinId, payload, publishTelemetryRequestOptions); } /** @@ -789,10 +789,10 @@ public void publishTelemetry(String digitalTwinId, String payload) { * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. */ - public void publishTelemetry(String digitalTwinId, String payload, TelemetryOptions telemetryOptions) { - publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, Context.NONE); + public void publishTelemetry(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { + publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, Context.NONE); } /** @@ -801,12 +801,12 @@ public void publishTelemetry(String digitalTwinId, String payload, TelemetryOpti * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. * @param digitalTwinId The Id of the digital twin. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link Response}. */ - public Response publishTelemetryWithResponse(String digitalTwinId, String payload, TelemetryOptions telemetryOptions, Context context) { - return digitalTwinsAsyncClient.publishTelemetryWithResponse(digitalTwinId, payload, telemetryOptions, context).block(); + public Response publishTelemetryWithResponse(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { + return digitalTwinsAsyncClient.publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context).block(); } /** @@ -818,8 +818,8 @@ public Response publishTelemetryWithResponse(String digitalTwinId, String * @param payload The application/json telemetry payload to be sent. */ public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { - TelemetryOptions telemetryOptions = new TelemetryOptions(); - publishComponentTelemetry(digitalTwinId, componentName, payload, telemetryOptions); + PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); + publishComponentTelemetry(digitalTwinId, componentName, payload, publishTelemetryRequestOptions); } /** @@ -829,10 +829,10 @@ public void publishComponentTelemetry(String digitalTwinId, String componentName * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. */ - public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions) { - publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, Context.NONE); + public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { + publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, Context.NONE); } /** @@ -842,12 +842,12 @@ public void publishComponentTelemetry(String digitalTwinId, String componentName * @param digitalTwinId The Id of the digital twin. * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. - * @param telemetryOptions The additional information to be used when processing a telemetry request. + * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link Response}. */ - public Response publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, TelemetryOptions telemetryOptions, Context context) { - return digitalTwinsAsyncClient.publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, telemetryOptions, context).block(); + public Response publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { + return digitalTwinsAsyncClient.publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context).block(); } //endregion TelemetryAPIs diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/PublishTelemetryRequestOptions.java similarity index 70% rename from sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java rename to sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/PublishTelemetryRequestOptions.java index 65fe37dc9919b..6ea564ad2d708 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/TelemetryOptions.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/util/PublishTelemetryRequestOptions.java @@ -10,7 +10,7 @@ * The additional information to be used when processing a telemetry request. */ @Fluent -public final class TelemetryOptions { +public final class PublishTelemetryRequestOptions { /** * A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. @@ -22,7 +22,7 @@ public final class TelemetryOptions { * An RFC 3339 timestamp that identifies the time the telemetry was measured. * It defaults to the current date/time UTC. */ - private OffsetDateTime timeStamp = OffsetDateTime.now(ZoneOffset.UTC); + private OffsetDateTime timestamp = OffsetDateTime.now(ZoneOffset.UTC); /** * Gets the message Id. @@ -36,27 +36,27 @@ public String getMessageId() { * Gets the timestamp. * @return The timestamp that identifies the time the telemetry was measured. */ - public OffsetDateTime getTimeStamp() { - return this.timeStamp; + public OffsetDateTime getTimestamp() { + return this.timestamp; } /** * Set the message Id * @param messageId A unique message identifier (within the scope of the digital twin id) that is commonly used for de-duplicating messages. - * @return The TelemetryOption object itself. + * @return The PublishTelemetryRequestOptions object itself. */ - public TelemetryOptions setMessageId(String messageId) { + public PublishTelemetryRequestOptions setMessageId(String messageId) { this.messageId = messageId; return this; } /** * Set the timestamp - * @param timeStamp The timestamp that identifies the time the telemetry was measured. - * @return The TelemetryOption object itself. + * @param timestamp The timestamp that identifies the time the telemetry was measured. + * @return The PublishTelemetryRequestOptions object itself. */ - public TelemetryOptions setTimeStamp(OffsetDateTime timeStamp) { - this.timeStamp = timeStamp; + public PublishTelemetryRequestOptions setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; return this; } } From 82029a035cdf0932af8fad1ada0fb1d8558c11d3 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 12:39:47 -0700 Subject: [PATCH 04/11] Update DigitalTwinsAsyncClient.java --- .../digitaltwins/core/DigitalTwinsAsyncClient.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index 6beeabd0bb4ca..21bf4b4e47d4b 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1436,11 +1436,21 @@ public Mono> publishComponentTelemetryWithResponse(String digital } Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { + + Object payloadObject = null; + try { + payloadObject = mapper.readValue(payload, Object.class); + } + catch (JsonProcessingException e) { + logger.error("Could not parse the payload [%s]: %s", payload, e); + return Mono.error(e); + } + return protocolLayer.getDigitalTwins().sendComponentTelemetryWithResponseAsync( digitalTwinId, componentName, publishTelemetryRequestOptions.getMessageId(), - payload, + payloadObject, publishTelemetryRequestOptions.getTimestamp().toString(), context); } From ff38b3b8d49ef3ef979e0c9036a1f1eaedf22606 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 14:04:45 -0700 Subject: [PATCH 05/11] Update DigitalTwinsAsyncClient.java --- .../digitaltwins/core/DigitalTwinsAsyncClient.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index 21bf4b4e47d4b..518042260f836 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1383,10 +1383,19 @@ public Mono> publishTelemetryWithResponse(String digitalTwinId, S } Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { + Object payloadObject = null; + try { + payloadObject = mapper.readValue(payload, Object.class); + } + catch (JsonProcessingException e) { + logger.error("Could not parse the payload [%s]: %s", payload, e); + return Mono.error(e); + } + return protocolLayer.getDigitalTwins().sendTelemetryWithResponseAsync( digitalTwinId, publishTelemetryRequestOptions.getMessageId(), - payload, + payloadObject, publishTelemetryRequestOptions.getTimestamp().toString(), context); } From 7c44895d31b3cd17233493045e0b82436fff5e37 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 14:45:22 -0700 Subject: [PATCH 06/11] Update ComponentsAsyncTests.java --- .../java/com/azure/digitaltwins/core/ComponentsAsyncTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/ComponentsAsyncTests.java b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/ComponentsAsyncTests.java index 638a43221019d..06f2eb8c9bbeb 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/ComponentsAsyncTests.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/test/java/com/azure/digitaltwins/core/ComponentsAsyncTests.java @@ -64,7 +64,7 @@ public void componentLifecycleTest(HttpClient httpClient, DigitalTwinsServiceVer StepVerifier.create(asyncClient.updateComponentWithResponse(roomWithWifiTwinId, wifiComponentName, TestAssetsHelper.getWifiComponentUpdatePayload(), new UpdateComponentRequestOptions())) .assertNext(updateResponse -> { assertEquals(updateResponse.getStatusCode(), HttpURLConnection.HTTP_NO_CONTENT); - logger.info("Updated component successfully"); + logger.info("Updated the component successfully"); }) .verifyComplete(); } From ec9fc765d9f62d04ada4fa677e50471b532c0fab Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 14:56:09 -0700 Subject: [PATCH 07/11] Remove unnecessary APIs --- .../core/DigitalTwinsAsyncClient.java | 29 ------------------- .../digitaltwins/core/DigitalTwinsClient.java | 25 ---------------- 2 files changed, 54 deletions(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index 518042260f836..04ed4d1536704 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1355,20 +1355,6 @@ public Mono publishTelemetry(String digitalTwinId, String payload) { .flatMap(voidResponse -> Mono.empty()); } - /** - * Publishes telemetry from a digital twin - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} - * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. - * @param digitalTwinId The Id of the digital twin. - * @param payload The application/json telemetry payload to be sent. - * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. - * @return An empty mono. - */ - public Mono publishTelemetry(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { - return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context)) - .flatMap(voidResponse -> Mono.empty()); - } - /** * Publishes telemetry from a digital twin * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} @@ -1415,21 +1401,6 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone .flatMap(voidResponse -> Mono.empty()); } - /** - * Publishes telemetry from a digital twin's component - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} - * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. - * @param digitalTwinId The Id of the digital twin. - * @param componentName The name of the DTDL component. - * @param payload The application/json telemetry payload to be sent. - * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. - * @return An empty mono. - */ - public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { - return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context)) - .flatMap(voidResponse -> Mono.empty()); - } - /** * Publishes telemetry from a digital twin's component * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index d897158f9b911..67b261c1e3dbf 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -780,18 +780,6 @@ public PagedIterable listEventRoutes(EventRoutesListOptions options, */ public void publishTelemetry(String digitalTwinId, String payload) { PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); - publishTelemetry(digitalTwinId, payload, publishTelemetryRequestOptions); - } - - /** - * Publishes telemetry from a digital twin - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} - * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. - * @param digitalTwinId The Id of the digital twin. - * @param payload The application/json telemetry payload to be sent. - * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. - */ - public void publishTelemetry(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, Context.NONE); } @@ -819,19 +807,6 @@ public Response publishTelemetryWithResponse(String digitalTwinId, String */ public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); - publishComponentTelemetry(digitalTwinId, componentName, payload, publishTelemetryRequestOptions); - } - - /** - * Publishes telemetry from a digital twin's component - * The result is then consumed by one or many destination endpoints (subscribers) defined under {@link EventRoute} - * These event routes need to be set before publishing a telemetry message, in order for the telemetry message to be consumed. - * @param digitalTwinId The Id of the digital twin. - * @param componentName The name of the DTDL component. - * @param payload The application/json telemetry payload to be sent. - * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. - */ - public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, Context.NONE); } From c09ff123be1713d46ddd9980e9e256351d4a9259 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 15:04:45 -0700 Subject: [PATCH 08/11] Update DigitalTwinsClient.java --- .../java/com/azure/digitaltwins/core/DigitalTwinsClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index 67b261c1e3dbf..8186264967d96 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -717,10 +717,11 @@ public void createEventRoute(String eventRouteId, EventRoute eventRoute) { * @param eventRouteId The id of the event route to create. * @param eventRoute The event route to create. * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public void createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, Context context) { - this.digitalTwinsAsyncClient.createEventRouteWithResponse(eventRouteId, eventRoute, context).block(); + public Response createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, Context context) { + return this.digitalTwinsAsyncClient.createEventRouteWithResponse(eventRouteId, eventRoute, context).block(); } /** From 43b34e80107b90ce5e2dfcf3cb9c5b1d2e23ddd2 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 15:05:42 -0700 Subject: [PATCH 09/11] Update DigitalTwinsClient.java --- .../java/com/azure/digitaltwins/core/DigitalTwinsClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index 8186264967d96..273a07fca9b2c 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -720,7 +720,7 @@ public void createEventRoute(String eventRouteId, EventRoute eventRoute) { * @return A {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, Context context) { + public Response createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, Context context) { return this.digitalTwinsAsyncClient.createEventRouteWithResponse(eventRouteId, eventRoute, context).block(); } From d028ba2523803af23c97001e85bad3f904eaec2f Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 15:10:21 -0700 Subject: [PATCH 10/11] Add ServiceMethod annotations --- .../com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java | 4 ++++ .../java/com/azure/digitaltwins/core/DigitalTwinsClient.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index 04ed4d1536704..fc280145a1143 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -1349,6 +1349,7 @@ Mono> listEventRoutesNextPage(String nextLink, Context * @param payload The application/json telemetry payload to be sent. * @return An empty mono. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Mono publishTelemetry(String digitalTwinId, String payload) { PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context)) @@ -1364,6 +1365,7 @@ public Mono publishTelemetry(String digitalTwinId, String payload) { * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @return A {@link Response} containing an empty mono. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Mono> publishTelemetryWithResponse(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { return withContext(context -> publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context)); } @@ -1395,6 +1397,7 @@ Mono> publishTelemetryWithResponse(String digitalTwinId, String p * @param payload The application/json telemetry payload to be sent. * @return An empty mono. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Mono publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context)) @@ -1411,6 +1414,7 @@ public Mono publishComponentTelemetry(String digitalTwinId, String compone * @param publishTelemetryRequestOptions The additional information to be used when processing a telemetry request. * @return A {@link Response} containing an empty mono. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Mono> publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions) { return withContext(context -> publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context)); } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index 273a07fca9b2c..6741247f08bb4 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -779,6 +779,7 @@ public PagedIterable listEventRoutes(EventRoutesListOptions options, * @param digitalTwinId The Id of the digital twin. * @param payload The application/json telemetry payload to be sent. */ + @ServiceMethod(returns = ReturnType.SINGLE) public void publishTelemetry(String digitalTwinId, String payload) { PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, Context.NONE); @@ -794,6 +795,7 @@ public void publishTelemetry(String digitalTwinId, String payload) { * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link Response}. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Response publishTelemetryWithResponse(String digitalTwinId, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { return digitalTwinsAsyncClient.publishTelemetryWithResponse(digitalTwinId, payload, publishTelemetryRequestOptions, context).block(); } @@ -806,6 +808,7 @@ public Response publishTelemetryWithResponse(String digitalTwinId, String * @param componentName The name of the DTDL component. * @param payload The application/json telemetry payload to be sent. */ + @ServiceMethod(returns = ReturnType.SINGLE) public void publishComponentTelemetry(String digitalTwinId, String componentName, String payload) { PublishTelemetryRequestOptions publishTelemetryRequestOptions = new PublishTelemetryRequestOptions(); publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, Context.NONE); @@ -822,6 +825,7 @@ public void publishComponentTelemetry(String digitalTwinId, String componentName * @param context Additional context that is passed through the Http pipeline during the service call. * @return A {@link Response}. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Response publishComponentTelemetryWithResponse(String digitalTwinId, String componentName, String payload, PublishTelemetryRequestOptions publishTelemetryRequestOptions, Context context) { return digitalTwinsAsyncClient.publishComponentTelemetryWithResponse(digitalTwinId, componentName, payload, publishTelemetryRequestOptions, context).block(); } From 6cef198757cac41d8ef7bb73f2ed2a7c8172e8d9 Mon Sep 17 00:00:00 2001 From: Azad Abbasi Date: Thu, 10 Sep 2020 15:12:03 -0700 Subject: [PATCH 11/11] More missing serviceMethod annotations --- .../com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java | 2 ++ .../java/com/azure/digitaltwins/core/DigitalTwinsClient.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java index fc280145a1143..bfd3c7767b075 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java @@ -937,6 +937,7 @@ PagedFlux listRelationships(String digitalTwinId, String relationshipNam * @param modelId The Id of the model to decommission. * @return an empty Mono */ + @ServiceMethod(returns = ReturnType.SINGLE) public Mono decommissionModel(String modelId) { return decommissionModelWithResponse(modelId) .flatMap(voidResponse -> Mono.empty()); @@ -947,6 +948,7 @@ public Mono decommissionModel(String modelId) { * @param modelId The Id of the model to decommission. * @return The http response. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Mono> decommissionModelWithResponse(String modelId) { return withContext(context -> decommissionModelWithResponse(modelId, context)); } diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java index 6741247f08bb4..9cd82068cc28c 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsClient.java @@ -550,6 +550,7 @@ public Response deleteModelWithResponse(String modelId, Context context) { * Decommissions a model. * @param modelId The Id of the model to decommission. */ + @ServiceMethod(returns = ReturnType.SINGLE) public void decommissionModel(String modelId) { decommissionModelWithResponse(modelId, Context.NONE); } @@ -560,6 +561,7 @@ public void decommissionModel(String modelId) { * @param context Additional context that is passed through the Http pipeline during the service call. * @return The http response. */ + @ServiceMethod(returns = ReturnType.SINGLE) public Response decommissionModelWithResponse(String modelId, Context context) { return digitalTwinsAsyncClient.decommissionModelWithResponse(modelId, context).block(); }