Skip to content

Commit

Permalink
Merge pull request #621 from jianghaolu/autorest
Browse files Browse the repository at this point in the history
Support lazy loaded lists and streaming
  • Loading branch information
jianghaolu committed Mar 21, 2016
2 parents 2b00e6f + b48dd8a commit 9433365
Show file tree
Hide file tree
Showing 99 changed files with 937 additions and 795 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import com.microsoft.azure.management.compute.models.AvailabilitySet;
import com.microsoft.azure.management.compute.models.PageImpl;
import com.microsoft.azure.management.compute.models.VirtualMachineSize;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
import java.io.IOException;
import java.util.List;

/**
* An instance of this class provides access to all the operations defined
Expand Down Expand Up @@ -106,7 +106,7 @@ public interface AvailabilitySetsOperations {
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List<AvailabilitySet> object wrapped in {@link ServiceResponse} if successful.
*/
ServiceResponse<List<AvailabilitySet>> list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException;
ServiceResponse<PagedList<AvailabilitySet>> list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException;

/**
* The operation to list the availability sets.
Expand All @@ -128,7 +128,7 @@ public interface AvailabilitySetsOperations {
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;VirtualMachineSize&gt; object wrapped in {@link ServiceResponse} if successful.
*/
ServiceResponse<List<VirtualMachineSize>> listAvailableSizes(final String resourceGroupName, final String availabilitySetName) throws CloudException, IOException, IllegalArgumentException;
ServiceResponse<PagedList<VirtualMachineSize>> listAvailableSizes(final String resourceGroupName, final String availabilitySetName) throws CloudException, IOException, IllegalArgumentException;

