Search in sources :

Example 1 with Product

use of fixtures.paging.models.Product in project autorest.java by Azure.

the class PagingsImpl method getOdataMultiplePagesSinglePageAsync.

/**
 * A paging operation that includes a nextLink in odata format that has 10 pages.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the PagedList<Product> object wrapped in {@link ServiceResponse} if successful.
 */
public Observable<ServiceResponse<Page<Product>>> getOdataMultiplePagesSinglePageAsync() {
    final String clientRequestId = null;
    final PagingGetOdataMultiplePagesOptions pagingGetOdataMultiplePagesOptions = null;
    Integer maxresults = null;
    Integer timeout = null;
    return service.getOdataMultiplePages(clientRequestId, this.client.acceptLanguage(), maxresults, timeout, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<Product>>>>() {

        @Override
        public Observable<ServiceResponse<Page<Product>>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<PageImpl1<Product>> result = getOdataMultiplePagesDelegate(response);
                return Observable.just(new ServiceResponse<Page<Product>>(result.body(), result.response()));
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Product(fixtures.paging.models.Product) PagingGetOdataMultiplePagesOptions(fixtures.paging.models.PagingGetOdataMultiplePagesOptions) Page(com.microsoft.azure.Page) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody) Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse)

Example 2 with Product

use of fixtures.paging.models.Product in project autorest.java by Azure.

the class PagingsImpl method getMultiplePagesWithOffset.

/**
 * A paging operation that includes a nextLink that has 10 pages.
 *
 * @param pagingGetMultiplePagesWithOffsetOptions Additional parameters for the operation
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException 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;Product&gt; object if successful.
 */
public PagedList<Product> getMultiplePagesWithOffset(final PagingGetMultiplePagesWithOffsetOptions pagingGetMultiplePagesWithOffsetOptions) {
    ServiceResponse<Page<Product>> response = getMultiplePagesWithOffsetSinglePageAsync(pagingGetMultiplePagesWithOffsetOptions).toBlocking().single();
    return new PagedList<Product>(response.body()) {

        @Override
        public Page<Product> nextPage(String nextPageLink) {
            PagingGetMultiplePagesWithOffsetNextOptions pagingGetMultiplePagesWithOffsetNextOptions = new PagingGetMultiplePagesWithOffsetNextOptions();
            pagingGetMultiplePagesWithOffsetNextOptions.withMaxresults(pagingGetMultiplePagesWithOffsetOptions.maxresults());
            pagingGetMultiplePagesWithOffsetNextOptions.withTimeout(pagingGetMultiplePagesWithOffsetOptions.timeout());
            return getMultiplePagesWithOffsetNextSinglePageAsync(nextPageLink, null, pagingGetMultiplePagesWithOffsetNextOptions).toBlocking().single().body();
        }
    };
}
Also used : PagingGetMultiplePagesWithOffsetNextOptions(fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions) PagedList(com.microsoft.azure.PagedList) Product(fixtures.paging.models.Product) Page(com.microsoft.azure.Page)

Example 3 with Product

use of fixtures.paging.models.Product in project autorest.java by Azure.

the class PagingsImpl method getMultiplePagesWithOffset.

/**
 * A paging operation that includes a nextLink that has 10 pages.
 *
 * @param pagingGetMultiplePagesWithOffsetOptions Additional parameters for the operation
 * @param clientRequestId the String value
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException 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;Product&gt; object if successful.
 */
public PagedList<Product> getMultiplePagesWithOffset(final PagingGetMultiplePagesWithOffsetOptions pagingGetMultiplePagesWithOffsetOptions, final String clientRequestId) {
    ServiceResponse<Page<Product>> response = getMultiplePagesWithOffsetSinglePageAsync(pagingGetMultiplePagesWithOffsetOptions, clientRequestId).toBlocking().single();
    return new PagedList<Product>(response.body()) {

        @Override
        public Page<Product> nextPage(String nextPageLink) {
            PagingGetMultiplePagesWithOffsetNextOptions pagingGetMultiplePagesWithOffsetNextOptions = new PagingGetMultiplePagesWithOffsetNextOptions();
            pagingGetMultiplePagesWithOffsetNextOptions.withMaxresults(pagingGetMultiplePagesWithOffsetOptions.maxresults());
            pagingGetMultiplePagesWithOffsetNextOptions.withTimeout(pagingGetMultiplePagesWithOffsetOptions.timeout());
            return getMultiplePagesWithOffsetNextSinglePageAsync(nextPageLink, clientRequestId, pagingGetMultiplePagesWithOffsetNextOptions).toBlocking().single().body();
        }
    };
}
Also used : PagingGetMultiplePagesWithOffsetNextOptions(fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions) PagedList(com.microsoft.azure.PagedList) Product(fixtures.paging.models.Product) Page(com.microsoft.azure.Page)

Example 4 with Product

use of fixtures.paging.models.Product in project autorest.java by Azure.

the class PagingTests method getMultiplePagesFragmentWithGroupingNextLink.

@Test
public void getMultiplePagesFragmentWithGroupingNextLink() throws Exception {
    List<Product> response = client.pagings().getMultiplePagesFragmentWithGroupingNextLink(new CustomParameterGroup().withTenant("test_user").withApiVersion("1.6"));
    Assert.assertEquals(10, response.size());
}
Also used : CustomParameterGroup(fixtures.paging.models.CustomParameterGroup) Product(fixtures.paging.models.Product) Test(org.junit.Test)

Example 5 with Product

use of fixtures.paging.models.Product in project autorest.java by Azure.

the class PagingsImpl method getMultiplePagesSinglePageAsync.

/**
 * A paging operation that includes a nextLink that has 10 pages.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the PagedList&lt;Product&gt; object wrapped in {@link ServiceResponse} if successful.
 */
public Observable<ServiceResponse<Page<Product>>> getMultiplePagesSinglePageAsync() {
    final String clientRequestId = null;
    final PagingGetMultiplePagesOptions pagingGetMultiplePagesOptions = null;
    Integer maxresults = null;
    Integer timeout = null;
    return service.getMultiplePages(clientRequestId, this.client.acceptLanguage(), maxresults, timeout, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<Product>>>>() {

        @Override
        public Observable<ServiceResponse<Page<Product>>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<PageImpl<Product>> result = getMultiplePagesDelegate(response);
                return Observable.just(new ServiceResponse<Page<Product>>(result.body(), result.response()));
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Product(fixtures.paging.models.Product) Page(com.microsoft.azure.Page) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody) PagingGetMultiplePagesOptions(fixtures.paging.models.PagingGetMultiplePagesOptions) Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse)

Aggregations

Product (fixtures.paging.models.Product)8 Page (com.microsoft.azure.Page)7 ServiceResponse (com.microsoft.rest.ServiceResponse)5 ResponseBody (okhttp3.ResponseBody)5 Response (retrofit2.Response)5 Observable (rx.Observable)5 PagingGetMultiplePagesWithOffsetNextOptions (fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions)3 PagedList (com.microsoft.azure.PagedList)2 PagingGetMultiplePagesOptions (fixtures.paging.models.PagingGetMultiplePagesOptions)2 PagingGetOdataMultiplePagesOptions (fixtures.paging.models.PagingGetOdataMultiplePagesOptions)2 CustomParameterGroup (fixtures.paging.models.CustomParameterGroup)1 Test (org.junit.Test)1