Skip to content

Commit 2a2a77d

Browse files
mgmt, compute, improve javadoc (Azure#27667)
* mgmt, compute, improve javadoc * compute, virtualMachineSizeType as typed alias of name in VirtualMachineSize
1 parent 48cb91c commit 2a2a77d

File tree

6 files changed

+36
-6
lines changed

6 files changed

+36
-6
lines changed

sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
### Features Added
66

7-
### Breaking Changes
8-
9-
### Bugs Fixed
10-
11-
### Other Changes
7+
- Supported `virtualMachineSizeType()` in `VirtualMachineSize` as a typed alias of `name`.
128

139
## 2.13.0 (2022-03-11)
1410

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/ComputeSkuImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public ComputeResourceType resourceType() {
6565
@Override
6666
public VirtualMachineSizeTypes virtualMachineSizeType() {
6767
if (this.inner.resourceType() != null
68-
&& this.inner.resourceType().equalsIgnoreCase("virtualMachines")
68+
&& this.inner.resourceType().equalsIgnoreCase(ComputeResourceType.VIRTUALMACHINES.toString())
6969
&& this.inner.name() != null) {
7070
return VirtualMachineSizeTypes.fromString(this.inner.name());
7171
} else {

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineSizeImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.azure.resourcemanager.compute.models.VirtualMachineSize;
66
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineSizeInner;
7+
import com.azure.resourcemanager.compute.models.VirtualMachineSizeTypes;
78
import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils;
89

910
/** The implementation for {@link VirtualMachineSize}. */
@@ -43,4 +44,13 @@ public int memoryInMB() {
4344
public int maxDataDiskCount() {
4445
return ResourceManagerUtils.toPrimitiveInt(innerModel.maxDataDiskCount());
4546
}
47+
48+
@Override
49+
public VirtualMachineSizeTypes virtualMachineSizeType() {
50+
if (this.innerModel.name() != null) {
51+
return VirtualMachineSizeTypes.fromString(this.innerModel.name());
52+
} else {
53+
return null;
54+
}
55+
}
4656
}

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachine.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.azure.core.annotation.Fluent;
77
import com.azure.core.http.rest.PagedIterable;
8+
import com.azure.core.management.Region;
89
import com.azure.resourcemanager.authorization.models.BuiltInRole;
910
import com.azure.resourcemanager.compute.ComputeManager;
1011
import com.azure.resourcemanager.compute.fluent.models.VirtualMachineInner;
@@ -1233,6 +1234,9 @@ interface WithVMSize {
12331234
/**
12341235
* Selects the size of the virtual machine.
12351236
*
1237+
* See {@link ComputeSkus#listByRegion(Region)} for virtual machine sizes in region,
1238+
* and {@link AvailabilitySet#listVirtualMachineSizes()} for virtual machine sizes in availability set.
1239+
*
12361240
* @param sizeName the name of a size for the virtual machine as text
12371241
* @return the next stage of the definition
12381242
*/
@@ -1241,6 +1245,10 @@ interface WithVMSize {
12411245
/**
12421246
* Specifies the size of the virtual machine.
12431247
*
1248+
* {@link VirtualMachineSizeTypes} is not the complete list of virtual machine sizes.
1249+
* See {@link ComputeSkus#listByRegion(Region)} for virtual machine sizes in region,
1250+
* and {@link AvailabilitySet#listVirtualMachineSizes()} for virtual machine sizes in availability set.
1251+
*
12441252
* @param size a size from the list of available sizes for the virtual machine
12451253
* @return the next stage of the definition
12461254
*/
@@ -2440,6 +2448,8 @@ interface Update
24402448
/**
24412449
* Specifies a new size for the virtual machine.
24422450
*
2451+
* See {@link VirtualMachine#availableSizes()} for resizing.
2452+
*
24432453
* @param sizeName the name of a size for the virtual machine as text
24442454
* @return the next stage of the update
24452455
*/
@@ -2448,6 +2458,9 @@ interface Update
24482458
/**
24492459
* Specifies a new size for the virtual machine.
24502460
*
2461+
* {@link VirtualMachineSizeTypes} is not the complete list of virtual machine sizes.
2462+
* See {@link VirtualMachine#availableSizes()} for resizing.
2463+
*
24512464
* @param size a size from the list of available sizes for the virtual machine
24522465
* @return the next stage of the definition
24532466
*/

sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/models/VirtualMachineSize.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,14 @@ public interface VirtualMachineSize extends HasName {
2222

2323
/** @return the maximum number of data disks allowed by a VM size */
2424
int maxDataDiskCount();
25+
26+
/**
27+
* The virtual machine size type if the sku describes sku for virtual machine resource type.
28+
*
29+
* <p>The size can be used for {@link VirtualMachine.DefinitionStages.WithVMSize#withSize(VirtualMachineSizeTypes)}
30+
* and {@link VirtualMachine.Update#withSize(VirtualMachineSizeTypes)}.
31+
*
32+
* @return the virtual machine size type
33+
*/
34+
VirtualMachineSizeTypes virtualMachineSizeType();
2535
}

sdk/resourcemanager/azure-resourcemanager/src/test/java/com/azure/resourcemanager/TestAvailabilitySet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public AvailabilitySet createResource(AvailabilitySets availabilitySets) throws
2727
Assertions.assertTrue(TestUtilities.getSize(vmSizes) > 0);
2828
for (VirtualMachineSize vmSize : vmSizes) {
2929
Assertions.assertNotNull(vmSize.name());
30+
Assertions.assertNotNull(vmSize.virtualMachineSizeType());
3031
}
3132
return aset;
3233
}

0 commit comments

Comments
 (0)