Skip to content

Commit

Permalink
Merge pull request #730 from anuchandy/master
Browse files Browse the repository at this point in the history
Availability sets fluent methods in VirtualMachine, adding some javadocs
  • Loading branch information
jianghaolu committed May 25, 2016
2 parents e0d20b2 + d76b773 commit 5ada16f
Show file tree
Hide file tree
Showing 9 changed files with 375 additions and 205 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,70 +13,52 @@
import java.util.List;

/**
* The type representing Azure virtual machine image.
* An immutable client-side representation of an Azure virtual machine image.
*/
public interface VirtualMachineImage extends
Wrapper<VirtualMachineImageInner> {
/**
* The region in which virtual machine image is available.
*
* @return The region
* @return the region in which virtual machine image is available
*/
Region location();

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

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

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

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

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

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

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

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

Expand All @@ -85,25 +67,21 @@ public interface VirtualMachineImage extends
*/
interface Publisher {
/**
* Gets the region where virtual machine images from this publisher is available.
*
* @return The region name
* @return the region where virtual machine images from this publisher is available
*/
Region region();

/**
* Gets the name of the virtual machine image publisher.
*
* @return The publisher name
* @return the name of the virtual machine image publisher
*/
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
* @throws CloudException thrown for an invalid response from the service
* @throws IOException thrown for IO exception
*/
List<Offer> listOffers() throws CloudException, IOException;
}
Expand All @@ -113,25 +91,27 @@ interface Publisher {
*/
interface Offer {
/**
* Gets the region where this virtual machine image offer is available.
*
* @return The region name
* @return the region where this virtual machine image offer is available
*/
Region region();

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

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

/**
* Lists the virtual machine image SKUs in this offer.
*
* @return the virtual machine image SKUs
* @throws CloudException thrown for an invalid response from the service
* @throws IOException thrown for IO exception
*/
List<Sku> listSkus() throws CloudException, IOException;
}

Expand All @@ -140,32 +120,32 @@ interface Offer {
*/
interface Sku {
/**
* Gets the region where this virtual machine image offer SKU is available.
*
* @return The region name
* @return the region where this virtual machine image offer SKU is available
*/
Region region();

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

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

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

/**
* Lists the virtual machines in this SKU.
*
* @return the virtual machine images
* @throws CloudException thrown for an invalid response from the service
* @throws IOException thrown for IO exception
*/
List<VirtualMachineImage> listImages() throws CloudException, IOException;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
import java.util.List;

/**
* The type representing Azure virtual machine image collection.
* Entry point to virtual machine image management API.
*/
public interface VirtualMachineImages extends
SupportsListingByLocation<VirtualMachineImage> {
/**
* 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.
* @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
Expand Up @@ -5,32 +5,32 @@
*/
public interface VirtualMachineSize {
/**
* Gets the VM size name.
* @return the VM size name
*/
String name();

/**
* Gets the Number of cores supported by a VM size.
* @return the Number of cores supported by a VM size
*/
Integer numberOfCores();

/**
* Gets the OS disk size allowed by a VM size.
* @return the OS disk size allowed by a VM size
*/
Integer osDiskSizeInMB();

/**
* Gets Resource disk size allowed by a VM size.
* @return Resource disk size allowed by a VM size
*/
Integer resourceDiskSizeInMB();

/**
* Gets the Memory size supported by a VM size.
* @return the Memory size supported by a VM size
*/
Integer memoryInMB();

/**
* Gets the Maximum number of data disks allowed by a VM size.
* @return 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 @@ -12,7 +12,7 @@
import java.io.IOException;

/**
* The type representing Azure virtual machine collection.
* Entry point to virtual machine management API.
*/
public interface VirtualMachines extends
SupportsListing<VirtualMachine>,
Expand All @@ -26,13 +26,13 @@ public interface VirtualMachines extends
*
* @param region The region upon which virtual-machine-sizes is queried.
* @return the List&lt;VirtualMachineSize&gt; if successful.
* @throws CloudException Thrown for an invalid response from the service.
* @throws IOException Thrown for IO exception.
* @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.
* Entry point to virtual machine management API within a specific resource group.
*/
interface InGroup extends
SupportsListing<VirtualMachine>,
Expand All @@ -41,10 +41,10 @@ interface InGroup extends
/**
* Lists all available virtual machine sizes in a region.
*
* @param region The region upon which virtual-machine-sizes is queried.
* @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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import com.microsoft.rest.RestClient;
import com.microsoft.rest.credentials.ServiceClientCredentials;

/**
* Entry point to Azure compute resource management.
*/
public final class ComputeManager {
// The service managers
private ResourceManager resourceManager;
Expand All @@ -19,25 +22,52 @@ public final class ComputeManager {
private AvailabilitySets availabilitySets;
private VirtualMachines virtualMachines;

/**
* Get a Configurable instance that can be used to create ComputeManager with optional configuration.
*
* @return Configurable
*/
public static Configurable configure() {
return new ComputeManager.ConfigurableImpl();
}

/**
* Creates an instance of ComputeManager that exposes Compute resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription
* @return the ComputeManager
*/
public static ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
return new ComputeManager(AzureEnvironment.AZURE.newRestClientBuilder()
.withCredentials(credentials)
.build(), subscriptionId);
}

/**
* Creates an instance of ComputeManager that exposes Compute resource management API entry points.
*
* @param restClient the RestClient to be used for API calls.
* @param subscriptionId the subscription
* @return the ComputeManager
*/
public static ComputeManager authenticate(RestClient restClient, String subscriptionId) {
return new ComputeManager(restClient, subscriptionId);
}

public interface Configurable extends AzureConfigurable<Configurable> {
/**
* Creates an instance of ComputeManager that exposes Compute resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription
* @return the ComputeManager
*/
ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId);
}

private static final class ConfigurableImpl extends AzureConfigurableImpl<Configurable> implements Configurable {
@Override
public ComputeManager authenticate(ServiceClientCredentials credentials, String subscriptionId) {
return ComputeManager.authenticate(buildRestClient(credentials), subscriptionId);
}
Expand All @@ -49,8 +79,12 @@ private ComputeManager(RestClient restClient, String subscriptionId) {
resourceManager = ResourceManager.authenticate(restClient).withSubscription(subscriptionId);
}

private ComputeManager() {}
private ComputeManager() {
}

/**
* @return the availability set resource management API entry point
*/
public AvailabilitySets availabilitySets() {
if (availabilitySets == null) {
availabilitySets = new AvailabilitySetsImpl(computeManagementClient.availabilitySets(),
Expand All @@ -59,6 +93,9 @@ public AvailabilitySets availabilitySets() {
return availabilitySets;
}

/**
* @return the virtual machine resource management API entry point
*/
public VirtualMachines virtualMachines() {
if (virtualMachines == null) {
virtualMachines = new VirtualMachinesImpl(computeManagementClient.virtualMachines(), computeManagementClient.virtualMachineSizes());
Expand Down
Loading

0 comments on commit 5ada16f

Please sign in to comment.