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

[Az.RecoveryServices.Backup] Added support for undelete soft deleted container and other fixes #26872

Merged
merged 6 commits into from
Jan 27, 2025
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 @@ -361,6 +361,9 @@ public static string GetServiceClientWorkloadType(CmdletModel.WorkloadType workl
case CmdletModel.WorkloadType.MSSQL:
serviceClientWorkloadType = ServiceClientModel.WorkloadType.SQLDataBase.ToString();
break;
case CmdletModel.WorkloadType.AzureFiles:
serviceClientWorkloadType = ServiceClientModel.WorkloadType.AzureFileShare.ToString(); // this might cause some issue later, monitor for failures.
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ internal FetchTieringCostOperations (RecoveryServicesBackupClient client)
public RecoveryServicesBackupClient Client { get; private set; }

/// <summary>
/// Provides the details of the tiering related sizes and cost. Status of the operation can be fetched using GetTieringCostOperationStatus API and result using GetTieringCostOperationResult API.
/// Provides the details of the tiering related sizes and cost. Status of the
/// operation can be fetched using GetTieringCostOperationStatus API and result
/// using GetTieringCostOperationResult API.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group where the recovery services vault is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public AzureSqlagWorkloadContainerProtectionContainer()
/// &#39;SAPAseDatabase&#39;, &#39;SAPHanaDBInstance&#39;</param>

/// <param name="operationType">Re-Do Operation
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;</param>
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;, &#39;Rehydrate&#39;</param>
public AzureSqlagWorkloadContainerProtectionContainer(string friendlyName = default(string), string backupManagementType = default(string), string registrationStatus = default(string), string healthStatus = default(string), string protectableObjectType = default(string), string sourceResourceId = default(string), System.DateTime? lastUpdatedTime = default(System.DateTime?), AzureWorkloadContainerExtendedInfo extendedInfo = default(AzureWorkloadContainerExtendedInfo), string workloadType = default(string), string operationType = default(string))

: base(friendlyName, backupManagementType, registrationStatus, healthStatus, protectableObjectType, sourceResourceId, lastUpdatedTime, extendedInfo, workloadType, operationType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public AzureStorageContainer()

/// <param name="acquireStorageAccountLock">Whether storage account lock is to be acquired for this container or not.
/// Possible values include: &#39;Acquire&#39;, &#39;NotAcquire&#39;</param>
public AzureStorageContainer(string friendlyName = default(string), string backupManagementType = default(string), string registrationStatus = default(string), string healthStatus = default(string), string protectableObjectType = default(string), string sourceResourceId = default(string), string storageAccountVersion = default(string), string resourceGroup = default(string), long? protectedItemCount = default(long?), string acquireStorageAccountLock = default(string))

/// <param name="operationType">Re-Do Operation
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;, &#39;Rehydrate&#39;</param>
public AzureStorageContainer(string friendlyName = default(string), string backupManagementType = default(string), string registrationStatus = default(string), string healthStatus = default(string), string protectableObjectType = default(string), string sourceResourceId = default(string), string storageAccountVersion = default(string), string resourceGroup = default(string), long? protectedItemCount = default(long?), string acquireStorageAccountLock = default(string), string operationType = default(string))

: base(friendlyName, backupManagementType, registrationStatus, healthStatus, protectableObjectType)
{
Expand All @@ -65,6 +68,7 @@ public AzureStorageContainer()
this.ResourceGroup = resourceGroup;
this.ProtectedItemCount = protectedItemCount;
this.AcquireStorageAccountLock = acquireStorageAccountLock;
this.OperationType = operationType;
CustomInit();
}

Expand Down Expand Up @@ -104,5 +108,11 @@ public AzureStorageContainer()
/// </summary>
[Newtonsoft.Json.JsonProperty(PropertyName = "acquireStorageAccountLock")]
public string AcquireStorageAccountLock {get; set; }

/// <summary>
/// Gets or sets re-Do Operation Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;, &#39;Rehydrate&#39;
/// </summary>
[Newtonsoft.Json.JsonProperty(PropertyName = "operationType")]
public string OperationType {get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public AzureVMAppContainerProtectionContainer()
/// &#39;SAPAseDatabase&#39;, &#39;SAPHanaDBInstance&#39;</param>

/// <param name="operationType">Re-Do Operation
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;</param>
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;, &#39;Rehydrate&#39;</param>
public AzureVMAppContainerProtectionContainer(string friendlyName = default(string), string backupManagementType = default(string), string registrationStatus = default(string), string healthStatus = default(string), string protectableObjectType = default(string), string sourceResourceId = default(string), System.DateTime? lastUpdatedTime = default(System.DateTime?), AzureWorkloadContainerExtendedInfo extendedInfo = default(AzureWorkloadContainerExtendedInfo), string workloadType = default(string), string operationType = default(string))

: base(friendlyName, backupManagementType, registrationStatus, healthStatus, protectableObjectType, sourceResourceId, lastUpdatedTime, extendedInfo, workloadType, operationType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AzureWorkloadContainer()
/// &#39;SAPAseDatabase&#39;, &#39;SAPHanaDBInstance&#39;</param>

/// <param name="operationType">Re-Do Operation
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;</param>
/// Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;, &#39;Rehydrate&#39;</param>
public AzureWorkloadContainer(string friendlyName = default(string), string backupManagementType = default(string), string registrationStatus = default(string), string healthStatus = default(string), string protectableObjectType = default(string), string sourceResourceId = default(string), System.DateTime? lastUpdatedTime = default(System.DateTime?), AzureWorkloadContainerExtendedInfo extendedInfo = default(AzureWorkloadContainerExtendedInfo), string workloadType = default(string), string operationType = default(string))

: base(friendlyName, backupManagementType, registrationStatus, healthStatus, protectableObjectType)
Expand Down Expand Up @@ -104,7 +104,7 @@ public AzureWorkloadContainer()
public string WorkloadType {get; set; }

/// <summary>
/// Gets or sets re-Do Operation Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;
/// Gets or sets re-Do Operation Possible values include: &#39;Invalid&#39;, &#39;Register&#39;, &#39;Reregister&#39;, &#39;Rehydrate&#39;
/// </summary>
[Newtonsoft.Json.JsonProperty(PropertyName = "operationType")]
public string OperationType {get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public static class OperationType
public const string Invalid = "Invalid";
public const string Register = "Register";
public const string Reregister = "Reregister";
public const string Rehydrate = "Rehydrate";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ internal PrivateEndpointConnectionOperations (RecoveryServicesBackupClient clien

}
/// <summary>
/// Approve or Reject Private Endpoint requests. This call is made by Backup Admin.
/// Approve or Reject Private Endpoint requests. This call is made by Backup
/// Admin.
/// </summary>
/// <param name='vaultName'>
/// The name of the recovery services vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ internal ProtectionContainersOperations (RecoveryServicesBackupClient client)

}
/// <summary>
/// Registers the container with Recovery Services vault. This is an asynchronous operation. To track the operation status, use location header to call get latest status of the operation.
/// Registers the container with Recovery Services vault. This is an
/// asynchronous operation. To track the operation status, use location header
/// to call get latest status of the operation.
/// </summary>
/// <param name='vaultName'>
/// The name of the recovery services vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ internal ProtectionPoliciesOperations (RecoveryServicesBackupClient client)

}
/// <summary>
/// Deletes specified backup policy from your Recovery Services Vault. This is an asynchronous operation. Status of the operation can be fetched using GetProtectionPolicyOperationResult API.
/// Deletes specified backup policy from your Recovery Services Vault. This is
/// an asynchronous operation. Status of the operation can be fetched using
/// GetProtectionPolicyOperationResult API.
/// </summary>
/// <param name='vaultName'>
/// The name of the recovery services vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private void Initialize()
this.GetTieringCostOperationResult = new GetTieringCostOperationResultOperations(this);
this.TieringCostOperationStatus = new TieringCostOperationStatusOperations(this);
this.BaseUri = new System.Uri("https://management.azure.com");
this.ApiVersion = "2024-04-01";
this.ApiVersion = "2024-10-01";
this.AcceptLanguage = "en-US";
this.LongRunningOperationRetryTimeout = 30;
this.GenerateClientRequestId = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ internal RestoresOperations (RecoveryServicesBackupClient client)
public RecoveryServicesBackupClient Client { get; private set; }

/// <summary>
/// Restores the specified backed up data. This is an asynchronous operation. To know the status of this API call, use GetProtectedItemOperationResult API.
/// Restores the specified backed up data. This is an asynchronous operation.
/// To know the status of this API call, use GetProtectedItemOperationResult
/// API.
/// </summary>
/// <param name='vaultName'>
/// The name of the recovery services vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ internal ValidateOperationOperations (RecoveryServicesBackupClient client)
public RecoveryServicesBackupClient Client { get; private set; }

/// <summary>
/// Validate operation for specified backed up item in the form of an asynchronous operation. Returns tracking headers which can be tracked using GetValidateOperationResult API.
/// Validate operation for specified backed up item in the form of an
/// asynchronous operation. Returns tracking headers which can be tracked using
/// GetValidateOperationResult API.
/// </summary>
/// <param name='vaultName'>
/// The name of the recovery services vault.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ payload-flattening-threshold: 2

###
``` yaml
commit: e6a20fec72ed3bcb4b43c559ee20b56ca2786ec0
commit: 58740206b853320974ef5e4864f7be8120b15a27
input-file:
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2024-04-01/bms.json
- https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2024-10-01/bms.json

directive:
- from: swagger-document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,48 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
/// </summary>
public class AzureFileShareContainer : AzureContainer
{
/// <summary>
/// Gets resource Id represents the complete path to the resource.
/// </summary>
public string Id { get; set; }

/// <summary>
/// Gets or sets ARM ID of the storage account
/// </summary>
public string SourceResourceId { get; set; }

/// <summary>
/// Gets or sets status of health of the container.
/// </summary>
public string HealthStatus { get; set; }

/// <summary>
/// Gets or sets number of items backed up in this container.
/// </summary>
public long? ProtectedItemCount { get; set; }

/// <summary>
/// Gets or sets whether storage account lock is to be acquired for this
/// container or not. Possible values include: Acquire, NotAcquire
/// </summary>
public string AcquireStorageAccountLock { get; set; }

/// <summary>
/// Constructor. Takes the service client object representing the container
/// and converts it in to the PS container model
/// </summary>
/// <param name="protectionContainerResource">Service client object representing the container</param>
public AzureFileShareContainer(ProtectionContainerResource protectionContainerResource)
: base(protectionContainerResource) { }
: base(protectionContainerResource) {

var protectionContainer = (AzureStorageContainer)protectionContainerResource.Properties;

Id = protectionContainerResource.Id;
SourceResourceId = protectionContainer.SourceResourceId;
HealthStatus = protectionContainer.HealthStatus;
ProtectedItemCount = protectionContainer.ProtectedItemCount;
AcquireStorageAccountLock = protectionContainer.AcquireStorageAccountLock;

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public AzureFileShareItem(ProtectedItemResource protectedItemResource,
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
FriendlyName = protectedItem.FriendlyName;
ResourceState = "";
if(protectedItem.ExtendedInfo != null && protectedItem.ExtendedInfo.ResourceState != null)

IsArchiveEnabled = protectedItem.IsArchiveEnabled;
SoftDeleteRetentionPeriodInDays = protectedItem.SoftDeleteRetentionPeriodInDays;
IsScheduledForDeferredDelete = protectedItem.IsScheduledForDeferredDelete;
DeferredDeleteTimeInUtc = protectedItem.DeferredDeleteTimeInUtc;

if (protectedItem.ExtendedInfo != null && protectedItem.ExtendedInfo.ResourceState != null)
{
ResourceState = protectedItem.ExtendedInfo.ResourceState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,27 @@ public class AzureItem : ItemBase
/// </summary>
public ItemDeleteState DeleteState { get; set; }

/// <summary>
/// Gets or sets flag to identify whether datasource is protected in archive
/// </summary>
public bool? IsArchiveEnabled { get; set; }

/// <summary>
/// Gets or sets soft delete retention period in days
/// </summary>
public int? SoftDeleteRetentionPeriodInDays { get; set; }

/// <summary>
/// Gets or sets flag to identify whether the DS is scheduled for deferred
/// delete
/// </summary>
public bool? IsScheduledForDeferredDelete { get; set; }

/// <summary>
/// Gets or sets time for deferred deletion in UTC
/// </summary>
public System.DateTime? DeferredDeleteTimeInUtc { get; set; }

public AzureItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using CrrModel = Microsoft.Azure.Management.RecoveryServices.Backup.CrossRegionRestore.Models;
Expand Down Expand Up @@ -52,11 +51,17 @@ public AzureVmItem(ProtectedItemResource protectedItemResource,
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
VirtualMachineId = protectedItem.VirtualMachineId;
HealthStatus = protectedItem.HealthStatus;
IsArchiveEnabled = protectedItem.IsArchiveEnabled;
SoftDeleteRetentionPeriodInDays = protectedItem.SoftDeleteRetentionPeriodInDays;
IsScheduledForDeferredDelete = protectedItem.IsScheduledForDeferredDelete;
DeferredDeleteTimeInUtc = protectedItem.DeferredDeleteTimeInUtc;

DateOfPurge = null;
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("NotDeleted");
if (protectedItem.IsScheduledForDeferredDelete.HasValue)
if (protectedItem.IsScheduledForDeferredDelete.HasValue && protectedItem.IsScheduledForDeferredDelete.Value)
{
DateOfPurge = protectedItem.DeferredDeleteTimeInUtc.Value.AddDays(14);
int softDeleteRetentionDays = protectedItem?.SoftDeleteRetentionPeriodInDays ?? 14;
DateOfPurge = protectedItem.DeferredDeleteTimeInUtc.Value.AddDays((int)softDeleteRetentionDays);
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("ToBeDeleted");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ public AzureWorkloadSAPHanaDatabaseProtectedItem(ProtectedItemResource protected
ProtectionState =
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);

IsArchiveEnabled = protectedItem.IsArchiveEnabled;
SoftDeleteRetentionPeriodInDays = protectedItem.SoftDeleteRetentionPeriodInDays;
IsScheduledForDeferredDelete = protectedItem.IsScheduledForDeferredDelete;
DeferredDeleteTimeInUtc = protectedItem.DeferredDeleteTimeInUtc;

DateOfPurge = null;
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("NotDeleted");
if (protectedItem.IsScheduledForDeferredDelete.HasValue)
if (protectedItem.IsScheduledForDeferredDelete.HasValue && protectedItem.IsScheduledForDeferredDelete.Value)
{
DateOfPurge = protectedItem.DeferredDeleteTimeInUtc.Value.AddDays(14);
DateOfPurge = protectedItem.DeferredDeleteTimeInUtc.Value.AddDays((int)protectedItem.SoftDeleteRetentionPeriodInDays);
DeleteState = EnumUtils.GetEnum<ItemDeleteState>("ToBeDeleted");
}
}
Expand Down
Loading