From 49d7bb557cd0fbd0e31660cdb91558bdd0a11c83 Mon Sep 17 00:00:00 2001 From: bikamani <41314966+bikamani@users.noreply.github.com> Date: Tue, 1 Sep 2020 14:03:37 -0700 Subject: [PATCH] Add implementation of DT Apis (#14671) --- .../azure-digitaltwins-core/API design.md | 59 +---- .../core/DeleteDigitalTwinRequestOptions.java | 18 ++ .../core/DigitalTwinsAsyncClient.java | 204 +++++++++++++++++- .../digitaltwins/core/DigitalTwinsClient.java | 163 ++++++++++++++ .../core/UpdateDigitalTwinRequestOptions.java | 20 ++ 5 files changed, 406 insertions(+), 58 deletions(-) create mode 100644 sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DeleteDigitalTwinRequestOptions.java create mode 100644 sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/UpdateDigitalTwinRequestOptions.java diff --git a/sdk/digitaltwins/azure-digitaltwins-core/API design.md b/sdk/digitaltwins/azure-digitaltwins-core/API design.md index aa75a9e3450c2..3d065d4832b4e 100644 --- a/sdk/digitaltwins/azure-digitaltwins-core/API design.md +++ b/sdk/digitaltwins/azure-digitaltwins-core/API design.md @@ -400,21 +400,9 @@ public Mono> deleteDigitalTwinWithResponse(String digitalTwinId, * * @param digitalTwinId The Id of the digital twin. * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin - * @return The updated application/json digital twin. */ @ServiceMethod(returns = ReturnType.SINGLE) -public Mono updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations) - - /** - * Updates a digital twin. - * - * @param digitalTwinId The Id of the digital twin. - * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin - * @param classType The model class to convert the response to. - * @return The updated application/json digital twin. - */ -@ServiceMethod(returns = ReturnType.SINGLE) -public Mono updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations, Class classType) +public Mono updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations) /** * Updates a digital twin. @@ -422,22 +410,11 @@ public Mono updateDigitalTwin(String digitalTwinId, List digitalT * @param digitalTwinId The Id of the digital twin. * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin * @param options The optional settings for this request - * @return A Http response containing updated application/json digital twin. + * @return A Http response */ @ServiceMethod(returns = ReturnType.SINGLE) -public Mono> updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, RequestOptions options) +public Mono> updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, RequestOptions options) - /** - * Updates a digital twin. - * - * @param digitalTwinId The Id of the digital twin. - * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin - * @param classType The model class to convert the response to. - * @param options The optional settings for this request - * @return A Http response containing updated application/json digital twin. - */ -@ServiceMethod(returns = ReturnType.SINGLE) -public Mono> updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, RequestOptions options, Class classType) ``` @@ -555,21 +532,9 @@ public Response deleteDigitalTwinWithResponse(String digitalTwinId, Reques * * @param digitalTwinId The Id of the digital twin. * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin - * @return The updated application/json digital twin. */ @ServiceMethod(returns = ReturnType.SINGLE) -public String updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations) - - /** - * Updates a digital twin. - * - * @param digitalTwinId The Id of the digital twin. - * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin - * @param classType The model class to convert the response to. - * @return The updated application/json digital twin. - */ -@ServiceMethod(returns = ReturnType.SINGLE) -public updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations, Class classType) +public void updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations) /** * Updates a digital twin. @@ -578,23 +543,11 @@ public updateDigitalTwin(String digitalTwinId, List digitalTwinUpdat * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin * @param options The optional settings for this request * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A Http response containing updated application/json digital twin. + * @return A Http response */ @ServiceMethod(returns = ReturnType.SINGLE) -public Response updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, RequestOptions options, Context context) +public Response updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, RequestOptions options, Context context) -/** - * Updates a digital twin. - * - * @param digitalTwinId The Id of the digital twin. - * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin - * @param options The optional settings for this request - * @param classType The model class to convert the response to. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A Http response containing updated application/json digital twin. - */ -@ServiceMethod(returns = ReturnType.SINGLE) -public Response updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, RequestOptions options, Class classType, Context context) ``` diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DeleteDigitalTwinRequestOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DeleteDigitalTwinRequestOptions.java new file mode 100644 index 0000000000000..5ded3a86fc101 --- /dev/null +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DeleteDigitalTwinRequestOptions.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.digitaltwins.core; + +/** + * Optional settings that are specific to calls to {@link DigitalTwinsClient#deleteDigitalTwin(String)} and its overloads. + */ +public class DeleteDigitalTwinRequestOptions extends RequestOptions { + // This class exists to be added to later if the deleteDigitalTwin APIs get a new optional parameter in later service + // API versions and so that we don't have to expose that new optional parameter for other APIs using RequestOptions + + @Override + public DeleteDigitalTwinRequestOptions setIfMatch(String ifMatch) { + super.setIfMatch(ifMatch); + return this; + } +} 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 159c7b2cee56f..8266fdaca32c1 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 @@ -91,8 +91,27 @@ public HttpPipeline getHttpPipeline() { return this.protocolLayer.getHttpPipeline(); } - // TODO: This is a temporary implementation for sample purposes. This should be spruced up/replaced once this API is actually designed. - // Input is String and output is Response. + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @return The application/json string representing the digital twin created. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createDigitalTwin(String digitalTwinId, String digitalTwin) + { + return createDigitalTwinWithResponse(digitalTwinId, digitalTwin) + .map(DigitalTwinsResponse::getValue); + } + + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @return A {@link DigitalTwinsResponse} containing the application/json string representing the digital twin created. + */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createDigitalTwinWithResponse(String digitalTwinId, String digitalTwin) { return withContext(context -> createDigitalTwinWithResponse(digitalTwinId, digitalTwin, context)); @@ -108,14 +127,37 @@ Mono> createDigitalTwinWithResponse(String digitalT DigitalTwinsResponseHeaders twinHeaders = mapper.convertValue(response.getDeserializedHeaders(), DigitalTwinsResponseHeaders.class); return Mono.just(new DigitalTwinsResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), jsonResponse, twinHeaders)); } catch (JsonProcessingException e) { - logger.error("JsonProcessingException occurred while creating a digital twin: ", e); + logger.error("JsonProcessingException occurred while serializing json object into string ", e); return Mono.error(e); } }); } - // TODO: This is a temporary implementation for sample purposes. This should be spruced up/replaced once this API is actually designed. - // Input is Object and output is Response. + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @return The deserialized application/json object representing the digital twin created. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createDigitalTwin(String digitalTwinId, Object digitalTwin, Class clazz) + { + return createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz) + .map(DigitalTwinsResponse::getValue); + } + + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @return A {@link DigitalTwinsResponse} containing the deserialized application/json object representing the digital twin created. + */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createDigitalTwinWithResponse(String digitalTwinId, Object digitalTwin, Class clazz) { return withContext(context -> createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, context)); @@ -132,6 +174,158 @@ Mono> createDigitalTwinWithResponse(String digitalTw }); } + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @return The application/json string representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDigitalTwin(String digitalTwinId) + { + return getDigitalTwinWithResponse(digitalTwinId) + .map(DigitalTwinsResponse::getValue); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @return A {@link DigitalTwinsResponse} containing the application/json string representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDigitalTwinWithResponse(String digitalTwinId) + { + return withContext(context -> getDigitalTwinWithResponse(digitalTwinId, context)); + } + + Mono> getDigitalTwinWithResponse(String digitalTwinId, Context context) { + return protocolLayer + .getDigitalTwins() + .getByIdWithResponseAsync(digitalTwinId, context) + .flatMap(response -> { + try { + String jsonResponse = mapper.writeValueAsString(response.getValue()); + DigitalTwinsResponseHeaders twinHeaders = mapper.convertValue(response.getDeserializedHeaders(), DigitalTwinsResponseHeaders.class); + return Mono.justOrEmpty(new DigitalTwinsResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), jsonResponse, twinHeaders)); + } catch (JsonProcessingException e) { + logger.error("JsonProcessingException occurred while serializing json object into string: ", e); + return Mono.error(e); + } + }); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @return The deserialized application/json object representing the digital twin + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getDigitalTwin(String digitalTwinId, Class clazz) + { + return getDigitalTwinWithResponse(digitalTwinId, clazz) + .map(DigitalTwinsResponse::getValue); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @return A {@link DigitalTwinsResponse} containing the deserialized application/json object representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getDigitalTwinWithResponse(String digitalTwinId, Class clazz) + { + return withContext(context -> getDigitalTwinWithResponse(digitalTwinId, clazz, context)); + } + + Mono> getDigitalTwinWithResponse(String digitalTwinId, Class clazz, Context context) { + return protocolLayer + .getDigitalTwins() + .getByIdWithResponseAsync(digitalTwinId, context) + .map(response -> { + T genericResponse = mapper.convertValue(response.getValue(), clazz); + DigitalTwinsResponseHeaders twinHeaders = mapper.convertValue(response.getDeserializedHeaders(), DigitalTwinsResponseHeaders.class); + return new DigitalTwinsResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), genericResponse, twinHeaders); + }); + } + + /** + * Updates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin + * @return An empty Mono + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations) + { + return updateDigitalTwinWithResponse(digitalTwinId, digitalTwinUpdateOperations, new UpdateDigitalTwinRequestOptions()) + .flatMap(voidResponse -> Mono.empty()); + } + + /** + * Updates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin + * @param options The optional settings for this request + * @return A {@link DigitalTwinsResponse} + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, UpdateDigitalTwinRequestOptions options) + { + return withContext(context -> updateDigitalTwinWithResponse(digitalTwinId, digitalTwinUpdateOperations, options, context)); + } + + Mono> updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, UpdateDigitalTwinRequestOptions options, Context context) { + String ifMatch = options != null ? options.getIfMatch() : null; + return protocolLayer + .getDigitalTwins() + .updateWithResponseAsync(digitalTwinId, digitalTwinUpdateOperations, ifMatch, context) + .map(response -> { + DigitalTwinsResponseHeaders twinHeaders = mapper.convertValue(response.getDeserializedHeaders(), DigitalTwinsResponseHeaders.class); + return new DigitalTwinsResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), response.getValue(), twinHeaders); + }); + } + + /** + * Deletes a digital twin. All relationships referencing the digital twin must already be deleted. + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @return An empty Mono + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteDigitalTwin(String digitalTwinId) + { + return deleteDigitalTwinWithResponse(digitalTwinId, new DeleteDigitalTwinRequestOptions()) + .flatMap(voidResponse -> Mono.empty()); + } + + /** + * Deletes a digital twin. All relationships referencing the digital twin must already be deleted. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param options The optional settings for this request + * @return The Http response + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteDigitalTwinWithResponse(String digitalTwinId, DeleteDigitalTwinRequestOptions options) + { + return withContext(context -> deleteDigitalTwinWithResponse(digitalTwinId, options, context)); + } + + Mono> deleteDigitalTwinWithResponse(String digitalTwinId, DeleteDigitalTwinRequestOptions options, Context context) { + String ifMatch = options != null ? options.getIfMatch() : null; + return protocolLayer + .getDigitalTwins() + .deleteWithResponseAsync(digitalTwinId, ifMatch, context); + } + /** * Creates a relationship on a digital twin. * 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 67b6031fe492e..a8e404eb9d04b 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 @@ -59,6 +59,169 @@ public DigitalTwinsServiceVersion getServiceVersion() { return this.digitalTwinsAsyncClient.getServiceVersion(); } + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @return The application/json string representing the digital twin created. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public String createDigitalTwin(String digitalTwinId, String digitalTwin) + { + return createDigitalTwinWithResponse(digitalTwinId, digitalTwin, Context.NONE).getValue(); + } + + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link DigitalTwinsResponse} containing the application/json string representing the digital twin created. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createDigitalTwinWithResponse(String digitalTwinId, String digitalTwin, Context context) + { + return digitalTwinsAsyncClient.createDigitalTwinWithResponse(digitalTwinId, digitalTwin, context).block(); + } + + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @param digitalTwin The application/json digital twin to create. + * @return The deserialized application/json object representing the digital twin created. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public T createDigitalTwin(String digitalTwinId, Object digitalTwin, Class clazz) + { + return createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, Context.NONE).getValue(); + } + + /** + * Creates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwin The application/json digital twin to create. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link DigitalTwinsResponse} containing the deserialized application/json object representing the digital twin created. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createDigitalTwinWithResponse(String digitalTwinId, Object digitalTwin, Class clazz, Context context) + { + return digitalTwinsAsyncClient.createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, context).block(); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @return The application/json string representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public String getDigitalTwin(String digitalTwinId) + { + return getDigitalTwinWithResponse(digitalTwinId, Context.NONE).getValue(); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link DigitalTwinsResponse} containing the application/json string representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DigitalTwinsResponse getDigitalTwinWithResponse(String digitalTwinId, Context context) + { + return digitalTwinsAsyncClient.getDigitalTwinWithResponse(digitalTwinId, context).block(); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @return The deserialized application/json object representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public T getDigitalTwin(String digitalTwinId, Class clazz) + { + return getDigitalTwinWithResponse(digitalTwinId, clazz, Context.NONE).getValue(); + } + + /** + * Gets a digital twin. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param clazz The model class to deserialize the response with. + * @param The generic type to deserialize the digital twin with. + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link DigitalTwinsResponse} containing the deserialized application/json object representing the digital twin. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DigitalTwinsResponse getDigitalTwinWithResponse(String digitalTwinId, Class clazz, Context context) + { + return digitalTwinsAsyncClient.getDigitalTwinWithResponse(digitalTwinId, clazz, context).block(); + } + + /** + * Updates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations) + { + updateDigitalTwinWithResponse(digitalTwinId, digitalTwinUpdateOperations, new UpdateDigitalTwinRequestOptions(), Context.NONE); + } + + /** + * Updates a digital twin. + * + * @param digitalTwinId The Id of the digital twin. + * @param digitalTwinUpdateOperations The application/json-patch+json operations to be performed on the specified digital twin + * @param options The optional settings for this request + * @param context Additional context that is passed through the Http pipeline during the service call. + * @return A {@link DigitalTwinsResponse} + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DigitalTwinsResponse updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, UpdateDigitalTwinRequestOptions options, Context context) + { + return digitalTwinsAsyncClient.updateDigitalTwinWithResponse(digitalTwinId, digitalTwinUpdateOperations, options, context).block(); + } + + /** + * Deletes a digital twin. All relationships referencing the digital twin must already be deleted. + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteDigitalTwin(String digitalTwinId) + { + deleteDigitalTwinWithResponse(digitalTwinId, new DeleteDigitalTwinRequestOptions(), Context.NONE); + } + + /** + * Deletes a digital twin. All relationships referencing the digital twin must already be deleted. + * + * @param digitalTwinId The Id of the digital twin. The Id is unique within the service and case sensitive. + * @param options The optional settings for this request + * @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 deleteDigitalTwinWithResponse(String digitalTwinId, DeleteDigitalTwinRequestOptions options, Context context) + { + return digitalTwinsAsyncClient.deleteDigitalTwinWithResponse(digitalTwinId, options, context).block(); + } + /** * Creates a relationship on a digital twin. * diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/UpdateDigitalTwinRequestOptions.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/UpdateDigitalTwinRequestOptions.java new file mode 100644 index 0000000000000..7c5f07eb1ead8 --- /dev/null +++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/UpdateDigitalTwinRequestOptions.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.digitaltwins.core; + +import java.util.List; + +/** + * Optional settings that are specific to calls to {@link DigitalTwinsClient#updateDigitalTwin(String, List)} and its overloads. + */ +public class UpdateDigitalTwinRequestOptions extends RequestOptions { + // This class exists to be added to later if the updateDigitalTwin APIs get a new optional parameter in later service + // API versions and so that we don't have to expose that new optional parameter for other APIs using RequestOptions + + @Override + public UpdateDigitalTwinRequestOptions setIfMatch(String ifMatch) { + super.setIfMatch(ifMatch); + return this; + } +}