Azure / autorest.typescript

Extension for AutoRest (https://github.com/Azure/autorest) that generates TypeScript code. The transpiled javascript code is isomorphic. It can be run in browser and in node.js environment.
MIT License
177 stars 75 forks source link

Paging LROs should return a poller #944

Open deyaaeldeen opened 3 years ago

deyaaeldeen commented 3 years ago

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 commented 3 years ago

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

joheredi commented 2 years ago

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?

deyaaeldeen commented 2 years ago

@joheredi Yes!