/// <summary> /// Update current Snapshot policy hourly schedule /// </summary> /// <param name="anfClient">ANF client</param> /// <param name="resourceGroupName">Resource Group name</param> /// <param name="location">Azure location</param> /// <param name="accountName">Azure NetApp Files Account name</param> /// <param name="snapshotPolicyName">Azure NetApp Files Snapshot Policy name</param> /// <param name="currentHourlySchedule">Current Snapshot hourly schedule</param> /// <returns>Returns current Snapshot Policy</returns> public static async Task <SnapshotPolicy> UpdateANFSnapshotPolicy(AzureNetAppFilesManagementClient anfClient, string resourceGroupName, string location, string accountName, string snapshotPolicyName, HourlySchedule currentHourlySchedule) { HourlySchedule newHourlySchedule = currentHourlySchedule; newHourlySchedule.SnapshotsToKeep = 10; SnapshotPolicyPatch snapshotPolicyPatch = new SnapshotPolicyPatch() { HourlySchedule = newHourlySchedule, Enabled = true, Location = location }; return(await anfClient.SnapshotPolicies.UpdateAsync(snapshotPolicyPatch, resourceGroupName, accountName, snapshotPolicyName)); }
public void PatchSnapshotPolicy() { HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath(); using (MockContext context = MockContext.Start(this.GetType())) { var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); //Create acccount ResourceUtils.CreateAccount(netAppMgmtClient); //create the snapshotPolicy var snapshotPolicy = CreatePolicy(ResourceUtils.location, ResourceUtils.snapshotPolicyName1); var createSnapshotPolicy = netAppMgmtClient.SnapshotPolicies.Create(snapshotPolicy, ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.snapshotPolicyName1); var dict = new Dictionary <string, string>(); dict.Add("Tag1", "Value1"); var patchDailySchedule = new DailySchedule(1, 1, 1); // Now try and modify it var patchSnapshotPolicy = new SnapshotPolicyPatch() { //DailySchedule = patchDailySchedule, Tags = dict, DailySchedule = patchDailySchedule }; var resultSnapshotPolicy = netAppMgmtClient.SnapshotPolicies.Update(patchSnapshotPolicy, ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.snapshotPolicyName1); Assert.NotNull(resultSnapshotPolicy); Assert.NotNull(resultSnapshotPolicy.DailySchedule); //Assert.Equal(patchDailySchedule.SnapshotsToKeep, resultSnapShotPolicy.DailySchedule.SnapshotsToKeep); // cleanup netAppMgmtClient.SnapshotPolicies.Delete(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.snapshotPolicyName1); ResourceUtils.DeletePool(netAppMgmtClient); ResourceUtils.DeleteAccount(netAppMgmtClient); } }
/// <summary> /// Patch a snapshot policy /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// Snapshot policy object supplied in the body of the operation. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='accountName'> /// The name of the NetApp account /// </param> /// <param name='snapshotPolicyName'> /// The name of the snapshot policy target /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <SnapshotPolicy> UpdateAsync(this ISnapshotPoliciesOperations operations, SnapshotPolicyPatch body, string resourceGroupName, string accountName, string snapshotPolicyName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(body, resourceGroupName, accountName, snapshotPolicyName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Patch a snapshot policy /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// Snapshot policy object supplied in the body of the operation. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='accountName'> /// The name of the NetApp account /// </param> /// <param name='snapshotPolicyName'> /// The name of the snapshot policy target /// </param> public static SnapshotPolicy Update(this ISnapshotPoliciesOperations operations, SnapshotPolicyPatch body, string resourceGroupName, string accountName, string snapshotPolicyName) { return(operations.UpdateAsync(body, resourceGroupName, accountName, snapshotPolicyName).GetAwaiter().GetResult()); }