From 2a2a77d02fefd79f3919b23cf9a3f2caf37905ff Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 15 Mar 2022 13:51:00 +0800 Subject: [PATCH] mgmt, compute, improve javadoc (#27667) * mgmt, compute, improve javadoc * compute, virtualMachineSizeType as typed alias of name in VirtualMachineSize --- .../azure-resourcemanager-compute/CHANGELOG.md | 6 +----- .../compute/implementation/ComputeSkuImpl.java | 2 +- .../implementation/VirtualMachineSizeImpl.java | 10 ++++++++++ .../compute/models/VirtualMachine.java | 13 +++++++++++++ .../compute/models/VirtualMachineSize.java | 10 ++++++++++ .../azure/resourcemanager/TestAvailabilitySet.java | 1 + 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md b/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md index 90931dfe55cd9..b94269455370e 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md +++ b/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md @@ -4,11 +4,7 @@ ### Features Added -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- Supported `virtualMachineSizeType()` in `VirtualMachineSize` as a typed alias of `name`. ## 2.13.0 (2022-03-11) diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/ComputeSkuImpl.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/ComputeSkuImpl.java index d8b03dbe8e38a..318defddc4e10 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/ComputeSkuImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/ComputeSkuImpl.java @@ -65,7 +65,7 @@ public ComputeResourceType resourceType() { @Override public VirtualMachineSizeTypes virtualMachineSizeType() { if (this.inner.resourceType() != null - && this.inner.resourceType().equalsIgnoreCase("virtualMachines") + && this.inner.resourceType().equalsIgnoreCase(ComputeResourceType.VIRTUALMACHINES.toString()) && this.inner.name() != null) { return VirtualMachineSizeTypes.fromString(this.inner.name()); } else { diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineSizeImpl.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineSizeImpl.java index f429307a69ab2..fe50b6e3532de 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineSizeImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineSizeImpl.java @@ -4,6 +4,7 @@ import com.azure.resourcemanager.compute.models.VirtualMachineSize; import com.azure.resourcemanager.compute.fluent.models.VirtualMachineSizeInner; +import com.azure.resourcemanager.compute.models.VirtualMachineSizeTypes; import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils; /** The implementation for {@link VirtualMachineSize}. */ @@ -43,4 +44,13 @@ public int memoryInMB() { public int maxDataDiskCount() { return ResourceManagerUtils.toPrimitiveInt(innerModel.maxDataDiskCount()); } + + @Override + public VirtualMachineSizeTypes virtualMachineSizeType() { + if (this.innerModel.name() != null) { + return VirtualMachineSizeTypes.fromString(this.innerModel.name()); + } else { + return null; + } + } } diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachine.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachine.java index 8237753bf6f9e..96b49f08bca52 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachine.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachine.java @@ -5,6 +5,7 @@ import com.azure.core.annotation.Fluent; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.Region; import com.azure.resourcemanager.authorization.models.BuiltInRole; import com.azure.resourcemanager.compute.ComputeManager; import com.azure.resourcemanager.compute.fluent.models.VirtualMachineInner; @@ -1233,6 +1234,9 @@ interface WithVMSize { /** * Selects the size of the virtual machine. * + * See {@link ComputeSkus#listByRegion(Region)} for virtual machine sizes in region, + * and {@link AvailabilitySet#listVirtualMachineSizes()} for virtual machine sizes in availability set. + * * @param sizeName the name of a size for the virtual machine as text * @return the next stage of the definition */ @@ -1241,6 +1245,10 @@ interface WithVMSize { /** * Specifies the size of the virtual machine. * + * {@link VirtualMachineSizeTypes} is not the complete list of virtual machine sizes. + * See {@link ComputeSkus#listByRegion(Region)} for virtual machine sizes in region, + * and {@link AvailabilitySet#listVirtualMachineSizes()} for virtual machine sizes in availability set. + * * @param size a size from the list of available sizes for the virtual machine * @return the next stage of the definition */ @@ -2440,6 +2448,8 @@ interface Update /** * Specifies a new size for the virtual machine. * + * See {@link VirtualMachine#availableSizes()} for resizing. + * * @param sizeName the name of a size for the virtual machine as text * @return the next stage of the update */ @@ -2448,6 +2458,9 @@ interface Update /** * Specifies a new size for the virtual machine. * + * {@link VirtualMachineSizeTypes} is not the complete list of virtual machine sizes. + * See {@link VirtualMachine#availableSizes()} for resizing. + * * @param size a size from the list of available sizes for the virtual machine * @return the next stage of the definition */ diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachineSize.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachineSize.java index d03ed97697921..e18ca5ed2b5ac 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachineSize.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachineSize.java @@ -22,4 +22,14 @@ public interface VirtualMachineSize extends HasName { /** @return the maximum number of data disks allowed by a VM size */ int maxDataDiskCount(); + + /** + * The virtual machine size type if the sku describes sku for virtual machine resource type. + * + *

The size can be used for {@link VirtualMachine.DefinitionStages.WithVMSize#withSize(VirtualMachineSizeTypes)} + * and {@link VirtualMachine.Update#withSize(VirtualMachineSizeTypes)}. + * + * @return the virtual machine size type + */ + VirtualMachineSizeTypes virtualMachineSizeType(); } diff --git a/sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/TestAvailabilitySet.java b/sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/TestAvailabilitySet.java index 22c522a6a365a..62982c15344ee 100644 --- a/sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/TestAvailabilitySet.java +++ b/sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/TestAvailabilitySet.java @@ -27,6 +27,7 @@ public AvailabilitySet createResource(AvailabilitySets availabilitySets) throws Assertions.assertTrue(TestUtilities.getSize(vmSizes) > 0); for (VirtualMachineSize vmSize : vmSizes) { Assertions.assertNotNull(vmSize.name()); + Assertions.assertNotNull(vmSize.virtualMachineSizeType()); } return aset; }