autorest.typescript icon indicating copy to clipboard operation
autorest.typescript copied to clipboard

Paging LROs should return a poller

Open deyaaeldeen opened this issue 4 years ago • 3 comments

Some APIs are both LROs and the response is pageable. Combining these two features is challenging. Currently, we only generate a method that returns async iterator over pageable results and has the suffix AndWait. However, we also need to generate for these APIs another overload that does not have this suffix and returns a poller which eventually will return the async iterator.

deyaaeldeen avatar May 13 '21 03:05 deyaaeldeen

This could be done by taking advantage of the processResult function in the options bag in the LroEngine class. Text Analytics has an example for such function that processes a pageable results with getPagedAsyncIterator here: https://github.com/Azure/azure-sdk-for-js/blob/b8f21fc9ca3675c73f6eea6ba0942eeb8084309d/sdk/textanalytics/ai-text-analytics/src/healthLro.ts#L182-L227

deyaaeldeen avatar Aug 12 '21 22:08 deyaaeldeen

Currently we are generating a Short LRO method for these operations that combine Paging + LRO which are suffixed with AndWait, these would pollUntilDone internally and give back the PagedAsyncIterator.

Implementing this would generate an additional method without the AndWait suffix, and keep the Short LRO one. So this would be an additive change and not a breaking change.

I can see this change split in 2 phases

  1. Make a change to cswitch to the new paging getPagedAsyncIterator which would help remove most of the private methods we are generating. This would be a non-breaking change.
  2. implement what Deya referenced above

@deyaaeldeen do you think the assesement above is accurate?

joheredi avatar Oct 06 '21 23:10 joheredi

@joheredi Yes!

deyaaeldeen avatar Oct 07 '21 16:10 deyaaeldeen