Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPS changes based on API reviews, PR reviews, and changes to LLC plans #21968

Merged
merged 8 commits into from
Jun 18, 2021

Conversation

KrzysztofCwalina
Copy link
Member

  • all method groups now have protocol methods (methods taking RequestOptions)
  • changed semantics of string messages (they are serialized as plaintext by default)
  • added overloads allowing to specify expiresAt, in addition to expiresAfter.
  • small renames

@KrzysztofCwalina KrzysztofCwalina changed the title Changes based on API reviews, PR reviews, and changes to LLC plans WPS Changes based on API reviews, PR reviews, and changes to LLC plans Jun 18, 2021
@KrzysztofCwalina KrzysztofCwalina changed the title WPS Changes based on API reviews, PR reviews, and changes to LLC plans WPS changes based on API reviews, PR reviews, and changes to LLC plans Jun 18, 2021
Copy link
Member

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

Some comments - don't really understand about the use of DateTime instead of DateTimeOffset. Also, a small tip on a way to remove editing the swagger (and hopefully we can remove all of this ceremony when the code generator just generates the correct output shape for HEAD methods that are doing Exists checks.


using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Usage", "AZC0002:DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.", Justification = "CancellationToken can be passed through RequestOptions")]
Copy link
Member

Choose a reason for hiding this comment

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

Opened Azure/azure-sdk-tools#1715 so we don't lose track of fixing the analyzer 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.

Though, to be clear. I think this is triggered by my experiments in not having CT parameters in some helper overloads.

/// <param name="hmacSha512">SHA512 if true, otherwise SHA256</param>
/// <returns></returns>
public static string GenerateAccessToken(
string audience,
IEnumerable<Claim> claims,
AzureKeyCredential key,
TimeSpan expireAfter = default,
DateTime expiresAtUtc = default,
Copy link
Member

Choose a reason for hiding this comment

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

Why is this not DateTimeOffset ?

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 feel like DT is better for representing UTC times, i.e. is has explicit support for UTC. Possibly I should change it to DTO to comply with guidelines.

Copy link
Member Author

Choose a reason for hiding this comment

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

After a discussions, we decided to switch to DTO. But I will do it after the JWT implementation is changed. The current JWT library does not take in DTO.

Copy link
Member

Choose a reason for hiding this comment

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

We talked about this offline and you are going to move to DTO with the next set of changes.

@@ -99,7 +99,7 @@
"webpubsub"
],
"summary": "Check if the connection with the given connectionId exists.",
"operationId": "WebPubSubService_ConnectionExists",
"operationId": "WebPubSubService_ConnectionExistsImpl",
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to do this via a transform in the auto-rest MD (so you don't have to make this change in the swagger itself, so we can keep it in sync with the authoritative version.)

Maybe something like this in the autorest.md?

Make WebPubSubPermission a regular enum

- from: swagger-document
  where: $.paths
  transform: >
    $["/api/hubs/{hub}/connections/{connectionId}"].head.operationId = "WebPubSubService_ConnectionExistsImpl";
    $["/api/hubs/{hub}/groups/{group}"].head.operationId = "WebPubSubService_GroupExistsImpl";
    $["/api/hubs/{hub}/users/{userId}"].head.operationId = "WebPubSubService_UserExistsImpl";

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is temporary. Having said that, this swagger is already forked (PR a week ago). It's forked to generate some methods as internal (and possibly some other small changes). We should work on getting all these customizations out and get back to the original swagger.

/// <returns>A <see cref="Response"/> if successful.</returns>
public virtual async Task<Response> SendToAllAsync(string message, IEnumerable<string> excluded = null, CancellationToken cancellationToken = default)
public virtual async Task<Response> SendToAllAsync(string content, ContentType contentType = default)
Copy link
Member

Choose a reason for hiding this comment

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

I still miss having cancellation tokens on these high level methods, FWIW.

Copy link
Member Author

@KrzysztofCwalina KrzysztofCwalina Jun 18, 2021

Choose a reason for hiding this comment

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

Let's chat more about it. What I am going after is a very common BCL pattern where only the most powerful overload takes CTs. See https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.writeasync?view=net-5.0 as an example.
I am not sure why we want to add CTs to all overloads. I think we went too far with the support for CTs. They prevent us from having simple overloads, from using param arrays, etc.

@KrzysztofCwalina KrzysztofCwalina marked this pull request as ready for review June 18, 2021 18:29
Copy link
Member

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

LGTM,

@KrzysztofCwalina KrzysztofCwalina merged commit a358f10 into Azure:main Jun 18, 2021
@KrzysztofCwalina KrzysztofCwalina deleted the WPS3 branch July 8, 2021 16:19
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-net that referenced this pull request Dec 22, 2022
Add a note to Event Grid readme about review (Azure#21968)

* Add a note to Event Grid readme about review

* Update specification/eventgrid/data-plane/readme.md

Co-authored-by: Laurent Mazuel <[email protected]>

Co-authored-by: Laurent Mazuel <[email protected]>
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.

2 participants