Skip to content

Commit

Permalink
Rename digital twins create APIs to be createOrReplace (#16808)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtay-microsoft authored Oct 26, 2020
1 parent 3b9c33b commit 19e3106
Show file tree
Hide file tree
Showing 24 changed files with 136 additions and 139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public DigitalTwinsServiceVersion getServiceVersion() {
* @return The deserialized application/json object representing the digital twin created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<T> createDigitalTwin(String digitalTwinId, T digitalTwin, Class<T> clazz)
public <T> Mono<T> createOrReplaceDigitalTwin(String digitalTwinId, T digitalTwin, Class<T> clazz)
{
return createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, null)
return createOrReplaceDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, null)
.map(DigitalTwinsResponse::getValue);
}

Expand All @@ -141,11 +141,11 @@ public <T> Mono<T> createDigitalTwin(String digitalTwinId, T digitalTwin, Class<
* @return A {@link DigitalTwinsResponse} containing the deserialized application/json object representing the digital twin created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<DigitalTwinsResponse<T>> createDigitalTwinWithResponse(String digitalTwinId, T digitalTwin, Class<T> clazz, CreateDigitalTwinOptions options) {
return withContext(context -> createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, options, context));
public <T> Mono<DigitalTwinsResponse<T>> createOrReplaceDigitalTwinWithResponse(String digitalTwinId, T digitalTwin, Class<T> clazz, CreateDigitalTwinOptions options) {
return withContext(context -> createOrReplaceDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, options, context));
}