/**
* Lists virtual-machine-sizes available to be used for an availability set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.microsoft.azure.management.compute.models.AvailabilitySet;
import com.microsoft.azure.management.compute.models.PageImpl;
import com.microsoft.azure.management.compute.models.VirtualMachineSize;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
Expand Down Expand Up @@ -348,7 +350,7 @@ private ServiceResponse<AvailabilitySet> getDelegate(Response<ResponseBody> resp
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;AvailabilitySet&gt; object wrapped in {@link ServiceResponse} if successful.
*/
public ServiceResponse<List<AvailabilitySet>> list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException {
public ServiceResponse<PagedList<AvailabilitySet>> list(final String resourceGroupName) throws CloudException, IOException, IllegalArgumentException {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
Expand All @@ -360,11 +362,12 @@ public ServiceResponse<List<AvailabilitySet>> list(final String resourceGroupNam
}
Call<ResponseBody> call = service.list(resourceGroupName, this.client.getSubscriptionId(), this.client.getApiVersion(), this.client.getAcceptLanguage());
ServiceResponse<PageImpl<AvailabilitySet>> response = listDelegate(call.execute());
List<AvailabilitySet> result = response.getBody().getItems();
while (response.getBody().getNextPageLink() != null) {
response = listNext(response.getBody().getNextPageLink());
result.addAll(response.getBody().getItems());
}
PagedList<AvailabilitySet> result = new PagedList<AvailabilitySet>(response.getBody()) {
@Override
public Page<AvailabilitySet> nextPage(String nextPageLink) throws CloudException, IOException {
return listNext(nextPageLink).getBody();
}
};
return new ServiceResponse<>(result, response.getResponse());
}

Expand Down Expand Up @@ -431,7 +434,7 @@ private ServiceResponse<PageImpl<AvailabilitySet>> listDelegate(Response<Respons
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;VirtualMachineSize&gt; object wrapped in {@link ServiceResponse} if successful.
*/
public ServiceResponse<List<VirtualMachineSize>> listAvailableSizes(final String resourceGroupName, final String availabilitySetName) throws CloudException, IOException, IllegalArgumentException {
public ServiceResponse<PagedList<VirtualMachineSize>> listAvailableSizes(final String resourceGroupName, final String availabilitySetName) throws CloudException, IOException, IllegalArgumentException {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
Expand All @@ -446,11 +449,12 @@ public ServiceResponse<List<VirtualMachineSize>> listAvailableSizes(final String
}
Call<ResponseBody> call = service.listAvailableSizes(resourceGroupName, availabilitySetName, this.client.getSubscriptionId(), this.client.getApiVersion(), this.client.getAcceptLanguage());
ServiceResponse<PageImpl<VirtualMachineSize>> response = listAvailableSizesDelegate(call.execute());
List<VirtualMachineSize> result = response.getBody().getItems();
while (response.getBody().getNextPageLink() != null) {
response = listAvailableSizesNext(response.getBody().getNextPageLink());
result.addAll(response.getBody().getItems());
}
PagedList<VirtualMachineSize> result = new PagedList<VirtualMachineSize>(response.getBody()) {
@Override
public Page<VirtualMachineSize> nextPage(String nextPageLink) throws CloudException, IOException {
return listAvailableSizesNext(nextPageLink).getBody();
}
};
return new ServiceResponse<>(result, response.getResponse());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.management.compute.models.PageImpl;
import com.microsoft.azure.management.compute.models.Usage;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceResponse;
import java.io.IOException;
import java.util.List;

/**
* An instance of this class provides access to all the operations defined
Expand All @@ -33,7 +33,7 @@ public interface UsageOperations {
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;Usage&gt; object wrapped in {@link ServiceResponse} if successful.
*/
ServiceResponse<List<Usage>> list(final String location) throws CloudException, IOException, IllegalArgumentException;
ServiceResponse<PagedList<Usage>> list(final String location) throws CloudException, IOException, IllegalArgumentException;

/**
* Lists compute usages for a subscription.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.microsoft.azure.ListOperationCallback;
import com.microsoft.azure.management.compute.models.PageImpl;
import com.microsoft.azure.management.compute.models.Usage;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.ServiceResponseCallback;
Expand Down Expand Up @@ -77,7 +79,7 @@ interface UsageService {
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;Usage&gt; object wrapped in {@link ServiceResponse} if successful.
*/
public ServiceResponse<List<Usage>> list(final String location) throws CloudException, IOException, IllegalArgumentException {
public ServiceResponse<PagedList<Usage>> list(final String location) throws CloudException, IOException, IllegalArgumentException {
if (location == null) {
throw new IllegalArgumentException("Parameter location is required and cannot be null.");
}
Expand All @@ -89,11 +91,12 @@ public ServiceResponse<List<Usage>> list(final String location) throws CloudExce
}
Call<ResponseBody> call = service.list(location, this.client.getSubscriptionId(), this.client.getApiVersion(), this.client.getAcceptLanguage());
ServiceResponse<PageImpl<Usage>> response = listDelegate(call.execute());
List<Usage> result = response.getBody().getItems();
while (response.getBody().getNextPageLink() != null) {
response = listNext(response.getBody().getNextPageLink());
result.addAll(response.getBody().getItems());
}
PagedList<Usage> result = new PagedList<Usage>(response.getBody()) {
@Override
public Page<Usage> nextPage(String nextPageLink) throws CloudException, IOException {
return listNext(nextPageLink).getBody();
}
};
return new ServiceResponse<>(result, response.getResponse());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ public ServiceResponse<List<VirtualMachineImageResource>> listVersions(String lo
if (this.client.getApiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.getApiVersion() is required and cannot be null.");
}
VirtualMachineImageResource filter = null;
Integer top = null;
String orderby = null;
final VirtualMachineImageResource filter = null;
final Integer top = null;
final String orderby = null;
Call<ResponseBody> call = service.listVersions(location, publisherName, type, this.client.getSubscriptionId(), this.client.getMapperAdapter().serializeRaw(filter), top, orderby, this.client.getApiVersion(), this.client.getAcceptLanguage());
return listVersionsDelegate(call.execute());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public ServiceResponse<VirtualMachineExtension> get(String resourceGroupName, St
if (this.client.getApiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.getApiVersion() is required and cannot be null.");
}
String expand = null;
final String expand = null;
Call<ResponseBody> call = service.get(resourceGroupName, vmName, vmExtensionName, this.client.getSubscriptionId(), expand, this.client.getApiVersion(), this.client.getAcceptLanguage());
return getDelegate(call.execute());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ public ServiceResponse<List<VirtualMachineImageResource>> list(String location,
if (this.client.getApiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.getApiVersion() is required and cannot be null.");
}
VirtualMachineImageResource filter = null;
Integer top = null;
String orderby = null;
final VirtualMachineImageResource filter = null;
final Integer top = null;
final String orderby = null;
Call<ResponseBody> call = service.list(location, publisherName, offer, skus, this.client.getSubscriptionId(), this.client.getMapperAdapter().serializeRaw(filter), top, orderby, this.client.getApiVersion(), this.client.getAcceptLanguage());
return listDelegate(call.execute());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import com.microsoft.azure.management.compute.models.PageImpl;
import com.microsoft.azure.management.compute.models.VirtualMachineScaleSetVM;
import com.microsoft.azure.management.compute.models.VirtualMachineScaleSetVMInstanceView;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
import java.io.IOException;
import java.util.List;

/**
* An instance of this class provides access to all the operations defined
Expand Down Expand Up @@ -239,7 +239,7 @@ public interface VirtualMachineScaleSetVMsOperations {
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;VirtualMachineScaleSetVM&gt; object wrapped in {@link ServiceResponse} if successful.
*/
ServiceResponse<List<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName) throws CloudException, IOException, IllegalArgumentException;
ServiceResponse<PagedList<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName) throws CloudException, IOException, IllegalArgumentException;

/**
* The operation to list virtual machine scale sets VMs.
Expand All @@ -264,7 +264,7 @@ public interface VirtualMachineScaleSetVMsOperations {
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;VirtualMachineScaleSetVM&gt; object wrapped in {@link ServiceResponse} if successful.
*/
ServiceResponse<List<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName, final VirtualMachineScaleSetVM filter, final String select, final String expand) throws CloudException, IOException, IllegalArgumentException;
ServiceResponse<PagedList<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName, final VirtualMachineScaleSetVM filter, final String select, final String expand) throws CloudException, IOException, IllegalArgumentException;

/**
* The operation to list virtual machine scale sets VMs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import com.microsoft.azure.management.compute.models.PageImpl;
import com.microsoft.azure.management.compute.models.VirtualMachineScaleSetVM;
import com.microsoft.azure.management.compute.models.VirtualMachineScaleSetVMInstanceView;
import com.microsoft.azure.Page;
import com.microsoft.azure.PagedList;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
Expand Down Expand Up @@ -802,7 +804,7 @@ private ServiceResponse<VirtualMachineScaleSetVMInstanceView> getInstanceViewDel
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;VirtualMachineScaleSetVM&gt; object wrapped in {@link ServiceResponse} if successful.
*/
public ServiceResponse<List<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName) throws CloudException, IOException, IllegalArgumentException {
public ServiceResponse<PagedList<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName) throws CloudException, IOException, IllegalArgumentException {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
Expand All @@ -815,16 +817,17 @@ public ServiceResponse<List<VirtualMachineScaleSetVM>> list(final String resourc
if (this.client.getApiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.getApiVersion() is required and cannot be null.");
}
VirtualMachineScaleSetVM filter = null;
String select = null;
String expand = null;
final VirtualMachineScaleSetVM filter = null;
final String select = null;
final String expand = null;
Call<ResponseBody> call = service.list(resourceGroupName, virtualMachineScaleSetName, this.client.getSubscriptionId(), this.client.getMapperAdapter().serializeRaw(filter), select, expand, this.client.getApiVersion(), this.client.getAcceptLanguage());
ServiceResponse<PageImpl<VirtualMachineScaleSetVM>> response = listDelegate(call.execute());
List<VirtualMachineScaleSetVM> result = response.getBody().getItems();
while (response.getBody().getNextPageLink() != null) {
response = listNext(response.getBody().getNextPageLink());
result.addAll(response.getBody().getItems());
}
PagedList<VirtualMachineScaleSetVM> result = new PagedList<VirtualMachineScaleSetVM>(response.getBody()) {
@Override
public Page<VirtualMachineScaleSetVM> nextPage(String nextPageLink) throws CloudException, IOException {
return listNext(nextPageLink).getBody();
}
};
return new ServiceResponse<>(result, response.getResponse());
}

Expand Down Expand Up @@ -895,7 +898,7 @@ public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response)
* @throws IllegalArgumentException exception thrown from invalid parameters
* @return the List&lt;VirtualMachineScaleSetVM&gt; object wrapped in {@link ServiceResponse} if successful.
*/
public ServiceResponse<List<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName, final VirtualMachineScaleSetVM filter, final String select, final String expand) throws CloudException, IOException, IllegalArgumentException {
public ServiceResponse<PagedList<VirtualMachineScaleSetVM>> list(final String resourceGroupName, final String virtualMachineScaleSetName, final VirtualMachineScaleSetVM filter, final String select, final String expand) throws CloudException, IOException, IllegalArgumentException {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
Expand All @@ -911,11 +914,12 @@ public ServiceResponse<List<VirtualMachineScaleSetVM>> list(final String resourc
Validator.validate(filter);
Call<ResponseBody> call = service.list(resourceGroupName, virtualMachineScaleSetName, this.client.getSubscriptionId(), this.client.getMapperAdapter().serializeRaw(filter), select, expand, this.client.getApiVersion(), this.client.getAcceptLanguage());
ServiceResponse<PageImpl<VirtualMachineScaleSetVM>> response = listDelegate(call.execute());
List<VirtualMachineScaleSetVM> result = response.getBody().getItems();
while (response.getBody().getNextPageLink() != null) {
response = listNext(response.getBody().getNextPageLink());
result.addAll(response.getBody().getItems());
}
PagedList<VirtualMachineScaleSetVM> result = new PagedList<VirtualMachineScaleSetVM>(response.getBody()) {
@Override
public Page<VirtualMachineScaleSetVM> nextPage(String nextPageLink) throws CloudException, IOException {
return listNext(nextPageLink).getBody();
}
};
return new ServiceResponse<>(result, response.getResponse());
}

Expand Down
Loading

0 comments on commit 9433365

Please sign in to comment.