Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgmt remove deprecate APIs in compute #15417

Merged
merged 5 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSku;
import com.azure.resourcemanager.compute.models.DiskSkuTypes;
import com.azure.resourcemanager.compute.models.DiskStorageAccountTypes;
import com.azure.resourcemanager.compute.models.EncryptionSettingsCollection;
import com.azure.resourcemanager.compute.models.GrantAccessData;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
import com.azure.resourcemanager.compute.models.Snapshot;
import com.azure.resourcemanager.compute.fluent.inner.DiskInner;
import com.azure.resourcemanager.compute.models.SnapshotSkuType;
import com.azure.resourcemanager.resources.fluentcore.arm.AvailabilityZoneId;
import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
Expand Down Expand Up @@ -179,7 +181,7 @@ public DiskImpl withLinuxFromSnapshot(Snapshot sourceSnapshot) {
if (sourceSnapshot.osType() != null) {
this.withOSType(sourceSnapshot.osType());
}
this.withSku(sourceSnapshot.sku());
this.withSku(this.fromSnapshotSkuType(sourceSnapshot.skuType()));
return this;
}

Expand Down Expand Up @@ -235,7 +237,7 @@ public DiskImpl withWindowsFromSnapshot(Snapshot sourceSnapshot) {
if (sourceSnapshot.osType() != null) {
this.withOSType(sourceSnapshot.osType());
}
this.withSku(sourceSnapshot.sku());
this.withSku(this.fromSnapshotSkuType(sourceSnapshot.skuType()));
return this;
}

Expand Down Expand Up @@ -384,4 +386,11 @@ public Accepted<Disk> beginCreate() {
},
this::setInner);
}

