Skip to content

Comments

support pagination with 1st page LRO#652

Merged
weidongxu-microsoft merged 2 commits intoAzure:v4from
weidongxu-microsoft:v4_fluent_lro_pagination
Jul 13, 2020
Merged

support pagination with 1st page LRO#652
weidongxu-microsoft merged 2 commits intoAzure:v4from
weidongxu-microsoft:v4_fluent_lro_pagination

Conversation

@weidongxu-microsoft
Copy link
Member

fix #638

generated code

    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<PagedResponse<SiteInner>> changeVnetSinglePageAsync(
        String resourceGroupName, String name, VirtualNetworkProfile vnetInfo, Context context) {
        if (this.client.getEndpoint() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getEndpoint() is required and cannot be null."));
        }
        if (resourceGroupName == null) {
            return Mono
                .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."));
        }
        if (name == null) {
            return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null."));
        }
        if (this.client.getSubscriptionId() == null) {
            return Mono
                .error(
                    new IllegalArgumentException(
                        "Parameter this.client.getSubscriptionId() is required and cannot be null."));
        }
        if (vnetInfo == null) {
            return Mono.error(new IllegalArgumentException("Parameter vnetInfo is required and cannot be null."));
        } else {
            vnetInfo.validate();
        }
        context = this.client.mergeContext(context);
        Mono<Response<Flux<ByteBuffer>>> mono =
            service
                .changeVnet(
                    this.client.getEndpoint(),
                    resourceGroupName,
                    name,
                    this.client.getSubscriptionId(),
                    this.client.getApiVersion(),
                    vnetInfo,
                    context)
                .cache();
        return Mono
            .zip(
                mono,
                this
                    .client
                    .<WebAppCollectionInner, WebAppCollectionInner>getLroResultAsync(
                        mono, this.client.getHttpPipeline(), WebAppCollectionInner.class, WebAppCollectionInner.class)
                    .last()
                    .flatMap(this.client::getLroFinalResultOrError))
            .map(
                res ->
                    new PagedResponseBase<>(
                        res.getT1().getRequest(),
                        res.getT1().getStatusCode(),
                        res.getT1().getHeaders(),
                        res.getT2().value(),
                        res.getT2().nextLink(),
                        null));
    }

AddOptionalVariables(function, clientMethod, restAPIMethod.getParameters(), settings);
if (clientMethod.getReturnValue().getType() == ClassType.InputStream) {
function.line("Iterator<ByteBufferBackedInputStream> iterator = %s(%S).map(ByteBufferBackedInputStream::new).toStream().iterator();",
function.line("Iterator<ByteBufferBackedInputStream> iterator = %s(%s).map(ByteBufferBackedInputStream::new).toStream().iterator();",
Copy link
Member Author

Choose a reason for hiding this comment

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

unrelated bug fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for LRO with paging

1 participant