Skip to content

Commit

Permalink
Merge pull request #15 from leonardbf/ANF-368
Browse files Browse the repository at this point in the history
ANF-368 new SDK for R5 (2019-07-01 API)
  • Loading branch information
leonardbf authored Sep 20, 2019
2 parents 3e08e1d + 2edd67b commit d681707
Show file tree
Hide file tree
Showing 44 changed files with 6,677 additions and 7,503 deletions.
4 changes: 2 additions & 2 deletions eng/mgmt/mgmtmetadata/netapp_resource-manager.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/netapp/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\azure-sdk-for-net\sdk
2019-07-09 10:29:25 UTC
2019-09-12 13:18:08 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 597f7dd325c864dd4db48d9374451c16e0337158
Commit: d3f2c3d909f34d63d5d01b63ca928130c5c5627a
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4283
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private void Initialize()
MountTargets = new MountTargetsOperations(this);
Snapshots = new SnapshotsOperations(this);
BaseUri = new System.Uri("https://management.azure.com");
ApiVersion = "2019-06-01";
ApiVersion = "2019-07-01";
AcceptLanguage = "en-US";
LongRunningOperationRetryTimeout = 30;
GenerateClientRequestId = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ public ExportPolicyRule()
/// <param name="unixReadWrite">Read and write access</param>
/// <param name="cifs">Allows CIFS protocol</param>
/// <param name="nfsv3">Allows NFSv3 protocol</param>
/// <param name="nfsv4">Allows NFSv4 protocol</param>
/// <param name="nfsv41">Allows NFSv4.1 protocol</param>
/// <param name="allowedClients">Client ingress specification as comma
/// separated string with IPv4 CIDRs, IPv4 host addresses and host
/// names</param>
public ExportPolicyRule(int? ruleIndex = default(int?), bool? unixReadOnly = default(bool?), bool? unixReadWrite = default(bool?), bool? cifs = default(bool?), bool? nfsv3 = default(bool?), bool? nfsv4 = default(bool?), string allowedClients = default(string))
public ExportPolicyRule(int? ruleIndex = default(int?), bool? unixReadOnly = default(bool?), bool? unixReadWrite = default(bool?), bool? cifs = default(bool?), bool? nfsv3 = default(bool?), bool? nfsv41 = default(bool?), string allowedClients = default(string))
{
RuleIndex = ruleIndex;
UnixReadOnly = unixReadOnly;
UnixReadWrite = unixReadWrite;
Cifs = cifs;
Nfsv3 = nfsv3;
Nfsv4 = nfsv4;
Nfsv41 = nfsv41;
AllowedClients = allowedClients;
CustomInit();
}
Expand Down Expand Up @@ -86,10 +86,10 @@ public ExportPolicyRule()
public bool? Nfsv3 { get; set; }

/// <summary>
/// Gets or sets allows NFSv4 protocol
/// Gets or sets allows NFSv4.1 protocol
/// </summary>
[JsonProperty(PropertyName = "nfsv4")]
public bool? Nfsv4 { get; set; }
[JsonProperty(PropertyName = "nfsv41")]
public bool? Nfsv41 { get; set; }

/// <summary>
/// Gets or sets client ingress specification as comma separated string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public Snapshot()
/// <param name="tags">Resource tags</param>
/// <param name="snapshotId">snapshotId</param>
/// <param name="fileSystemId">fileSystemId</param>
/// <param name="creationDate">name</param>
/// <param name="created">name</param>
/// <param name="provisioningState">Azure lifecycle management</param>
public Snapshot(string location, string id = default(string), string name = default(string), string type = default(string), object tags = default(object), string snapshotId = default(string), string fileSystemId = default(string), System.DateTime? creationDate = default(System.DateTime?), string provisioningState = default(string))
public Snapshot(string location, string id = default(string), string name = default(string), string type = default(string), object tags = default(object), string snapshotId = default(string), string fileSystemId = default(string), System.DateTime? created = default(System.DateTime?), string provisioningState = default(string))
{
Location = location;
Id = id;
Expand All @@ -51,7 +51,7 @@ public Snapshot()
Tags = tags;
SnapshotId = snapshotId;
FileSystemId = fileSystemId;
CreationDate = creationDate;
Created = created;
ProvisioningState = provisioningState;
CustomInit();
}
Expand Down Expand Up @@ -115,8 +115,8 @@ public Snapshot()
/// <remarks>
/// The creation date of the snapshot
/// </remarks>
[JsonProperty(PropertyName = "properties.creationDate")]
public System.DateTime? CreationDate { get; private set; }
[JsonProperty(PropertyName = "properties.created")]
public System.DateTime? Created { get; private set; }

/// <summary>
/// Gets azure lifecycle management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,27 @@ public static IEnumerable<Tuple<string, string, string>> ApiInfo_NetAppManagemen
{
return new Tuple<string, string, string>[]
{
new Tuple<string, string, string>("NetApp", "Accounts", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "CheckFilePathAvailability", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "CheckNameAvailability", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "MountTargets", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "Operations", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "Pools", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "Snapshots", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "Volumes", "2019-06-01"),
new Tuple<string, string, string>("NetApp", "Accounts", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "CheckFilePathAvailability", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "CheckNameAvailability", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "MountTargets", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "Operations", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "Pools", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "Snapshots", "2019-07-01"),
new Tuple<string, string, string>("NetApp", "Volumes", "2019-07-01"),
}.AsEnumerable();
}
}
// BEGIN: Code Generation Metadata Section
public static readonly String AutoRestVersion = "latest";
public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4283";
public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/netapp/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\\azure-sdk-for-net\\sdk";
public static readonly String GithubForkName = "Azure";
public static readonly String GithubBranchName = "master";
public static readonly String GithubCommidId = "d3f2c3d909f34d63d5d01b63ca928130c5c5627a";
public static readonly String CodeGenerationErrors = "";
public static readonly String GithubRepoName = "azure-rest-api-specs";
// END: Code Generation Metadata Section
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageTags>MicrosoftAzure Management;NetApp</PackageTags>
<PackageReleaseNotes>
<![CDATA[
Version 1.1.0 relates to NetApp Files (ANF) RP R4.5 GA.
Version 1.2.0 relates to NetApp Files (ANF) RP R5 GA.
Azure NetApp Files provides the capability to create multiple file system volumes through Microsoft Azure.
Volumes reside within an account pool, a container representing the total data allocation available. A typical usage might be:
Create an account and pool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class ResourceUtils
{
public const long gibibyte = 1024L * 1024L * 1024L;

public const string vnet = "sdk-net-tests-rg-wus-vnet";
public const string vnet = "sdk-net-tests-rg-cys-vnet";
public const string subsId = "0661b131-4a11-479b-96bf-2f95acca2f73";
public const string location = "westcentralus";
public const string resourceGroup = "sdk-net-tests-rg-wus";
public const string resourceGroup = "sdk-net-tests-rg-cys";
public const string accountName1 = "sdk-net-tests-acc-1";
public const string accountName2 = "sdk-net-tests-acc-2";
public const string poolName1 = "sdk-net-tests-pool-1";
Expand All @@ -41,7 +41,7 @@ public class ResourceUtils
UnixReadWrite = true,
Cifs = false,
Nfsv3 = true,
Nfsv4 = false,
Nfsv41 = false,
AllowedClients = "0.0.0.0/0"
};

Expand All @@ -55,8 +55,8 @@ public class ResourceUtils
Rules = defaultExportPolicyRuleList
};

private const int delay = 5000;
private const int retryAttempts = 3;
private const int delay = 30000;
private const int retryAttempts = 4;

public static NetAppAccount CreateAccount(AzureNetAppFilesManagementClient netAppMgmtClient, string accountName = accountName1, string resourceGroup = resourceGroup, string location = location, object tags = null, ActiveDirectory activeDirectory = null)
{
Expand Down Expand Up @@ -195,8 +195,11 @@ public static void DeletePool(AzureNetAppFilesManagementClient netAppMgmtClient,
// find and delete all nested resources - not implemented
}

// now delete the pool - with retry for test robustness due to ARM caching
// (arm continues to tidy up even after the awaited async op has returned)
// now delete the pool - with retry for test robustness due to
// - ARM caching (ARM continues to tidy up even after the awaited async op
// has returned)
// - other async actions in RP/SDE/NRP
// e.g. snapshot deletion might not be complete and therefore pool has child resource
while (retry == true)
{
Thread.Sleep(delay);
Expand Down Expand Up @@ -227,8 +230,11 @@ public static void DeleteVolume(AzureNetAppFilesManagementClient netAppMgmtClien
// find and delete all nested resources - not implemented
}

// now delete the volume - with retry for test robustness due to ARM caching
// (arm continues to tidy up even after the awaited async op has returned)
// now delete the volume - with retry for test robustness due to
// - ARM caching (ARM continues to tidy up even after the awaited async op
// has returned)
// - other async actions in RP/SDE/NRP
// e.g. snapshot deletion might not be complete and therefore volume has child resource
while (retry == true)
{
Thread.Sleep(delay);
Expand Down Expand Up @@ -259,8 +265,12 @@ public static void DeleteSnapshot(AzureNetAppFilesManagementClient netAppMgmtCli
// find and delete all nested resources - not implemented
}

// now delete the snapshot - with retry for test robustness due to ARM caching
// (arm continues to tidy up even after the awaited async op has returned)
// now delete the snapshot - with retry for test robustness due to
// - ARM caching (ARM continues to tidy up even after the awaited async op
// has returned)
// - other async actions in RP/SDE/NRP
// e.g. snapshot deletion might fail if the actual creation is not complete at
// all levels
while (retry == true)
{
Thread.Sleep(delay);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NetApp.Tests.Helpers;
using NetApp.Tests.Helpers;
using Microsoft.Azure.Management.NetApp;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Test.HttpRecorder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NetApp.Tests.Helpers;
using NetApp.Tests.Helpers;
using Microsoft.Azure.Management.NetApp;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Test.HttpRecorder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NetApp.Tests.Helpers;
using NetApp.Tests.Helpers;
using Microsoft.Azure.Management.NetApp;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Test.HttpRecorder;
Expand Down Expand Up @@ -32,14 +32,14 @@ public void CreateDeletePool()
ResourceUtils.CreatePool(netAppMgmtClient, ResourceUtils.poolName1, ResourceUtils.accountName1, poolOnly: true);
var poolsBefore = netAppMgmtClient.Pools.List(ResourceUtils.resourceGroup, ResourceUtils.accountName1);
Assert.Single(poolsBefore);

/*
// delete the pool and check again
netAppMgmtClient.Pools.Delete(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1);
var poolsAfter = netAppMgmtClient.Pools.List(ResourceUtils.resourceGroup, ResourceUtils.accountName1);
Assert.Empty(poolsAfter);
// cleanup - remove the account
ResourceUtils.DeleteAccount(netAppMgmtClient);
ResourceUtils.DeleteAccount(netAppMgmtClient);*/
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NetApp.Tests.Helpers;
using NetApp.Tests.Helpers;
using Microsoft.Azure.Management.NetApp;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Test.HttpRecorder;
Expand All @@ -24,12 +24,17 @@ public void CreateDeleteSnapshot()
{
var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });

var timeNow = DateTime.UtcNow;

// create the snapshot
ResourceUtils.CreateSnapshot(netAppMgmtClient);

// check snapshot exists
var snapshotsBefore = netAppMgmtClient.Snapshots.List(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.Single(snapshotsBefore);
// check date created - might have taken a few minutes
Assert.True((timeNow < snapshotsBefore.First().Created) &&
(snapshotsBefore.First().Created <(timeNow.AddMinutes(20))));

// delete the snapshot and check again
netAppMgmtClient.Snapshots.Delete(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1, ResourceUtils.snapshotName1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NetApp.Tests.Helpers;
using NetApp.Tests.Helpers;
using Microsoft.Azure.Management.NetApp.Models;
using Microsoft.Azure.Management.NetApp;
using Microsoft.Azure.Management.Resources;
Expand All @@ -23,7 +23,7 @@ public class VolumeTests : TestBase
UnixReadWrite = true,
Cifs = false,
Nfsv3 = true,
Nfsv4 = false,
Nfsv41 = false,
AllowedClients = "1.2.3.0/24"
};

Expand Down Expand Up @@ -80,7 +80,7 @@ public void CreateVolumeWithProperties()
// create a volume with tags and export policy
var dict = new Dictionary<string, string>();
dict.Add("Tag2", "Value2");
var protocolTypes = new List<string>() { "NFSv3", "NFSv4" };
var protocolTypes = new List<string>() { "NFSv3", "NFSv4.1" };

var resource = ResourceUtils.CreateVolume(netAppMgmtClient, protocolTypes: protocolTypes, tags: dict, exportPolicy: exportPolicy);
Assert.Equal(exportPolicy.ToString(), resource.ExportPolicy.ToString());
Expand Down Expand Up @@ -314,15 +314,15 @@ public void UpdateVolume()
var volume = new Volume
{
Location = oldVolume.Location,
UsageThreshold = 2 * oldVolume.UsageThreshold,
ServiceLevel = oldVolume.ServiceLevel,
CreationToken = oldVolume.CreationToken,
SubnetId = oldVolume.SubnetId,
};
// update
volume.ServiceLevel = "Standard";
volume.UsageThreshold = 2 * oldVolume.UsageThreshold;

var updatedVolume = netAppMgmtClient.Volumes.CreateOrUpdate(volume, ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.Equal("Standard", updatedVolume.ServiceLevel);
Assert.Equal("Premium", updatedVolume.ServiceLevel); // didn't attempt to change - it would be rejected
Assert.Equal(100 * ResourceUtils.gibibyte * 2, updatedVolume.UsageThreshold);

// cleanup
Expand All @@ -343,7 +343,9 @@ public void PatchVolume()
// create the volume
var volume = ResourceUtils.CreateVolume(netAppMgmtClient);
Assert.Equal("Premium", volume.ServiceLevel);

Assert.Equal(100 * ResourceUtils.gibibyte, volume.UsageThreshold);
Assert.Equal(ResourceUtils.defaultExportPolicy.ToString(), volume.ExportPolicy.ToString());
Assert.Null(volume.Tags);

// create a volume with tags and export policy
var dict = new Dictionary<string, string>();
Expand All @@ -352,14 +354,15 @@ public void PatchVolume()
// Now try and modify it
var volumePatch = new VolumePatch()
{
ServiceLevel = "Standard",
UsageThreshold = 2 * volume.UsageThreshold,
Tags = dict,
ExportPolicy = exportPatchPolicy
};

// patch
var updatedVolume = netAppMgmtClient.Volumes.Update(volumePatch, ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.Equal("Standard", updatedVolume.ServiceLevel);
Assert.Equal("Premium", updatedVolume.ServiceLevel); // didn't attempt to change - it would be rejected
Assert.Equal(200 * ResourceUtils.gibibyte, updatedVolume.UsageThreshold);
Assert.Equal(exportPolicy.ToString(), updatedVolume.ExportPolicy.ToString());
Assert.True(updatedVolume.Tags.ToString().Contains("Tag2") && updatedVolume.Tags.ToString().Contains("Value2"));

Expand Down
Loading

0 comments on commit d681707

Please sign in to comment.