Esempio n. 1
0
        // <summary>
        /// Helper function to convert ps recovery point model from service response.
        /// </summary>
        public static RecoveryPointBase GetPSAzureRecoveryPoints(ServiceClientModel.RecoveryPointResponse rpResponse, AzureVmItem item)
        {
            if (rpResponse == null || rpResponse.RecPoint == null)
            {
                throw new ArgumentNullException(Resources.GetRPResponseIsNull);
            }

            ServiceClientModel.RecoveryPoint recPoint = rpResponse.RecPoint.Properties as ServiceClientModel.RecoveryPoint;
            Dictionary <UriEnums, string>    uriDict  = HelperUtils.ParseUri(item.Id);
            string   containerUri      = HelperUtils.GetContainerUri(uriDict, item.Id);
            string   protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id);
            DateTime recPointTime      = DateTime.ParseExact(
                recPoint.RecoveryPointTime,
                @"MM/dd/yyyy HH:mm:ss",
                CultureInfo.InvariantCulture);

            AzureVmRecoveryPoint result = new AzureVmRecoveryPoint()
            {
                RecoveryPointId      = rpResponse.RecPoint.Name,
                BackupManagementType = item.BackupManagementType,
                ItemName             = protectedItemName,
                ContainerName        = containerUri,
                ContainerType        = item.ContainerType,
                RecoveryPointTime    = recPointTime,
                RecoveryPointType    = recPoint.RecoveryPointType,
                Id           = rpResponse.RecPoint.Id,
                WorkloadType = item.WorkloadType,
                RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                SourceResourceId            = item.SourceResourceId,
            };

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Helper function to convert ps recovery points list model from service response.
        /// </summary>
        public static List <RecoveryPointBase> GetPSAzureRecoveryPoints(ServiceClientModel.RecoveryPointListResponse rpList, AzureVmItem item)
        {
            if (rpList == null || rpList.RecoveryPointList == null ||
                rpList.RecoveryPointList.RecoveryPoints == null)
            {
                throw new ArgumentNullException("RPList");
            }

            Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id);
            string containerUri      = HelperUtils.GetContainerUri(uriDict, item.Id);
            string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id);

            List <RecoveryPointBase> result = new List <RecoveryPointBase>();

            foreach (ServiceClientModel.RecoveryPointResource rp in rpList.RecoveryPointList.RecoveryPoints)
            {
                ServiceClientModel.RecoveryPoint recPoint = rp.Properties as ServiceClientModel.RecoveryPoint;

                DateTime             recPointTime = DateTime.ParseExact(recPoint.RecoveryPointTime, @"MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                AzureVmRecoveryPoint rpBase       = new AzureVmRecoveryPoint()
                {
                    RecoveryPointId      = rp.Name,
                    BackupManagementType = item.BackupManagementType,
                    ItemName             = protectedItemName,
                    ContainerName        = containerUri,
                    ContainerType        = item.ContainerType,
                    RecoveryPointTime    = recPointTime,
                    RecoveryPointType    = recPoint.RecoveryPointType,
                    Id           = rp.Id,
                    WorkloadType = item.WorkloadType,
                    RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                    SourceVMStorageType         = recPoint.SourceVMStorageType,
                    SourceResourceId            = item.SourceResourceId,
                };
                result.Add(rpBase);
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Helper function to convert ps recovery points list model from service response.
        /// </summary>
        public static List <RecoveryPointBase> GetPSAzureRecoveryPoints(
            ServiceClientModel.RecoveryPointListResponse rpList,
            ItemBase item)
        {
            if (rpList == null || rpList.RecoveryPointList == null ||
                rpList.RecoveryPointList.RecoveryPoints == null)
            {
                throw new ArgumentNullException("RPList");
            }

            Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id);
            string containerUri     = HelperUtils.GetContainerUri(uriDict, item.Id);
            string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, item.Id);

            string containerName     = IdUtils.GetNameFromUri(containerUri);
            string protectedItemName = IdUtils.GetNameFromUri(protectedItemUri);

            List <RecoveryPointBase> result = new List <RecoveryPointBase>();

            foreach (ServiceClientModel.RecoveryPointResource rp in rpList.RecoveryPointList.RecoveryPoints)
            {
                if (rp.Properties.GetType() == typeof(ServiceClientModel.RecoveryPoint))
                {
                    ServiceClientModel.RecoveryPoint recPoint =
                        rp.Properties as ServiceClientModel.RecoveryPoint;

                    DateTime recPointTime = DateTime.ParseExact(
                        recPoint.RecoveryPointTime,
                        @"MM/dd/yyyy HH:mm:ss",
                        CultureInfo.InvariantCulture);

                    AzureVmRecoveryPoint rpBase = new AzureVmRecoveryPoint()
                    {
                        RecoveryPointId      = rp.Name,
                        BackupManagementType = item.BackupManagementType,
                        ItemName             = protectedItemName,
                        ContainerName        = containerName,
                        ContainerType        = item.ContainerType,
                        RecoveryPointTime    = recPointTime,
                        RecoveryPointType    = recPoint.RecoveryPointType,
                        Id           = rp.Id,
                        WorkloadType = item.WorkloadType,
                        RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                        SourceVMStorageType         = recPoint.SourceVMStorageType,
                        SourceResourceId            = item.SourceResourceId,
                        EncryptionEnabled           = recPoint.IsSourceVMEncrypted.HasValue ?
                                                      recPoint.IsSourceVMEncrypted.Value : false,
                        IlrSessionActive = recPoint.IsInstantILRSessionActive,
                    };

                    result.Add(rpBase);
                }

                if (rp.Properties.GetType() == typeof(ServiceClientModel.GenericRecoveryPoint))
                {
                    ServiceClientModel.GenericRecoveryPoint recPoint =
                        rp.Properties as ServiceClientModel.GenericRecoveryPoint;

                    DateTime recPointTime = DateTime.ParseExact(
                        recPoint.RecoveryPointTime,
                        @"MM/dd/yyyy HH:mm:ss",
                        CultureInfo.InvariantCulture);

                    AzureSqlRecoveryPoint rpBase = new AzureSqlRecoveryPoint()
                    {
                        RecoveryPointId      = rp.Name,
                        BackupManagementType = item.BackupManagementType,
                        ItemName             = protectedItemName,
                        ContainerName        = containerUri,
                        ContainerType        = item.ContainerType,
                        RecoveryPointTime    = recPointTime,
                        RecoveryPointType    = recPoint.RecoveryPointType,
                        Id           = rp.Id,
                        WorkloadType = item.WorkloadType,
                        RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                        FriendlyName = recPoint.FriendlyName,
                    };

                    result.Add(rpBase);
                }
            }

            return(result);
        }
