com.microsoft.rest.RestException Java Examples

The following examples show how to use com.microsoft.rest.RestException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChildListFlattener.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * flatten the  child paged lists.
 *
 * @return the lazy flattened paged list from the child paged lists
 * @throws CloudException exceptions thrown from the cloud
 * @throws IOException exceptions thrown from serialization/deserialization
 */
public PagedList<ChildT> flatten() {
    this.currentChildList = nextChildList();
    if (this.currentChildList == null) {
        return emptyPagedList();
    }
    return new PagedList<ChildT>(childListPage(currentChildList.currentPage())) {
        @Override
        public Page<ChildT> nextPage(String nextPageLink) throws RestException, IOException {
            if (nextPageLink.equalsIgnoreCase(switchToCousin)) {
                // Reached end of current child paged list, make next child list(cousin) as current
                // paged list and return it's first page.
                currentChildList = nextChildList();
                return childListPage(currentChildList.currentPage());
            } else {
                currentChildList.loadNextPage();
                return childListPage(currentChildList.currentPage());
            }
        }
    };
}
 
Example #2
Source File: ComputeSkusImpl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Util function to block on an observable and turn that to a paged list with one page.
 *
 * @param skuObservable the observable
 * @param <T> the item type
 * @return a paged list with items collected from the given observable
 */
private static <T> PagedList<T> toPagedList(final Observable<T> skuObservable) {
    Page<T> singlePage = new Page<T>() {
        @Override
        public List<T> items() {
            return Lists.newArrayList(skuObservable.toBlocking().toIterable());
        }

        @Override
        public String nextPageLink() {
            return null;
        }
    };
    return new PagedList<T>(singlePage) {
        @Override
        public Page<T> nextPage(String s) throws RestException, IOException {
            return null;
        }
    };
}
 
Example #3
Source File: AzureVirtualMachineServiceTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private PagedList<VirtualMachine> createPagedListWithOnePage() {
    PagedList<VirtualMachine> pagedList = new PagedList<>() {
        @Override
        public Page<VirtualMachine> nextPage(String nextPageLink) throws RestException {
            return null;
        }

        @Override
        public void loadNextPage() {
        }

        @Override
        public boolean hasNextPage() {
            return false;
        }
    };
    pagedList.add(createVirtualMachine(INSTANCE_1));
    return pagedList;
}
 
Example #4
Source File: ChildListFlattener.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * @return an empty paged list
 */
private PagedList<ChildT> emptyPagedList() {
    return new PagedList<ChildT>(emptyPage()) {
        @Override
        public Page<ChildT> nextPage(String nextPageLink) throws RestException, IOException {
            return null;
        }
    };
}
 
Example #5
Source File: AzureVirtualMachineServiceTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private PagedList<VirtualMachine> createPagedList() {
    PagedList<VirtualMachine> pagedList = new PagedList<>() {
        @Override
        public Page<VirtualMachine> nextPage(String nextPageLink) throws RestException {
            return null;
        }
    };
    pagedList.add(createVirtualMachine(INSTANCE_1));
    pagedList.add(createVirtualMachine(INSTANCE_2));
    pagedList.add(createVirtualMachine(INSTANCE_3));
    return pagedList;
}
 
Example #6
Source File: AzureScannerTest.java    From clouditor with Apache License 2.0 4 votes vote down vote up
@Override
public Page<E> nextPage(String nextPageLink) throws RestException {
  return null;
}
 
Example #7
Source File: AzureResponseBuilder.java    From autorest-clientruntime-for-java with MIT License 4 votes vote down vote up
@Override
public ResponseBuilder<T, E> registerError(Class<? extends RestException> type) {
    baseBuilder.registerError(type);
    return this;
}
 
Example #8
Source File: AzureResponseBuilder.java    From autorest-clientruntime-for-java with MIT License 4 votes vote down vote up
@Override
public <T, E extends RestException> AzureResponseBuilder<T, E> newInstance(final SerializerAdapter<?> serializerAdapter) {
    return new AzureResponseBuilder<T, E>(serializerAdapter);
}
 
Example #9
Source File: PagedList.java    From autorest-clientruntime-for-java with MIT License 2 votes vote down vote up
/**
 * Override this method to load the next page of items from a next page link.
 *
 * @param nextPageLink the link to get the next page of items.
 * @return the {@link Page} object storing a page of items and a link to the next page.
 * @throws RestException thrown if an error is raised from Azure.
 * @throws IOException thrown if there's any failure in deserialization.
 */
public abstract Page<E> nextPage(String nextPageLink) throws RestException, IOException;
 
Example #10
Source File: ResponseBuilder.java    From autorest-clientruntime-for-java with MIT License 2 votes vote down vote up
/**
 * Register a destination type for errors with models.
 *
 * @param type the type to deserialize.
 * @return the same builder instance.
 */
ResponseBuilder<T, E> registerError(Class<? extends RestException> type);
 
Example #11
Source File: ResponseBuilder.java    From autorest-clientruntime-for-java with MIT License 2 votes vote down vote up
/**
 * Returns a response builder instance. This can be created new or cached.
 *
 * @param <T> the type of the return object
 * @param <E> the type of the exception
 * @param serializerAdapter the serializer adapter to deserialize the response
 * @return a response builder instance
 */
<T, E extends RestException> ResponseBuilder<T, E> newInstance(SerializerAdapter<?> serializerAdapter);