From eca38a21e613a4e4e52743251d018df4a4dd5462 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 18 May 2016 14:36:56 -0700 Subject: [PATCH 01/30] Defining fluent flow for attaching multiple data disks --- .../management/compute/VirtualMachine.java | 88 +++++++++ .../implementation/VirtualMachineImpl.java | 176 ++++++++++++++++-- 2 files changed, 253 insertions(+), 11 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java index 19eb7f6b73c36..0d0e4491ebf7b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java @@ -264,18 +264,105 @@ interface DefinitionOSDiskSettings { interface DefinitionWithVMSize { /** + * Specifies the virtual machine size * @param sizeName The name of the size for the virtual machine as text * @return The stage representing creatable VM definition */ T withSize(String sizeName); /** + * Specifies the virtual machine size * @param size A size from the list of available sizes for the virtual machine * @return The stage representing creatable VM definition */ T withSize(VirtualMachineSizeTypes size); } + interface ConfigureDataDisk { + /** + * Specifies the logical unit number for the data disk + * @param lun The logical unit number + * @return The stage representing optional additional configurations for the attachable data disk + */ + ConfigureDataDisk withLun(Integer lun); + + /** + * Specifies the caching type for the data disk + * @param cachingType The disk caching type. Possible values include: 'None', 'ReadOnly', 'ReadWrite' + * @return The stage representing optional additional configurations for the attachable data disk + */ + ConfigureDataDisk withCaching(CachingTypes cachingType); + + /** + * Adds the data disk to the list of virtual machine's data disks + * @return The stage representing creatable VM definition + */ + T attach(); + } + + interface ConfigureNewDataDiskWithStoreAt extends ConfigureDataDisk { + /** + * Specifies where the VHD associated with the new blank data disk needs to be stored + * @param storageAccountName The storage account name + * @param containerName The name of the container to hold the new VHD file + * @param vhdName The name for the new VHD file + * @return The stage representing optional additional configurations for the attachable data disk + */ + ConfigureDataDisk storeAt(String storageAccountName, String containerName, String vhdName); + } + + interface ConfigureNewDataDisk { + /** + * Specifies the initial disk size in GB for new blank data disk + * @param size The disk size in GB + * @return The stage representing optional additional configurations for the attachable data disk + */ + ConfigureNewDataDiskWithStoreAt withSizeInGB(Integer size); + } + + interface ConfigureExistingDataDisk { + /** + * Specifies an existing VHD that needs to be attached to the virtual machine as data disk + * @param storageAccountName The storage account name + * @param containerName The name of the container holding the VHD file + * @param vhdName The name for the VHD file + * @return The stage representing optional additional configurations for the attachable data disk + */ + ConfigureDataDisk from(String storageAccountName, String containerName, String vhdName); + } + + interface DefinitionWithDataDisk { + /** + * Specifies that a new blank data disk needs to be attached to virtual machine + * @param sizeInGB The disk size in GB + * @return The stage representing creatable VM definition + */ + T withNewDataDisk(Integer sizeInGB); + + /** + * Specifies an existing VHD that needs to be attached to the virtual machine as data disk + * @param storageAccountName The storage account name + * @param containerName The name of the container holding the VHD file + * @param vhdName The name for the VHD file + * @return The stage representing creatable VM definition + */ + T withExistingDataDisk(String storageAccountName, String containerName, String vhdName); + + /** + * Specifies a new blank data disk to be attached to the virtual machine along with it's configuration + * @param name The name for the data disk + * @return The stage representing configuration for the data disk + */ + ConfigureNewDataDisk defineNewDataDisk(String name); + + /** + * Specifies an existing VHD that needs to be attached to the virtual machine as data disk along with it's configuration + * @param name The name for the data disk + * @return The stage representing configuration for the data disk + */ + ConfigureExistingDataDisk defineExistingDataDisk(String name); + } + interface DefinitionStorageAccount { /** * Specifies the name of the storage account to create, the OS disk for VM created from a market-place @@ -310,6 +397,7 @@ interface DefinitionCreatable extends DefinitionOSDiskSettings, DefinitionWithVMSize, DefinitionStorageAccount, + DefinitionWithDataDisk, Creatable { } } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index c0f6c967f19e3..c31eb2007335b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -18,13 +18,17 @@ class VirtualMachineImpl VirtualMachine.DefinitionBlank, VirtualMachine.DefinitionWithGroup, VirtualMachine.DefinitionWithOS, - VirtualMachine.DefinitionWithMarketplaceImage, + VirtualMachine.DefinitionWithMarketplaceImage, VirtualMachine.DefinitionWithOSType, VirtualMachine.DefinitionWithRootUserName, VirtualMachine.DefinitionWithAdminUserName, VirtualMachine.DefinitionLinuxCreatable, VirtualMachine.DefinitionWindowsCreatable, - VirtualMachine.DefinitionCreatable { + VirtualMachine.DefinitionCreatable, + VirtualMachine.ConfigureDataDisk, + VirtualMachine.ConfigureNewDataDiskWithStoreAt, + VirtualMachine.ConfigureNewDataDisk, + VirtualMachine.ConfigureExistingDataDisk { private final VirtualMachinesInner client; private final VirtualMachineInner innerModel; private final ResourceManager resourceManager; @@ -42,6 +46,7 @@ class VirtualMachineImpl this.innerModel.setStorageProfile(new StorageProfile()); this.innerModel.storageProfile().setOsDisk(new OSDisk()); + this.innerModel.storageProfile().setDataDisks(new ArrayList()); this.innerModel.setOsProfile(new OSProfile()); this.innerModel.setHardwareProfile(new HardwareProfile()); } @@ -264,7 +269,7 @@ public DefinitionCreatable withOSDiskCaching(CachingTypes cachingType) { @Override public DefinitionCreatable withOSDiskVhdLocation(String containerName, String vhdName) { VirtualHardDisk osVhd = new VirtualHardDisk(); - osVhd.setUri(null); // TODO generate and sets VHD URI. + osVhd.setUri(blobUrl(this.storageAccountName, containerName, vhdName)); this.innerModel.storageProfile().osDisk().setVhd(osVhd); return this; } @@ -287,6 +292,88 @@ public DefinitionCreatable withOSDiskName(String name) { return this; } + // Virtual machine data disk fluent methods + // + + @Override + public ConfigureDataDisk withLun(Integer lun) { + DataDisk dataDisk = currentDataDisk(); + dataDisk.setLun(lun); + return this; + } + + @Override + public ConfigureDataDisk withCaching(CachingTypes cachingType) { + DataDisk dataDisk = currentDataDisk(); + dataDisk.setCaching(cachingType); + return this; + } + + @Override + public DefinitionCreatable attach() { + return this; + } + + @Override + public ConfigureDataDisk storeAt(String storageAccountName, String containerName, String vhdName) { + DataDisk dataDisk = currentDataDisk(); + dataDisk.setVhd(new VirtualHardDisk()); + dataDisk.vhd().setUri(blobUrl(storageAccountName, containerName, vhdName)); // URL points to where the new data disk needs to be stored. + return this; + } + + @Override + public ConfigureNewDataDiskWithStoreAt withSizeInGB(Integer sizeInGB) { + DataDisk dataDisk = currentDataDisk(); + dataDisk.setDiskSizeGB(sizeInGB); + return this; + } + + @Override + public ConfigureDataDisk from(String storageAccountName, String containerName, String vhdName) { + DataDisk dataDisk = currentDataDisk(); + dataDisk.setVhd(new VirtualHardDisk()); + dataDisk.vhd().setUri(blobUrl(storageAccountName, containerName, vhdName)); // URL points to an existing data disk to be attached. + return this; + } + + @Override + public ConfigureNewDataDisk defineNewDataDisk(String name) { + DataDisk dataDisk = prepareNewDataDisk(); + dataDisk.setName(name); + dataDisk.setCreateOption(DiskCreateOptionTypes.EMPTY); + return this; + } + + @Override + public ConfigureExistingDataDisk defineExistingDataDisk(String name) { + DataDisk dataDisk = prepareNewDataDisk(); + dataDisk.setName(name); + dataDisk.setCreateOption(DiskCreateOptionTypes.ATTACH); + return this; + } + + @Override + public DefinitionCreatable withNewDataDisk(Integer sizeInGB) { + DataDisk dataDisk = prepareNewDataDisk(); + dataDisk.setDiskSizeGB(sizeInGB); + dataDisk.setCreateOption(DiskCreateOptionTypes.EMPTY); + return this; + } + + @Override + public DefinitionCreatable withExistingDataDisk(String storageAccountName, String containerName, String vhdName) { + DataDisk dataDisk = prepareNewDataDisk(); + VirtualHardDisk diskVhd = new VirtualHardDisk(); + diskVhd.setUri(blobUrl(storageAccountName, containerName, vhdName)); + dataDisk.setVhd(diskVhd); + dataDisk.setCreateOption(DiskCreateOptionTypes.ATTACH); + return this; + } + + // Virtual machine storage account fluent methods + // + @Override public DefinitionCreatable withNewStorageAccount(String name) { return withNewStorageAccount(storageManager.storageAccounts().define(name) @@ -307,24 +394,22 @@ public DefinitionCreatable withExistingStorageAccount(String name) { return this; } - @Override public VirtualMachine create() throws Exception { setDefaults(); return null; } - // Helper methods + // helper methods to set various virtual machine's default properties // - private boolean isStoredImage(OSDisk osDisk) { - return osDisk.image() != null; - } - private boolean isOSDiskAttached(OSDisk osDisk) { - return osDisk.createOption() == DiskCreateOptionTypes.ATTACH; + private void setDefaults() { + setOSDiskAndOSProfileDefaults(); + setHardwareProfileDefaults(); + setDataDisksDefaults(); } - private void setDefaults() { + private void setOSDiskAndOSProfileDefaults() { OSDisk osDisk = this.innerModel.storageProfile().osDisk(); if (!isOSDiskAttached(osDisk)) { if (osDisk.vhd() == null) { @@ -347,10 +432,79 @@ private void setDefaults() { if (osDisk.name() == null) { withOSDiskName(null /*TODO generate random OSDisk name */); } + } + private void setHardwareProfileDefaults() { HardwareProfile hardwareProfile = this.innerModel.hardwareProfile(); if (hardwareProfile.vmSize() == null) { hardwareProfile.setVmSize(VirtualMachineSizeTypes.BASIC_A0); } } + + private void setDataDisksDefaults() { + List dataDisks = this.innerModel.storageProfile().dataDisks(); + if (dataDisks.size() == 0) { + this.innerModel.storageProfile().setDataDisks(null); + return; + } + + List usedLuns = new ArrayList<>(); + for (DataDisk dataDisk : dataDisks) { + if (dataDisk.lun() != -1) { + usedLuns.add(dataDisk.lun()); + } + } + + for (DataDisk dataDisk : dataDisks) { + if (dataDisk.lun() == -1) { + Integer i = 0; + while (usedLuns.contains(i)) { + i++; + } + dataDisk.setLun(i); + usedLuns.add(i); + } + + if (dataDisk.vhd() == null) { + VirtualHardDisk diskVhd = new VirtualHardDisk(); + diskVhd.setUri(blobUrl(this.storageAccountName, "vhds", null /* TODO generate Vhd name*/)); + dataDisk.setVhd(diskVhd); + } + + if (dataDisk.name() == null) { + dataDisk.setName(null /*TODO generate random name for new DataDisk */); + } + + if (dataDisk.caching() == null) { + dataDisk.setCaching(CachingTypes.READ_WRITE); + } + } + } + + // Helper methods + // + + private boolean isStoredImage(OSDisk osDisk) { + return osDisk.image() != null; + } + + private boolean isOSDiskAttached(OSDisk osDisk) { + return osDisk.createOption() == DiskCreateOptionTypes.ATTACH; + } + + private DataDisk prepareNewDataDisk() { + DataDisk dataDisk = new DataDisk(); + dataDisk.setLun(-1); + this.innerModel.storageProfile().dataDisks().add(dataDisk); + return dataDisk; + } + + private DataDisk currentDataDisk() { + List dataDisks = this.innerModel.storageProfile().dataDisks(); + return dataDisks.get(dataDisks.size() - 1); + } + + private String blobUrl(String storageAccountName, String containerName, String blobName) { + return storageAccountName + ".blob.core.windows.net" + "/" + containerName + "/" + blobName ; + } } From faba238b76023e3b3181a5c4ca84945a4dbdc65b Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 18 May 2016 15:29:09 -0700 Subject: [PATCH 02/30] generating names for os, data disks and it's vhds --- .../compute/implementation/VirtualMachineImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index c31eb2007335b..f97d2b1605977 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; class VirtualMachineImpl extends GroupableResourceImpl @@ -414,7 +415,7 @@ private void setOSDiskAndOSProfileDefaults() { if (!isOSDiskAttached(osDisk)) { if (osDisk.vhd() == null) { // Sets the OS disk VHD for "UserImage" and "VM(Platform)Image" - withOSDiskVhdLocation("vhds", null /*TODO generate random vhd name */); + withOSDiskVhdLocation("vhds", this.name() + "-os-disk-" + UUID.randomUUID().toString() + ".vhd"); } OSProfile osProfile = this.innerModel.osProfile(); if (osDisk.osType() == OperatingSystemTypes.LINUX) { @@ -430,7 +431,7 @@ private void setOSDiskAndOSProfileDefaults() { } if (osDisk.name() == null) { - withOSDiskName(null /*TODO generate random OSDisk name */); + withOSDiskName(this.name() + "-os-disk"); } } @@ -467,12 +468,13 @@ private void setDataDisksDefaults() { if (dataDisk.vhd() == null) { VirtualHardDisk diskVhd = new VirtualHardDisk(); - diskVhd.setUri(blobUrl(this.storageAccountName, "vhds", null /* TODO generate Vhd name*/)); + diskVhd.setUri(blobUrl(this.storageAccountName, "vhds", + this.name() + "-data-disk-" + dataDisk.lun() + "-" + UUID.randomUUID().toString() + ".vhd")); dataDisk.setVhd(diskVhd); } if (dataDisk.name() == null) { - dataDisk.setName(null /*TODO generate random name for new DataDisk */); + dataDisk.setName(this.name() + "-data-disk-" + dataDisk.lun()); } if (dataDisk.caching() == null) { From 0e68a2770a043d83f84bc27790424e8adfa9a17c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 May 2016 18:19:21 -0700 Subject: [PATCH 03/30] remainder of the PublicIPAddress model --- .../management/network/PublicIpAddress.java | 14 +++++++---- .../implementation/PublicIpAddressImpl.java | 23 ++++++++++++++++--- .../java/com/microsoft/azure/AzureTests.java | 8 +++++-- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index 34ff20520f03c..5ca774bc16211 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -22,10 +22,12 @@ public interface PublicIpAddress extends /*********************************************************** * Getters ***********************************************************/ - String ipAddress(); - String leafDomainLabel(); - String fqdn(); - String reverseFqdn(); + public String ipAddress(); + public String leafDomainLabel(); + public String fqdn(); + public String reverseFqdn(); + public String ipAllocationMethod(); + public int idleTimeoutInMinutes(); /************************************************************** * Fluent interfaces for provisioning @@ -142,13 +144,14 @@ public interface UpdatableWithReverseFQDN { */ T withoutReverseFqdn(); } - + interface DefinitionCreatable extends Creatable, DefinitionWithLeafDomainLabel, DefinitionWithIpAddress, DefinitionWithReverseFQDN { + DefinitionCreatable withIdleTimeoutInMinutes(int minutes); } interface Update extends @@ -156,6 +159,7 @@ interface Update extends UpdatableWithIpAddress, UpdatableWithLeafDomainLabel, UpdatableWithReverseFQDN { + Update withIdleTimeoutInMinutes(int minutes); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java index a355bef58a049..84fca67d39b35 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/implementation/PublicIpAddressImpl.java @@ -6,6 +6,7 @@ package com.microsoft.azure.management.network.implementation; import com.microsoft.azure.management.network.PublicIpAddress; +import com.microsoft.azure.management.network.implementation.api.IPAllocationMethod; import com.microsoft.azure.management.network.implementation.api.PublicIPAddressDnsSettings; import com.microsoft.azure.management.network.implementation.api.PublicIPAddressInner; import com.microsoft.azure.management.network.implementation.api.PublicIPAddressesInner; @@ -64,17 +65,23 @@ private void clearWrapperProperties() { /***************************************** * Setters (fluent) *****************************************/ - + + @Override + public PublicIpAddressImpl withIdleTimeoutInMinutes(int minutes) { + this.inner().setIdleTimeoutInMinutes(minutes); + return this; + } + @Override public PublicIpAddressImpl withStaticIp() { - this.inner().setPublicIPAllocationMethod("Static"); // TODO: Replace with IpAllocationMethod.STATIC + this.inner().setPublicIPAllocationMethod(IPAllocationMethod.STATIC); return this; } @Override public PublicIpAddressImpl withDynamicIp() { - this.inner().setPublicIPAllocationMethod("Dynamic"); // TODO: Replace with IpAllocationMethod.DYNAMIC + this.inner().setPublicIPAllocationMethod(IPAllocationMethod.DYNAMIC); return this; } @@ -114,6 +121,16 @@ private PublicIPAddressDnsSettings ensureDnsSettings() { /********************************************** * Getters **********************************************/ + @Override + public int idleTimeoutInMinutes() { + return this.inner().idleTimeoutInMinutes(); + } + + @Override + public String ipAllocationMethod() { // TODO: This should really return an enum + return this.inner().publicIPAllocationMethod(); + } + @Override public String fqdn() { return this.inner().dnsSettings().fqdn(); diff --git a/azure/src/test/java/com/microsoft/azure/AzureTests.java b/azure/src/test/java/com/microsoft/azure/AzureTests.java index 09aa93a901f99..1b354a519d89e 100644 --- a/azure/src/test/java/com/microsoft/azure/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/AzureTests.java @@ -28,7 +28,7 @@ public class AzureTests { private Azure azure, azure2; public static void main(String[] args) throws IOException, CloudException { - final File credFile = new File("azureauth.properties"); + final File credFile = new File("my.azureauth"); Azure azure = Azure.authenticate(credFile) .withDefaultSubscription(); System.out.println(String.valueOf(azure.resourceGroups().list().size())); @@ -49,7 +49,7 @@ public void setup() throws Exception { azure = azureAuthed.withSubscription(subscriptionId); // Authenticate based on file - this.azure2 = Azure.authenticate(new File("my.auth")) + this.azure2 = Azure.authenticate(new File("my.azureauth")) .withDefaultSubscription(); } @@ -66,6 +66,7 @@ public void setup() throws Exception { .withNewGroup() .withDynamicIp() .withLeafDomainLabel(newPipName) + .withIdleTimeoutInMinutes(10) .create(); // Verify list @@ -84,6 +85,7 @@ public void setup() throws Exception { .withStaticIp() .withLeafDomainLabel(newPipName + "xx") .withReverseFqdn(pip.leafDomainLabel() + "." + pip.region() + ".cloudapp.azure.com") + .withIdleTimeoutInMinutes(10) .apply(); printPublicIpAddress(pip); pip = azure2.publicIpAddresses().get(pip.id()); @@ -102,6 +104,8 @@ private void printPublicIpAddress(PublicIpAddress pip) { .append("\n\tResource group: ").append(pip.resourceGroupName()) .append("\n\tFQDN: ").append(pip.fqdn()) .append("\n\tReverse FQDN: ").append(pip.reverseFqdn()) + .append("\n\tIdle timeout (minutes): ").append(pip.idleTimeoutInMinutes()) + .append("\n\tIP allocation method: ").append(pip.ipAllocationMethod()) .toString()); } From 8f6efefa307e2900ff53db249c3197eec752833b Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 18 May 2016 18:22:47 -0700 Subject: [PATCH 04/30] Adding some javadocs and rename location to region --- .../compute/VirtualMachineImage.java | 55 ++++++++++++++++++- .../compute/VirtualMachineImages.java | 9 ++- .../compute/VirtualMachineSize.java | 3 + .../VirtualMachineImageOfferImpl.java | 6 +- .../VirtualMachineImagePublisherImpl.java | 4 +- .../VirtualMachineImageSkuImpl.java | 10 ++-- .../VirtualMachineImagesImpl.java | 6 +- .../implementation/api/UsagesInner.java | 12 ++-- .../VirtualMachineExtensionImagesInner.java | 28 +++++----- .../api/VirtualMachineImageResourceInner.java | 10 ++-- .../api/VirtualMachineImagesInner.java | 44 +++++++-------- .../api/VirtualMachineSizesInner.java | 16 +++--- 12 files changed, 131 insertions(+), 72 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java index dbc19fdf08795..02c6cf94dcffd 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java @@ -21,22 +21,71 @@ public interface VirtualMachineImage extends List dataDiskImages(); 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 listOffers() throws CloudException, IOException; } 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 listSkus() throws CloudException, IOException; } 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 listImages() throws CloudException, IOException; } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java index ef5bad04641e0..f73421189ce32 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java @@ -9,5 +9,12 @@ public interface VirtualMachineImages extends SupportsListingByLocation { - List 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 + * @throws IOException + */ + List listPublishers(final Region region) throws CloudException, IOException; } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java index 6a6a1392113f4..b386d44fbe8d9 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java @@ -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. diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageOfferImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageOfferImpl.java index c9fd49b090a4c..cf27184542b04 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageOfferImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageOfferImpl.java @@ -23,8 +23,8 @@ class VirtualMachineImageOfferImpl } @Override - public Region location() { - return publisher.location(); + public Region region() { + return publisher.region(); } @Override @@ -41,7 +41,7 @@ public String offer() { public List listSkus() throws CloudException, IOException { List 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; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagePublisherImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagePublisherImpl.java index 305673e5f61bc..e517dc3d46132 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagePublisherImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagePublisherImpl.java @@ -23,7 +23,7 @@ class VirtualMachineImagePublisherImpl } @Override - public Region location() { + public Region region() { return location; } @@ -36,7 +36,7 @@ public String publisher() { public List listOffers() throws CloudException, IOException { List 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; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageSkuImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageSkuImpl.java index 7f544cee5d582..0475d2769077f 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageSkuImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImageSkuImpl.java @@ -23,8 +23,8 @@ class VirtualMachineImageSkuImpl } @Override - public Region location() { - return offer.location(); + public Region region() { + return offer.region(); } @Override @@ -46,18 +46,18 @@ public List listImages() throws CloudException, IOException List 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; diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java index 0539682495ac3..9276259368e83 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImagesImpl.java @@ -20,11 +20,11 @@ class VirtualMachineImagesImpl } @Override - public List listPublishers(final Region location) throws CloudException, IOException { + public List listPublishers(final Region region) throws CloudException, IOException { List 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; } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java index 0ae48418cd7f4..e42eb287e3334 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java @@ -55,8 +55,8 @@ public UsagesInner(Retrofit retrofit, ComputeManagementClientImpl client) { */ interface UsagesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") - Call list(@Path("location") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/usages") + Call list(@Path("region") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") @GET @@ -67,7 +67,7 @@ interface UsagesService { /** * Lists compute usages for a subscription. * - * @param location The location upon which resource usage is queried. + * @param location The region upon which resource usage is queried. * @throws CloudException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -75,7 +75,7 @@ interface UsagesService { */ public ServiceResponse> list(final String location) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); @@ -97,7 +97,7 @@ public Page nextPage(String nextPageLink) throws CloudException, IOE /** * Lists compute usages for a subscription. * - * @param location The location upon which resource usage is queried. + * @param location The region upon which resource usage is queried. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object @@ -107,7 +107,7 @@ public ServiceCall listAsync(final String location, final ListOperationCallback< throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (this.client.subscriptionId() == null) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java index b37f7d1e4ff92..0c217485f8535 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java @@ -52,16 +52,16 @@ public VirtualMachineExtensionImagesInner(Retrofit retrofit, ComputeManagementCl */ interface VirtualMachineExtensionImagesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") - Call get(@Path("location") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") + Call get(@Path("region") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") - Call listTypes(@Path("location") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmextension/types") + Call listTypes(@Path("region") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") - Call listVersions(@Path("location") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") + Call listVersions(@Path("region") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); } @@ -79,7 +79,7 @@ interface VirtualMachineExtensionImagesService { */ public ServiceResponse get(String location, String publisherName, String type, String version) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -116,7 +116,7 @@ public ServiceCall getAsync(String location, String publisherName, String type, throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -173,7 +173,7 @@ private ServiceResponse getDelegate(Response< */ public ServiceResponse> listTypes(String location, String publisherName) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -202,7 +202,7 @@ public ServiceCall listTypesAsync(String location, String publisherName, final S throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -252,7 +252,7 @@ private ServiceResponse> listTypesDelega */ public ServiceResponse> listVersions(String location, String publisherName, String type) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -288,7 +288,7 @@ public ServiceCall listVersionsAsync(String location, String publisherName, Stri throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -341,7 +341,7 @@ public void onResponse(Call call, Response response) */ public ServiceResponse> listVersions(String location, String publisherName, String type, String filter, Integer top, String orderby) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -377,7 +377,7 @@ public ServiceCall listVersionsAsync(String location, String publisherName, Stri throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java index e06ded585227d..4038d7223ae08 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java @@ -21,7 +21,7 @@ public class VirtualMachineImageResourceInner extends SubResource { private String name; /** - * Gets or sets the location of the resource. + * Gets or sets the region of the resource. */ @JsonProperty(required = true) private String location; @@ -52,18 +52,18 @@ public VirtualMachineImageResourceInner setName(String name) { } /** - * Get the location value. + * Get the region value. * - * @return the location value + * @return the region value */ public String location() { return this.location; } /** - * Set the location value. + * Set the region value. * - * @param location the location value to set + * @param location the region value to set * @return the VirtualMachineImageResourceInner object itself. */ public VirtualMachineImageResourceInner setLocation(String location) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java index 88fb0ee06e4b6..827dc09dedeef 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java @@ -52,24 +52,24 @@ public VirtualMachineImagesInner(Retrofit retrofit, ComputeManagementClientImpl */ interface VirtualMachineImagesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") - Call get(@Path("location") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") + Call get(@Path("region") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") - Call list(@Path("location") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") + Call list(@Path("region") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") - Call listOffers(@Path("location") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers") + Call listOffers(@Path("region") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") - Call listPublishers(@Path("location") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers") + Call listPublishers(@Path("region") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") - Call listSkus(@Path("location") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") + Call listSkus(@Path("region") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); } @@ -88,7 +88,7 @@ interface VirtualMachineImagesService { */ public ServiceResponse get(String location, String publisherName, String offer, String skus, String version) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -129,7 +129,7 @@ public ServiceCall getAsync(String location, String publisherName, String offer, throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -192,7 +192,7 @@ private ServiceResponse getDelegate(Response> list(String location, String publisherName, String offer, String skus) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -232,7 +232,7 @@ public ServiceCall listAsync(String location, String publisherName, String offer throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -290,7 +290,7 @@ public void onResponse(Call call, Response response) */ public ServiceResponse> list(String location, String publisherName, String offer, String skus, String filter, Integer top, String orderby) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -330,7 +330,7 @@ public ServiceCall listAsync(String location, String publisherName, String offer throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -387,7 +387,7 @@ private ServiceResponse> listDelegate(Res */ public ServiceResponse> listOffers(String location, String publisherName) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -416,7 +416,7 @@ public ServiceCall listOffersAsync(String location, String publisherName, final throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { @@ -464,7 +464,7 @@ private ServiceResponse> listOffersDelega */ public ServiceResponse> listPublishers(String location) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); @@ -489,7 +489,7 @@ public ServiceCall listPublishersAsync(String location, final ServiceCallback
  • > listPublishersDe */ public ServiceResponse> listSkus(String location, String publisherName, String offer) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -568,7 +568,7 @@ public ServiceCall listSkusAsync(String location, String publisherName, String o throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); return null; } if (publisherName == null) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java index fe5f5a5e9528e..ab398419565b7 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java @@ -52,15 +52,15 @@ public VirtualMachineSizesInner(Retrofit retrofit, ComputeManagementClientImpl c */ interface VirtualMachineSizesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") - Call list(@Path("location") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/vmSizes") + Call list(@Path("region") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); } /** - * Lists all available virtual machine sizes for a subscription in a location. + * Lists all available virtual machine sizes for a subscription in a region. * - * @param location The location upon which virtual-machine-sizes is queried. + * @param location The region upon which virtual-machine-sizes is queried. * @throws CloudException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -68,7 +68,7 @@ interface VirtualMachineSizesService { */ public ServiceResponse> list(String location) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter location is required and cannot be null."); + throw new IllegalArgumentException("Parameter region is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); @@ -83,9 +83,9 @@ public ServiceResponse> list(String location) thro } /** - * Lists all available virtual machine sizes for a subscription in a location. + * Lists all available virtual machine sizes for a subscription in a region. * - * @param location The location upon which virtual-machine-sizes is queried. + * @param location The region upon which virtual-machine-sizes is queried. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object @@ -95,7 +95,7 @@ public ServiceCall listAsync(String location, final ServiceCallback Date: Wed, 18 May 2016 18:35:02 -0700 Subject: [PATCH 05/30] reverting some changes --- .../implementation/api/UsagesInner.java | 12 ++--- .../VirtualMachineExtensionImagesInner.java | 28 ++++++------ .../api/VirtualMachineImageResourceInner.java | 10 ++--- .../api/VirtualMachineImagesInner.java | 44 +++++++++---------- .../api/VirtualMachineSizesInner.java | 16 +++---- 5 files changed, 55 insertions(+), 55 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java index e42eb287e3334..0ae48418cd7f4 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/UsagesInner.java @@ -55,8 +55,8 @@ public UsagesInner(Retrofit retrofit, ComputeManagementClientImpl client) { */ interface UsagesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/usages") - Call list(@Path("region") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") + Call list(@Path("location") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") @GET @@ -67,7 +67,7 @@ interface UsagesService { /** * Lists compute usages for a subscription. * - * @param location The region upon which resource usage is queried. + * @param location The location upon which resource usage is queried. * @throws CloudException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -75,7 +75,7 @@ interface UsagesService { */ public ServiceResponse> list(final String location) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); @@ -97,7 +97,7 @@ public Page nextPage(String nextPageLink) throws CloudException, IOE /** * Lists compute usages for a subscription. * - * @param location The region upon which resource usage is queried. + * @param location The location upon which resource usage is queried. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object @@ -107,7 +107,7 @@ public ServiceCall listAsync(final String location, final ListOperationCallback< throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (this.client.subscriptionId() == null) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java index 0c217485f8535..b37f7d1e4ff92 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineExtensionImagesInner.java @@ -52,16 +52,16 @@ public VirtualMachineExtensionImagesInner(Retrofit retrofit, ComputeManagementCl */ interface VirtualMachineExtensionImagesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") - Call get(@Path("region") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") + Call get(@Path("location") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmextension/types") - Call listTypes(@Path("region") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") + Call listTypes(@Path("location") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") - Call listVersions(@Path("region") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") + Call listVersions(@Path("location") String location, @Path("publisherName") String publisherName, @Path("type") String type, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); } @@ -79,7 +79,7 @@ interface VirtualMachineExtensionImagesService { */ public ServiceResponse get(String location, String publisherName, String type, String version) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -116,7 +116,7 @@ public ServiceCall getAsync(String location, String publisherName, String type, throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -173,7 +173,7 @@ private ServiceResponse getDelegate(Response< */ public ServiceResponse> listTypes(String location, String publisherName) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -202,7 +202,7 @@ public ServiceCall listTypesAsync(String location, String publisherName, final S throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -252,7 +252,7 @@ private ServiceResponse> listTypesDelega */ public ServiceResponse> listVersions(String location, String publisherName, String type) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -288,7 +288,7 @@ public ServiceCall listVersionsAsync(String location, String publisherName, Stri throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -341,7 +341,7 @@ public void onResponse(Call call, Response response) */ public ServiceResponse> listVersions(String location, String publisherName, String type, String filter, Integer top, String orderby) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -377,7 +377,7 @@ public ServiceCall listVersionsAsync(String location, String publisherName, Stri throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java index 4038d7223ae08..e06ded585227d 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImageResourceInner.java @@ -21,7 +21,7 @@ public class VirtualMachineImageResourceInner extends SubResource { private String name; /** - * Gets or sets the region of the resource. + * Gets or sets the location of the resource. */ @JsonProperty(required = true) private String location; @@ -52,18 +52,18 @@ public VirtualMachineImageResourceInner setName(String name) { } /** - * Get the region value. + * Get the location value. * - * @return the region value + * @return the location value */ public String location() { return this.location; } /** - * Set the region value. + * Set the location value. * - * @param location the region value to set + * @param location the location value to set * @return the VirtualMachineImageResourceInner object itself. */ public VirtualMachineImageResourceInner setLocation(String location) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java index 827dc09dedeef..88fb0ee06e4b6 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineImagesInner.java @@ -52,24 +52,24 @@ public VirtualMachineImagesInner(Retrofit retrofit, ComputeManagementClientImpl */ interface VirtualMachineImagesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") - Call get(@Path("region") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") + Call get(@Path("location") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("version") String version, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") - Call list(@Path("region") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") + Call list(@Path("location") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("skus") String skus, @Path("subscriptionId") String subscriptionId, @Query("$filter") String filter, @Query("$top") Integer top, @Query("$orderby") String orderby, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers") - Call listOffers(@Path("region") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") + Call listOffers(@Path("location") String location, @Path("publisherName") String publisherName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers") - Call listPublishers(@Path("region") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") + Call listPublishers(@Path("location") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") - Call listSkus(@Path("region") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") + Call listSkus(@Path("location") String location, @Path("publisherName") String publisherName, @Path("offer") String offer, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); } @@ -88,7 +88,7 @@ interface VirtualMachineImagesService { */ public ServiceResponse get(String location, String publisherName, String offer, String skus, String version) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -129,7 +129,7 @@ public ServiceCall getAsync(String location, String publisherName, String offer, throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -192,7 +192,7 @@ private ServiceResponse getDelegate(Response> list(String location, String publisherName, String offer, String skus) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -232,7 +232,7 @@ public ServiceCall listAsync(String location, String publisherName, String offer throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -290,7 +290,7 @@ public void onResponse(Call call, Response response) */ public ServiceResponse> list(String location, String publisherName, String offer, String skus, String filter, Integer top, String orderby) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -330,7 +330,7 @@ public ServiceCall listAsync(String location, String publisherName, String offer throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -387,7 +387,7 @@ private ServiceResponse> listDelegate(Res */ public ServiceResponse> listOffers(String location, String publisherName) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -416,7 +416,7 @@ public ServiceCall listOffersAsync(String location, String publisherName, final throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { @@ -464,7 +464,7 @@ private ServiceResponse> listOffersDelega */ public ServiceResponse> listPublishers(String location) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); @@ -489,7 +489,7 @@ public ServiceCall listPublishersAsync(String location, final ServiceCallback
  • > listPublishersDe */ public ServiceResponse> listSkus(String location, String publisherName, String offer) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (publisherName == null) { throw new IllegalArgumentException("Parameter publisherName is required and cannot be null."); @@ -568,7 +568,7 @@ public ServiceCall listSkusAsync(String location, String publisherName, String o throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (location == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter region is required and cannot be null.")); + serviceCallback.failure(new IllegalArgumentException("Parameter location is required and cannot be null.")); return null; } if (publisherName == null) { diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java index ab398419565b7..fe5f5a5e9528e 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/api/VirtualMachineSizesInner.java @@ -52,15 +52,15 @@ public VirtualMachineSizesInner(Retrofit retrofit, ComputeManagementClientImpl c */ interface VirtualMachineSizesService { @Headers("Content-Type: application/json; charset=utf-8") - @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{region}/vmSizes") - Call list(@Path("region") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") + Call list(@Path("location") String location, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage); } /** - * Lists all available virtual machine sizes for a subscription in a region. + * Lists all available virtual machine sizes for a subscription in a location. * - * @param location The region upon which virtual-machine-sizes is queried. + * @param location The location upon which virtual-machine-sizes is queried. * @throws CloudException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -68,7 +68,7 @@ interface VirtualMachineSizesService { */ public ServiceResponse> list(String location) throws CloudException, IOException, IllegalArgumentException { if (location == null) { - throw new IllegalArgumentException("Parameter region is required and cannot be null."); + throw new IllegalArgumentException("Parameter location is required and cannot be null."); } if (this.client.subscriptionId() == null) { throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); @@ -83,9 +83,9 @@ public ServiceResponse> list(String location) thro } /** - * Lists all available virtual machine sizes for a subscription in a region. + * Lists all available virtual machine sizes for a subscription in a location. * - * @param location The region upon which virtual-machine-sizes is queried. + * @param location The location upon which virtual-machine-sizes is queried. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object @@ -95,7 +95,7 @@ public ServiceCall listAsync(String location, final ServiceCallback Date: Thu, 19 May 2016 09:11:19 -0700 Subject: [PATCH 06/30] minor test correction --- azure/src/test/java/com/microsoft/azure/AzureTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure/src/test/java/com/microsoft/azure/AzureTests.java b/azure/src/test/java/com/microsoft/azure/AzureTests.java index 1b354a519d89e..2f022e4f50fcf 100644 --- a/azure/src/test/java/com/microsoft/azure/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/AzureTests.java @@ -85,7 +85,7 @@ public void setup() throws Exception { .withStaticIp() .withLeafDomainLabel(newPipName + "xx") .withReverseFqdn(pip.leafDomainLabel() + "." + pip.region() + ".cloudapp.azure.com") - .withIdleTimeoutInMinutes(10) + .withIdleTimeoutInMinutes(15) .apply(); printPublicIpAddress(pip); pip = azure2.publicIpAddresses().get(pip.id()); @@ -93,7 +93,6 @@ public void setup() throws Exception { // Verify delete azure2.publicIpAddresses().delete(pip.id()); - azure2.resourceGroups().delete(resourceGroupName); azure2.resourceGroups().delete(pip.resourceGroupName()); } From 0cf43cf5240edacb04e85b685cf47700a17f4448 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2016 11:54:35 -0700 Subject: [PATCH 07/30] PublicIPAddress and related javadocs --- .../management/network/PublicIpAddress.java | 147 ++++++++++++++---- .../management/network/PublicIpAddresses.java | 9 +- .../collection/SupportsDeletingByGroup.java | 11 +- .../collection/SupportsGettingByGroup.java | 14 +- .../collection/SupportsListingByGroup.java | 13 +- .../collection/SupportsCreating.java | 23 ++- .../collection/SupportsDeleting.java | 11 +- .../collection/SupportsGetting.java | 16 +- .../collection/SupportsListing.java | 13 +- .../collection/SupportsListingByLocation.java | 15 +- .../collection/SupportsUpdating.java | 25 ++- 11 files changed, 247 insertions(+), 50 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index 5ca774bc16211..9b400df4c196f 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -22,16 +22,44 @@ public interface PublicIpAddress extends /*********************************************************** * Getters ***********************************************************/ + + /** + * @return the assigned IP address + */ public String ipAddress(); + + /** + * @return the assigned leaf domain label + */ public String leafDomainLabel(); + + /** + * @return the assigned FQDN (fully qualified domain name) + */ public String fqdn(); + + /** + * @return the assigned reverse FQDN, if any + */ public String reverseFqdn(); + + /** + * @return the IP address allocation method (Static/Dynamic) + */ public String ipAllocationMethod(); + + /** + * @return the idle connection timeout setting (in minutes) + */ public int idleTimeoutInMinutes(); /************************************************************** * Fluent interfaces for provisioning **************************************************************/ + + /** + * Container interface for all the definitions + */ interface Definitions extends DefinitionBlank, DefinitionWithGroup, @@ -39,40 +67,61 @@ interface Definitions extends DefinitionWithLeafDomainLabel, DefinitionCreatable {} - - interface DefinitionBlank extends GroupableResource.DefinitionWithRegion { + /** + * The first stage of the public IP address definition + */ + interface DefinitionBlank + extends GroupableResource.DefinitionWithRegion { } - interface DefinitionWithGroup extends GroupableResource.DefinitionWithGroup { + /** + * The stage of the public IP address definition allowing to specify the resource group + */ + interface DefinitionWithGroup + extends GroupableResource.DefinitionWithGroup { } + /** + * A public IP address definition allowing to set the IP allocation method (static or dynamic) + */ public interface DefinitionWithIpAddress { /** - * Enables static IP address allocation. The actual IP address allocated for this resource by Azure can be obtained - * after the provisioning process is complete from ipAddress(). - * @return The next stage of the public IP address definition + * Enables static IP address allocation. + *

    + * Use {@link PublicIpAddress#ipAddress()} after the public IP address is created to obtain the + * actual IP address allocated for this resource by Azure + * + * @return the next stage of the public IP address definition */ DefinitionCreatable withStaticIp(); /** * Enables dynamic IP address allocation. - * @return The next stage of the public IP address definition + * + * @return the next stage of the public IP address definition */ DefinitionCreatable withDynamicIp(); } + /** + * A public IP address update allowing to change the IP allocation method (static or dynamic) + */ public interface UpdatableWithIpAddress { /** - * Enables static IP address allocation. The actual IP address allocated for this resource by Azure can be obtained - * after the provisioning process is complete from ipAddress(). - * @return The next stage of the public IP address definition + * Enables static IP address allocation. + *

    + * Use {@link PublicIpAddress#ipAddress()} after the public IP address is updated to + * obtain the actual IP address allocated for this resource by Azure + * + * @return the next stage of the public IP address definition */ T withStaticIp(); /** * Enables dynamic IP address allocation. - * @return The next stage of the public IP address definition + * + * @return the next stage of the public IP address definition */ T withDynamicIp(); } @@ -83,58 +132,77 @@ public interface UpdatableWithIpAddress { */ public interface DefinitionWithLeafDomainLabel { /** - * Specifies the leaf domain label to associate with this public IP address. The fully qualified domain name (FQDN) + * Specifies the leaf domain label to associate with this public IP address. + *

    + * The fully qualified domain name (FQDN) * will be constructed automatically by appending the rest of the domain to this label. - * @param dnsName The leaf domain label to use. This must follow the required naming convention for leaf domain names. - * @return The next stage of the public IP address definition + * @param dnsName the leaf domain label to use. This must follow the required naming convention for leaf domain names. + * @return the next stage of the public IP address definition */ DefinitionCreatable withLeafDomainLabel(String dnsName); /** - * Ensures that no leaf domain label will be used. This means that this public IP address will not be associated with a domain name. - * @return The next stage of the public IP address definition + * Ensures that no leaf domain label will be used. + *

    + * This means that this public IP address will not be associated with a domain name. + * @return the next stage of the public IP address definition */ DefinitionCreatable withoutLeafDomainLabel(); } + /** + * A public IP address update allowing to change the leaf domain label, if any + */ public interface UpdatableWithLeafDomainLabel { /** - * Specifies the leaf domain label to associate with this public IP address. The fully qualified domain name (FQDN) + * Specifies the leaf domain label to associate with this public IP address. + *

    + * The fully qualified domain name (FQDN) * will be constructed automatically by appending the rest of the domain to this label. - * @param dnsName The leaf domain label to use. This must follow the required naming convention for leaf domain names. - * @return The next stage of the public IP address definition + * @param dnsName the leaf domain label to use. This must follow the required naming convention for leaf domain names. + * @return the next stage of the public IP address definition */ T withLeafDomainLabel(String dnsName); /** - * Ensures that no leaf domain label will be used. This means that this public IP address will not be associated with a domain name. - * @return The next stage of the resource definition + * Ensures that no leaf domain label will be used. + *

    + * This means that this public IP address will not be associated with a domain name. + * @return the next stage of the resource definition */ T withoutLeafDomainLabel(); } - + + /** + * A public IP address definition allowing the reverse FQDN to be specified + */ public interface DefinitionWithReverseFQDN { /** - * Specifies the reverse FQDN to assign to this public IP address - * @param reverseFQDN The reverse FQDN to assign - * @return The next stage of the resource definition + * Specifies the reverse FQDN to assign to this public IP address. + *

    + * + * @param reverseFQDN the reverse FQDN to assign + * @return the next stage of the resource definition */ T withReverseFqdn(String reverseFQDN); /** * Ensures that no reverse FQDN will be used. - * @return The next stage of the resource definition + * @return the next stage of the resource definition */ T withoutReverseFqdn(); } + /** + * A public IP address update allowing the reverse FQDN to be specified + */ public interface UpdatableWithReverseFQDN { /** * Specifies the reverse FQDN to assign to this public IP address - * @param reverseFQDN The reverse FQDN to assign - * @return The next stage of the resource definition + * @param reverseFQDN the reverse FQDN to assign + * @return the next stage of the resource definition */ T withReverseFqdn(String reverseFQDN); @@ -145,20 +213,39 @@ public interface UpdatableWithReverseFQDN { T withoutReverseFqdn(); } - + /** + * The stage of the public IP definition which contains all the minimum required inputs for + * the resource to be created (via {@link DefinitionCreatable#create()}), but also allows + * for the remaining optional settings to be specified. + */ interface DefinitionCreatable extends Creatable, DefinitionWithLeafDomainLabel, DefinitionWithIpAddress, DefinitionWithReverseFQDN { + /** + /** + * Specifies the timeout (in minutes) for an idle connection + * @param minutes the length of the time out in minutes + * @return the next stage of the resource definition + */ DefinitionCreatable withIdleTimeoutInMinutes(int minutes); } - + + /** + * The template for a public IP address update operation, containing all the settings that + * can be updated. + */ interface Update extends Appliable, UpdatableWithIpAddress, UpdatableWithLeafDomainLabel, UpdatableWithReverseFQDN { + /** + * Specifies the timeout (in minutes) for an idle connection + * @param minutes the length of the time out in minutes + * @return the next stage of the resource definition + */ Update withIdleTimeoutInMinutes(int minutes); } } diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java index 89286f9bae5c5..62654a3f19adb 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java @@ -13,6 +13,10 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsGetting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + +/** + * Entry point to public IP address management + */ public interface PublicIpAddresses extends SupportsCreating, SupportsListing, @@ -22,7 +26,10 @@ public interface PublicIpAddresses extends SupportsDeleting, SupportsDeletingByGroup { - interface InGroup extends + /** + * Entry point to public IP address management within a specific resource group + */ + public interface InGroup extends SupportsListing, SupportsCreating, SupportsDeleting { diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java index 1b84b9e113670..b5c3d57dc3a69 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsDeletingByGroup.java @@ -19,11 +19,16 @@ */ package com.microsoft.azure.management.resources.fluentcore.arm.collection; +/** + * Provides access to deleting a resource from Azure, identifying it by its name and its resource group + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsDeletingByGroup { /** - * Deletes a resource from a specific group - * @param groupName The group the resource is part of - * @param name The name of the resource within that group + * Deletes a resource from Azure, identifying it by its name and its resource group + * @param groupName the group the resource is part of + * @param name The name of the resource * @throws Exception */ void delete(String groupName, String name) throws Exception; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java index 6b92f205244b1..1369776eae4e3 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsGettingByGroup.java @@ -24,7 +24,19 @@ import java.io.IOException; -// Requires class to support reading entities with a supplied group name +/** + * Provides access to getting a specific Azure resource based on its name and resource group + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsGettingByGroup { + /** + * Gets the information about a resource from Azure based on the resource name and the name of its resource group + * @param groupName the name of the resource group the resource is in + * @param name the name of the resource. (Note, this is not the ID) + * @return an immutable representation of the resource + * @throws CloudException + * @throws IOException + */ T get(String groupName, String name) throws CloudException, IOException; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java index 6acda3c4d0eeb..640c9128ac623 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/collection/SupportsListingByGroup.java @@ -24,13 +24,16 @@ import com.microsoft.azure.PagedList; import java.io.IOException; -import java.util.List; +/** + * Provides access to listing Azure resources of a specific type in a specific resource group + *

    + * (Note: this interface is not intended to be implemented by user code) +*/ public interface SupportsListingByGroup { - /** - * List of the entities in a specific group - * @param groupName - * @return + /** Lists resources of the specified type in the specified resource group + * @param groupName the name of the resource group to list the resources from + * @return list of resources * @throws Exception */ PagedList list(String groupName) throws CloudException, IOException; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsCreating.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsCreating.java index fa697806c85d0..f05113b376259 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsCreating.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsCreating.java @@ -19,8 +19,29 @@ */ package com.microsoft.azure.management.resources.fluentcore.collection; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; -// Requires class to support creating entities +/** + * Providing access to creating Azure top level resources + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsCreating { + /** + * Begins a definition for a new resource. + *

    + * This is the beginning of the builder pattern used to create top level resources + * in Azure. The final method completing the definition and starting the actual resource creation + * process in Azure is {@link Creatable#create()}. + *

    + * Note that the {@link Creatable#create()} method is + * only available at the stage of the resource definition that has the minimum set of input + * parameters specified. If you do not see {@link Creatable#create()} among the available methods, it + * means you have not yet specified all the required input settings. Input settings generally begin + * with the word "with", for example: .withNewResourceGroup() and return the next stage + * of the resource definition, as an interface in the "fluent interface" style. + * @param name the name of the new resource + * @return the first stage of the new resource definition + */ T define(String name); } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java index ac71e974ba58f..27cc07a16a2b9 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsDeleting.java @@ -19,7 +19,16 @@ */ package com.microsoft.azure.management.resources.fluentcore.collection; -// Requires class to support deleting entities +/** + * Provides access to deleting a resource from Azure, identifying it by its resource ID + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsDeleting { + /** + * Deletes a resource from Azure, identifying it by its resource ID + * @param id the resource ID of the resource to delete + * @throws Exception + */ void delete(String id) throws Exception; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsGetting.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsGetting.java index cd3093618da95..5ef65f6f5d327 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsGetting.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsGetting.java @@ -23,7 +23,19 @@ import java.io.IOException; -// Requires class to support reading entities +/** + * Provides access to getting a specific Azure resource based on its ID + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsGetting { - T get(String name) throws CloudException, IOException; + /** + * Gets the information about a resource from Azure based on the resource ID + *

    + * @param id the full ID of the resource + * @return an immutable representation of the resource + * @throws CloudException + * @throws IOException + */ + T get(String id) throws CloudException, IOException; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java index 275cfa5abef1e..285f30fa84fae 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListing.java @@ -23,9 +23,18 @@ import com.microsoft.azure.PagedList; import java.io.IOException; -import java.util.List; -// Requires class to support listing entities +/** + * Provides access to listing Azure resources of a specific type in a subscription + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsListing { + /** + * Lists all the resources of the specified type in the currently selected subscription + * @return list of resources + * @throws CloudException + * @throws IOException + */ PagedList list() throws CloudException, IOException; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByLocation.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByLocation.java index c2dbe5263335c..abeaec6860300 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByLocation.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsListingByLocation.java @@ -25,7 +25,18 @@ import java.io.IOException; import java.util.List; -// Requires class to support listing entities +/** + * Provides access to listing Azure resources of a specific type based on their region (location) + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsListingByLocation { - List list(Region location) throws CloudException, IOException; + /** + * Lists all the resources of the specified type in the specified region + * @param region the Azure region to list the resources from + * @return list of resources + * @throws CloudException + * @throws IOException + */ + List list(Region region) throws CloudException, IOException; } diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsUpdating.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsUpdating.java index 503d808e69bd3..f496b24ad2cd9 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsUpdating.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/collection/SupportsUpdating.java @@ -20,7 +20,28 @@ package com.microsoft.azure.management.resources.fluentcore.collection; -// Requires class to support updating entities +/** + * Provides access to updating a specific Azure resource, based on its resource ID + *

    + * (Note: this interface is not intended to be implemented by user code) + */ public interface SupportsUpdating { - T update(String name); + + /** + * Begins an update definition for an existing resource. + *

    + * This is the beginning of the builder pattern used to modify top level resources + * in Azure. The final method completing the update definition and starting the actual resource update + * process in Azure is {@link Appliable#apply()}. + *

    + * Note that the {@link Appliable#apply()} method is available at any stage of the update definition + * because all the updatable settings are generally optional. + *

    Settings typically begin + * with the word "with", for example: .withRegion() and return the update definition itself, to enable chaining + * in the fluent interface style. + * @param id the resource id of the resource to update. Remember to call {@see Appliable#apply()} for the changes + * to go into effect on Azure. + * @return the update definition itself + */ + T update(String id); } From 05cffdc0be0395cef5f7a7081679ffd4a5e51518 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2016 13:57:15 -0700 Subject: [PATCH 08/30] addressing spacing feedback --- .../management/network/PublicIpAddress.java | 332 +++++++++--------- .../management/network/PublicIpAddresses.java | 6 +- 2 files changed, 167 insertions(+), 171 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index 9b400df4c196f..bb2b0ac879a17 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -22,32 +22,32 @@ public interface PublicIpAddress extends /*********************************************************** * Getters ***********************************************************/ - + /** * @return the assigned IP address */ public String ipAddress(); - + /** * @return the assigned leaf domain label */ public String leafDomainLabel(); - + /** * @return the assigned FQDN (fully qualified domain name) */ public String fqdn(); - + /** * @return the assigned reverse FQDN, if any */ public String reverseFqdn(); - + /** * @return the IP address allocation method (Static/Dynamic) */ public String ipAllocationMethod(); - + /** * @return the idle connection timeout setting (in minutes) */ @@ -56,180 +56,177 @@ public interface PublicIpAddress extends /************************************************************** * Fluent interfaces for provisioning **************************************************************/ - + /** * Container interface for all the definitions */ interface Definitions extends - DefinitionBlank, - DefinitionWithGroup, - DefinitionWithIpAddress, - DefinitionWithLeafDomainLabel, - DefinitionCreatable {} - + DefinitionBlank, + DefinitionWithGroup, + DefinitionWithIpAddress, + DefinitionWithLeafDomainLabel, + DefinitionCreatable {} + /** * The first stage of the public IP address definition */ - interface DefinitionBlank - extends GroupableResource.DefinitionWithRegion { - } + interface DefinitionBlank + extends GroupableResource.DefinitionWithRegion { + } /** * The stage of the public IP address definition allowing to specify the resource group */ interface DefinitionWithGroup - extends GroupableResource.DefinitionWithGroup { + extends GroupableResource.DefinitionWithGroup { } /** * A public IP address definition allowing to set the IP allocation method (static or dynamic) */ - public interface DefinitionWithIpAddress { - /** - * Enables static IP address allocation. - *

    - * Use {@link PublicIpAddress#ipAddress()} after the public IP address is created to obtain the - * actual IP address allocated for this resource by Azure - * - * @return the next stage of the public IP address definition - */ - DefinitionCreatable withStaticIp(); - - /** - * Enables dynamic IP address allocation. - * - * @return the next stage of the public IP address definition - */ - DefinitionCreatable withDynamicIp(); - } - - + public interface DefinitionWithIpAddress { + /** + * Enables static IP address allocation. + *

    + * Use {@link PublicIpAddress#ipAddress()} after the public IP address is created to obtain the + * actual IP address allocated for this resource by Azure + * + * @return the next stage of the public IP address definition + */ + DefinitionCreatable withStaticIp(); + + /** + * Enables dynamic IP address allocation. + * + * @return the next stage of the public IP address definition + */ + DefinitionCreatable withDynamicIp(); + } + + /** * A public IP address update allowing to change the IP allocation method (static or dynamic) */ - public interface UpdatableWithIpAddress { - /** - * Enables static IP address allocation. - *

    - * Use {@link PublicIpAddress#ipAddress()} after the public IP address is updated to - * obtain the actual IP address allocated for this resource by Azure - * - * @return the next stage of the public IP address definition - */ - T withStaticIp(); - - /** - * Enables dynamic IP address allocation. - * - * @return the next stage of the public IP address definition - */ - T withDynamicIp(); - } + public interface UpdatableWithIpAddress { + /** + * Enables static IP address allocation. + *

    + * Use {@link PublicIpAddress#ipAddress()} after the public IP address is updated to + * obtain the actual IP address allocated for this resource by Azure + * + * @return the next stage of the public IP address definition + */ + T withStaticIp(); - - /** - * A public IP address definition allowing to specify the leaf domain label, if any - */ - public interface DefinitionWithLeafDomainLabel { - /** - * Specifies the leaf domain label to associate with this public IP address. - *

    - * The fully qualified domain name (FQDN) - * will be constructed automatically by appending the rest of the domain to this label. - * @param dnsName the leaf domain label to use. This must follow the required naming convention for leaf domain names. - * @return the next stage of the public IP address definition - */ - DefinitionCreatable withLeafDomainLabel(String dnsName); - - /** - * Ensures that no leaf domain label will be used. - *

    - * This means that this public IP address will not be associated with a domain name. - * @return the next stage of the public IP address definition - */ - DefinitionCreatable withoutLeafDomainLabel(); - } - - - /** - * A public IP address update allowing to change the leaf domain label, if any - */ - public interface UpdatableWithLeafDomainLabel { - /** - * Specifies the leaf domain label to associate with this public IP address. - *

    - * The fully qualified domain name (FQDN) - * will be constructed automatically by appending the rest of the domain to this label. - * @param dnsName the leaf domain label to use. This must follow the required naming convention for leaf domain names. - * @return the next stage of the public IP address definition - */ - T withLeafDomainLabel(String dnsName); - - /** - * Ensures that no leaf domain label will be used. - *

    - * This means that this public IP address will not be associated with a domain name. - * @return the next stage of the resource definition - */ - T withoutLeafDomainLabel(); - } - + /** + * Enables dynamic IP address allocation. + * + * @return the next stage of the public IP address definition + */ + T withDynamicIp(); + } - /** - * A public IP address definition allowing the reverse FQDN to be specified - */ - public interface DefinitionWithReverseFQDN { - /** - * Specifies the reverse FQDN to assign to this public IP address. - *

    - * - * @param reverseFQDN the reverse FQDN to assign - * @return the next stage of the resource definition - */ - T withReverseFqdn(String reverseFQDN); - - /** - * Ensures that no reverse FQDN will be used. - * @return the next stage of the resource definition - */ - T withoutReverseFqdn(); - } - - /** - * A public IP address update allowing the reverse FQDN to be specified - */ - public interface UpdatableWithReverseFQDN { - /** - * Specifies the reverse FQDN to assign to this public IP address - * @param reverseFQDN the reverse FQDN to assign - * @return the next stage of the resource definition - */ - T withReverseFqdn(String reverseFQDN); - - /** - * Ensures that no reverse FQDN will be used. - * @return The next stage of the resource definition - */ - T withoutReverseFqdn(); - } - - /** - * The stage of the public IP definition which contains all the minimum required inputs for - * the resource to be created (via {@link DefinitionCreatable#create()}), but also allows - * for the remaining optional settings to be specified. - */ + /** + * A public IP address definition allowing to specify the leaf domain label, if any + */ + public interface DefinitionWithLeafDomainLabel { + /** + * Specifies the leaf domain label to associate with this public IP address. + *

    + * The fully qualified domain name (FQDN) + * will be constructed automatically by appending the rest of the domain to this label. + * @param dnsName the leaf domain label to use. This must follow the required naming convention for leaf domain names. + * @return the next stage of the public IP address definition + */ + DefinitionCreatable withLeafDomainLabel(String dnsName); + + /** + * Ensures that no leaf domain label will be used. + *

    + * This means that this public IP address will not be associated with a domain name. + * @return the next stage of the public IP address definition + */ + DefinitionCreatable withoutLeafDomainLabel(); + } + + + /** + * A public IP address update allowing to change the leaf domain label, if any + */ + public interface UpdatableWithLeafDomainLabel { + /** + * Specifies the leaf domain label to associate with this public IP address. + *

    + * The fully qualified domain name (FQDN) + * will be constructed automatically by appending the rest of the domain to this label. + * @param dnsName the leaf domain label to use. This must follow the required naming convention for leaf domain names. + * @return the next stage of the public IP address definition + */ + T withLeafDomainLabel(String dnsName); + + /** + * Ensures that no leaf domain label will be used. + *

    + * This means that this public IP address will not be associated with a domain name. + * @return the next stage of the resource definition + */ + T withoutLeafDomainLabel(); + } + + /** + * A public IP address definition allowing the reverse FQDN to be specified + */ + public interface DefinitionWithReverseFQDN { + /** + * Specifies the reverse FQDN to assign to this public IP address. + *

    + * + * @param reverseFQDN the reverse FQDN to assign + * @return the next stage of the resource definition + */ + T withReverseFqdn(String reverseFQDN); + + /** + * Ensures that no reverse FQDN will be used. + * @return the next stage of the resource definition + */ + T withoutReverseFqdn(); + } + + /** + * A public IP address update allowing the reverse FQDN to be specified + */ + public interface UpdatableWithReverseFQDN { + /** + * Specifies the reverse FQDN to assign to this public IP address + * @param reverseFQDN the reverse FQDN to assign + * @return the next stage of the resource definition + */ + T withReverseFqdn(String reverseFQDN); + + /** + * Ensures that no reverse FQDN will be used. + * @return The next stage of the resource definition + */ + T withoutReverseFqdn(); + } + + /** + * The stage of the public IP definition which contains all the minimum required inputs for + * the resource to be created (via {@link DefinitionCreatable#create()}), but also allows + * for the remaining optional settings to be specified. + */ interface DefinitionCreatable extends - Creatable, - DefinitionWithLeafDomainLabel, - DefinitionWithIpAddress, - DefinitionWithReverseFQDN { - /** - /** - * Specifies the timeout (in minutes) for an idle connection - * @param minutes the length of the time out in minutes - * @return the next stage of the resource definition - */ - DefinitionCreatable withIdleTimeoutInMinutes(int minutes); + Creatable, + DefinitionWithLeafDomainLabel, + DefinitionWithIpAddress, + DefinitionWithReverseFQDN { + /** + * Specifies the timeout (in minutes) for an idle connection + * @param minutes the length of the time out in minutes + * @return the next stage of the resource definition + */ + DefinitionCreatable withIdleTimeoutInMinutes(int minutes); } /** @@ -237,16 +234,15 @@ interface DefinitionCreatable extends * can be updated. */ interface Update extends - Appliable, - UpdatableWithIpAddress, - UpdatableWithLeafDomainLabel, - UpdatableWithReverseFQDN { - /** - * Specifies the timeout (in minutes) for an idle connection - * @param minutes the length of the time out in minutes - * @return the next stage of the resource definition - */ - Update withIdleTimeoutInMinutes(int minutes); + Appliable, + UpdatableWithIpAddress, + UpdatableWithLeafDomainLabel, + UpdatableWithReverseFQDN { + /** + * Specifies the timeout (in minutes) for an idle connection + * @param minutes the length of the time out in minutes + * @return the next stage of the resource definition + */ + Update withIdleTimeoutInMinutes(int minutes); } } - diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java index 62654a3f19adb..ef1a7ff056d73 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddresses.java @@ -26,9 +26,9 @@ public interface PublicIpAddresses extends SupportsDeleting, SupportsDeletingByGroup { - /** - * Entry point to public IP address management within a specific resource group - */ + /** + * Entry point to public IP address management within a specific resource group + */ public interface InGroup extends SupportsListing, SupportsCreating, From b5541db4d935f77c75b2f8873b5c58e017000441 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2016 14:12:36 -0700 Subject: [PATCH 09/30] cleaning up redundant public keywords --- .../management/network/PublicIpAddress.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index bb2b0ac879a17..945912ff68cea 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -26,32 +26,32 @@ public interface PublicIpAddress extends /** * @return the assigned IP address */ - public String ipAddress(); + String ipAddress(); /** * @return the assigned leaf domain label */ - public String leafDomainLabel(); + String leafDomainLabel(); /** * @return the assigned FQDN (fully qualified domain name) */ - public String fqdn(); + String fqdn(); /** * @return the assigned reverse FQDN, if any */ - public String reverseFqdn(); + String reverseFqdn(); /** * @return the IP address allocation method (Static/Dynamic) */ - public String ipAllocationMethod(); + String ipAllocationMethod(); /** * @return the idle connection timeout setting (in minutes) */ - public int idleTimeoutInMinutes(); + int idleTimeoutInMinutes(); /************************************************************** * Fluent interfaces for provisioning @@ -84,7 +84,7 @@ interface DefinitionWithGroup /** * A public IP address definition allowing to set the IP allocation method (static or dynamic) */ - public interface DefinitionWithIpAddress { + interface DefinitionWithIpAddress { /** * Enables static IP address allocation. *

    @@ -107,7 +107,7 @@ public interface DefinitionWithIpAddress { /** * A public IP address update allowing to change the IP allocation method (static or dynamic) */ - public interface UpdatableWithIpAddress { + interface UpdatableWithIpAddress { /** * Enables static IP address allocation. *

    @@ -129,7 +129,7 @@ public interface UpdatableWithIpAddress { /** * A public IP address definition allowing to specify the leaf domain label, if any */ - public interface DefinitionWithLeafDomainLabel { + interface DefinitionWithLeafDomainLabel { /** * Specifies the leaf domain label to associate with this public IP address. *

    @@ -153,7 +153,7 @@ public interface DefinitionWithLeafDomainLabel { /** * A public IP address update allowing to change the leaf domain label, if any */ - public interface UpdatableWithLeafDomainLabel { + interface UpdatableWithLeafDomainLabel { /** * Specifies the leaf domain label to associate with this public IP address. *

    @@ -176,7 +176,7 @@ public interface UpdatableWithLeafDomainLabel { /** * A public IP address definition allowing the reverse FQDN to be specified */ - public interface DefinitionWithReverseFQDN { + interface DefinitionWithReverseFQDN { /** * Specifies the reverse FQDN to assign to this public IP address. *

    @@ -196,7 +196,7 @@ public interface DefinitionWithReverseFQDN { /** * A public IP address update allowing the reverse FQDN to be specified */ - public interface UpdatableWithReverseFQDN { + interface UpdatableWithReverseFQDN { /** * Specifies the reverse FQDN to assign to this public IP address * @param reverseFQDN the reverse FQDN to assign From ea7a47747f51172bfa2308ed4333be2f8e759ab6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2016 15:04:23 -0700 Subject: [PATCH 10/30] refining the consistency in Update/Updatable naming. Updatable means it has .update(); Update* (think of it as noun) means it has the .with setters. Appliable means it has .apply() --- .../azure/management/network/PublicIpAddress.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java index 945912ff68cea..2891f1e272d44 100644 --- a/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java +++ b/azure-mgmt-network/src/main/java/com/microsoft/azure/management/network/PublicIpAddress.java @@ -107,7 +107,7 @@ interface DefinitionWithIpAddress { /** * A public IP address update allowing to change the IP allocation method (static or dynamic) */ - interface UpdatableWithIpAddress { + interface UpdateWithIpAddress { /** * Enables static IP address allocation. *

    @@ -153,7 +153,7 @@ interface DefinitionWithLeafDomainLabel { /** * A public IP address update allowing to change the leaf domain label, if any */ - interface UpdatableWithLeafDomainLabel { + interface UpdateWithLeafDomainLabel { /** * Specifies the leaf domain label to associate with this public IP address. *

    @@ -173,6 +173,7 @@ interface UpdatableWithLeafDomainLabel { T withoutLeafDomainLabel(); } + /** * A public IP address definition allowing the reverse FQDN to be specified */ @@ -196,7 +197,7 @@ interface DefinitionWithReverseFQDN { /** * A public IP address update allowing the reverse FQDN to be specified */ - interface UpdatableWithReverseFQDN { + interface UpdateWithReverseFQDN { /** * Specifies the reverse FQDN to assign to this public IP address * @param reverseFQDN the reverse FQDN to assign @@ -235,9 +236,9 @@ interface DefinitionCreatable extends */ interface Update extends Appliable, - UpdatableWithIpAddress, - UpdatableWithLeafDomainLabel, - UpdatableWithReverseFQDN { + UpdateWithIpAddress, + UpdateWithLeafDomainLabel, + UpdateWithReverseFQDN { /** * Specifies the timeout (in minutes) for an idle connection * @param minutes the length of the time out in minutes From f357496531830cc9502182ce5ec8de409b57289f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2016 15:27:59 -0700 Subject: [PATCH 11/30] refining the PublicIPAddress test --- .../java/com/microsoft/azure/AzureTests.java | 122 +++++++++--------- 1 file changed, 62 insertions(+), 60 deletions(-) diff --git a/azure/src/test/java/com/microsoft/azure/AzureTests.java b/azure/src/test/java/com/microsoft/azure/AzureTests.java index 2f022e4f50fcf..6e38f40b1ec87 100644 --- a/azure/src/test/java/com/microsoft/azure/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/AzureTests.java @@ -28,29 +28,29 @@ public class AzureTests { private Azure azure, azure2; public static void main(String[] args) throws IOException, CloudException { - final File credFile = new File("my.azureauth"); - Azure azure = Azure.authenticate(credFile) - .withDefaultSubscription(); - System.out.println(String.valueOf(azure.resourceGroups().list().size())); - - Azure.configure().withLogLevel(Level.BASIC).authenticate(credFile); - System.out.println(String.valueOf(azure.resourceGroups().list().size())); + final File credFile = new File("my.azureauth"); + Azure azure = Azure.authenticate(credFile) + .withDefaultSubscription(); + System.out.println(String.valueOf(azure.resourceGroups().list().size())); + + Azure.configure().withLogLevel(Level.BASIC).authenticate(credFile); + System.out.println(String.valueOf(azure.resourceGroups().list().size())); } - + @Before public void setup() throws Exception { // Authenticate based on credentials instance - Azure.Authenticated azureAuthed = Azure.configure() + Azure.Authenticated azureAuthed = Azure.configure() .withLogLevel(HttpLoggingInterceptor.Level.BASIC) .withUserAgent("AzureTests") .authenticate(credentials); subscriptions = azureAuthed.subscriptions(); azure = azureAuthed.withSubscription(subscriptionId); - + // Authenticate based on file - this.azure2 = Azure.authenticate(new File("my.azureauth")) - .withDefaultSubscription(); + this.azure2 = Azure.authenticate(new File("my.azureauth")) + .withDefaultSubscription(); } /** @@ -58,57 +58,59 @@ public void setup() throws Exception { * @throws Exception */ @Test public void testPublicIpAddresses() throws Exception { - // Verify creation of a new public IP address - String suffix = String.valueOf(System.currentTimeMillis()); - String newPipName = "pip" + suffix; - PublicIpAddress pip = azure2.publicIpAddresses().define(newPipName) - .withRegion(Region.US_WEST) - .withNewGroup() - .withDynamicIp() - .withLeafDomainLabel(newPipName) - .withIdleTimeoutInMinutes(10) - .create(); - - // Verify list - int publicIpAddressCount = azure2.publicIpAddresses().list().size(); - System.out.println(publicIpAddressCount); - Assert.assertTrue(0 < publicIpAddressCount); - - // Verify get - String resourceGroupName = pip.resourceGroupName(); - pip = azure2.publicIpAddresses().get(resourceGroupName, newPipName); - Assert.assertTrue(pip.name().equalsIgnoreCase(newPipName)); - printPublicIpAddress(pip); - - // Verify update - pip = pip.update() - .withStaticIp() - .withLeafDomainLabel(newPipName + "xx") - .withReverseFqdn(pip.leafDomainLabel() + "." + pip.region() + ".cloudapp.azure.com") - .withIdleTimeoutInMinutes(15) - .apply(); - printPublicIpAddress(pip); - pip = azure2.publicIpAddresses().get(pip.id()); - printPublicIpAddress(pip); - - // Verify delete - azure2.publicIpAddresses().delete(pip.id()); - azure2.resourceGroups().delete(pip.resourceGroupName()); + // Verify creation of a new public IP address + String suffix = String.valueOf(System.currentTimeMillis()); + String newPipName = "pip" + suffix; + PublicIpAddress pip = azure2.publicIpAddresses().define(newPipName) + .withRegion(Region.US_WEST) + .withNewGroup() + .withDynamicIp() + .withLeafDomainLabel(newPipName) + .withIdleTimeoutInMinutes(10) + .create(); + + // Verify list + int publicIpAddressCount = azure2.publicIpAddresses().list().size(); + System.out.println(publicIpAddressCount); + Assert.assertTrue(0 < publicIpAddressCount); + + // Verify get + String resourceGroupName = pip.resourceGroupName(); + pip = azure2.publicIpAddresses().get(resourceGroupName, newPipName); + Assert.assertTrue(pip.name().equalsIgnoreCase(newPipName)); + printPublicIpAddress(pip); + + // Verify update + final String updatedDnsName = newPipName + "xx"; + final int updatedIdleTimeout = 15; + pip = pip.update() + .withStaticIp() + .withLeafDomainLabel(updatedDnsName) + .withReverseFqdn(pip.leafDomainLabel() + "." + pip.region() + ".cloudapp.azure.com") + .withIdleTimeoutInMinutes(updatedIdleTimeout) + .apply(); + printPublicIpAddress(pip); + Assert.assertTrue(pip.leafDomainLabel().equalsIgnoreCase(updatedDnsName)); + Assert.assertTrue(pip.idleTimeoutInMinutes()==updatedIdleTimeout); + + // Verify delete + azure2.publicIpAddresses().delete(pip.id()); + azure2.resourceGroups().delete(pip.resourceGroupName()); } - + private void printPublicIpAddress(PublicIpAddress pip) { - System.out.println(new StringBuilder().append("Public IP Address: ").append(pip.id()) - .append("\n\tIP Address: ").append(pip.ipAddress()) - .append("\n\tLeaf domain label: ").append(pip.leafDomainLabel()) - .append("\n\tResource group: ").append(pip.resourceGroupName()) - .append("\n\tFQDN: ").append(pip.fqdn()) - .append("\n\tReverse FQDN: ").append(pip.reverseFqdn()) - .append("\n\tIdle timeout (minutes): ").append(pip.idleTimeoutInMinutes()) - .append("\n\tIP allocation method: ").append(pip.ipAllocationMethod()) - .toString()); + System.out.println(new StringBuilder().append("Public IP Address: ").append(pip.id()) + .append("\n\tIP Address: ").append(pip.ipAddress()) + .append("\n\tLeaf domain label: ").append(pip.leafDomainLabel()) + .append("\n\tResource group: ").append(pip.resourceGroupName()) + .append("\n\tFQDN: ").append(pip.fqdn()) + .append("\n\tReverse FQDN: ").append(pip.reverseFqdn()) + .append("\n\tIdle timeout (minutes): ").append(pip.idleTimeoutInMinutes()) + .append("\n\tIP allocation method: ").append(pip.ipAllocationMethod()) + .toString()); } - - + + @Test public void listSubscriptions() throws Exception { Assert.assertTrue(0 < subscriptions.list().size()); From b36afa8e0381cc8e5961a7e8d7ed659cc2a4d9c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 May 2016 18:00:15 -0700 Subject: [PATCH 12/30] enabling .withDefaultSubscription() to use the first subscription from the list as fallback adding Azure#subscriptionId() to identify which subscription the client is associated with more Javadocs and tests on Azure class --- .../implementation/SubscriptionImpl.java | 1 - .../microsoft/azure/implementation/Azure.java | 140 +++++++++++++----- .../java/com/microsoft/azure/AzureTests.java | 9 +- 3 files changed, 113 insertions(+), 37 deletions(-) diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java index 02d793e13d0c4..91e8063e12bcc 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/implementation/SubscriptionImpl.java @@ -4,7 +4,6 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.model.implementation.IndexableWrapperImpl; import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter; -import com.microsoft.azure.management.resources.implementation.api.SubscriptionClientImpl; import com.microsoft.azure.management.resources.implementation.api.SubscriptionsInner; import com.microsoft.azure.management.resources.Location; import com.microsoft.azure.management.resources.Subscription; diff --git a/azure/src/main/java/com/microsoft/azure/implementation/Azure.java b/azure/src/main/java/com/microsoft/azure/implementation/Azure.java index 97b1647d4b8ac..d8f495a735cb9 100644 --- a/azure/src/main/java/com/microsoft/azure/implementation/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/implementation/Azure.java @@ -7,6 +7,8 @@ package com.microsoft.azure.implementation; import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.PagedList; import com.microsoft.azure.credentials.ApplicationTokenCredentials; import com.microsoft.azure.management.compute.AvailabilitySets; import com.microsoft.azure.management.compute.VirtualMachines; @@ -15,6 +17,7 @@ import com.microsoft.azure.management.network.implementation.NetworkManager; import com.microsoft.azure.management.resources.Deployments; import com.microsoft.azure.management.resources.GenericResources; +import com.microsoft.azure.management.resources.Subscription; import com.microsoft.azure.management.resources.Subscriptions; import com.microsoft.azure.management.resources.Tenants; import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; @@ -37,7 +40,8 @@ public final class Azure { private final StorageManager storageManager; private final ComputeManager computeManager; private final NetworkManager networkManager; - + private final String subscriptionId; + public static Authenticated authenticate(ServiceClientCredentials credentials) { return new AuthenticatedImpl( AzureEnvironment.AZURE.newRestClientBuilder() @@ -46,27 +50,34 @@ public static Authenticated authenticate(ServiceClientCredentials credentials) { } /** - * Authenticates API access using a properties file containing the required credentials - * @param credentialsFile The file containing the credentials in the standard Java properties file format, - * with the following keys: - * subscription= - * tenant= - * client= - * key= - * managementURI= - * baseURL= - * authURL= - * @return Authenticated Azure client + * Authenticates API access using a properties file containing the required credentials. + * @param credentialsFile the file containing the credentials in the standard Java properties file format, + * with the following keys:

    + * + * subscription= #subscription ID
    + * tenant= #tenant ID
    + * client= #client id
    + * key= #client key
    + * managementURI= #management URI
    + * baseURL= #base URL
    + * authURL= #authentication URL
    + *
    + * @return authenticated Azure client * @throws IOException + * @throws CloudException */ public static Authenticated authenticate(File credentialsFile) throws IOException { ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credentialsFile); return new AuthenticatedImpl(AzureEnvironment.AZURE.newRestClientBuilder() .withCredentials(credentials) - .build()) - .withDefaultSubscription(credentials.defaultSubscriptionId()); + .build()).withDefaultSubscription(credentials.defaultSubscriptionId()); } + /** + * Authenticates API access using a {@link RestClient} instance. + * @param restClient the {@link RestClient} configured with Azure authentication credentials + * @return authenticated Azure client + */ public static Authenticated authenticate(RestClient restClient) { return new AuthenticatedImpl(restClient); } @@ -84,19 +95,12 @@ public interface Configurable extends AzureConfigurable { Authenticated authenticate(ServiceClientCredentials credentials); /** - * Authenticates API access using a properties file containing the required credentials - * @param credentialsFile The file containing the credentials in the standard Java properties file format, - * with the following keys: - * subscription= - * tenant= - * client= - * key= - * managementURI= - * baseURL= - * authURL= - * @return Authenticated Azure client - * @throws IOException - */ + * Authenticates API access using a properties file containing the required credentials. + * @param credentialsFile the file containing the credentials in the standard Java properties file format following + * the same schema as {@link Azure#authenticate(File)}.

    + * @return Authenticated Azure client + * @throws IOException + */ Authenticated authenticate(File credentialsFile) throws IOException; } @@ -114,11 +118,42 @@ public Authenticated authenticate(File credentialsFile) throws IOException { } + /** + * Provides authenticated access to a subset of Azure APIs that do not require a specific subscription. + *

    + * To access the subscription-specific APIs, use {@link Authenticated#withSubscription(String)}, + * or {@link Authenticated#withDefaultSubscription()} if a default subscription has already been previously specified + * (for example, in a previously specified authentication file). + * @see Azure#authenticate(File) + */ public interface Authenticated { + /** + * Entry point to subscription management + * @return Subscriptions interface providing access to subscription management + */ Subscriptions subscriptions(); Tenants tenants(); + + /** + * Selects a specific subscription for the APIs to work with. + *

    + * Most Azure APIs require a specific subscription to be selected. + * @param subscriptionId the ID of the subscription + * @return an authenticated Azure client configured to work with the specified subscription + */ Azure withSubscription(String subscriptionId); - Azure withDefaultSubscription(); + + /** + * Selects the default subscription as the subscription for the APIs to work with. + *

    + * The default subscription can be specified inside the authentication file using {@link Azure#authenticate(File)}. + * If no default subscription has been previously provided, the first subscription as + * returned by {@link Authenticated#subscriptions()} will be selected. + * @return an authenticated Azure client configured to work with the default subscription + * @throws IOException + * @throws CloudException + */ + Azure withDefaultSubscription() throws CloudException, IOException; } private static final class AuthenticatedImpl implements Authenticated { @@ -131,8 +166,8 @@ private AuthenticatedImpl(RestClient restClient) { this.restClient = restClient; } - private AuthenticatedImpl withDefaultSubscription(String subscriptionId) { - this.defaultSubscription = subscriptionId; + private AuthenticatedImpl withDefaultSubscription(String subscriptionId) throws IOException { + this.defaultSubscription = subscriptionId; return this; } @@ -152,8 +187,17 @@ public Azure withSubscription(String subscriptionId) { } @Override - public Azure withDefaultSubscription() { - return withSubscription(this.defaultSubscription); + public Azure withDefaultSubscription() throws CloudException, IOException { + if(this.defaultSubscription != null) { + return withSubscription(this.defaultSubscription); + } else { + PagedList subs = this.subscriptions().list(); + if(!subs.isEmpty()) { + return withSubscription(subs.get(0).subscriptionId()); + } else { + return withSubscription(null); + } + } } } @@ -167,9 +211,9 @@ public interface ResourceGroups extends SupportsListing, public interface ResourceGroup extends com.microsoft.azure.management.resources.ResourceGroup { Deployments.InGroup deployments(); StorageAccounts.InGroup storageAccounts(); - // VirtualMachinesInGroup virtualMachines(); + // VirtualMachinesInGroup virtualMachines(); //TODO AvailabilitySets.InGroup availabilitySets(); - // VirtualNetworksInGroup virtualNetworks(); + // VirtualNetworksInGroup virtualNetworks(); //TODO } private Azure(RestClient restClient, String subscriptionId) { @@ -180,8 +224,20 @@ private Azure(RestClient restClient, String subscriptionId) { this.storageManager = StorageManager.authenticate(restClient, subscriptionId); this.computeManager = ComputeManager.authenticate(restClient, subscriptionId); this.networkManager = NetworkManager.authenticate(restClient, subscriptionId); + this.subscriptionId = subscriptionId; } + /** + * @return the currently selected subscription ID this client is configured to work with + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Entry point to managing resource groups + * @return the {@link ResourceGroups} interface exposing the resource group management functionality + */ public ResourceGroups resourceGroups() { return resourceGroups; } @@ -190,6 +246,10 @@ public GenericResources genericResources() { return resourceManager.genericResources(); } + /** + * Entry point to managing storage accounts. + * @return the {@link StorageAccounts} interface exposing the storage account management functionality + */ public StorageAccounts storageAccounts() { return storageManager.storageAccounts(); } @@ -198,14 +258,26 @@ public Usages storageUsages() { return storageManager.usages(); } + /** + * Entry point to managing availability sets. + * @return the {@link AvailabilitySets} interface exposing the availability set management functionality + */ public AvailabilitySets availabilitySets() { return computeManager.availabilitySets(); } + /** + * Entry point to managing virtual machines. + * @return the {@link VirtualMachines} interface exposing the virtual machine management functionality + */ public VirtualMachines virtualMachines() { return computeManager.virtualMachines(); } + /** + * Entry point to managing public IP addresses. + * @return the {@link PublicIpAddresses} interface exposing the public IP address management functionality + */ public PublicIpAddresses publicIpAddresses() { return this.networkManager.publicIpAddresses(); } diff --git a/azure/src/test/java/com/microsoft/azure/AzureTests.java b/azure/src/test/java/com/microsoft/azure/AzureTests.java index 6e38f40b1ec87..9d4b40ef1057d 100644 --- a/azure/src/test/java/com/microsoft/azure/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/AzureTests.java @@ -29,11 +29,16 @@ public class AzureTests { public static void main(String[] args) throws IOException, CloudException { final File credFile = new File("my.azureauth"); - Azure azure = Azure.authenticate(credFile) - .withDefaultSubscription(); + Azure azure = Azure.authenticate(credFile).withDefaultSubscription(); System.out.println(String.valueOf(azure.resourceGroups().list().size())); Azure.configure().withLogLevel(Level.BASIC).authenticate(credFile); + System.out.println("Selected subscription: " + azure.subscriptionId()); + System.out.println(String.valueOf(azure.resourceGroups().list().size())); + + final File authFileNoSubscription = new File("nosub.azureauth"); + azure = Azure.authenticate(authFileNoSubscription).withDefaultSubscription(); + System.out.println("Selected subscription: " + azure.subscriptionId()); System.out.println(String.valueOf(azure.resourceGroups().list().size())); } From c3d5070151c265334f4fdb3c3a8b6f422c0094b7 Mon Sep 17 00:00:00 2001 From: anuchan Date: Fri, 20 May 2016 13:59:05 -0700 Subject: [PATCH 13/30] Addressing checkstyle errors in VirtualMachine.java --- .../management/compute/VirtualMachine.java | 188 +++++++++++++++--- 1 file changed, 157 insertions(+), 31 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java index 0d0e4491ebf7b..bde5269581a4d 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java @@ -2,7 +2,21 @@ import com.microsoft.azure.SubResource; import com.microsoft.azure.management.compute.implementation.KnownVirtualMachineImage; -import com.microsoft.azure.management.compute.implementation.api.*; +import com.microsoft.azure.management.compute.implementation.api.VirtualMachineInner; +import com.microsoft.azure.management.compute.implementation.api.Plan; +import com.microsoft.azure.management.compute.implementation.api.HardwareProfile; +import com.microsoft.azure.management.compute.implementation.api.StorageProfile; +import com.microsoft.azure.management.compute.implementation.api.OSProfile; +import com.microsoft.azure.management.compute.implementation.api.NetworkProfile; +import com.microsoft.azure.management.compute.implementation.api.DiagnosticsProfile; +import com.microsoft.azure.management.compute.implementation.api.VirtualMachineInstanceView; +import com.microsoft.azure.management.compute.implementation.api.VirtualMachineExtensionInner; +import com.microsoft.azure.management.compute.implementation.api.OperatingSystemTypes; +import com.microsoft.azure.management.compute.implementation.api.ImageReference; +import com.microsoft.azure.management.compute.implementation.api.WinRMListener; +import com.microsoft.azure.management.compute.implementation.api.CachingTypes; +import com.microsoft.azure.management.compute.implementation.api.DiskEncryptionSettings; +import com.microsoft.azure.management.compute.implementation.api.VirtualMachineSizeTypes; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; @@ -11,6 +25,9 @@ import java.util.List; +/** + * The type representing Azure virtual machine. + */ public interface VirtualMachine extends GroupableResource, Refreshable, @@ -92,95 +109,130 @@ public interface VirtualMachine extends */ List resources(); + /** + * The initial stage representing virtual machine definition. + */ interface DefinitionBlank extends GroupableResource.DefinitionWithRegion { } + /** + * The virtual machine definition stage with resource group. + */ interface DefinitionWithGroup extends GroupableResource.DefinitionWithGroup { } + /** + * The virtual machine definition stage with Operation System. + */ interface DefinitionWithOS { /** * Specifies the market-place image used for the virtual machine's OS. - * @return The next stage of the virtual machine definition. + * + * @return The next stage of the virtual machine definition */ DefinitionWithMarketplaceImage withMarketplaceImage(); /** * Specifies the user (generalized) image used for the virtual machine's OS. + * * @param imageUrl The url the the VHD - * @return The next stage of the virtual machine definition. + * @return The next stage of the virtual machine definition */ DefinitionWithOSType withStoredImage(String imageUrl); /** * Specifies the specialized operating system disk to be attached to the virtual machine. - * @param osDiskUrl The url to the OS disk in the Azure Storage account. - * @return The next stage of the Windows virtual machine definition. + * + * @param osDiskUrl The url to the OS disk in the Azure Storage account + * @return The next stage of the Windows virtual machine definition */ DefinitionCreatable withOSDisk(String osDiskUrl, OperatingSystemTypes osType); } + /** + * The virtual machine definition stage with marketplace (platform) image. + */ interface DefinitionWithMarketplaceImage { /** * Specifies the version of image. - * @param imageReference describes publisher, offer, sku and version of the market-place image. - * @return The next stage of the virtual machine definition. + * + * @param imageReference describes publisher, offer, sku and version of the market-place image + * @return The next stage of the virtual machine definition */ DefinitionWithOSType version(ImageReference imageReference); /** * Specifies that the latest version of the image needs to be used. + * * @param publisher Specifies the publisher of the image * @param offer Specifies the offer of the image * @param sku Specifies the SKU of the image - * @return The next stage of the virtual machine definition. + * @return The next stage of the virtual machine definition */ DefinitionWithOSType latest(String publisher, String offer, String sku); /** * Specifies the known image to be used. - * @param knownImage Enum value indicating known market-place image. - * @return The next stage of the virtual machine definition. + * + * @param knownImage Enum value indicating known market-place image + * @return The next stage of the virtual machine definition */ DefinitionWithOSType popular(KnownVirtualMachineImage knownImage); } + /** + * The virtual machine definition stage with Operating system type. + */ interface DefinitionWithOSType { /** * Specifies the OS type of the virtual machine as Linux. - * @return The next stage of the Linux virtual machine definition. + * + * @return The next stage of the Linux virtual machine definition */ DefinitionWithRootUserName withLinuxOS(); /** * Specifies the OS type as Windows. - * @return The next stage of the Windows virtual machine definition. + * + * @return The next stage of the Windows virtual machine definition */ DefinitionWithAdminUserName withWindowsOS(); } + /** + * The Linux virtual machine definition stage with root user name. + */ interface DefinitionWithRootUserName { /** * Specifies the root user name for the Linux virtual machine. - * @param rootUserName The Linux root user name. This must follow the required naming convention for Linux user name. - * @return The next stage of the Linux virtual machine definition. + * + * @param rootUserName The Linux root user name. This must follow the required naming convention for Linux user name + * @return The next stage of the Linux virtual machine definition */ DefinitionLinuxCreatable withRootUserName(String rootUserName); } + /** + * The Windows virtual machine definition stage with root user name. + */ interface DefinitionWithAdminUserName { /** * Specifies the administrator user name for the Windows virtual machine. + * * @param adminUserName The Windows administrator user name. This must follow the required naming convention for Windows user name. * @return The stage representing creatable Linux VM definition */ DefinitionWindowsCreatable withAdminUserName(String adminUserName); } + /** + * The Linux virtual machine in creatable stage. + */ interface DefinitionLinuxCreatable extends DefinitionCreatable { /** - * Specifies the SSH public key, each call to this method adds the given public key to the list - * of VM's public keys. + * Specifies the SSH public key. + *

    + * each call to this method adds the given public key to the list of VM's public keys. * * @param publicKey The SSH public key in PEM format. * @return The stage representing creatable Linux VM definition @@ -188,45 +240,65 @@ interface DefinitionLinuxCreatable extends DefinitionCreatable { DefinitionLinuxCreatable withSsh(String publicKey); } + /** + * The Windows virtual machine in cretable stage. + */ interface DefinitionWindowsCreatable extends DefinitionCreatable { /** * Specifies that VM Agent should not be provisioned. + * * @return The stage representing creatable Windows VM definition */ DefinitionWindowsCreatable disableVMAgent(); /** * Specifies that automatic updates should be disabled. + * * @return The stage representing creatable Windows VM definition */ DefinitionWindowsCreatable disableAutoUpdate(); /** * Specifies the time-zone. + * * @return The stage representing creatable Windows VM definition */ DefinitionWindowsCreatable withTimeZone(String timeZone); /** - * Specifies the WINRM listener, each call to this method adds the given listener to the list - * of VM's WinRM listeners. + * Specifies the WINRM listener. + *

    + * each call to this method adds the given listener to the list of VM's WinRM listeners. + * * @return The stage representing creatable Windows VM definition */ DefinitionWindowsCreatable withWinRM(WinRMListener listener); } + /** + * The virtual machine definition stage with password. + * + * @param The virtual machine definition in creatable stage. + */ interface DefinitionPassword { /** * Specifies the password for the virtual machine. + * * @param password The password. This must follow the criteria for Azure VM password. * @return The stage representing creatable VM definition */ T withPassword(String password); } + /** + * The virtual machine definition stage with OS disk configurations. + * + * @param The virtual machine definition in creatable stage. + */ interface DefinitionOSDiskSettings { /** * Specifies the caching type for the Operating System disk. + * * @param cachingType The caching type. * @return The stage representing creatable VM definition */ @@ -234,6 +306,7 @@ interface DefinitionOSDiskSettings { /** * Specifies the name of the OS Disk Vhd file and it's parent container. + * * @param containerName The name of the container in the selected storage account. * @param vhdName The name for the OS Disk vhd. * @return The stage representing creatable VM definition @@ -242,6 +315,7 @@ interface DefinitionOSDiskSettings { /** * Specifies the encryption settings for the OS Disk. + * * @param settings The encryption settings. * @return The stage representing creatable VM definition */ @@ -249,6 +323,7 @@ interface DefinitionOSDiskSettings { /** * Specifies the size of the OSDisk in GB. + * * @param size The VHD size. * @return The stage representing creatable VM definition */ @@ -256,53 +331,75 @@ interface DefinitionOSDiskSettings { /** * Specifies the name for the OS Disk. + * * @param name The OS Disk name. * @return The stage representing creatable VM definition */ T withOSDiskName(String name); } + /** + * The virtual machine definition stage with size. + * + * @param The virtual machine definition in creatable stage. + */ interface DefinitionWithVMSize { /** - * Specifies the virtual machine size + * Specifies the virtual machine size. + * * @param sizeName The name of the size for the virtual machine as text * @return The stage representing creatable VM definition */ T withSize(String sizeName); /** - * Specifies the virtual machine size + * Specifies the virtual machine size. + * * @param size A size from the list of available sizes for the virtual machine * @return The stage representing creatable VM definition */ T withSize(VirtualMachineSizeTypes size); } + /** + * The virtual machine definition stage with data disk configurations. + * + * @param The virtual machine definition in creatable stage. + */ interface ConfigureDataDisk { /** - * Specifies the logical unit number for the data disk + * Specifies the logical unit number for the data disk. + * * @param lun The logical unit number * @return The stage representing optional additional configurations for the attachable data disk */ ConfigureDataDisk withLun(Integer lun); /** - * Specifies the caching type for the data disk + * Specifies the caching type for the data disk. + * * @param cachingType The disk caching type. Possible values include: 'None', 'ReadOnly', 'ReadWrite' * @return The stage representing optional additional configurations for the attachable data disk */ ConfigureDataDisk withCaching(CachingTypes cachingType); /** - * Adds the data disk to the list of virtual machine's data disks + * Adds the data disk to the list of virtual machine's data disks. + * * @return The stage representing creatable VM definition */ T attach(); } + /** + * The virtual machine definition stage with data disk target location. + * + * @param The virtual machine definition in creatable stage. + */ interface ConfigureNewDataDiskWithStoreAt extends ConfigureDataDisk { /** - * Specifies where the VHD associated with the new blank data disk needs to be stored + * Specifies where the VHD associated with the new blank data disk needs to be stored. + * * @param storageAccountName The storage account name * @param containerName The name of the container to hold the new VHD file * @param vhdName The name for the new VHD file @@ -311,18 +408,30 @@ interface ConfigureNewDataDiskWithStoreAt extends ConfigureDataDisk storeAt(String storageAccountName, String containerName, String vhdName); } + /** + * The virtual machine definition stage with new data disk configuration. + * + * @param The virtual machine definition in creatable stage. + */ interface ConfigureNewDataDisk { /** - * Specifies the initial disk size in GB for new blank data disk + * Specifies the initial disk size in GB for new blank data disk. + * * @param size The disk size in GB * @return The stage representing optional additional configurations for the attachable data disk */ ConfigureNewDataDiskWithStoreAt withSizeInGB(Integer size); } + /** + * The virtual machine definition stage with existing data disk configuration. + * + * @param The virtual machine definition in creatable stage. + */ interface ConfigureExistingDataDisk { /** - * Specifies an existing VHD that needs to be attached to the virtual machine as data disk + * Specifies an existing VHD that needs to be attached to the virtual machine as data disk. + * * @param storageAccountName The storage account name * @param containerName The name of the container holding the VHD file * @param vhdName The name for the VHD file @@ -331,16 +440,23 @@ interface ConfigureExistingDataDisk { ConfigureDataDisk from(String storageAccountName, String containerName, String vhdName); } + /** + * The virtual machine definition stage with data disk configuration. + * + * @param The virtual machine definition in creatable stage. + */ interface DefinitionWithDataDisk { /** - * Specifies that a new blank data disk needs to be attached to virtual machine + * Specifies that a new blank data disk needs to be attached to virtual machine. + * * @param sizeInGB The disk size in GB * @return The stage representing creatable VM definition */ T withNewDataDisk(Integer sizeInGB); /** - * Specifies an existing VHD that needs to be attached to the virtual machine as data disk + * Specifies an existing VHD that needs to be attached to the virtual machine as data disk. + * * @param storageAccountName The storage account name * @param containerName The name of the container holding the VHD file * @param vhdName The name for the VHD file @@ -349,23 +465,30 @@ interface DefinitionWithDataDisk { T withExistingDataDisk(String storageAccountName, String containerName, String vhdName); /** - * Specifies a new blank data disk to be attached to the virtual machine along with it's configuration + * Specifies a new blank data disk to be attached to the virtual machine along with it's configuration. + * * @param name The name for the data disk * @return The stage representing configuration for the data disk */ ConfigureNewDataDisk defineNewDataDisk(String name); /** - * Specifies an existing VHD that needs to be attached to the virtual machine as data disk along with it's configuration + * Specifies an existing VHD that needs to be attached to the virtual machine as data disk along with it's configuration. + * * @param name The name for the data disk * @return The stage representing configuration for the data disk */ ConfigureExistingDataDisk defineExistingDataDisk(String name); } + /** + * The virtual machine definition stage with storage account. + * + * @param The virtual machine definition in creatable stage. + */ interface DefinitionStorageAccount { /** - * Specifies the name of the storage account to create, the OS disk for VM created from a market-place + * Specifies the name of the storage account to create, the OS disk for VM created from a market-place. * image will be stored in this account. * * @param name The name of the storage account @@ -392,6 +515,9 @@ interface DefinitionStorageAccount { T withExistingStorageAccount(String name); } + /** + * The virtual machine definition in cretable stage. + */ interface DefinitionCreatable extends DefinitionPassword, DefinitionOSDiskSettings, From bebdec5b1bbf8d0d2b6be78eb00cd2fc85646763 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 20 May 2016 14:34:51 -0700 Subject: [PATCH 14/30] Squashed 'runtimes/' changes from 6cdb496..0bcf347 0bcf347 Move checkstyle rules to runtimes b443c0f Fix styles and tests aabe677 Merge commit 'fddca6a8917951772a65a3e5b47c5e72c1f42fb5' into ua 63803e0 Fix runtime tests c2765e5 Merge commit '3420556ca4cee622a71e11aa166f8e9ec894f818' into ua 6037451 Send client specific user agent b887e80 Add user agent to every method 9d48136 Add a test for request id header 29d8857 Fix request id to be generated each time 41224f8 ComputeManager, rename region->location, etc 5e2de11 enabling Azure.authenticate(File).withDefaultSubscription() based on the subscription provided in the file daacda8 Merge pull request #702 from jianghaolu/master 788f625 support for Azure.authenticate(File propertiesFile) dab7626 Address eclipse build errors c8ecc0f Merge pull request #13 from jianghaolu/snap 69f21a2 Use sonatype as public snapshots git-subtree-dir: runtimes git-subtree-split: 0bcf347dca49573e758260370ac8b94e4f743595 --- .../build.gradle | 2 +- azure-client-authentication/build.gradle | 8 +- azure-client-authentication/pom.xml | 6 +- .../ApplicationTokenCredentials.java | 103 +++++++ .../credentials/UserTokenCredentials.java | 1 + .../UserTokenCredentialsTests.java | 3 +- azure-client-runtime/build.gradle | 6 +- .../java/com/microsoft/azure/AzureClient.java | 20 +- .../microsoft/azure}/AzureEnvironment.java | 46 +++- .../microsoft/azure/AzureServiceClient.java | 10 + .../azure/RequestIdHeaderInterceptor.java | 29 ++ .../RequestIdHeaderInterceptorTests.java | 90 +++++++ checkstyle/checkstyle.xml | 255 ++++++++++++++++++ checkstyle/suppressions.xml | 36 +++ client-runtime/build.gradle | 6 +- client-runtime/pom.xml | 5 - .../java/com/microsoft/rest/RestClient.java | 47 ++-- .../com/microsoft/rest/ServiceClient.java | 2 + .../microsoft/rest/UserAgentInterceptor.java | 35 ++- .../com/microsoft/rest/CredentialsTests.java | 3 + .../com/microsoft/rest/RetryHandlerTests.java | 7 +- .../microsoft/rest/ServiceClientTests.java | 6 +- .../com/microsoft/rest/UserAgentTests.java | 78 +++--- .../java/com/microsoft/rest/package-info.java | 4 - pom.xml | 59 +--- 25 files changed, 710 insertions(+), 157 deletions(-) rename {azure-client-authentication/src/main/java/com/microsoft/azure/credentials => azure-client-runtime/src/main/java/com/microsoft/azure}/AzureEnvironment.java (67%) create mode 100644 azure-client-runtime/src/main/java/com/microsoft/azure/RequestIdHeaderInterceptor.java create mode 100644 azure-client-runtime/src/test/java/com/microsoft/azure/RequestIdHeaderInterceptorTests.java create mode 100644 checkstyle/checkstyle.xml create mode 100644 checkstyle/suppressions.xml delete mode 100644 client-runtime/src/test/java/com/microsoft/rest/package-info.java diff --git a/azure-android-client-authentication/build.gradle b/azure-android-client-authentication/build.gradle index df85a81cc546d..24d3409361216 100644 --- a/azure-android-client-authentication/build.gradle +++ b/azure-android-client-authentication/build.gradle @@ -51,7 +51,7 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.microsoft.aad:adal:1.1.11' - compile 'com.microsoft.rest:client-runtime:1.0.0-beta1' + compile 'com.microsoft.azure:azure-client-runtime:1.0.0-SNAPSHOT' testCompile 'junit:junit:4.12' testCompile 'junit:junit-dep:4.11' deployerJars "org.apache.maven.wagon:wagon-ftp:2.10" diff --git a/azure-client-authentication/build.gradle b/azure-client-authentication/build.gradle index 5f20108264785..75d0404be1f54 100644 --- a/azure-client-authentication/build.gradle +++ b/azure-client-authentication/build.gradle @@ -13,14 +13,14 @@ apply plugin: 'checkstyle' version = '1.0.0-SNAPSHOT' checkstyle { - configFile = new File("$rootDir/Tools/checkstyle/checkstyle.xml") - configProperties = [samedir: "$rootDir/Tools/checkstyle"] - reportsDir = new File("$rootDir/Tools/checkstyle/reports") + configFile = new File("$rootDir/ClientRuntimes/Java/checkstyle/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/checkstyle"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/checkstyle/reports") } dependencies { compile 'com.microsoft.azure:adal4j:1.1.2' - compile 'com.microsoft.rest:client-runtime:1.0.0-beta1' + compile 'com.microsoft.azure:azure-client-runtime:1.0.0-SNAPSHOT' testCompile 'junit:junit:4.12' testCompile 'junit:junit-dep:4.11' deployerJars "org.apache.maven.wagon:wagon-ftp:2.10" diff --git a/azure-client-authentication/pom.xml b/azure-client-authentication/pom.xml index 4dc317b73c131..47582ca1eaa87 100644 --- a/azure-client-authentication/pom.xml +++ b/azure-client-authentication/pom.xml @@ -47,9 +47,9 @@ - com.microsoft.rest - client-runtime - ${parent.version} + com.microsoft.azure + azure-client-runtime + 1.0.0-SNAPSHOT com.microsoft.azure diff --git a/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/ApplicationTokenCredentials.java b/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/ApplicationTokenCredentials.java index 3e995fb06a087..163d10f60a1d5 100644 --- a/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/ApplicationTokenCredentials.java +++ b/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/ApplicationTokenCredentials.java @@ -10,9 +10,13 @@ import com.microsoft.aad.adal4j.AuthenticationContext; import com.microsoft.aad.adal4j.AuthenticationResult; import com.microsoft.aad.adal4j.ClientCredential; +import com.microsoft.azure.AzureEnvironment; import com.microsoft.rest.credentials.TokenCredentials; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -30,6 +34,8 @@ public class ApplicationTokenCredentials extends TokenCredentials { private AzureEnvironment environment; /** The current authentication result. */ private AuthenticationResult authenticationResult; + /** The default subscription to use, if any. */ + private String defaultSubscription; /** * Initializes a new instance of the UserTokenCredentials. @@ -52,6 +58,103 @@ public ApplicationTokenCredentials(String clientId, String domain, String secret } } + /** + * Contains the keys of the settings in a Properties file to read credentials from. + */ + private enum CredentialSettings { + /** The subscription GUID. */ + SUBSCRIPTION_ID("subscription"), + /** The tenant GUID or domain. */ + TENANT_ID("tenant"), + /** The client id for the client application. */ + CLIENT_ID("client"), + /** The client secret for the service principal. */ + CLIENT_KEY("key"), + /** The management endpoint. */ + MANAGEMENT_URI("managementURI"), + /** The base URL to the current Azure environment. */ + BASE_URL("baseURL"), + /** The URL to Active Directory authentication. */ + AUTH_URL("authURL"); + + /** The name of the key in the properties file. */ + private final String name; + + CredentialSettings(String name) { + this.name = name; + } + + @Override + public String toString() { + return this.name; + } + } + + /** + * @return The default subscription ID, if any + */ + public String defaultSubscriptionId() { + return defaultSubscription; + } + + /** + * Set default subscription ID. + * + * @param subscriptionId the default subscription ID. + * @return the credentials object itself. + */ + public ApplicationTokenCredentials withDefaultSubscriptionId(String subscriptionId) { + this.defaultSubscription = subscriptionId; + return this; + } + + /** + * Initializes the credentials based on the provided credentials file. + * + * @param credentialsFile A file with credentials, using the standard Java properties format. + * and the following keys: + * subscription= + * tenant= + * client= + * key= + * managementURI= + * baseURL= + * authURL= + * @return The credentials based on the file. + * @throws IOException exception thrown from file access errors. + */ + public static ApplicationTokenCredentials fromFile(File credentialsFile) throws IOException { + // Set defaults + Properties authSettings = new Properties(); + authSettings.put(CredentialSettings.AUTH_URL.toString(), AzureEnvironment.AZURE.getAuthenticationEndpoint()); + authSettings.put(CredentialSettings.BASE_URL.toString(), AzureEnvironment.AZURE.getBaseUrl()); + authSettings.put(CredentialSettings.MANAGEMENT_URI.toString(), AzureEnvironment.AZURE.getTokenAudience()); + + // Load the credentials from the file + FileInputStream credentialsFileStream = new FileInputStream(credentialsFile); + authSettings.load(credentialsFileStream); + credentialsFileStream.close(); + + final String clientId = authSettings.getProperty(CredentialSettings.CLIENT_ID.toString()); + final String tenantId = authSettings.getProperty(CredentialSettings.TENANT_ID.toString()); + final String clientKey = authSettings.getProperty(CredentialSettings.CLIENT_KEY.toString()); + final String mgmtUri = authSettings.getProperty(CredentialSettings.MANAGEMENT_URI.toString()); + final String authUrl = authSettings.getProperty(CredentialSettings.AUTH_URL.toString()); + final String baseUrl = authSettings.getProperty(CredentialSettings.BASE_URL.toString()); + final String defaultSubscriptionId = authSettings.getProperty(CredentialSettings.SUBSCRIPTION_ID.toString()); + + return new ApplicationTokenCredentials( + clientId, + tenantId, + clientKey, + new AzureEnvironment( + authUrl, + mgmtUri, + true, + baseUrl) + ).withDefaultSubscriptionId(defaultSubscriptionId); + } + /** * Gets the active directory application client id. * diff --git a/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/UserTokenCredentials.java b/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/UserTokenCredentials.java index af02c07507b74..60d6bdb3c0a58 100644 --- a/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/UserTokenCredentials.java +++ b/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/UserTokenCredentials.java @@ -9,6 +9,7 @@ import com.microsoft.aad.adal4j.AuthenticationContext; import com.microsoft.aad.adal4j.AuthenticationResult; +import com.microsoft.azure.AzureEnvironment; import com.microsoft.rest.credentials.TokenCredentials; import java.io.IOException; diff --git a/azure-client-authentication/src/test/java/com/microsoft/azure/credentials/UserTokenCredentialsTests.java b/azure-client-authentication/src/test/java/com/microsoft/azure/credentials/UserTokenCredentialsTests.java index afce04b56ecdf..7905ba7e7b21e 100644 --- a/azure-client-authentication/src/test/java/com/microsoft/azure/credentials/UserTokenCredentialsTests.java +++ b/azure-client-authentication/src/test/java/com/microsoft/azure/credentials/UserTokenCredentialsTests.java @@ -8,9 +8,8 @@ package com.microsoft.azure.credentials; import com.microsoft.aad.adal4j.AuthenticationResult; - +import com.microsoft.azure.AzureEnvironment; import org.junit.Assert; - import org.junit.Test; import java.io.IOException; diff --git a/azure-client-runtime/build.gradle b/azure-client-runtime/build.gradle index e8a50ca112428..775736ec22dba 100644 --- a/azure-client-runtime/build.gradle +++ b/azure-client-runtime/build.gradle @@ -14,9 +14,9 @@ version = '1.0.0-SNAPSHOT' checkstyle { toolVersion = "6.9" - configFile = new File("$rootDir/Tools/checkstyle/checkstyle.xml") - configProperties = [samedir: "$rootDir/Tools/checkstyle"] - reportsDir = new File("$rootDir/Tools/checkstyle/reports") + configFile = new File("$rootDir/ClientRuntimes/Java/checkstyle/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/checkstyle"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/checkstyle/reports") } dependencies { diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java index d8389869810f4..56f377008512e 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureClient.java @@ -7,7 +7,6 @@ package com.microsoft.azure; -import com.microsoft.rest.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceException; @@ -27,6 +26,7 @@ import retrofit2.Call; import retrofit2.Response; import retrofit2.http.GET; +import retrofit2.http.Header; import retrofit2.http.Url; /** @@ -44,13 +44,19 @@ public class AzureClient extends AzureServiceClient { */ private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); + /** + * The user agent from the service client that owns this Azure Client. + */ + private final String serviceClientUserAgent; + /** * Initializes an instance of this class with customized client metadata. * - * @param restClient the REST client to connect to Azure + * @param serviceClient the caller client that initiates the asynchronous request. */ - public AzureClient(RestClient restClient) { - super(restClient); + public AzureClient(AzureServiceClient serviceClient) { + super(serviceClient.restClient()); + this.serviceClientUserAgent = serviceClient.userAgent(); } /** @@ -647,7 +653,7 @@ private Response poll(String url) throws CloudException, IOExcepti port = endpoint.getDefaultPort(); } AsyncService service = restClient().retrofit().create(AsyncService.class); - Response response = service.get(endpoint.getFile()).execute(); + Response response = service.get(endpoint.getFile(), serviceClientUserAgent).execute(); int statusCode = response.code(); if (statusCode != 200 && statusCode != 201 && statusCode != 202 && statusCode != 204) { CloudException exception = new CloudException(statusCode + " is not a valid polling status code"); @@ -684,7 +690,7 @@ private Call pollAsync(String url, final ServiceCallback call = service.get(endpoint.getFile()); + Call call = service.get(endpoint.getFile(), serviceClientUserAgent); call.enqueue(new ServiceResponseCallback(callback) { @Override public void onResponse(Call call, Response response) { @@ -735,7 +741,7 @@ public void setLongRunningOperationRetryTimeout(Integer longRunningOperationRetr */ private interface AsyncService { @GET - Call get(@Url String url); + Call get(@Url String url, @Header("User-Agent") String userAgent); } /** diff --git a/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/AzureEnvironment.java b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureEnvironment.java similarity index 67% rename from azure-client-authentication/src/main/java/com/microsoft/azure/credentials/AzureEnvironment.java rename to azure-client-runtime/src/main/java/com/microsoft/azure/AzureEnvironment.java index dd8a1a2dc9de9..1721e2ff97bb8 100644 --- a/azure-client-authentication/src/main/java/com/microsoft/azure/credentials/AzureEnvironment.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureEnvironment.java @@ -5,20 +5,30 @@ * */ -package com.microsoft.azure.credentials; +package com.microsoft.azure; + +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; +import com.microsoft.rest.RestClient; /** * An instance of this class describes an environment in Azure. */ public final class AzureEnvironment { + /** + * Base URL for calls to Azure management API. + */ + private final String baseURL; + /** * ActiveDirectory Endpoint for the Azure Environment. */ private String authenticationEndpoint; + /** * Token audience for an endpoint. */ private String tokenAudience; + /** * Determines whether the authentication endpoint should * be validated with Azure AD. Default value is true. @@ -32,11 +42,17 @@ public final class AzureEnvironment { * @param tokenAudience token audience for an endpoint. * @param validateAuthority whether the authentication endpoint should * be validated with Azure AD. + * @param baseUrl the base URL for the current environment. */ - public AzureEnvironment(String authenticationEndpoint, String tokenAudience, boolean validateAuthority) { + public AzureEnvironment( + String authenticationEndpoint, + String tokenAudience, + boolean validateAuthority, + String baseUrl) { this.authenticationEndpoint = authenticationEndpoint; this.tokenAudience = tokenAudience; this.validateAuthority = validateAuthority; + this.baseURL = baseUrl; } /** @@ -45,7 +61,8 @@ public AzureEnvironment(String authenticationEndpoint, String tokenAudience, boo public static final AzureEnvironment AZURE = new AzureEnvironment( "https://login.windows.net/", "https://management.core.windows.net/", - true); + true, + "https://management.azure.com/"); /** * Provides the settings for authentication with Azure China. @@ -53,7 +70,28 @@ public AzureEnvironment(String authenticationEndpoint, String tokenAudience, boo public static final AzureEnvironment AZURE_CHINA = new AzureEnvironment( "https://login.chinacloudapi.cn/", "https://management.core.chinacloudapi.cn/", - true); + true, + "https://management.chinacloudapi.cn"); + + /** + * Gets the base URL of the management service. + * + * @return the Base URL for the management service. + */ + public String getBaseUrl() { + return this.baseURL; + } + + /** + * Gets a builder for {@link RestClient}. + * + * @return a builder for the rest client. + */ + public RestClient.Builder newRestClientBuilder() { + return new RestClient.Builder(baseURL) + .withInterceptor(new RequestIdHeaderInterceptor()) + .withMapperAdapter(new AzureJacksonMapperAdapter()); + } /** * Gets the ActiveDirectory Endpoint for the Azure Environment. diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceClient.java b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceClient.java index 94142029cfc67..08094b67d5071 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceClient.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/AzureServiceClient.java @@ -17,6 +17,7 @@ public abstract class AzureServiceClient extends ServiceClient { protected AzureServiceClient(String baseUrl) { this(new RestClient.Builder(baseUrl) + .withInterceptor(new RequestIdHeaderInterceptor()) .withMapperAdapter(new AzureJacksonMapperAdapter()).build()); } @@ -28,4 +29,13 @@ protected AzureServiceClient(String baseUrl) { protected AzureServiceClient(RestClient restClient) { super(restClient); } + + /** + * The default User-Agent header. Override this method to override the user agent. + * + * @return the user agent string. + */ + public String userAgent() { + return "Azure-SDK-For-Java/" + getClass().getPackage().getImplementationVersion(); + } } diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/RequestIdHeaderInterceptor.java b/azure-client-runtime/src/main/java/com/microsoft/azure/RequestIdHeaderInterceptor.java new file mode 100644 index 0000000000000..ddbe0db30ec0b --- /dev/null +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/RequestIdHeaderInterceptor.java @@ -0,0 +1,29 @@ +/** + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + */ + +package com.microsoft.azure; + +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +import java.io.IOException; +import java.util.UUID; + +/** + * An instance of this class puts an UUID in the request header. Azure uses + * the request id as the unique identifier for + */ +public class RequestIdHeaderInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request().newBuilder() + .header("x-ms-client-request-id", UUID.randomUUID().toString()) + .build(); + return chain.proceed(request); + } +} diff --git a/azure-client-runtime/src/test/java/com/microsoft/azure/RequestIdHeaderInterceptorTests.java b/azure-client-runtime/src/test/java/com/microsoft/azure/RequestIdHeaderInterceptorTests.java new file mode 100644 index 0000000000000..e8cce598b05f4 --- /dev/null +++ b/azure-client-runtime/src/test/java/com/microsoft/azure/RequestIdHeaderInterceptorTests.java @@ -0,0 +1,90 @@ +/** + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + */ + +package com.microsoft.azure; + +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.retry.RetryHandler; +import okhttp3.Interceptor; +import okhttp3.Protocol; +import okhttp3.Request; +import okhttp3.Response; +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; + +public class RequestIdHeaderInterceptorTests { + private static final String REQUEST_ID_HEADER = "x-ms-client-request-id"; + + @Test + public void newRequestIdForEachCall() throws Exception { + RestClient restClient = new RestClient.Builder("http://localhost") + .withInterceptor(new RequestIdHeaderInterceptor()) + .withInterceptor(new Interceptor() { + private String firstRequestId = null; + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + if (request.header(REQUEST_ID_HEADER) != null) { + if (firstRequestId == null) { + firstRequestId = request.header(REQUEST_ID_HEADER); + return new Response.Builder().code(200).request(request) + .protocol(Protocol.HTTP_1_1).build(); + } else if (!request.header(REQUEST_ID_HEADER).equals(firstRequestId)) { + return new Response.Builder().code(200).request(request) + .protocol(Protocol.HTTP_1_1).build(); + } + } + return new Response.Builder().code(400).request(request) + .protocol(Protocol.HTTP_1_1).build(); + } + }) + .withMapperAdapter(new AzureJacksonMapperAdapter()) + .build(); + AzureServiceClient serviceClient = new AzureServiceClient(restClient) { }; + Response response = serviceClient.restClient().httpClient() + .newCall(new Request.Builder().get().url("http://localhost").build()).execute(); + Assert.assertEquals(200, response.code()); + response = serviceClient.restClient().httpClient() + .newCall(new Request.Builder().get().url("http://localhost").build()).execute(); + Assert.assertEquals(200, response.code()); + } + + @Test + public void sameRequestIdForRetry() throws Exception { + RestClient restClient = new RestClient.Builder("http://localhost") + .withInterceptor(new RequestIdHeaderInterceptor()) + .withInterceptor(new RetryHandler()) + .withInterceptor(new Interceptor() { + private String firstRequestId = null; + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + if (request.header(REQUEST_ID_HEADER) != null) { + if (firstRequestId == null) { + firstRequestId = request.header(REQUEST_ID_HEADER); + return new Response.Builder().code(500).request(request) + .protocol(Protocol.HTTP_1_1).build(); + } else if (request.header(REQUEST_ID_HEADER).equals(firstRequestId)) { + return new Response.Builder().code(200).request(request) + .protocol(Protocol.HTTP_1_1).build(); + } + } + return new Response.Builder().code(400).request(request) + .protocol(Protocol.HTTP_1_1).build(); + } + }) + .withMapperAdapter(new AzureJacksonMapperAdapter()) + .build(); + AzureServiceClient serviceClient = new AzureServiceClient(restClient) { }; + Response response = serviceClient.restClient().httpClient() + .newCall(new Request.Builder().get().url("http://localhost").build()).execute(); + Assert.assertEquals(200, response.code()); + } +} diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml new file mode 100644 index 0000000000000..d2b92aa67f9ef --- /dev/null +++ b/checkstyle/checkstyle.xml @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml new file mode 100644 index 0000000000000..690bb7a9fc35f --- /dev/null +++ b/checkstyle/suppressions.xml @@ -0,0 +1,36 @@ + + + + + + + + + \ No newline at end of file diff --git a/client-runtime/build.gradle b/client-runtime/build.gradle index 2558fc5055f9a..b17a86a50eadf 100644 --- a/client-runtime/build.gradle +++ b/client-runtime/build.gradle @@ -16,9 +16,9 @@ version = '1.0.0-SNAPSHOT' checkstyle { toolVersion = "6.9" - configFile = new File("$rootDir/Tools/checkstyle/checkstyle.xml") - configProperties = [samedir: "$rootDir/Tools/checkstyle"] - reportsDir = new File("$rootDir/Tools/checkstyle/reports") + configFile = new File("$rootDir/ClientRuntimes/Java/checkstyle/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/checkstyle"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/checkstyle/reports") } dependencies { diff --git a/client-runtime/pom.xml b/client-runtime/pom.xml index 029c12e26022d..a7c0b7441b02c 100644 --- a/client-runtime/pom.xml +++ b/client-runtime/pom.xml @@ -105,11 +105,6 @@ - - org.apache.maven.plugins - maven-antrun-plugin - - org.codehaus.mojo build-helper-maven-plugin diff --git a/client-runtime/src/main/java/com/microsoft/rest/RestClient.java b/client-runtime/src/main/java/com/microsoft/rest/RestClient.java index ffc52643040d7..0d5436b4fa6e1 100644 --- a/client-runtime/src/main/java/com/microsoft/rest/RestClient.java +++ b/client-runtime/src/main/java/com/microsoft/rest/RestClient.java @@ -36,17 +36,21 @@ public final class RestClient { private BaseUrlHandler baseUrlHandler; /** The adapter to a Jackson {@link com.fasterxml.jackson.databind.ObjectMapper}. */ private JacksonMapperAdapter mapperAdapter; + /** The interceptor to set 'User-Agent' header. */ + private UserAgentInterceptor userAgentInterceptor; private RestClient(OkHttpClient httpClient, Retrofit retrofit, ServiceClientCredentials credentials, CustomHeadersInterceptor customHeadersInterceptor, + UserAgentInterceptor userAgentInterceptor, BaseUrlHandler baseUrlHandler, JacksonMapperAdapter mapperAdapter) { this.httpClient = httpClient; this.retrofit = retrofit; this.credentials = credentials; this.customHeadersInterceptor = customHeadersInterceptor; + this.userAgentInterceptor = userAgentInterceptor; this.baseUrlHandler = baseUrlHandler; this.mapperAdapter = mapperAdapter; } @@ -92,7 +96,11 @@ public Retrofit retrofit() { * URL instead of the raw one might be returned. * * @return the base URL. +<<<<<<< HEAD * @see {@link RestClient#setBaseUrl(String...)} +======= + * @see RestClient#setBaseUrl(String...) +>>>>>>> fddca6a8917951772a65a3e5b47c5e72c1f42fb5 */ public String baseUrl() { return baseUrlHandler.baseUrl(); @@ -135,11 +143,13 @@ public static class Builder { private BaseUrlHandler baseUrlHandler; /** The adapter to a Jackson {@link com.fasterxml.jackson.databind.ObjectMapper}. */ private JacksonMapperAdapter mapperAdapter; + /** The interceptor to set 'User-Agent' header. */ + private UserAgentInterceptor userAgentInterceptor; /** * Creates an instance of the builder with a base URL to the service. * - * @param baseUrl the dynamic base URL with varialbes wrapped in "{" and "}". + * @param baseUrl the dynamic base URL with variables wrapped in "{" and "}". */ public Builder(String baseUrl) { this(baseUrl, new OkHttpClient.Builder(), new Retrofit.Builder()); @@ -148,7 +158,7 @@ public Builder(String baseUrl) { /** * Creates an instance of the builder with a base URL and 2 custom builders. * - * @param baseUrl the dynamic base URL with varialbes wrapped in "{" and "}". + * @param baseUrl the dynamic base URL with variables wrapped in "{" and "}". * @param httpClientBuilder the builder to build an {@link OkHttpClient}. * @param retrofitBuilder the builder to build a {@link Retrofit}. */ @@ -166,27 +176,15 @@ public Builder(String baseUrl, OkHttpClient.Builder httpClientBuilder, Retrofit. cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); customHeadersInterceptor = new CustomHeadersInterceptor(); baseUrlHandler = new BaseUrlHandler(baseUrl); + userAgentInterceptor = new UserAgentInterceptor(); // Set up OkHttp client this.httpClientBuilder = httpClientBuilder .cookieJar(new JavaNetCookieJar(cookieManager)) - .addInterceptor(new RetryHandler()) - .addInterceptor(new UserAgentInterceptor()); + .addInterceptor(userAgentInterceptor); // Set up rest adapter this.retrofitBuilder = retrofitBuilder.baseUrl(baseUrl); } - /** - * Sets the base URL. - * - * @param baseUrl the dynamic base URL. - * @return the builder itself for chaining. - */ - public Builder withBaseUrl(String baseUrl) { - this.retrofitBuilder.baseUrl(baseUrl); - this.baseUrlHandler = new BaseUrlHandler(baseUrl); - return this; - } - /** * Sets the user agent header. * @@ -194,7 +192,7 @@ public Builder withBaseUrl(String baseUrl) { * @return the builder itself for chaining. */ public Builder withUserAgent(String userAgent) { - this.httpClientBuilder.addInterceptor(new UserAgentInterceptor(userAgent)); + this.userAgentInterceptor.setUserAgent(userAgent); return this; } @@ -205,10 +203,7 @@ public Builder withUserAgent(String userAgent) { * @return the builder itself for chaining. */ public Builder withMapperAdapter(JacksonMapperAdapter mapperAdapter) { - if (mapperAdapter != null) { - this.mapperAdapter = mapperAdapter; - this.retrofitBuilder = retrofitBuilder.addConverterFactory(mapperAdapter.getConverterFactory()); - } + this.mapperAdapter = mapperAdapter; return this; } @@ -254,14 +249,22 @@ public Builder withInterceptor(Interceptor interceptor) { * @return a {@link RestClient}. */ public RestClient build() { + if (mapperAdapter == null) { + throw new IllegalArgumentException("Please set mapper adapter."); + } OkHttpClient httpClient = httpClientBuilder .addInterceptor(baseUrlHandler) .addInterceptor(customHeadersInterceptor) + .addInterceptor(new RetryHandler()) .build(); return new RestClient(httpClient, - retrofitBuilder.client(httpClient).build(), + retrofitBuilder + .client(httpClient) + .addConverterFactory(mapperAdapter.getConverterFactory()) + .build(), credentials, customHeadersInterceptor, + userAgentInterceptor, baseUrlHandler, mapperAdapter); } diff --git a/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java b/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java index ef2f8cae9cfec..674b6a1bc6253 100644 --- a/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java +++ b/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java @@ -20,6 +20,8 @@ public abstract class ServiceClient { /** * Initializes a new instance of the ServiceClient class. + * + * @param baseUrl the service endpoint */ protected ServiceClient(String baseUrl) { this(new RestClient.Builder(baseUrl) diff --git a/client-runtime/src/main/java/com/microsoft/rest/UserAgentInterceptor.java b/client-runtime/src/main/java/com/microsoft/rest/UserAgentInterceptor.java index 4c6c4f6ca5dff..ac4a5ec5a73c4 100644 --- a/client-runtime/src/main/java/com/microsoft/rest/UserAgentInterceptor.java +++ b/client-runtime/src/main/java/com/microsoft/rest/UserAgentInterceptor.java @@ -10,7 +10,6 @@ import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; -import okhttp3.internal.Version; import java.io.IOException; @@ -33,28 +32,44 @@ public class UserAgentInterceptor implements Interceptor { * 'User-Agent' header. */ public UserAgentInterceptor() { - this(DEFAULT_USER_AGENT_HEADER); + this.userAgent = DEFAULT_USER_AGENT_HEADER; } /** - * Initialize an instance of {@link UserAgentInterceptor} class with the specified - * 'User-Agent' header. + * Overwrite the User-Agent header. * - * @param userAgent the 'User-Agent' header value. + * @param userAgent the new user agent value. */ - public UserAgentInterceptor(String userAgent) { + public void setUserAgent(String userAgent) { this.userAgent = userAgent; } + /** + * Append a text to the User-Agent header. + * + * @param userAgent the user agent value to append. + */ + public void appendUserAgent(String userAgent) { + this.userAgent += " " + userAgent; + } + @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); String header = request.header("User-Agent"); - if (header == null || header.equals(Version.userAgent()) || header.equals(DEFAULT_USER_AGENT_HEADER)) { - request = chain.request().newBuilder() - .header("User-Agent", userAgent) - .build(); + if (header == null) { + header = DEFAULT_USER_AGENT_HEADER; + } + if (!userAgent.equals(DEFAULT_USER_AGENT_HEADER)) { + if (header.equals(DEFAULT_USER_AGENT_HEADER)) { + header = userAgent; + } else { + header = userAgent + " " + header; + } } + request = chain.request().newBuilder() + .header("User-Agent", header) + .build(); return chain.proceed(request); } } diff --git a/client-runtime/src/test/java/com/microsoft/rest/CredentialsTests.java b/client-runtime/src/test/java/com/microsoft/rest/CredentialsTests.java index 19b7a8ca2a4f5..3e05c5d723fdb 100644 --- a/client-runtime/src/test/java/com/microsoft/rest/CredentialsTests.java +++ b/client-runtime/src/test/java/com/microsoft/rest/CredentialsTests.java @@ -9,6 +9,7 @@ import com.microsoft.rest.credentials.BasicAuthenticationCredentials; import com.microsoft.rest.credentials.TokenCredentials; +import com.microsoft.rest.serializer.JacksonMapperAdapter; import org.junit.Assert; import org.junit.Test; @@ -29,6 +30,7 @@ public void basicCredentialsTest() throws Exception { Retrofit.Builder retrofitBuilder = new Retrofit.Builder(); BasicAuthenticationCredentials credentials = new BasicAuthenticationCredentials("user", "pass"); RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder) + .withMapperAdapter(new JacksonMapperAdapter()) .withCredentials(credentials) .withInterceptor(new Interceptor() { @Override @@ -53,6 +55,7 @@ public void tokenCredentialsTest() throws Exception { Retrofit.Builder retrofitBuilder = new Retrofit.Builder(); TokenCredentials credentials = new TokenCredentials(null, "this_is_a_token"); RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder) + .withMapperAdapter(new JacksonMapperAdapter()) .withCredentials(credentials) .withInterceptor(new Interceptor() { @Override diff --git a/client-runtime/src/test/java/com/microsoft/rest/RetryHandlerTests.java b/client-runtime/src/test/java/com/microsoft/rest/RetryHandlerTests.java index 050e7374aba18..97c46f6fe4fc3 100644 --- a/client-runtime/src/test/java/com/microsoft/rest/RetryHandlerTests.java +++ b/client-runtime/src/test/java/com/microsoft/rest/RetryHandlerTests.java @@ -9,6 +9,7 @@ import com.microsoft.rest.retry.RetryHandler; +import com.microsoft.rest.serializer.JacksonMapperAdapter; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Protocol; @@ -41,7 +42,8 @@ public Response intercept(Chain chain) throws IOException { .build(); } }); - RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder); + RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder) + .withMapperAdapter(new JacksonMapperAdapter()); ServiceClient serviceClient = new ServiceClient(restBuilder.build()) { }; Response response = serviceClient.restClient().httpClient().newCall( new Request.Builder().url("http://localhost").get().build()).execute(); @@ -67,7 +69,8 @@ public Response intercept(Chain chain) throws IOException { .build(); } }); - RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder); + RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder) + .withMapperAdapter(new JacksonMapperAdapter()); ServiceClient serviceClient = new ServiceClient(restBuilder.build()) { }; Response response = serviceClient.restClient().httpClient().newCall( new Request.Builder().url("http://localhost").get().build()).execute(); diff --git a/client-runtime/src/test/java/com/microsoft/rest/ServiceClientTests.java b/client-runtime/src/test/java/com/microsoft/rest/ServiceClientTests.java index 5497d607549d7..6423ef23d8081 100644 --- a/client-runtime/src/test/java/com/microsoft/rest/ServiceClientTests.java +++ b/client-runtime/src/test/java/com/microsoft/rest/ServiceClientTests.java @@ -7,8 +7,10 @@ package com.microsoft.rest; +import com.microsoft.rest.serializer.JacksonMapperAdapter; import org.junit.Assert; import org.junit.Test; +import retrofit2.Retrofit; import java.io.IOException; @@ -17,7 +19,6 @@ import okhttp3.Protocol; import okhttp3.Request; import okhttp3.Response; -import retrofit2.Retrofit; public class ServiceClientTests { @Test @@ -38,7 +39,8 @@ public Response intercept(Chain chain) throws IOException { .build(); } }); - RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder); + RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder) + .withMapperAdapter(new JacksonMapperAdapter()); ServiceClient serviceClient = new ServiceClient(restBuilder.build()) { }; Response response = serviceClient.restClient().httpClient().newCall(new Request.Builder().url("http://localhost").build()).execute(); Assert.assertEquals(200, response.code()); diff --git a/client-runtime/src/test/java/com/microsoft/rest/UserAgentTests.java b/client-runtime/src/test/java/com/microsoft/rest/UserAgentTests.java index e6b938f933683..35970714e3a83 100644 --- a/client-runtime/src/test/java/com/microsoft/rest/UserAgentTests.java +++ b/client-runtime/src/test/java/com/microsoft/rest/UserAgentTests.java @@ -7,56 +7,62 @@ package com.microsoft.rest; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.Protocol; -import okhttp3.Response; -import retrofit2.Retrofit; +import com.microsoft.rest.serializer.JacksonMapperAdapter; import org.junit.Assert; import org.junit.Test; import java.io.IOException; +import okhttp3.Interceptor; +import okhttp3.Protocol; +import okhttp3.Request; +import okhttp3.Response; + public class UserAgentTests { @Test public void defaultUserAgentTests() throws Exception { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); - Retrofit.Builder retrofitBuilder = new Retrofit.Builder(); - clientBuilder.addInterceptor(new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - String header = chain.request().header("User-Agent"); - Assert.assertEquals("AutoRest-Java", header); - return new Response.Builder() - .request(chain.request()) - .code(200) - .protocol(Protocol.HTTP_1_1) - .build(); - } - }); - RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder); + RestClient.Builder restBuilder = new RestClient.Builder("http://localhost") + .withInterceptor(new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + String header = chain.request().header("User-Agent"); + Assert.assertEquals("AutoRest-Java", header); + return new Response.Builder() + .request(chain.request()) + .code(200) + .protocol(Protocol.HTTP_1_1) + .build(); + } + }) + .withMapperAdapter(new JacksonMapperAdapter()); ServiceClient serviceClient = new ServiceClient(restBuilder.build()) { }; + Response response = serviceClient.restClient().httpClient() + .newCall(new Request.Builder().get().url("http://localhost").build()).execute(); + Assert.assertEquals(200, response.code()); } @Test public void customUserAgentTests() throws Exception { - OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); - Retrofit.Builder retrofitBuilder = new Retrofit.Builder(); - clientBuilder.addInterceptor(new UserAgentInterceptor("Awesome")); - clientBuilder.addInterceptor(new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - String header = chain.request().header("User-Agent"); - Assert.assertEquals("Awesome", header); - return new Response.Builder() - .request(chain.request()) - .code(200) - .protocol(Protocol.HTTP_1_1) - .build(); - } - }); - RestClient.Builder restBuilder = new RestClient.Builder("http://localhost", clientBuilder, retrofitBuilder); + + RestClient.Builder restBuilder = new RestClient.Builder("http://localhost") + .withUserAgent("Awesome") + .withInterceptor(new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + String header = chain.request().header("User-Agent"); + Assert.assertEquals("Awesome", header); + return new Response.Builder() + .request(chain.request()) + .code(200) + .protocol(Protocol.HTTP_1_1) + .build(); + } + }) + .withMapperAdapter(new JacksonMapperAdapter()); ServiceClient serviceClient = new ServiceClient(restBuilder.build()) { }; + Response response = serviceClient.restClient().httpClient() + .newCall(new Request.Builder().get().url("http://localhost").build()).execute(); + Assert.assertEquals(200, response.code()); } } diff --git a/client-runtime/src/test/java/com/microsoft/rest/package-info.java b/client-runtime/src/test/java/com/microsoft/rest/package-info.java deleted file mode 100644 index 137d82e99154e..0000000000000 --- a/client-runtime/src/test/java/com/microsoft/rest/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * The package contains the tests for the client runtime. - */ -package com.microsoft.rest; \ No newline at end of file diff --git a/pom.xml b/pom.xml index 98b38905b457f..b6bb0bb29b042 100644 --- a/pom.xml +++ b/pom.xml @@ -44,28 +44,8 @@ - azureoss-snapshots-pr - Azure Private Snapshots - http://azureoss.westus.cloudapp.azure.com:8080/nexus/content/repositories/snapshots-pr/ - default - - true - always - - - - adx-snapshots - Azure ADX Snapshots - http://adxsnapshots.azurewebsites.net - default - - true - always - - - - oss-snapshots - Open Source Snapshots + ossrh + Sonatype Snapshots https://oss.sonatype.org/content/repositories/snapshots/ default @@ -77,12 +57,17 @@ - adx-snapshots - Azure ADX Snapshots - ftp://waws-prod-bay-005.ftp.azurewebsites.windows.net/site/wwwroot + ossrh + Maven Central Snapshots + https://oss.sonatype.org/content/repositories/snapshots true default + + ossrh + Maven Central + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + @@ -158,23 +143,6 @@ - - org.apache.maven.plugins - maven-help-plugin - 2.1.1 - - - validate - - evaluate - - - legal - - - - - org.apache.maven.plugins maven-compiler-plugin @@ -201,12 +169,6 @@
    */]]>
    - - - org.apache.maven.plugins - maven-release-plugin - 2.5.3 -
    @@ -238,7 +200,6 @@
    - org.apache.maven.plugins maven-release-plugin From 4056423e9e4092bfd4d980462eb339177cacfcf2 Mon Sep 17 00:00:00 2001 From: anuchan Date: Fri, 20 May 2016 14:50:21 -0700 Subject: [PATCH 15/30] Addressing more checkstyle errors --- .../compute/VirtualMachineImage.java | 101 ++++++++++++++++-- .../compute/VirtualMachineImages.java | 4 + .../compute/VirtualMachineSize.java | 2 +- .../management/compute/VirtualMachines.java | 5 + 4 files changed, 100 insertions(+), 12 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java index 02c6cf94dcffd..d2e0363ee9f1e 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImage.java @@ -1,40 +1,106 @@ 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 { + /** + * 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 dataDiskImages(); + /** + * Represents a virtual image image publisher. + */ interface Publisher { /** - * Gets the region where virtual machine images from this publisher is available + * 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 + * 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 + * Lists the virtual machine image offers from this publisher in the specific region. + * * @return list of virtual machine image offers * @throws CloudException * @throws IOException @@ -42,48 +108,61 @@ interface Publisher { List listOffers() throws CloudException, IOException; } + /** + * Represents a virtual machine image offer. + */ interface Offer { /** - * Gets the region where this virtual machine image offer is available + * 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 + * 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 + * Gets the name of the virtual machine image offer. + * * @return The offer name */ String offer(); List listSkus() throws CloudException, IOException; } + /** + * Represents a virtual machine image SKU. + */ interface Sku { /** - * Gets the region where this virtual machine image offer SKU is available + * 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 + * 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 + * 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) + * Gets the commercial name of the virtual machine image (SKU). + * * @return The SKU name */ String sku(); diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java index f73421189ce32..91cf47683ae6e 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java @@ -7,10 +7,14 @@ import java.io.IOException; import java.util.List; +/** + * The type representing Azure virtual machine image collection. + */ public interface VirtualMachineImages extends SupportsListingByLocation { /** * Lists the virtual machine publishers in a region. + * * @param region The region * @return The list of VM image publishers * @throws CloudException diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java index b386d44fbe8d9..b8a7aacbb797f 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineSize.java @@ -30,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(); } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java index a6862840c70d3..32950739550d7 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java @@ -11,6 +11,9 @@ import java.io.IOException; +/** + * The type representing Azure virtual machine collection. + */ public interface VirtualMachines extends SupportsListing, SupportsListingByGroup, @@ -20,6 +23,7 @@ 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<VirtualMachineSize> if successful. * @throws CloudException @@ -32,6 +36,7 @@ interface InGroup extends SupportsDeleting { /** * Lists all available virtual machine sizes in a region. + * * @param region The region upon which virtual-machine-sizes is queried. * @return the List<VirtualMachineSize> if successful. * @throws CloudException From 7ed9047c39002d5e6925e1ce86ca45b97afbb38c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 May 2016 14:56:11 -0700 Subject: [PATCH 16/30] AvailabilitySet refinements, javadocs, bug fixes --- .../management/compute/AvailabilitySet.java | 58 ++++++++++++++----- .../management/compute/AvailabilitySets.java | 6 ++ .../implementation/AvailabilitySetImpl.java | 27 ++++----- .../resources/fluentcore/arm/Region.java | 2 +- .../fluentcore/arm/models/Resource.java | 2 +- .../implementation/GroupableResourceImpl.java | 2 +- 6 files changed, 63 insertions(+), 34 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySet.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySet.java index 8720685da6419..b47330185188b 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySet.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySet.java @@ -9,60 +9,90 @@ import java.util.List; +/** + * An immutable client-side representation of an Azure availability set. + */ public interface AvailabilitySet extends GroupableResource, Refreshable, Wrapper { /** - * Get the update domain count of availability set, an update domain represents the group of virtual + * Returns the update domain count of an availability set. + *

    + * An update domain represents the group of virtual * machines and underlying physical hardware that can be rebooted at the same time. * - * @return the platformUpdateDomainCount value + * @return the update domain count */ - Integer updateDomainCount(); + int updateDomainCount(); /** - * Get the fault domain count of availability set., a fault domain represents the group of virtual + * Returns the fault domain count of availability set. + *

    + * A fault domain represents the group of virtual * machines that shares common power source and network switch. * - * @return the platformUpdateDomainCount value + * @return the fault domain count */ - Integer FaultDomainCount(); + int faultDomainCount(); /** - * Get the list of ids of virtual machines in the availability set. + * Lists the resource IDs of the virtual machines in the availability set. * - * @return the virtualMachineIds value + * @return list of resource ID strings */ List virtualMachineIds(); /** - * Get the list of virtual machines in the availability set. + * Lists the virtual machines in the availability set. * - * @return the virtualMachineIds value + * @return list of virtual machines */ List virtualMachines() throws Exception; /** - * Get the statuses value. + * Lists the statuses of the existing virtual machines in the availability set. * - * @return the statuses value + * @return list of virtual machine statuses */ List statuses(); + /************************************************************** * Fluent interfaces to provision an AvailabilitySet **************************************************************/ + /** + * The first stage of an availability set definition + */ interface DefinitionBlank extends GroupableResource.DefinitionWithRegion { } + /** + * The stage of the availability set definition allowing to specify the resource group + */ interface DefinitionWithGroup extends GroupableResource.DefinitionWithGroup { } + /** + * The stage of an availability set definition which contains all the minimum required inputs for + * the resource to be created (via {@link DefinitionCreatable#create()}), but also allows + * for any other optional settings to be specified. + */ interface DefinitionCreatable extends Creatable { - DefinitionCreatable withUpdateDomainCount(Integer updateDomainCount); - DefinitionCreatable withFaultDomainCount(Integer faultDomainCount); + /** + * Specifies the update domain count for the availability set. + * @param updateDomainCount update domain count + * @return the next stage of the resource definition + */ + DefinitionCreatable withUpdateDomainCount(int updateDomainCount); + + /** + * Specifies the fault domain count for the availability set. + * @param faultDomainCount fault domain count + * @return the next stage of the resource definition + */ + DefinitionCreatable withFaultDomainCount(int faultDomainCount); } } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java index 59197b8baee41..50548277d1863 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/AvailabilitySets.java @@ -7,6 +7,9 @@ import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; +/** + * Entry point to availability set management API. + */ public interface AvailabilitySets extends SupportsListing, SupportsListingByGroup, @@ -14,6 +17,9 @@ public interface AvailabilitySets extends SupportsCreating, SupportsDeleting, SupportsDeletingByGroup { + /** + * Entry point to availability set management API within a specific resource group. + */ interface InGroup extends SupportsListing, SupportsCreating, diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java index d6ecf1b48a920..d47862c5fbe97 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/AvailabilitySetImpl.java @@ -14,6 +14,7 @@ import com.microsoft.rest.ServiceResponse; import java.util.ArrayList; +import java.util.Collections; import java.util.List; class AvailabilitySetImpl @@ -23,7 +24,6 @@ class AvailabilitySetImpl AvailabilitySet.DefinitionBlank, AvailabilitySet.DefinitionWithGroup, AvailabilitySet.DefinitionCreatable { - private String name; private List idOfVMsInSet; private List vmsInSet; @@ -37,19 +37,18 @@ class AvailabilitySetImpl final AvailabilitySetsInner client, final ResourceGroups resourceGroups, final VirtualMachines virtualMachines) { - super(innerModel.id(), innerModel, resourceGroups); - this.name = name; + super(name, innerModel, resourceGroups); this.client = client; this.virtualMachines = virtualMachines; } @Override - public Integer updateDomainCount() { + public int updateDomainCount() { return this.inner().platformUpdateDomainCount(); } @Override - public Integer FaultDomainCount() { + public int faultDomainCount() { return this.inner().platformFaultDomainCount(); } @@ -62,7 +61,7 @@ public List virtualMachineIds() { } } - return idOfVMsInSet; + return Collections.unmodifiableList(idOfVMsInSet); } @Override @@ -75,18 +74,12 @@ public VirtualMachine load(String resourceGroupName, String resourceName) throws } }); } - return vmsInSet; + return Collections.unmodifiableList(vmsInSet); } @Override public List statuses() { - return this.inner().statuses(); - } - - @Override - public String name() { - // TODO: This method should be removed once once Runtime::Resource::setName is available. - return this.name; + return Collections.unmodifiableList(this.inner().statuses()); } @Override @@ -99,13 +92,13 @@ public AvailabilitySet refresh() throws Exception { } @Override - public AvailabilitySetImpl withUpdateDomainCount(Integer updateDomainCount) { + public AvailabilitySetImpl withUpdateDomainCount(int updateDomainCount) { this.inner().setPlatformUpdateDomainCount(updateDomainCount); return this; } @Override - public AvailabilitySetImpl withFaultDomainCount(Integer faultDomainCount) { + public AvailabilitySetImpl withFaultDomainCount(int faultDomainCount) { this.inner().setPlatformFaultDomainCount(faultDomainCount); return this; } @@ -115,7 +108,7 @@ public AvailabilitySetImpl create() throws Exception { for (Creatable provisionable : prerequisites().values()) { provisionable.create(); } - ServiceResponse response = this.client.createOrUpdate(this.resourceGroupName(), this.name(), this.inner()); + ServiceResponse response = this.client.createOrUpdate(this.resourceGroupName(), this.key, this.inner()); AvailabilitySetInner availabilitySetInner = response.getBody(); this.setInner(availabilitySetInner); this.idOfVMsInSet = null; diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/Region.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/Region.java index 0aedd4c77b830..db1d234251ea3 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/Region.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/Region.java @@ -8,7 +8,7 @@ public enum Region { US_CENTRAL("centralus", "Central US"), US_EAST("eastus", "East US"), US_EAST2("eastus2", "East US 2"), - US_NORTH_CENTRAL("nothcentralus", "North Central US"), + US_NORTH_CENTRAL("northcentralus", "North Central US"), US_SOUTH_CENTRAL("southcentralus", "South Central US"), EUROPE_NORTH("northeurope", "North Europe"), EUROPE_WEST("westeurope", "West Europe"), diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java index 4529b294175fb..7f505b624793a 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/Resource.java @@ -17,7 +17,7 @@ public interface Resource extends Indexable { */ interface DefinitionWithRegion { /** - * @param regionName The name of the location for the resource + * @param regionName The name of the region for the resource * @return The next stage of the resource definition */ T withRegion(String regionName); diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java index a5817954eea94..ea5a4f34575b6 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java @@ -63,7 +63,7 @@ public final FluentModelImplT withNewGroup(String groupName) { } public final FluentModelImplT withNewGroup() { - return this.withNewGroup(this.name() + "group"); + return this.withNewGroup(this.key() + "group"); } @SuppressWarnings("unchecked") From f35826e0a026a1f5a7a99d8b99fc22d79b2e6cdb Mon Sep 17 00:00:00 2001 From: anuchan Date: Fri, 20 May 2016 15:35:16 -0700 Subject: [PATCH 17/30] Addressing more stylecheck errors --- .../azure/management/compute/VirtualMachineImages.java | 4 ++-- .../azure/management/compute/VirtualMachines.java | 8 ++++++-- .../compute/implementation/VirtualMachineImpl.java | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java index 91cf47683ae6e..59cffaa8a1a19 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachineImages.java @@ -17,8 +17,8 @@ public interface VirtualMachineImages extends * * @param region The region * @return The list of VM image publishers - * @throws CloudException - * @throws IOException + * @throws CloudException Thrown for an invalid response from the service. + * @throws IOException Thrown for IO exception. */ List listPublishers(final Region region) throws CloudException, IOException; } diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java index 32950739550d7..1f37b5aab7a48 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachines.java @@ -26,10 +26,14 @@ public interface VirtualMachines extends * * @param region The region upon which virtual-machine-sizes is queried. * @return the List<VirtualMachineSize> if successful. - * @throws CloudException - * @throws IOException + * @throws CloudException Thrown for an invalid response from the service. + * @throws IOException Thrown for IO exception. */ PagedList listSizes(String region) throws CloudException, IOException; + + /** + * A type representing Azure virtual machine under a resource gorup. + */ interface InGroup extends SupportsListing, SupportsCreating, diff --git a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java index f97d2b1605977..9df87884dad51 100644 --- a/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java @@ -12,6 +12,9 @@ import java.util.List; import java.util.UUID; +/** + * The type representing Azure virtual machine. + */ class VirtualMachineImpl extends GroupableResourceImpl implements @@ -507,6 +510,6 @@ private DataDisk currentDataDisk() { } private String blobUrl(String storageAccountName, String containerName, String blobName) { - return storageAccountName + ".blob.core.windows.net" + "/" + containerName + "/" + blobName ; + return storageAccountName + ".blob.core.windows.net" + "/" + containerName + "/" + blobName; } } From 63aa47f1c9cd848a7c5c9bcd96cfdcef2aaaca44 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 20 May 2016 17:34:26 -0700 Subject: [PATCH 18/30] Optional suppression file for maven scenario --- runtimes/checkstyle/checkstyle.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtimes/checkstyle/checkstyle.xml b/runtimes/checkstyle/checkstyle.xml index d2b92aa67f9ef..d156ff63e65f6 100644 --- a/runtimes/checkstyle/checkstyle.xml +++ b/runtimes/checkstyle/checkstyle.xml @@ -38,6 +38,7 @@ + + + 4.0.0 + + com.microsoft.azure + autorest-clientruntime-for-java + 1.0.0-SNAPSHOT + ../pom.xml + + + autorest-build-tools + jar + + Build tools for AutoRest client runtime for Java + This package contains the build tools for AutoRest generated Java clients. + https://github.com/Azure/autorest-clientruntime-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/autorest-clientruntime-for-java + scm:git:git@github.com:Azure/autorest-clientruntime-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + diff --git a/runtimes/checkstyle/checkstyle.xml b/runtimes/build-tools/src/main/resources/checkstyle.xml similarity index 100% rename from runtimes/checkstyle/checkstyle.xml rename to runtimes/build-tools/src/main/resources/checkstyle.xml diff --git a/runtimes/checkstyle/suppressions.xml b/runtimes/build-tools/src/main/resources/suppressions.xml similarity index 100% rename from runtimes/checkstyle/suppressions.xml rename to runtimes/build-tools/src/main/resources/suppressions.xml diff --git a/runtimes/client-runtime/pom.xml b/runtimes/client-runtime/pom.xml index 35af73ebb9a15..a7c0b7441b02c 100644 --- a/runtimes/client-runtime/pom.xml +++ b/runtimes/client-runtime/pom.xml @@ -36,8 +36,6 @@ UTF-8 - ${project.basedir}/../../tools/checkstyle.xml - ${project.basedir}/../../tools/suppressions.xml diff --git a/runtimes/pom.xml b/runtimes/pom.xml index 11ef8bb1ce53d..51a8ab8ffdcc5 100644 --- a/runtimes/pom.xml +++ b/runtimes/pom.xml @@ -31,8 +31,6 @@ UTF-8 - ${project.basedir}/../tools/checkstyle.xml - ${project.basedir}/../tools/suppressions.xml @@ -144,6 +142,29 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.17 + + + com.microsoft.azure + autorest-build-tools + 1.0.0-SNAPSHOT + + + com.puppycrawl.tools + checkstyle + 6.18 + + + + checkstyle.xml + samedir=build-tools/src/main/resources + suppressions.xml + + + org.apache.maven.plugins maven-compiler-plugin @@ -201,8 +222,9 @@ - ./client-runtime - ./azure-client-runtime - ./azure-client-authentication + build-tools + client-runtime + azure-client-runtime + azure-client-authentication From caa713ba193a5525f723d8b40940631cb16e0b6a Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 23 May 2016 14:42:41 -0700 Subject: [PATCH 29/30] Update travis to install build tools --- runtimes/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/.travis.yml b/runtimes/.travis.yml index 31d396e9f0281..05c26fa53735e 100644 --- a/runtimes/.travis.yml +++ b/runtimes/.travis.yml @@ -9,6 +9,6 @@ android: - extra-android-m2repository sudo: false script: - - mvn clean package + - mvn clean install - mvn checkstyle:check - cd ./azure-android-client-authentication && ./gradlew check From 0074034fc500ca2abde462a5ef6a257fa5b1263f Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 23 May 2016 14:51:14 -0700 Subject: [PATCH 30/30] Making corresponding changes to gradle --- runtimes/azure-client-authentication/build.gradle | 7 ++++--- runtimes/azure-client-runtime/build.gradle | 8 ++++---- runtimes/client-runtime/build.gradle | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/runtimes/azure-client-authentication/build.gradle b/runtimes/azure-client-authentication/build.gradle index 75d0404be1f54..7c4d070dc10a5 100644 --- a/runtimes/azure-client-authentication/build.gradle +++ b/runtimes/azure-client-authentication/build.gradle @@ -13,9 +13,10 @@ apply plugin: 'checkstyle' version = '1.0.0-SNAPSHOT' checkstyle { - configFile = new File("$rootDir/ClientRuntimes/Java/checkstyle/checkstyle.xml") - configProperties = [samedir: "$rootDir/ClientRuntimes/Java/checkstyle"] - reportsDir = new File("$rootDir/ClientRuntimes/Java/checkstyle/reports") + toolVersion = "6.18" + configFile = new File("$rootDir/ClientRuntimes/Java/build-tools/src/main/resources/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/build-tools/src/main/resources"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/build-tools/reports") } dependencies { diff --git a/runtimes/azure-client-runtime/build.gradle b/runtimes/azure-client-runtime/build.gradle index 775736ec22dba..5c29359536abc 100644 --- a/runtimes/azure-client-runtime/build.gradle +++ b/runtimes/azure-client-runtime/build.gradle @@ -13,10 +13,10 @@ apply plugin: 'checkstyle' version = '1.0.0-SNAPSHOT' checkstyle { - toolVersion = "6.9" - configFile = new File("$rootDir/ClientRuntimes/Java/checkstyle/checkstyle.xml") - configProperties = [samedir: "$rootDir/ClientRuntimes/Java/checkstyle"] - reportsDir = new File("$rootDir/ClientRuntimes/Java/checkstyle/reports") + toolVersion = "6.18" + configFile = new File("$rootDir/ClientRuntimes/Java/build-tools/src/main/resources/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/build-tools/src/main/resources"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/build-tools/reports") } dependencies { diff --git a/runtimes/client-runtime/build.gradle b/runtimes/client-runtime/build.gradle index b17a86a50eadf..a163e9a9f89f1 100644 --- a/runtimes/client-runtime/build.gradle +++ b/runtimes/client-runtime/build.gradle @@ -15,10 +15,10 @@ group = 'com.microsoft.rest' version = '1.0.0-SNAPSHOT' checkstyle { - toolVersion = "6.9" - configFile = new File("$rootDir/ClientRuntimes/Java/checkstyle/checkstyle.xml") - configProperties = [samedir: "$rootDir/ClientRuntimes/Java/checkstyle"] - reportsDir = new File("$rootDir/ClientRuntimes/Java/checkstyle/reports") + toolVersion = "6.18" + configFile = new File("$rootDir/ClientRuntimes/Java/build-tools/src/main/resources/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/build-tools/src/main/resources"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/build-tools/reports") } dependencies {