<T> Mono<DigitalTwinsResponse<T>> createDigitalTwinWithResponse(String digitalTwinId, T digitalTwin, Class<T> clazz, CreateDigitalTwinOptions options, Context context) {
<T> Mono<DigitalTwinsResponse<T>> createOrReplaceDigitalTwinWithResponse(String digitalTwinId, T digitalTwin, Class<T> clazz, CreateDigitalTwinOptions options, Context context) {
return protocolLayer
.getDigitalTwins()
.addWithResponseAsync(digitalTwinId, digitalTwin, OptionsConverter.toProtocolLayerOptions(options), context)
Expand All @@ -167,7 +167,7 @@ <T> Mono<DigitalTwinsResponse<T>> createDigitalTwinWithResponse(String digitalTw
/**
* Gets a digital twin.
*
<p><strong>Code Samples</strong></p>
* <p><strong>Code Samples</strong></p>
*
* <p>
* A Strongly typed object type such as {@link BasicDigitalTwin} can be provided as an input parameter for {@code clazz}
Expand Down Expand Up @@ -341,11 +341,11 @@ Mono<Response<Void>> deleteDigitalTwinWithResponse(String digitalTwinId, DeleteD
*
* <p>A strongly typed digital twin object such as {@link BasicRelationship} can be provided as the input parameter to deserialize the response into.</p>
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createRelationship#String-String-Object-Class#BasicRelationship}
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createOrReplaceRelationship#String-String-Object-Class#BasicRelationship}
*
* <p>Or alternatively String can be used as input and output deserialization type:</p>
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createRelationship#String-String-Object-Class#String}
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createOrReplaceRelationship#String-String-Object-Class#String}
*
* @param digitalTwinId The Id of the source digital twin.
* @param relationshipId The Id of the relationship to be created.
Expand All @@ -355,8 +355,8 @@ Mono<Response<Void>> deleteDigitalTwinWithResponse(String digitalTwinId, DeleteD
* @return The relationship created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<T> createRelationship(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz) {
return createRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, null)
public <T> Mono<T> createOrReplaceRelationship(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz) {
return createOrReplaceRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, null)
.map(DigitalTwinsResponse::getValue);
}

Expand All @@ -368,11 +368,11 @@ public <T> Mono<T> createRelationship(String digitalTwinId, String relationshipI
*
* <p>A strongly typed digital twin object such as {@link BasicRelationship} can be provided as the input parameter to deserialize the response into.</p>
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createRelationshipWithResponse#String-String-Object-Class-Options#BasicRelationship}
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createOrReplaceRelationshipWithResponse#String-String-Object-Class-Options#BasicRelationship}
*
* <p>Or alternatively String can be used as input and output deserialization type:</p>
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createRelationshipWithResponse#String-String-Object-Class-Options#String}
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createOrReplaceRelationshipWithResponse#String-String-Object-Class-Options#String}
*
* @param digitalTwinId The Id of the source digital twin.
* @param relationshipId The Id of the relationship to be created.
Expand All @@ -383,11 +383,11 @@ public <T> Mono<T> createRelationship(String digitalTwinId, String relationshipI
* @return A {@link DigitalTwinsResponse} containing the relationship created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<DigitalTwinsResponse<T>> createRelationshipWithResponse(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz, CreateRelationshipOptions options) {
return withContext(context -> createRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, options, context));
public <T> Mono<DigitalTwinsResponse<T>> createOrReplaceRelationshipWithResponse(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz, CreateRelationshipOptions options) {
return withContext(context -> createOrReplaceRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, options, context));
}

<T> Mono<DigitalTwinsResponse<T>> createRelationshipWithResponse(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz, CreateRelationshipOptions options, Context context) {
<T> Mono<DigitalTwinsResponse<T>> createOrReplaceRelationshipWithResponse(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz, CreateRelationshipOptions options, Context context) {
return protocolLayer
.getDigitalTwins()
.addRelationshipWithResponseAsync(digitalTwinId, relationshipId, relationship, OptionsConverter.toProtocolLayerOptions(options), context)
Expand Down Expand Up @@ -1242,14 +1242,14 @@ <T> Mono<PagedResponse<T>> queryNextPage(String nextLink, Class<T> clazz, QueryO
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createEventRoute#String-EventRoute}
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createOrReplaceEventRoute#String-EventRoute}
*
* @param eventRouteId The Id of the event route to create.
* @param eventRoute The event route to create.
* @return An empty mono.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> createEventRoute(String eventRouteId, EventRoute eventRoute)
public Mono<Void> createOrReplaceEventRoute(String eventRouteId, EventRoute eventRoute)
{
return createEventRouteWithResponse(eventRouteId, eventRoute, null)
.flatMap(voidResponse -> Mono.empty());
Expand All @@ -1261,7 +1261,7 @@ public Mono<Void> createEventRoute(String eventRouteId, EventRoute eventRoute)
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createEventRouteWithResponse#String-EventRoute-Options}
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createOrReplaceEventRouteWithResponse#String-EventRoute-Options}
*
* @param eventRouteId The Id of the event route to create.
* @param eventRoute The event route to create.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public DigitalTwinsServiceVersion getServiceVersion() {
* @return The deserialized application/json object representing the digital twin created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> T createDigitalTwin(String digitalTwinId, T digitalTwin, Class<T> clazz)
public <T> T createOrReplaceDigitalTwin(String digitalTwinId, T digitalTwin, Class<T> clazz)
{
return createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, null, Context.NONE).getValue();
return createOrReplaceDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, null, Context.NONE).getValue();
}

/**
Expand All @@ -97,9 +97,9 @@ public <T> T createDigitalTwin(String digitalTwinId, T digitalTwin, Class<T> cla
* @return A {@link DigitalTwinsResponse} containing the deserialized application/json object representing the digital twin created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Response<T> createDigitalTwinWithResponse(String digitalTwinId, T digitalTwin, Class<T> clazz, CreateDigitalTwinOptions options, Context context)
public <T> Response<T> createOrReplaceDigitalTwinWithResponse(String digitalTwinId, T digitalTwin, Class<T> clazz, CreateDigitalTwinOptions options, Context context)
{
return digitalTwinsAsyncClient.createDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, options, context).block();
return digitalTwinsAsyncClient.createOrReplaceDigitalTwinWithResponse(digitalTwinId, digitalTwin, clazz, options, context).block();
}

/**
Expand Down Expand Up @@ -244,11 +244,11 @@ public Response<Void> deleteDigitalTwinWithResponse(String digitalTwinId, Delete
*
* <p>A strongly typed digital twin object such as {@link BasicRelationship} can be provided as the input parameter to deserialize the response into.</p>
*
* {@codesnippet com.azure.digitaltwins.core.syncClient.createRelationship#String-String-Object-Class#BasicRelationship}
* {@codesnippet com.azure.digitaltwins.core.syncClient.createOrReplaceRelationship#String-String-Object-Class#BasicRelationship}
*
* <p>Or alternatively String can be used as input and output deserialization type:</p>
*
* {@codesnippet com.azure.digitaltwins.core.syncClient.createRelationship#String-String-Object-Class#String}
* {@codesnippet com.azure.digitaltwins.core.syncClient.createOrReplaceRelationship#String-String-Object-Class#String}
*
* @param digitalTwinId The Id of the source digital twin.
* @param relationshipId The Id of the relationship to be created.
Expand All @@ -258,8 +258,8 @@ public Response<Void> deleteDigitalTwinWithResponse(String digitalTwinId, Delete
* @return The relationship created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> T createRelationship(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz) {
return createRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, null, Context.NONE).getValue();
public <T> T createOrReplaceRelationship(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz) {
return createOrReplaceRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, null, Context.NONE).getValue();
}

/**
Expand All @@ -270,11 +270,11 @@ public <T> T createRelationship(String digitalTwinId, String relationshipId, T r
*
* <p>A strongly typed digital twin object such as {@link BasicRelationship} can be provided as the input parameter to deserialize the response into.</p>
*
* {@codesnippet com.azure.digitaltwins.core.syncClient.createRelationshipWithResponse#String-String-Object-Class-Options-Context#BasicRelationship}
* {@codesnippet com.azure.digitaltwins.core.syncClient.createOrReplaceRelationshipWithResponse#String-String-Object-Class-Options-Context#BasicRelationship}
*
* <p>Or alternatively String can be used as input and output deserialization type:</p>
*
* {@codesnippet com.azure.digitaltwins.core.syncClient.createRelationshipWithResponse#String-String-Object-Class-Options-Context#String}
* {@codesnippet com.azure.digitaltwins.core.syncClient.createOrReplaceRelationshipWithResponse#String-String-Object-Class-Options-Context#String}
*
* @param digitalTwinId The Id of the source digital twin.
* @param relationshipId The Id of the relationship to be created.
Expand All @@ -286,8 +286,8 @@ public <T> T createRelationship(String digitalTwinId, String relationshipId, T r
* @return A {@link DigitalTwinsResponse} containing the relationship created.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> DigitalTwinsResponse<T> createRelationshipWithResponse(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz, CreateRelationshipOptions options, Context context) {
return digitalTwinsAsyncClient.createRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, options, context).block();
public <T> DigitalTwinsResponse<T> createOrReplaceRelationshipWithResponse(String digitalTwinId, String relationshipId, T relationship, Class<T> clazz, CreateRelationshipOptions options, Context context) {
return digitalTwinsAsyncClient.createOrReplaceRelationshipWithResponse(digitalTwinId, relationshipId, relationship, clazz, options, context).block();
}

/**
Expand Down Expand Up @@ -808,14 +808,14 @@ public <T> PagedIterable<T> query(String query, Class<T> clazz, QueryOptions opt
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.digitaltwins.core.syncClient.createEventRoute#String-EventRoute}
* {@codesnippet com.azure.digitaltwins.core.syncClient.createOrReplaceEventRoute#String-EventRoute}
*
* @param eventRouteId The id of the event route to create.
* @param eventRoute The event route to create.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void createEventRoute(String eventRouteId, EventRoute eventRoute) {
createEventRouteWithResponse(eventRouteId, eventRoute, null, Context.NONE);
public void createOrReplaceEventRoute(String eventRouteId, EventRoute eventRoute) {
createOrReplaceEventRouteWithResponse(eventRouteId, eventRoute, null, Context.NONE);
}

/**
Expand All @@ -824,7 +824,7 @@ public void createEventRoute(String eventRouteId, EventRoute eventRoute) {
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.digitaltwins.core.syncClient.createEventRouteWithResponse#String-EventRoute-Options-Context}
* {@codesnippet com.azure.digitaltwins.core.syncClient.createOrReplaceEventRouteWithResponse#String-EventRoute-Options-Context}
*
* @param eventRouteId The id of the event route to create.
* @param eventRoute The event route to create.
Expand All @@ -833,7 +833,7 @@ public void createEventRoute(String eventRouteId, EventRoute eventRoute) {
* @return A {@link Response}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> createEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, CreateEventRouteOptions options, Context context) {
public Response<Void> createOrReplaceEventRouteWithResponse(String eventRouteId, EventRoute eventRoute, CreateEventRouteOptions options, Context context) {
return this.digitalTwinsAsyncClient.createEventRouteWithResponse(eventRouteId, eventRoute, options, context).block();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

import com.azure.core.annotation.Fluent;
import com.azure.core.util.Context;
import com.azure.digitaltwins.core.implementation.models.DigitalTwinsAddOptions;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The optional parameters for
* {@link com.azure.digitaltwins.core.DigitalTwinsClient#createDigitalTwinWithResponse(String, Object, Class, CreateDigitalTwinOptions, Context)} and
* {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#createDigitalTwinWithResponse(String, Object, Class, CreateDigitalTwinOptions)}
* {@link com.azure.digitaltwins.core.DigitalTwinsClient#createOrReplaceDigitalTwinWithResponse(String, Object, Class, CreateDigitalTwinOptions, Context)} and
* {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#createOrReplaceDigitalTwinWithResponse(String, Object, Class, CreateDigitalTwinOptions)}
*/
@Fluent
public final class CreateDigitalTwinOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

import com.azure.core.annotation.Fluent;
import com.azure.core.util.Context;
import com.azure.digitaltwins.core.implementation.models.EventRoutesAddOptions;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The optional parameters for
* {@link com.azure.digitaltwins.core.DigitalTwinsClient#createEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions, Context)} and
* {@link com.azure.digitaltwins.core.DigitalTwinsClient#createOrReplaceEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions, Context)} and
* {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#createEventRouteWithResponse(String, EventRoute, CreateEventRouteOptions)}
*/
@Fluent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

import com.azure.core.annotation.Fluent;
import com.azure.core.util.Context;
import com.azure.digitaltwins.core.implementation.models.DigitalTwinsAddRelationshipOptions;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The optional parameters for
* {@link com.azure.digitaltwins.core.DigitalTwinsClient#createRelationshipWithResponse(String, String, Object, Class, CreateRelationshipOptions, Context)} and
* {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#createRelationshipWithResponse(String, String, Object, Class, CreateRelationshipOptions)}
* {@link com.azure.digitaltwins.core.DigitalTwinsClient#createOrReplaceRelationshipWithResponse(String, String, Object, Class, CreateRelationshipOptions, Context)} and
* {@link com.azure.digitaltwins.core.DigitalTwinsAsyncClient#createOrReplaceRelationshipWithResponse(String, String, Object, Class, CreateRelationshipOptions)}
*/
@Fluent
public final class CreateRelationshipOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static void runComponentSample() throws JsonProcessingException {

String basicDigitalTwinPayload = mapper.writeValueAsString(basicTwin);

BasicDigitalTwin basicTwinResponse = client.createDigitalTwin(basicDigitalTwinId, basicTwin, BasicDigitalTwin.class);
BasicDigitalTwin basicTwinResponse = client.createOrReplaceDigitalTwin(basicDigitalTwinId, basicTwin, BasicDigitalTwin.class);

ConsoleLogger.print("Created digital twin " + basicTwinResponse.getId());

Expand Down
Loading

0 comments on commit 19e3106

Please sign in to comment.