/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 */

package com.microsoft.azure.batch.protocol.implementation;

import retrofit2.Retrofit;
import com.microsoft.azure.batch.protocol.ComputeNodeExtensions;
import com.google.common.base.Joiner;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.AzureServiceFuture;
import com.microsoft.azure.batch.protocol.models.BatchErrorException;
import com.microsoft.azure.batch.protocol.models.ComputeNodeExtensionGetHeaders;
import com.microsoft.azure.batch.protocol.models.ComputeNodeExtensionGetOptions;
import com.microsoft.azure.batch.protocol.models.ComputeNodeExtensionListHeaders;
import com.microsoft.azure.batch.protocol.models.ComputeNodeExtensionListNextOptions;
import com.microsoft.azure.batch.protocol.models.ComputeNodeExtensionListOptions;
import com.microsoft.azure.batch.protocol.models.NodeVMExtension;
import com.microsoft.azure.batch.protocol.models.PageImpl;
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.DateTimeRfc1123;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceResponseWithHeaders;
import com.microsoft.rest.Validator;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import okhttp3.ResponseBody;
import org.joda.time.DateTime;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
 * An instance of this class provides access to all the operations defined
 * in ComputeNodeExtensions.
 */
public class ComputeNodeExtensionsImpl implements ComputeNodeExtensions {
    /** The Retrofit service to perform REST calls. */
    private ComputeNodeExtensionsService service;
    /** The service client containing this operation class. */
    private BatchServiceClientImpl client;

    /**
     * Initializes an instance of ComputeNodeExtensionsImpl.
     *
     * @param retrofit the Retrofit instance built from a Retrofit Builder.
     * @param client the instance of the service client containing this operation class.
     */
    public ComputeNodeExtensionsImpl(Retrofit retrofit, BatchServiceClientImpl client) {
        this.service = retrofit.create(ComputeNodeExtensionsService.class);
        this.client = client;
    }

