Skip to content

Commit d3ab974

Browse files
support disk encryption set in disk (#1432)
1 parent 5cbcac2 commit d3ab974

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/Disk.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,17 @@ interface WithSku {
496496
WithCreate withSku(DiskSkuTypes sku);
497497
}
498498

499+
/** The stage of the managed disk definition allowing to configure disk encryption. */
500+
interface WithDiskEncryption {
501+
/**
502+
* Specifies the disk encryption set.
503+
*
504+
* @param diskEncryptionSetId the ID of disk encryption set.
505+
* @return the next stage of the definition
506+
*/
507+
WithCreate withDiskEncryptionSet(String diskEncryptionSetId);
508+
}
509+
499510
/**
500511
* The stage of the definition which contains all the minimum required inputs for
501512
* the resource to be created, but also allows
@@ -505,7 +516,8 @@ interface WithCreate extends
505516
Creatable<Disk>,
506517
Resource.DefinitionWithTags<Disk.DefinitionStages.WithCreate>,
507518
WithSku,
508-
WithAvailabilityZone {
519+
WithAvailabilityZone,
520+
WithDiskEncryption {
509521
}
510522
}
511523

@@ -551,6 +563,18 @@ interface WithOSSettings {
551563
*/
552564
Update withOSType(OperatingSystemTypes osType);
553565
}
566+
567+
/** The stage of the managed disk definition allowing to configure disk encryption. */
568+
interface WithDiskEncryption {
569+
/**
570+
* Specifies the disk encryption set.
571+
*
572+
* @param diskEncryptionSetId the ID of disk encryption set.
573+
* @param encryptionType the encryption type.
574+
* @return the next stage of the definition
575+
*/
576+
Update withDiskEncryptionSet(String diskEncryptionSetId, EncryptionType encryptionType);
577+
}
554578
}
555579

556580
/**
@@ -562,6 +586,7 @@ interface Update extends
562586
Resource.UpdateWithTags<Disk.Update>,
563587
UpdateStages.WithSku,
564588
UpdateStages.WithSize,
565-
UpdateStages.WithOSSettings {
589+
UpdateStages.WithOSSettings,
590+
UpdateStages.WithDiskEncryption {
566591
}
567592
}

azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/DiskImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import com.microsoft.azure.management.compute.DiskCreateOption;
1515
import com.microsoft.azure.management.compute.DiskSku;
1616
import com.microsoft.azure.management.compute.DiskSkuTypes;
17+
import com.microsoft.azure.management.compute.Encryption;
1718
import com.microsoft.azure.management.compute.EncryptionSettingsCollection;
19+
import com.microsoft.azure.management.compute.EncryptionType;
1820
import com.microsoft.azure.management.compute.GrantAccessData;
1921
import com.microsoft.azure.management.compute.OperatingSystemTypes;
2022
import com.microsoft.azure.management.compute.Snapshot;
@@ -374,6 +376,29 @@ public DiskImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
374376
return this;
375377
}
376378

379+
@Override
380+
public DiskImpl withDiskEncryptionSet(String diskEncryptionSetId) {
381+
Encryption encryption = this.inner().encryption();
382+
if (encryption == null) {
383+
encryption = new Encryption();
384+
this.inner().withEncryption(encryption);
385+
}
386+
encryption.withDiskEncryptionSetId(diskEncryptionSetId);
387+
return this;
388+
}
389+
390+
@Override
391+
public DiskImpl withDiskEncryptionSet(String diskEncryptionSetId, EncryptionType encryptionType) {
392+
Encryption encryption = this.inner().encryption();
393+
if (encryption == null) {
394+
encryption = new Encryption();
395+
this.inner().withEncryption(encryption);
396+
}
397+
encryption.withType(encryptionType);
398+
encryption.withDiskEncryptionSetId(diskEncryptionSetId);
399+
return this;
400+
}
401+
377402
@Override
378403
public Observable<Disk> createResourceAsync() {
379404
final String resourceGroupName = resourceGroupName();

0 commit comments

Comments
 (0)