private DiskSkuTypes fromSnapshotSkuType(SnapshotSkuType skuType) {
if (skuType == null) {
return null;
}
return DiskSkuTypes.fromStorageAccountType(DiskStorageAccountTypes.fromString(skuType.toString()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.azure.resourcemanager.compute.models.Disk;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSkuTypes;
import com.azure.resourcemanager.compute.models.DiskStorageAccountTypes;
import com.azure.resourcemanager.compute.models.GrantAccessData;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
import com.azure.resourcemanager.compute.models.Snapshot;
Expand All @@ -36,16 +35,6 @@ class SnapshotImpl extends GroupableResourceImpl<Snapshot, SnapshotInner, Snapsh
super(name, innerModel, computeManager);
}

@Override
public DiskSkuTypes sku() {
if (this.inner().sku() == null || this.inner().sku().name() == null) {
return null;
} else {
return DiskSkuTypes
.fromStorageAccountType(DiskStorageAccountTypes.fromString(this.inner().sku().name().toString()));
}
}

@Override
public SnapshotSkuType skuType() {
if (this.inner().sku() == null) {
Expand Down Expand Up @@ -164,7 +153,7 @@ public SnapshotImpl withLinuxFromSnapshot(Snapshot sourceSnapshot) {
if (sourceSnapshot.osType() != null) {
this.withOSType(sourceSnapshot.osType());
}
this.withSku(sourceSnapshot.sku());
this.withSku(sourceSnapshot.skuType());
return this;
}

Expand Down Expand Up @@ -226,7 +215,7 @@ public SnapshotImpl withWindowsFromSnapshot(Snapshot sourceSnapshot) {
if (sourceSnapshot.osType() != null) {
this.withOSType(sourceSnapshot.osType());
}
this.withSku(sourceSnapshot.sku());
this.withSku(sourceSnapshot.skuType());
return this;
}

Expand Down Expand Up @@ -297,8 +286,7 @@ public SnapshotImpl withOSType(OperatingSystemTypes osType) {
return this;
}

@Override
public SnapshotImpl withSku(DiskSkuTypes sku) {
private SnapshotImpl withSku(DiskSkuTypes sku) {
SnapshotSku snapshotSku = new SnapshotSku();
snapshotSku.withName(SnapshotStorageAccountTypes.fromString(sku.accountType().toString()));
this.inner().withSku(snapshotSku);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,12 +881,6 @@ public VirtualMachineImpl withOSDiskEncryptionSettings(DiskEncryptionSettings se
return this;
}

@Override
public VirtualMachineImpl withOSDiskSizeInGB(Integer size) {
this.inner().storageProfile().osDisk().withDiskSizeGB(size);
return this;
}

@Override
public VirtualMachineImpl withOSDiskSizeInGB(int size) {
this.inner().storageProfile().osDisk().withDiskSizeGB(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public interface ComputeSku extends HasInner<ResourceSkuInner> {
* The managed disk or snapshot sku type if the sku describes sku for disk or snapshot resource type.
*
* <p>The sku type can be used for {@link Disk.DefinitionStages.WithSku#withSku(DiskSkuTypes)}, {@link
* Disk.UpdateStages.WithSku#withSku(DiskSkuTypes)}, {@link Snapshot.DefinitionStages.WithSku#withSku(DiskSkuTypes)}
* and {@link Snapshot.UpdateStages.WithSku#withSku(DiskSkuTypes)}.
* Disk.UpdateStages.WithSku#withSku(DiskSkuTypes)}.
*
* @return the managed disk or snapshot sku type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
@Fluent
public interface Snapshot
extends GroupableResource<ComputeManager, SnapshotInner>, Refreshable<Snapshot>, Updatable<Snapshot.Update> {
/**
* @return the snapshot SKU type.
* @deprecated use {@link Snapshot#skuType()} instead.
*/
@Deprecated
DiskSkuTypes sku();

/** @return the snapshot SKU type. */
SnapshotSkuType skuType();

Expand Down Expand Up @@ -350,16 +343,6 @@ interface WithIncremental {

/** The stage of the snapshot definition allowing to choose account type. */
interface WithSku {
/**
* Specifies the SKU type.
*
* @deprecated use {@link WithSku#withSku(SnapshotSkuType)} instead.
* @param sku SKU type
* @return the next stage of the definition
*/
@Deprecated
WithCreate withSku(DiskSkuTypes sku);

/**
* Specifies the SKU type.
*
Expand All @@ -386,16 +369,6 @@ interface WithCreate
interface UpdateStages {
/** The stage of the managed snapshot update allowing to choose account type. */
interface WithSku {
/**
* Specifies the SKU type.
*
* @deprecated use {@link WithSku#withSku(SnapshotSkuType)} instead.
* @param sku SKU type
* @return the next stage of the update
*/
@Deprecated
Update withSku(DiskSkuTypes sku);

/**
* Specifies the SKU type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1123,15 +1123,6 @@ interface WithOSDiskSettings {
*/
WithCreate withOSDiskEncryptionSettings(DiskEncryptionSettings settings);

/**
* Specifies the size of the OSDisk in GB.
*
* @param size the VHD size
* @return the next stage of the definition
* @deprecated use {@link #withOSDiskSizeInGB(int)} instead
*/
@Deprecated
WithCreate withOSDiskSizeInGB(Integer size);

/**
* Specifies the size of the OSDisk in GB.
Expand Down Expand Up @@ -2191,19 +2182,6 @@ interface Update
*/
Update withOSDiskCaching(CachingTypes cachingType);

/**
* Specifies the size of the OS disk in GB.
*
* <p>Only unmanaged disks may be resized as part of a VM update. Managed disks must be resized separately,
* using managed disk API.
*
* @param size a disk size.
* @return the next stage of the update
* @deprecated use {@link #withOSDiskSizeInGB(int)} instead.
*/
@Deprecated
Update withOSDiskSizeInGB(Integer size);

/**
* Specifies the size of the OS disk in GB.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void canOperateOnManagedDiskFromSnapshot() {

Assertions.assertNotNull(snapshot.id());
Assertions.assertTrue(snapshot.name().equalsIgnoreCase(snapshotName));
Assertions.assertEquals(snapshot.sku(), DiskSkuTypes.STANDARD_LRS);
Assertions.assertEquals(snapshot.skuType().toString(), DiskSkuTypes.STANDARD_LRS.toString());
Assertions.assertEquals(snapshot.creationMethod(), DiskCreateOption.COPY);
Assertions.assertEquals(snapshot.sizeInGB(), 200);
Assertions.assertNull(snapshot.osType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.Disk;
import com.azure.resourcemanager.compute.models.DiskSkuTypes;
import com.azure.resourcemanager.compute.models.KnownLinuxVirtualMachineImage;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
import com.azure.resourcemanager.compute.models.Snapshot;
import com.azure.resourcemanager.compute.models.SnapshotSkuType;
import com.azure.resourcemanager.compute.models.VirtualMachine;
import com.azure.resourcemanager.compute.models.VirtualMachineDataDisk;
import com.azure.resourcemanager.compute.models.VirtualMachineSizeTypes;
Expand Down Expand Up @@ -132,7 +132,7 @@ public static boolean runSample(AzureResourceManager azureResourceManager) {
.withRegion(region)
.withExistingResourceGroup(rgName)
.withDataFromDisk(dataDisk)
.withSku(DiskSkuTypes.STANDARD_LRS)
.withSku(SnapshotSkuType.STANDARD_LRS)
.create();
dataSnapshots.add(dataSnapshot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.compute.models.SnapshotSkuType;
import com.azure.resourcemanager.samples.Utils;
import com.jcraft.jsch.JSchException;
import com.azure.resourcemanager.compute.models.CachingTypes;
import com.azure.resourcemanager.compute.models.Disk;
import com.azure.resourcemanager.compute.models.DiskSkuTypes;
import com.azure.resourcemanager.compute.models.KnownLinuxVirtualMachineImage;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
import com.azure.resourcemanager.compute.models.Snapshot;
Expand Down Expand Up @@ -261,7 +261,7 @@ public static boolean runSample(AzureResourceManager azureResourceManager) {
.withRegion(region)
.withExistingResourceGroup(rgName)
.withDataFromDisk(dataDisks.get(0))
.withSku(DiskSkuTypes.STANDARD_LRS)
.withSku(SnapshotSkuType.STANDARD_LRS)
.create();

System.out.println("Created managed data snapshot [from managed data disk]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.azure.core.management.profile.AzureProfile;
import com.azure.identity.ManagedIdentityCredential;
import com.azure.identity.ManagedIdentityCredentialBuilder;
import com.azure.resourcemanager.Azure;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.compute.models.KnownLinuxVirtualMachineImage;
import com.azure.resourcemanager.compute.models.VirtualMachine;
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
Expand Down Expand Up @@ -54,7 +54,7 @@ public static void main(String[] args) {

AzureProfile profile = new AzureProfile(null, subscriptionId, AzureEnvironment.AZURE);

Azure azure = Azure.configure()
AzureResourceManager azure = AzureResourceManager.configure()
.withLogLevel(HttpLogDetailLevel.BASIC)
.authenticate(credential, profile)
.withSubscription(subscriptionId);
Expand Down