    /**
     * The interface defining all the services for ComputeNodeExtensions to be
     * used by Retrofit to perform actually REST calls.
     */
    interface ComputeNodeExtensionsService {
        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.batch.protocol.ComputeNodeExtensions get" })
        @GET("pools/{poolId}/nodes/{nodeId}/extensions/{extensionName}")
        Observable<Response<ResponseBody>> get(@Path("poolId") String poolId, @Path("nodeId") String nodeId, @Path("extensionName") String extensionName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$select") String select, @Query("timeout") Integer timeout, @Header("client-request-id") UUID clientRequestId, @Header("return-client-request-id") Boolean returnClientRequestId, @Header("ocp-date") DateTimeRfc1123 ocpDate, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.batch.protocol.ComputeNodeExtensions list" })
        @GET("pools/{poolId}/nodes/{nodeId}/extensions")
        Observable<Response<ResponseBody>> list(@Path("poolId") String poolId, @Path("nodeId") String nodeId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Query("$select") String select, @Query("maxresults") Integer maxResults, @Query("timeout") Integer timeout, @Header("client-request-id") UUID clientRequestId, @Header("return-client-request-id") Boolean returnClientRequestId, @Header("ocp-date") DateTimeRfc1123 ocpDate, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.batch.protocol.ComputeNodeExtensions listNext" })
        @GET
        Observable<Response<ResponseBody>> listNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("client-request-id") UUID clientRequestId, @Header("return-client-request-id") Boolean returnClientRequestId, @Header("ocp-date") DateTimeRfc1123 ocpDate, @Header("User-Agent") String userAgent);

    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws BatchErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the NodeVMExtension object if successful.
     */
    public NodeVMExtension get(String poolId, String nodeId, String extensionName) {
        return getWithServiceResponseAsync(poolId, nodeId, extensionName).toBlocking().single().body();
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<NodeVMExtension> getAsync(String poolId, String nodeId, String extensionName, final ServiceCallback<NodeVMExtension> serviceCallback) {
        return ServiceFuture.fromHeaderResponse(getWithServiceResponseAsync(poolId, nodeId, extensionName), serviceCallback);
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the NodeVMExtension object
     */
    public Observable<NodeVMExtension> getAsync(String poolId, String nodeId, String extensionName) {
        return getWithServiceResponseAsync(poolId, nodeId, extensionName).map(new Func1<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>, NodeVMExtension>() {
            @Override
            public NodeVMExtension call(ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders> response) {
                return response.body();
            }
        });
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the NodeVMExtension object
     */
    public Observable<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>> getWithServiceResponseAsync(String poolId, String nodeId, String extensionName) {
        if (this.client.batchUrl() == null) {
            throw new IllegalArgumentException("Parameter this.client.batchUrl() is required and cannot be null.");
        }
        if (poolId == null) {
            throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
        }
        if (nodeId == null) {
            throw new IllegalArgumentException("Parameter nodeId is required and cannot be null.");
        }
        if (extensionName == null) {
            throw new IllegalArgumentException("Parameter extensionName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final ComputeNodeExtensionGetOptions computeNodeExtensionGetOptions = null;
        String select = null;
        Integer timeout = null;
        UUID clientRequestId = null;
        Boolean returnClientRequestId = null;
        DateTime ocpDate = null;
        String parameterizedHost = Joiner.on(", ").join("{batchUrl}", this.client.batchUrl());
        DateTimeRfc1123 ocpDateConverted = null;
        if (ocpDate != null) {
            ocpDateConverted = new DateTimeRfc1123(ocpDate);
        }
        return service.get(poolId, nodeId, extensionName, this.client.apiVersion(), this.client.acceptLanguage(), select, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, parameterizedHost, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders> clientResponse = getDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @param computeNodeExtensionGetOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws BatchErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the NodeVMExtension object if successful.
     */
    public NodeVMExtension get(String poolId, String nodeId, String extensionName, ComputeNodeExtensionGetOptions computeNodeExtensionGetOptions) {
        return getWithServiceResponseAsync(poolId, nodeId, extensionName, computeNodeExtensionGetOptions).toBlocking().single().body();
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @param computeNodeExtensionGetOptions Additional parameters for the operation
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<NodeVMExtension> getAsync(String poolId, String nodeId, String extensionName, ComputeNodeExtensionGetOptions computeNodeExtensionGetOptions, final ServiceCallback<NodeVMExtension> serviceCallback) {
        return ServiceFuture.fromHeaderResponse(getWithServiceResponseAsync(poolId, nodeId, extensionName, computeNodeExtensionGetOptions), serviceCallback);
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @param computeNodeExtensionGetOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the NodeVMExtension object
     */
    public Observable<NodeVMExtension> getAsync(String poolId, String nodeId, String extensionName, ComputeNodeExtensionGetOptions computeNodeExtensionGetOptions) {
        return getWithServiceResponseAsync(poolId, nodeId, extensionName, computeNodeExtensionGetOptions).map(new Func1<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>, NodeVMExtension>() {
            @Override
            public NodeVMExtension call(ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders> response) {
                return response.body();
            }
        });
    }

    /**
     * Gets information about the specified Compute Node Extension.
     *
     * @param poolId The ID of the Pool that contains the Compute Node.
     * @param nodeId The ID of the Compute Node that contains the extensions.
     * @param extensionName The name of the of the Compute Node Extension that you want to get information about.
     * @param computeNodeExtensionGetOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the NodeVMExtension object
     */
    public Observable<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>> getWithServiceResponseAsync(String poolId, String nodeId, String extensionName, ComputeNodeExtensionGetOptions computeNodeExtensionGetOptions) {
        if (this.client.batchUrl() == null) {
            throw new IllegalArgumentException("Parameter this.client.batchUrl() is required and cannot be null.");
        }
        if (poolId == null) {
            throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
        }
        if (nodeId == null) {
            throw new IllegalArgumentException("Parameter nodeId is required and cannot be null.");
        }
        if (extensionName == null) {
            throw new IllegalArgumentException("Parameter extensionName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(computeNodeExtensionGetOptions);
        String select = null;
        if (computeNodeExtensionGetOptions != null) {
            select = computeNodeExtensionGetOptions.select();
        }
        Integer timeout = null;
        if (computeNodeExtensionGetOptions != null) {
            timeout = computeNodeExtensionGetOptions.timeout();
        }
        UUID clientRequestId = null;
        if (computeNodeExtensionGetOptions != null) {
            clientRequestId = computeNodeExtensionGetOptions.clientRequestId();
        }
        Boolean returnClientRequestId = null;
        if (computeNodeExtensionGetOptions != null) {
            returnClientRequestId = computeNodeExtensionGetOptions.returnClientRequestId();
        }
        DateTime ocpDate = null;
        if (computeNodeExtensionGetOptions != null) {
            ocpDate = computeNodeExtensionGetOptions.ocpDate();
        }
        String parameterizedHost = Joiner.on(", ").join("{batchUrl}", this.client.batchUrl());
        DateTimeRfc1123 ocpDateConverted = null;
        if (ocpDate != null) {
            ocpDateConverted = new DateTimeRfc1123(ocpDate);
        }
        return service.get(poolId, nodeId, extensionName, this.client.apiVersion(), this.client.acceptLanguage(), select, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, parameterizedHost, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders> clientResponse = getDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponseWithHeaders<NodeVMExtension, ComputeNodeExtensionGetHeaders> getDelegate(Response<ResponseBody> response) throws BatchErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<NodeVMExtension, BatchErrorException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<NodeVMExtension>() { }.getType())
                .registerError(BatchErrorException.class)
                .buildWithHeaders(response, ComputeNodeExtensionGetHeaders.class);
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws BatchErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PagedList&lt;NodeVMExtension&gt; object if successful.
     */
    public PagedList<NodeVMExtension> list(final String poolId, final String nodeId) {
        ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response = listSinglePageAsync(poolId, nodeId).toBlocking().single();
        return new PagedList<NodeVMExtension>(response.body()) {
            @Override
            public Page<NodeVMExtension> nextPage(String nextPageLink) {
                return listNextSinglePageAsync(nextPageLink, null).toBlocking().single().body();
            }
        };
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<NodeVMExtension>> listAsync(final String poolId, final String nodeId, final ListOperationCallback<NodeVMExtension> serviceCallback) {
        return AzureServiceFuture.fromHeaderPageResponse(
            listSinglePageAsync(poolId, nodeId),
            new Func1<String, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(String nextPageLink) {
                    return listNextSinglePageAsync(nextPageLink, null);
                }
            },
            serviceCallback);
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<Page<NodeVMExtension>> listAsync(final String poolId, final String nodeId) {
        return listWithServiceResponseAsync(poolId, nodeId)
            .map(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Page<NodeVMExtension>>() {
                @Override
                public Page<NodeVMExtension> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response) {
                    return response.body();
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listWithServiceResponseAsync(final String poolId, final String nodeId) {
        return listSinglePageAsync(poolId, nodeId)
            .concatMap(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> page) {
                    String nextPageLink = page.body().nextPageLink();
                    if (nextPageLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, null));
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the PagedList&lt;NodeVMExtension&gt; object wrapped in {@link ServiceResponseWithHeaders} if successful.
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listSinglePageAsync(final String poolId, final String nodeId) {
        if (this.client.batchUrl() == null) {
            throw new IllegalArgumentException("Parameter this.client.batchUrl() is required and cannot be null.");
        }
        if (poolId == null) {
            throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
        }
        if (nodeId == null) {
            throw new IllegalArgumentException("Parameter nodeId is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final ComputeNodeExtensionListOptions computeNodeExtensionListOptions = null;
        String select = null;
        Integer maxResults = null;
        Integer timeout = null;
        UUID clientRequestId = null;
        Boolean returnClientRequestId = null;
        DateTime ocpDate = null;
        String parameterizedHost = Joiner.on(", ").join("{batchUrl}", this.client.batchUrl());
        DateTimeRfc1123 ocpDateConverted = null;
        if (ocpDate != null) {
            ocpDateConverted = new DateTimeRfc1123(ocpDate);
        }
        return service.list(poolId, nodeId, this.client.apiVersion(), this.client.acceptLanguage(), select, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, parameterizedHost, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> result = listDelegate(response);
                        return Observable.just(new ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>(result.body(), result.headers(), result.response()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @param computeNodeExtensionListOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws BatchErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PagedList&lt;NodeVMExtension&gt; object if successful.
     */
    public PagedList<NodeVMExtension> list(final String poolId, final String nodeId, final ComputeNodeExtensionListOptions computeNodeExtensionListOptions) {
        ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response = listSinglePageAsync(poolId, nodeId, computeNodeExtensionListOptions).toBlocking().single();
        return new PagedList<NodeVMExtension>(response.body()) {
            @Override
            public Page<NodeVMExtension> nextPage(String nextPageLink) {
                ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions = null;
                if (computeNodeExtensionListOptions != null) {
                    computeNodeExtensionListNextOptions = new ComputeNodeExtensionListNextOptions();
                    computeNodeExtensionListNextOptions.withClientRequestId(computeNodeExtensionListOptions.clientRequestId());
                    computeNodeExtensionListNextOptions.withReturnClientRequestId(computeNodeExtensionListOptions.returnClientRequestId());
                    computeNodeExtensionListNextOptions.withOcpDate(computeNodeExtensionListOptions.ocpDate());
                }
                return listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions).toBlocking().single().body();
            }
        };
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @param computeNodeExtensionListOptions Additional parameters for the operation
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<NodeVMExtension>> listAsync(final String poolId, final String nodeId, final ComputeNodeExtensionListOptions computeNodeExtensionListOptions, final ListOperationCallback<NodeVMExtension> serviceCallback) {
        return AzureServiceFuture.fromHeaderPageResponse(
            listSinglePageAsync(poolId, nodeId, computeNodeExtensionListOptions),
            new Func1<String, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(String nextPageLink) {
                    ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions = null;
                    if (computeNodeExtensionListOptions != null) {
                        computeNodeExtensionListNextOptions = new ComputeNodeExtensionListNextOptions();
                        computeNodeExtensionListNextOptions.withClientRequestId(computeNodeExtensionListOptions.clientRequestId());
                        computeNodeExtensionListNextOptions.withReturnClientRequestId(computeNodeExtensionListOptions.returnClientRequestId());
                        computeNodeExtensionListNextOptions.withOcpDate(computeNodeExtensionListOptions.ocpDate());
                    }
                    return listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions);
                }
            },
            serviceCallback);
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @param computeNodeExtensionListOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<Page<NodeVMExtension>> listAsync(final String poolId, final String nodeId, final ComputeNodeExtensionListOptions computeNodeExtensionListOptions) {
        return listWithServiceResponseAsync(poolId, nodeId, computeNodeExtensionListOptions)
            .map(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Page<NodeVMExtension>>() {
                @Override
                public Page<NodeVMExtension> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response) {
                    return response.body();
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param poolId The ID of the Pool that contains Compute Node.
     * @param nodeId The ID of the Compute Node that you want to list extensions.
     * @param computeNodeExtensionListOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listWithServiceResponseAsync(final String poolId, final String nodeId, final ComputeNodeExtensionListOptions computeNodeExtensionListOptions) {
        return listSinglePageAsync(poolId, nodeId, computeNodeExtensionListOptions)
            .concatMap(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> page) {
                    String nextPageLink = page.body().nextPageLink();
                    if (nextPageLink == null) {
                        return Observable.just(page);
                    }
                    ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions = null;
                    if (computeNodeExtensionListOptions != null) {
                        computeNodeExtensionListNextOptions = new ComputeNodeExtensionListNextOptions();
                        computeNodeExtensionListNextOptions.withClientRequestId(computeNodeExtensionListOptions.clientRequestId());
                        computeNodeExtensionListNextOptions.withReturnClientRequestId(computeNodeExtensionListOptions.returnClientRequestId());
                        computeNodeExtensionListNextOptions.withOcpDate(computeNodeExtensionListOptions.ocpDate());
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, computeNodeExtensionListNextOptions));
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
    ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> * @param poolId The ID of the Pool that contains Compute Node.
    ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> * @param nodeId The ID of the Compute Node that you want to list extensions.
    ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> * @param computeNodeExtensionListOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the PagedList&lt;NodeVMExtension&gt; object wrapped in {@link ServiceResponseWithHeaders} if successful.
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listSinglePageAsync(final String poolId, final String nodeId, final ComputeNodeExtensionListOptions computeNodeExtensionListOptions) {
        if (this.client.batchUrl() == null) {
            throw new IllegalArgumentException("Parameter this.client.batchUrl() is required and cannot be null.");
        }
        if (poolId == null) {
            throw new IllegalArgumentException("Parameter poolId is required and cannot be null.");
        }
        if (nodeId == null) {
            throw new IllegalArgumentException("Parameter nodeId is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(computeNodeExtensionListOptions);
        String select = null;
        if (computeNodeExtensionListOptions != null) {
            select = computeNodeExtensionListOptions.select();
        }
        Integer maxResults = null;
        if (computeNodeExtensionListOptions != null) {
            maxResults = computeNodeExtensionListOptions.maxResults();
        }
        Integer timeout = null;
        if (computeNodeExtensionListOptions != null) {
            timeout = computeNodeExtensionListOptions.timeout();
        }
        UUID clientRequestId = null;
        if (computeNodeExtensionListOptions != null) {
            clientRequestId = computeNodeExtensionListOptions.clientRequestId();
        }
        Boolean returnClientRequestId = null;
        if (computeNodeExtensionListOptions != null) {
            returnClientRequestId = computeNodeExtensionListOptions.returnClientRequestId();
        }
        DateTime ocpDate = null;
        if (computeNodeExtensionListOptions != null) {
            ocpDate = computeNodeExtensionListOptions.ocpDate();
        }
        String parameterizedHost = Joiner.on(", ").join("{batchUrl}", this.client.batchUrl());
        DateTimeRfc1123 ocpDateConverted = null;
        if (ocpDate != null) {
            ocpDateConverted = new DateTimeRfc1123(ocpDate);
        }
        return service.list(poolId, nodeId, this.client.apiVersion(), this.client.acceptLanguage(), select, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, parameterizedHost, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> result = listDelegate(response);
                        return Observable.just(new ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>(result.body(), result.headers(), result.response()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> listDelegate(Response<ResponseBody> response) throws BatchErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<PageImpl<NodeVMExtension>, BatchErrorException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<PageImpl<NodeVMExtension>>() { }.getType())
                .registerError(BatchErrorException.class)
                .buildWithHeaders(response, ComputeNodeExtensionListHeaders.class);
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws BatchErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PagedList&lt;NodeVMExtension&gt; object if successful.
     */
    public PagedList<NodeVMExtension> listNext(final String nextPageLink) {
        ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response = listNextSinglePageAsync(nextPageLink).toBlocking().single();
        return new PagedList<NodeVMExtension>(response.body()) {
            @Override
            public Page<NodeVMExtension> nextPage(String nextPageLink) {
                return listNextSinglePageAsync(nextPageLink, null).toBlocking().single().body();
            }
        };
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param serviceFuture the ServiceFuture object tracking the Retrofit calls
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<NodeVMExtension>> listNextAsync(final String nextPageLink, final ServiceFuture<List<NodeVMExtension>> serviceFuture, final ListOperationCallback<NodeVMExtension> serviceCallback) {
        return AzureServiceFuture.fromHeaderPageResponse(
            listNextSinglePageAsync(nextPageLink),
            new Func1<String, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(String nextPageLink) {
                    return listNextSinglePageAsync(nextPageLink, null);
                }
            },
            serviceCallback);
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<Page<NodeVMExtension>> listNextAsync(final String nextPageLink) {
        return listNextWithServiceResponseAsync(nextPageLink)
            .map(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Page<NodeVMExtension>>() {
                @Override
                public Page<NodeVMExtension> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response) {
                    return response.body();
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listNextWithServiceResponseAsync(final String nextPageLink) {
        return listNextSinglePageAsync(nextPageLink)
            .concatMap(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> page) {
                    String nextPageLink = page.body().nextPageLink();
                    if (nextPageLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, null));
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the PagedList&lt;NodeVMExtension&gt; object wrapped in {@link ServiceResponseWithHeaders} if successful.
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listNextSinglePageAsync(final String nextPageLink) {
        if (nextPageLink == null) {
            throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
        }
        final ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions = null;
        UUID clientRequestId = null;
        Boolean returnClientRequestId = null;
        DateTime ocpDate = null;
        DateTimeRfc1123 ocpDateConverted = null;
        if (ocpDate != null) {
            ocpDateConverted = new DateTimeRfc1123(ocpDate);
        }
        String nextUrl = String.format("%s", nextPageLink);
        return service.listNext(nextUrl, this.client.acceptLanguage(), clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> result = listNextDelegate(response);
                        return Observable.just(new ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>(result.body(), result.headers(), result.response()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param computeNodeExtensionListNextOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws BatchErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the PagedList&lt;NodeVMExtension&gt; object if successful.
     */
    public PagedList<NodeVMExtension> listNext(final String nextPageLink, final ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions) {
        ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response = listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions).toBlocking().single();
        return new PagedList<NodeVMExtension>(response.body()) {
            @Override
            public Page<NodeVMExtension> nextPage(String nextPageLink) {
                return listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions).toBlocking().single().body();
            }
        };
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param computeNodeExtensionListNextOptions Additional parameters for the operation
     * @param serviceFuture the ServiceFuture object tracking the Retrofit calls
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceFuture} object
     */
    public ServiceFuture<List<NodeVMExtension>> listNextAsync(final String nextPageLink, final ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions, final ServiceFuture<List<NodeVMExtension>> serviceFuture, final ListOperationCallback<NodeVMExtension> serviceCallback) {
        return AzureServiceFuture.fromHeaderPageResponse(
            listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions),
            new Func1<String, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(String nextPageLink) {
                    return listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions);
                }
            },
            serviceCallback);
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param computeNodeExtensionListNextOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<Page<NodeVMExtension>> listNextAsync(final String nextPageLink, final ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions) {
        return listNextWithServiceResponseAsync(nextPageLink, computeNodeExtensionListNextOptions)
            .map(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Page<NodeVMExtension>>() {
                @Override
                public Page<NodeVMExtension> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> response) {
                    return response.body();
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
     * @param nextPageLink The NextLink from the previous successful call to List operation.
     * @param computeNodeExtensionListNextOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the PagedList&lt;NodeVMExtension&gt; object
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listNextWithServiceResponseAsync(final String nextPageLink, final ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions) {
        return listNextSinglePageAsync(nextPageLink, computeNodeExtensionListNextOptions)
            .concatMap(new Func1<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders> page) {
                    String nextPageLink = page.body().nextPageLink();
                    if (nextPageLink == null) {
                        return Observable.just(page);
                    }
                    return Observable.just(page).concatWith(listNextWithServiceResponseAsync(nextPageLink, computeNodeExtensionListNextOptions));
                }
            });
    }

    /**
     * Lists the Compute Nodes Extensions in the specified Pool.
     *
    ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> * @param nextPageLink The NextLink from the previous successful call to List operation.
    ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> * @param computeNodeExtensionListNextOptions Additional parameters for the operation
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the PagedList&lt;NodeVMExtension&gt; object wrapped in {@link ServiceResponseWithHeaders} if successful.
     */
    public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> listNextSinglePageAsync(final String nextPageLink, final ComputeNodeExtensionListNextOptions computeNodeExtensionListNextOptions) {
        if (nextPageLink == null) {
            throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
        }
        Validator.validate(computeNodeExtensionListNextOptions);
        UUID clientRequestId = null;
        if (computeNodeExtensionListNextOptions != null) {
            clientRequestId = computeNodeExtensionListNextOptions.clientRequestId();
        }
        Boolean returnClientRequestId = null;
        if (computeNodeExtensionListNextOptions != null) {
            returnClientRequestId = computeNodeExtensionListNextOptions.returnClientRequestId();
        }
        DateTime ocpDate = null;
        if (computeNodeExtensionListNextOptions != null) {
            ocpDate = computeNodeExtensionListNextOptions.ocpDate();
        }
        DateTimeRfc1123 ocpDateConverted = null;
        if (ocpDate != null) {
            ocpDateConverted = new DateTimeRfc1123(ocpDate);
        }
        String nextUrl = String.format("%s", nextPageLink);
        return service.listNext(nextUrl, this.client.acceptLanguage(), clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>>>() {
                @Override
                public Observable<ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> result = listNextDelegate(response);
                        return Observable.just(new ServiceResponseWithHeaders<Page<NodeVMExtension>, ComputeNodeExtensionListHeaders>(result.body(), result.headers(), result.response()));
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponseWithHeaders<PageImpl<NodeVMExtension>, ComputeNodeExtensionListHeaders> listNextDelegate(Response<ResponseBody> response) throws BatchErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().<PageImpl<NodeVMExtension>, BatchErrorException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken<PageImpl<NodeVMExtension>>() { }.getType())
                .registerError(BatchErrorException.class)
                .buildWithHeaders(response, ComputeNodeExtensionListHeaders.class);
    }

}
