Skip to content

Add Azure.Core JsonPatchDocument to DigitalTwins project to replace UpdateOperationsUtility#16129

Merged
timtay-microsoft merged 3 commits intomasterfrom
feature/adt/timtay/jsonPatch
Oct 21, 2020
Merged

Add Azure.Core JsonPatchDocument to DigitalTwins project to replace UpdateOperationsUtility#16129
timtay-microsoft merged 3 commits intomasterfrom
feature/adt/timtay/jsonPatch

Conversation

@timtay-microsoft
Copy link
Member

Since Azure.Core has not shipped this in a public Nuget yet, we will be taking a project dependency in the meantime

Since Azure.Core has not shipped this in a public Nuget yet, we will be taking a project dependency in the meantime
@ghost ghost added the DigitalTwins label Oct 20, 2020
@timtay-microsoft timtay-microsoft changed the title Add Azure.Core JsonPatchDocument to replace our UpdateOperationsUtility Add Azure.Core JsonPatchDocument to DigitalTwins project to replace UpdateOperationsUtility Oct 20, 2020
Copy link
Member

@abhipsaMisra abhipsaMisra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Did the Azure SDK board sign-off on exposing JsonPatchDocument in our public API? I had thought that we would use this as a helper, but the public API would still take in a string.

@timtay-microsoft
Copy link
Member Author

Nice!
Did the Azure SDK board sign-off on exposing JsonPatchDocument in our public API? I had thought that we would use this as a helper, but the public API would still take in a string.

I'll bring it up in the board review on Thursday, good question

public virtual System.Threading.Tasks.Task<Azure.Response> UpdateDigitalTwinAsync(string digitalTwinId, string jsonPatch, Azure.DigitalTwins.Core.UpdateDigitalTwinOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response UpdateRelationship(string digitalTwinId, string relationshipId, string jsonPatch, Azure.DigitalTwins.Core.UpdateRelationshipOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateRelationshipAsync(string digitalTwinId, string relationshipId, string jsonPatch, Azure.DigitalTwins.Core.UpdateRelationshipOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response UpdateComponent(string digitalTwinId, string componentName, Azure.JsonPatchDocument jsonPatchDocument, Azure.DigitalTwins.Core.UpdateComponentOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious we chose to require this specific data type, rather than a string that has json. My reasoning being that a customer wanted to use their own library, they can't do that now. Thoughts?

Copy link
Member Author

@timtay-microsoft timtay-microsoft Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. I can revert these APIs back to taking strings rather than the JsonPatchDocument itself for now. I'll add a note in our board review to talk about this further

Scratch that, the JsonPatchDocument class allows for users to set their own ObjectSerializer, so this isn't an issue. I'd still like to use this class directly in our APIs, especially if we are getting away from representing untyped json as strings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend leaving the way you have it for now, reach out to Krzysztof directly for direction advice, and then mention it in the board review.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drwill-ms just in case you signed off thinking I would revert the API shape back to taking a string. Thoughts on taking the JsonPatchDocument knowing that it takes an ObjectSerializer that allows for users to provide their favorite json library?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I didn't sign off with that understanding. I'd have been more explicit if that were the case.

</ItemGroup>

<Import Project="$(RepoRoot)\sdk\core\Azure.Core\src\Azure.Core.props" />
<!--Uncomment the below to take reference from Azure.Core based on how Azure.Core.props defines how libraries should take reference-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on the problem here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add more comments to the code itself, too, but the issue here is that the Azure.Core library hasn't had a release since they added the JsonPatchDocument class. So the only way we'll get access to it is to take a project reference instead.

This all becomes moot if we don't want the JsonPatchDocument in our API shape, though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Might put it in those words as the existing comment didn't make sense to me.

@timtay-microsoft
Copy link
Member Author

@KrzysztofCwalina any thoughts on us using the JsonPatchDocument type directly in our API vs having our API take a string, and having our samples use the JsonPatchDocument to create that string?

@timtay-microsoft timtay-microsoft merged commit 266e877 into master Oct 21, 2020
@timtay-microsoft timtay-microsoft deleted the feature/adt/timtay/jsonPatch branch October 21, 2020 21:39
annelo-msft pushed a commit to annelo-msft/azure-sdk-for-net that referenced this pull request Feb 17, 2021
…pdateOperationsUtility (Azure#16129)

Since Azure.Core has not shipped this in a public Nuget yet, we will be taking a project dependency in the meantime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants