Skip to content

Commit

Permalink
docs(adt): update RequestOptions documentation (#12571)
Browse files Browse the repository at this point in the history
  • Loading branch information
azabbasi authored Jun 8, 2020
1 parent c22891a commit 2c66b83
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static partial class QueryChargeHelper
public partial class RequestOptions
{
public RequestOptions() { }
public string IfMatchEtag { get { throw null; } set { } }
public string IfMatch { get { throw null; } set { } }
}
}
namespace Azure.DigitalTwins.Core.Models
Expand Down
20 changes: 10 additions & 10 deletions sdk/digitaltwins/Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public virtual Response<string> CreateDigitalTwin(string digitalTwinId, string d
/// </example>
public virtual Task<Response> DeleteDigitalTwinAsync(string digitalTwinId, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.DeleteAsync(digitalTwinId, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.DeleteAsync(digitalTwinId, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand All @@ -283,7 +283,7 @@ public virtual Task<Response> DeleteDigitalTwinAsync(string digitalTwinId, Reque
/// </exception>
public virtual Response DeleteDigitalTwin(string digitalTwinId, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.Delete(digitalTwinId, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.Delete(digitalTwinId, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand All @@ -305,7 +305,7 @@ public virtual Response DeleteDigitalTwin(string digitalTwinId, RequestOptions r
/// </exception>
public virtual Task<Response<string>> UpdateDigitalTwinAsync(string digitalTwinId, string digitalTwinUpdateOperations, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.UpdateAsync(digitalTwinId, digitalTwinUpdateOperations, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.UpdateAsync(digitalTwinId, digitalTwinUpdateOperations, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand All @@ -330,7 +330,7 @@ public virtual Task<Response<string>> UpdateDigitalTwinAsync(string digitalTwinI
/// </seealso>
public virtual Response<string> UpdateDigitalTwin(string digitalTwinId, string digitalTwinUpdateOperations, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.Update(digitalTwinId, digitalTwinUpdateOperations, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.Update(digitalTwinId, digitalTwinUpdateOperations, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -418,7 +418,7 @@ public virtual Response<string> GetComponent(string digitalTwinId, string compon
public virtual Task<Response<string>> UpdateComponentAsync(string digitalTwinId, string componentPath, string componentUpdateOperations, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
// TODO how can we make this patch easier to construct?
return _dtRestClient.UpdateComponentAsync(digitalTwinId, componentPath, componentUpdateOperations, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.UpdateComponentAsync(digitalTwinId, componentPath, componentUpdateOperations, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand All @@ -444,7 +444,7 @@ public virtual Task<Response<string>> UpdateComponentAsync(string digitalTwinId,
/// </seealso>
public virtual Response<string> UpdateComponent(string digitalTwinId, string componentPath, string componentUpdateOperations, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.UpdateComponent(digitalTwinId, componentPath, componentUpdateOperations, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.UpdateComponent(digitalTwinId, componentPath, componentUpdateOperations, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -747,7 +747,7 @@ public virtual Response<string> GetRelationship(string digitalTwinId, string rel
/// </exception>
public virtual Task<Response> DeleteRelationshipAsync(string digitalTwinId, string relationshipId, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.DeleteRelationshipAsync(digitalTwinId, relationshipId, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.DeleteRelationshipAsync(digitalTwinId, relationshipId, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand All @@ -772,7 +772,7 @@ public virtual Task<Response> DeleteRelationshipAsync(string digitalTwinId, stri
/// </seealso>
public virtual Response DeleteRelationship(string digitalTwinId, string relationshipId, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.DeleteRelationship(digitalTwinId, relationshipId, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.DeleteRelationship(digitalTwinId, relationshipId, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand Down Expand Up @@ -877,7 +877,7 @@ public virtual Response<string> CreateRelationship(string digitalTwinId, string
public virtual Task<Response> UpdateRelationshipAsync(string digitalTwinId, string relationshipId, string relationshipUpdateOperations, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
// TODO how can we make this patch easier to construct?
return _dtRestClient.UpdateRelationshipAsync(digitalTwinId, relationshipId, relationshipUpdateOperations, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.UpdateRelationshipAsync(digitalTwinId, relationshipId, relationshipUpdateOperations, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand All @@ -903,7 +903,7 @@ public virtual Task<Response> UpdateRelationshipAsync(string digitalTwinId, stri
/// </seealso>
public virtual Response UpdateRelationship(string digitalTwinId, string relationshipId, string relationshipUpdateOperations, RequestOptions requestOptions = default, CancellationToken cancellationToken = default)
{
return _dtRestClient.UpdateRelationship(digitalTwinId, relationshipId, relationshipUpdateOperations, requestOptions?.IfMatchEtag, cancellationToken);
return _dtRestClient.UpdateRelationship(digitalTwinId, relationshipId, relationshipUpdateOperations, requestOptions?.IfMatch, cancellationToken);
}

/// <summary>
Expand Down
19 changes: 10 additions & 9 deletions sdk/digitaltwins/Azure.DigitalTwins.Core/src/RequestOptions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;

namespace Azure.DigitalTwins.Core
{
/// <summary>
Expand All @@ -13,13 +9,18 @@ namespace Azure.DigitalTwins.Core
public class RequestOptions
{
/// <summary>
/// A string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232. The request's operation is performed
/// only if this ETag matches the value maintained by the server, indicating that the entity has not been modified since it was last retrieved.
/// To force the operation to execute only if the entity exists, set the ETag to the wildcard character '*'. To force the operation to execute unconditionally, leave this value null.
/// A string representing a weak ETag for the entity that this request performs an operation against, as per RFC7232.
/// </summary>
/// <remarks>
/// If this value is not set, it defaults to null, and the ifMatch header will not be sent with the request. This means that update and delete will be unconditional and the operation will execute regardless of the existence of the resource.
/// <para>
/// The request's operation is performed only if this ETag matches the value maintained by the server,
/// indicating that the entity has not been modified since it was last retrieved.
/// To force the operation to execute only if the entity exists, set the ETag to the wildcard character '*'.
/// To force the operation to execute unconditionally, leave this value null.
/// If this value is not set, it defaults to null, and the ifMatch header will not be sent with the request.
/// This means that update and delete will be unconditional and the operation will execute regardless of the existence of the resource.
/// </para>
/// </remarks>
public string IfMatchEtag { get; set; } = null;
public string IfMatch { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Azure.Core.TestFramework;
using FluentAssertions;
using NUnit.Framework;

Expand Down Expand Up @@ -49,6 +48,7 @@ public async Task DigitalTwins_Lifecycle()

// update twin
string updateTwin = TestAssetsHelper.GetRoomTwinUpdatePayload();

await client.UpdateDigitalTwinAsync(roomTwinId, updateTwin).ConfigureAwait(false);

// delete a twin
Expand All @@ -59,6 +59,7 @@ public async Task DigitalTwins_Lifecycle()
{
await client.GetDigitalTwinAsync(roomTwinId).ConfigureAwait(false);
};

act.Should().Throw<RequestFailedException>()
.And.Status.Should().Be((int)HttpStatusCode.NotFound);
}
Expand Down

0 comments on commit 2c66b83

Please sign in to comment.