Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 166 forks source link

Support HTTP Post with Pagination (LRO Pageable) #1624

Open ArthurMa1978 opened 3 years ago

ArthurMa1978 commented 3 years ago

There are API definitions which define pagination in HTTP post.

Example See https://github.com/Azure/azure-rest-api-specs/blob/a2d4dc4b1296624eefd4b5c235d56af46f7c39d2/specification/network/resource-manager/Microsoft.Network/stable/2021-02-01/bastionHost.json#L266

We have: POST /Microsoft.Network/bastionHosts/{bastionHostName}/createShareableLinks "x-ms-long-running-operation": true "x-ms-pageable" POST /Microsoft.Network/bastionHosts/{bastionHostName}/getShareableLinks "x-ms-pageable" POST /Microsoft.Network/bastionHosts/{bastionHostName}/getActiveSessions "x-ms-long-running-operation": true "x-ms-pageable" POST /Microsoft.Network/bastionHosts/{bastionHostName}/disconnectActiveSessions "x-ms-pageable" Some open questions: Shall we use the same HTTP method for subsequent requests? If the 1st request is long running, shall we do the long running for subsequent requests?

ArthurMa1978 commented 3 years ago

From @archerzz : As for whether the subsequent requests should be long running, the specification doesn't clearly define that. However, a reasonable assumption is that the subsequent requests should NOT be long running.

ArthurMa1978 commented 3 years ago

From @archerzz : As for the HTTP methods for the next link, it should always be a HTTP Get according to the x-ms-pageable specification: Note: The request to get the nextPage will always be a GET request

However, there are exceptions. Some API uses the same HTTP method for subsequent requests. See: https://github.com/Azure/azure-rest-api-specs/issues/15136

ArthurMa1978 commented 3 years ago

Not high priority, ideally we need to do it for GA but also can post GA

ArcturusZhang commented 3 years ago

Web RP has some operations that fall into this case.

The request path PR leaves a placeholder to implement this: https://github.com/Azure/autorest.csharp/blob/bbba45922308e94ecd5ca0d8f7035957a417e469/src/AutoRest.CSharp/Mgmt/Generation/MgmtClientBaseWriter.cs#L195

ArthurMa1978 commented 2 years ago

Handwrite before GA and auto-gen after GA