Skip to content

Commit

Permalink
Merge pull request #719 from anuchandy/master
Browse files Browse the repository at this point in the history
Defining fluent flow for attaching multiple data disks
  • Loading branch information
jianghaolu committed May 20, 2016
2 parents 8ee11ab + f35826e commit acf16ff
Show file tree
Hide file tree
Showing 10 changed files with 577 additions and 53 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,42 +1,170 @@
package com.microsoft.azure.management.compute;

import com.microsoft.azure.CloudException;
import com.microsoft.azure.management.compute.implementation.api.*;
import com.microsoft.azure.management.compute.implementation.api.ImageReference;
import com.microsoft.azure.management.compute.implementation.api.VirtualMachineImageInner;
import com.microsoft.azure.management.compute.implementation.api.PurchasePlan;
import com.microsoft.azure.management.compute.implementation.api.OSDiskImage;
import com.microsoft.azure.management.compute.implementation.api.DataDiskImage;
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;

import java.io.IOException;
import java.util.List;

/**
* The type representing Azure virtual machine image.
*/
public interface VirtualMachineImage extends
Wrapper<VirtualMachineImageInner> {
/**
* The region in which virtual machine image is available.
*
* @return The region
*/
Region location();

/**
* The publisher name of the virtual machine image.
*
* @return The publisher name
*/
String publisher();

/**
* The name of the virtual machine image offer.
*
* @return The offer name
*/
String offer();

/**
* The commercial name of the virtual machine image (SKU).
*
* @return The SKU name
*/
String sku();

/**
* The version of the virtual machine image.
*
* @return The version
*/
String version();

/**
* The image reference representing publisher, offer, sku and version of the virtual machine image.
*
* @return The image reference
*/
ImageReference imageReference();

/**
* The purchase plan for the virtual machine image.
*
* @return The purchase plan.
*/
PurchasePlan plan();

/**
* Describes the OS Disk image in the virtual machine image.
*
* @return The OS Disk image
*/
OSDiskImage osDiskImage();

/**
* Describes the Data disk images in the virtual machine.
*
* @return The data disks.
*/
List<DataDiskImage> dataDiskImages();

/**
* Represents a virtual image image publisher.
*/
interface Publisher {
Region location();
/**
* Gets the region where virtual machine images from this publisher is available.
*
* @return The region name
*/
Region region();

/**
* Gets the name of the virtual machine image publisher.
*
* @return The publisher name
*/
String publisher();

/**
* Lists the virtual machine image offers from this publisher in the specific region.
*
* @return list of virtual machine image offers
* @throws CloudException
* @throws IOException
*/
List<Offer> listOffers() throws CloudException, IOException;
}

/**
* Represents a virtual machine image offer.
*/
interface Offer {
Region location();
/**
* Gets the region where this virtual machine image offer is available.
*
* @return The region name
*/
Region region();

/**
* Gets the publisher name of this virtual machine image offer.
*
* @return The publisher name
*/
String publisher();

/**
* Gets the name of the virtual machine image offer.
*
* @return The offer name
*/
String offer();
List<Sku> listSkus() throws CloudException, IOException;
}

/**
* Represents a virtual machine image SKU.
*/
interface Sku {
Region location();
/**
* Gets the region where this virtual machine image offer SKU is available.
*
* @return The region name
*/
Region region();

/**
* Gets the publisher name of this virtual machine image offer SKU.
*
* @return The publisher name
*/
String publisher();

/**
* Gets the virtual machine offer name that this SKU belongs to.
*
* @return The offer name
*/
String offer();

/**
* Gets the commercial name of the virtual machine image (SKU).
*
* @return The SKU name
*/
String sku();
List<VirtualMachineImage> listImages() throws CloudException, IOException;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@
import java.io.IOException;
import java.util.List;

/**
* The type representing Azure virtual machine image collection.
*/
public interface VirtualMachineImages extends
SupportsListingByLocation<VirtualMachineImage> {
List<VirtualMachineImage.Publisher> listPublishers(final Region location) throws CloudException, IOException;
/**
* Lists the virtual machine publishers in a region.
*
* @param region The region
* @return The list of VM image publishers
* @throws CloudException Thrown for an invalid response from the service.
* @throws IOException Thrown for IO exception.
*/
List<VirtualMachineImage.Publisher> listPublishers(final Region region) throws CloudException, IOException;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.microsoft.azure.management.compute;

/**
* A type representing virtual machine size available for a subscription in a region.
*/
public interface VirtualMachineSize {
/**
* Gets the VM size name.
Expand Down Expand Up @@ -27,7 +30,7 @@ public interface VirtualMachineSize {
Integer memoryInMB();

/**
* Gets or the Maximum number of data disks allowed by a VM size.
* Gets the Maximum number of data disks allowed by a VM size.
*/
Integer maxDataDiskCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

import java.io.IOException;

/**
* The type representing Azure virtual machine collection.
*/
public interface VirtualMachines extends
SupportsListing<VirtualMachine>,
SupportsListingByGroup<VirtualMachine>,
Expand All @@ -20,18 +23,24 @@ public interface VirtualMachines extends
SupportsDeletingByGroup {
/**
* Lists all available virtual machine sizes in a region.
*
* @param region The region upon which virtual-machine-sizes is queried.
* @return the List&lt;VirtualMachineSize&gt; if successful.
* @throws CloudException
* @throws IOException
* @throws CloudException Thrown for an invalid response from the service.
* @throws IOException Thrown for IO exception.
*/
PagedList<VirtualMachineSize> listSizes(String region) throws CloudException, IOException;

/**
* A type representing Azure virtual machine under a resource gorup.
*/
interface InGroup extends
SupportsListing<VirtualMachine>,
SupportsCreating<VirtualMachine.DefinitionBlank>,
SupportsDeleting {
/**
* Lists all available virtual machine sizes in a region.
*
* @param region The region upon which virtual-machine-sizes is queried.
* @return the List&lt;VirtualMachineSize&gt; if successful.
* @throws CloudException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class VirtualMachineImageOfferImpl
}

@Override
public Region location() {
return publisher.location();
public Region region() {
return publisher.region();
}

@Override
Expand All @@ -41,7 +41,7 @@ public String offer() {
public List<VirtualMachineImage.Sku> listSkus() throws CloudException, IOException {
List<VirtualMachineImage.Sku> skus = new ArrayList<>();
for (VirtualMachineImageResourceInner inner :
client.listSkus(location().toString(), publisher(), offer()).getBody()) {
client.listSkus(region().toString(), publisher(), offer()).getBody()) {
skus.add(new VirtualMachineImageSkuImpl(this, inner.name(), client));
}
return skus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VirtualMachineImagePublisherImpl
}

@Override
public Region location() {
public Region region() {
return location;
}

Expand All @@ -36,7 +36,7 @@ public String publisher() {
public List<VirtualMachineImage.Offer> listOffers() throws CloudException, IOException {
List<VirtualMachineImage.Offer> offers = new ArrayList<>();
for (VirtualMachineImageResourceInner inner :
client.listOffers(location().toString(), publisher()).getBody()) {
client.listOffers(region().toString(), publisher()).getBody()) {
offers.add(new VirtualMachineImageOfferImpl(this, inner.name(), client));
}
return offers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class VirtualMachineImageSkuImpl
}

@Override
public Region location() {
return offer.location();
public Region region() {
return offer.region();
}

@Override
Expand All @@ -46,18 +46,18 @@ public List<VirtualMachineImage> listImages() throws CloudException, IOException
List<VirtualMachineImage> images = new ArrayList<>();
for (VirtualMachineImageResourceInner inner :
client.list(
location().toString(),
region().toString(),
publisher(),
offer(),
sku).getBody()) {
String version = inner.name();
images.add(new VirtualMachineImageImpl(
location(),
region(),
publisher(),
offer(),
sku,
version,
client.get(location().toString(), publisher(), offer(), sku, version).getBody(),
client.get(region().toString(), publisher(), offer(), sku, version).getBody(),
client));
}
return images;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class VirtualMachineImagesImpl
}

@Override
public List<VirtualMachineImage.Publisher> listPublishers(final Region location) throws CloudException, IOException {
public List<VirtualMachineImage.Publisher> listPublishers(final Region region) throws CloudException, IOException {
List<VirtualMachineImage.Publisher> publishers = new ArrayList<>();
for (VirtualMachineImageResourceInner inner :
client.listPublishers(location.toString()).getBody()) {
publishers.add(new VirtualMachineImagePublisherImpl(location, inner.name(), client));
client.listPublishers(region.toString()).getBody()) {
publishers.add(new VirtualMachineImagePublisherImpl(region, inner.name(), client));
}
return publishers;
}
Expand Down
Loading

0 comments on commit acf16ff

Please sign in to comment.