Esempio n. 4
0
        // <summary>
        /// Helper function to convert ps recovery point model from service response.
        /// </summary>
        public static RecoveryPointBase GetPSAzureRecoveryPoints(
            ServiceClientModel.RecoveryPointResponse rpResponse,
            ItemBase item)
        {
            if (rpResponse == null || rpResponse.RecPoint == null)
            {
                throw new ArgumentNullException(Resources.GetRPResponseIsNull);
            }

            RecoveryPointBase result = null;

            Dictionary <UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id);
            string containerUri      = HelperUtils.GetContainerUri(uriDict, item.Id);
            string containerName     = IdUtils.GetNameFromUri(containerUri);
            string protectedItemUri  = HelperUtils.GetProtectedItemUri(uriDict, item.Id);
            string protectedItemName = IdUtils.GetNameFromUri(protectedItemUri);

            if (rpResponse.RecPoint.Properties.GetType() ==
                typeof(ServiceClientModel.RecoveryPoint))
            {
                ServiceClientModel.RecoveryPoint recPoint =
                    rpResponse.RecPoint.Properties as ServiceClientModel.RecoveryPoint;

                DateTime recPointTime = DateTime.ParseExact(
                    recPoint.RecoveryPointTime,
                    @"MM/dd/yyyy HH:mm:ss",
                    CultureInfo.InvariantCulture);

                AzureVmRecoveryPoint vmResult = new AzureVmRecoveryPoint()
                {
                    RecoveryPointId      = rpResponse.RecPoint.Name,
                    BackupManagementType = item.BackupManagementType,
                    ItemName             = protectedItemName,
                    ContainerName        = containerName,
                    ContainerType        = item.ContainerType,
                    RecoveryPointTime    = recPointTime,
                    RecoveryPointType    = recPoint.RecoveryPointType,
                    Id           = rpResponse.RecPoint.Id,
                    WorkloadType = item.WorkloadType,
                    RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                    EncryptionEnabled           = recPoint.IsSourceVMEncrypted.HasValue ?
                                                  recPoint.IsSourceVMEncrypted.Value : false,
                    IlrSessionActive    = recPoint.IsInstantILRSessionActive,
                    SourceResourceId    = item.SourceResourceId,
                    SourceVMStorageType = recPoint.SourceVMStorageType,
                };

                if (vmResult.EncryptionEnabled && recPoint.KeyAndSecret != null)
                {
                    vmResult.KeyAndSecretDetails = new KeyAndSecretDetails()
                    {
                        SecretUrl     = recPoint.KeyAndSecret.BekDetails.SecretUrl,
                        KeyUrl        = recPoint.KeyAndSecret.KekDetails.KeyUrl,
                        SecretData    = recPoint.KeyAndSecret.BekDetails.SecretData,
                        KeyBackupData = recPoint.KeyAndSecret.KekDetails.KeyBackupData,
                        KeyVaultId    = recPoint.KeyAndSecret.KekDetails.KeyVaultId,
                        SecretVaultId = recPoint.KeyAndSecret.BekDetails.SecretVaultId,
                    };
                }

                result = vmResult;
            }

            if (rpResponse.RecPoint.Properties.GetType() ==
                typeof(ServiceClientModel.GenericRecoveryPoint))
            {
                ServiceClientModel.GenericRecoveryPoint recPoint =
                    rpResponse.RecPoint.Properties as ServiceClientModel.GenericRecoveryPoint;

                DateTime recPointTime = DateTime.ParseExact(
                    recPoint.RecoveryPointTime,
                    @"MM/dd/yyyy HH:mm:ss",
                    CultureInfo.InvariantCulture);

                AzureSqlRecoveryPoint sqlResult = new AzureSqlRecoveryPoint()
                {
                    RecoveryPointId      = rpResponse.RecPoint.Name,
                    BackupManagementType = item.BackupManagementType,
                    ItemName             = protectedItemName,
                    ContainerName        = containerName,
                    ContainerType        = item.ContainerType,
                    RecoveryPointTime    = recPointTime,
                    RecoveryPointType    = recPoint.RecoveryPointType,
                    Id           = rpResponse.RecPoint.Id,
                    WorkloadType = item.WorkloadType,
                    RecoveryPointAdditionalInfo = recPoint.RecoveryPointAdditionalInfo,
                    SourceResourceId            = item.SourceResourceId,
                    FriendlyName = recPoint.FriendlyName
                };

                result = sqlResult;
            }
            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the RecoveryPointResource class.
 /// </summary>
 /// <param name="id">Resource Id represents the complete path to the
 /// resource.</param>
 /// <param name="name">Resource name associated with the
 /// resource.</param>
 /// <param name="type">Resource type represents the complete path of
 /// the form Namespace/ResourceType/ResourceType/...</param>
 /// <param name="location">Resource location.</param>
 /// <param name="tags">Resource tags.</param>
 /// <param name="eTag">Optional ETag.</param>
 /// <param name="properties">RecoveryPointResource properties</param>
 public RecoveryPointResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), string eTag = default(string), RecoveryPoint properties = default(RecoveryPoint))
     : base(id, name, type, location, tags, eTag)
 {
     Properties = properties;
     CustomInit();
 }
 /// <summary>
 /// Initializes a new instance of the
 /// OperationStatusRecoveryPointExtendedInfo class.
 /// </summary>
 /// <param name="updatedRecoveryPoint">Recovery Point info with updated
 /// source snapshot URI</param>
 /// <param name="deletedBackupItemVersion">In case the share is in
 /// soft-deleted state, populate this field with deleted backup
 /// item</param>
 public OperationStatusRecoveryPointExtendedInfo(RecoveryPoint updatedRecoveryPoint = default(RecoveryPoint), string deletedBackupItemVersion = default(string))
 {
     UpdatedRecoveryPoint     = updatedRecoveryPoint;
     DeletedBackupItemVersion = deletedBackupItemVersion;
     CustomInit();
 }