private void MoveRecoveryPoint(Dictionary <Enum, object> ProviderData)
        {
            string            vaultName         = (string)ProviderData[VaultParams.VaultName];
            string            resourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName];
            string            recoveryPointId   = (string)ProviderData[RecoveryPointParams.RecoveryPointId];
            RecoveryPointTier SourceTier        = (RecoveryPointTier)ProviderData[RecoveryPointParams.SourceTier];
            RecoveryPointTier TargetTier        = (RecoveryPointTier)ProviderData[RecoveryPointParams.TargetTier];

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

            recoveryPointId = uriDict[UriEnums.RecoveryPoints];

            ServiceClientModel.MoveRPAcrossTiersRequest moveRPAcrossTiersRequest = new ServiceClientModel.MoveRPAcrossTiersRequest();
            moveRPAcrossTiersRequest.SourceTierType = RecoveryPointConversions.GetServiceClientRecoveryPointTier(SourceTier);
            moveRPAcrossTiersRequest.TargetTierType = RecoveryPointConversions.GetServiceClientRecoveryPointTier(TargetTier);

            var response = ServiceClientAdapter.MoveRecoveryPoint(
                containerUri,
                protectedItemName,
                moveRPAcrossTiersRequest,
                recoveryPointId,
                vaultName,
                resourceGroupName
                );

            HandleCreatedJob(
                response,
                Resources.MoveRPOperation,
                vaultName: vaultName,
                resourceGroupName: resourceGroupName);
        }
        public List <RecoveryPointBase> ListRecoveryPoints(Dictionary <Enum, object> ProviderData)
        {
            string   vaultName             = (string)ProviderData[VaultParams.VaultName];
            string   resourceGroupName     = (string)ProviderData[VaultParams.ResourceGroupName];
            DateTime startDate             = (DateTime)(ProviderData[RecoveryPointParams.StartDate]);
            DateTime endDate               = (DateTime)(ProviderData[RecoveryPointParams.EndDate]);
            string   restorePointQueryType = ProviderData.ContainsKey(RecoveryPointParams.RestorePointQueryType) ?
                                             (string)ProviderData[RecoveryPointParams.RestorePointQueryType] : "All";
            bool secondaryRegion         = (bool)ProviderData[CRRParams.UseSecondaryRegion];
            RecoveryPointTier targetTier = (RecoveryPointTier)ProviderData[RecoveryPointParams.TargetTier];
            bool isReadyForMove          = (bool)ProviderData[RecoveryPointParams.IsReadyForMove];
            RecoveryPointTier tier       = (RecoveryPointTier)ProviderData[RecoveryPointParams.Tier];

            ItemBase item = ProviderData[RecoveryPointParams.Item] as ItemBase;

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

            //we need to fetch the list of RPs
            var queryFilterString = "null";

            if (string.Compare(restorePointQueryType, "All") == 0)
            {
                queryFilterString = QueryBuilder.Instance.GetQueryString(new BMSRPQueryObject()
                {
                    StartDate = startDate,
                    EndDate   = endDate,
                });
            }
            else
            {
                queryFilterString = QueryBuilder.Instance.GetQueryString(new BMSRPQueryObject()
                {
                    StartDate             = startDate,
                    EndDate               = endDate,
                    RestorePointQueryType = restorePointQueryType,
                    ExtendedInfo          = true
                });
            }

            ODataQuery <BMSRPQueryObject> queryFilter = new ODataQuery <BMSRPQueryObject>();

            queryFilter.Filter = queryFilterString;

            List <RecoveryPointResource> rpListResponse;

            if (secondaryRegion)
            {
                //fetch recovery points from secondary region
                rpListResponse = ServiceClientAdapter.GetRecoveryPointsFromSecondaryRegion(
                    containerUri,
                    protectedItemName,
                    queryFilter,
                    vaultName: vaultName,
                    resourceGroupName: resourceGroupName);
            }
            else
            {
                rpListResponse = ServiceClientAdapter.GetRecoveryPoints(
                    containerUri,
                    protectedItemName,
                    queryFilter,
                    vaultName: vaultName,
                    resourceGroupName: resourceGroupName);
            }

            var recoveryPointList = RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item);

            //filter out archived recovery points for secondary region
            if (secondaryRegion)
            {
                recoveryPointList = recoveryPointList.Where(
                    recoveryPoint =>
                {
                    if (recoveryPoint.GetType() == typeof(AzureVmRecoveryPoint))
                    {
                        return(((AzureVmRecoveryPoint)recoveryPoint).RecoveryPointTier != RecoveryPointTier.VaultArchive);
                    }

                    if (recoveryPoint.GetType() == typeof(CmdletModel.AzureWorkloadRecoveryPoint))
                    {
                        return(((CmdletModel.AzureWorkloadRecoveryPoint)recoveryPoint).RecoveryPointTier != RecoveryPointTier.VaultArchive);
                    }

                    return(false);
                }).ToList();
            }

            // filter move readness based on target tier
            recoveryPointList = RecoveryPointConversions.CheckRPMoveReadiness(recoveryPointList, targetTier, isReadyForMove);

            //filter RPs based on tier
            return(RecoveryPointConversions.FilterRPsBasedOnTier(recoveryPointList, tier));
        }
        /// <summary>
        /// filter move readness based on target tier
        /// </summary>
        /// <param name="recoveryPointList"></param>
        /// <param name="TargetTier"></param>
        /// <param name="IsReadyForMove"></param>
        /// <returns></returns>
        public static List <RecoveryPointBase> CheckRPMoveReadiness(List <RecoveryPointBase> recoveryPointList, RecoveryPointTier targetTier, bool isReadyForMove)
        {
            if (recoveryPointList != null && targetTier != 0)   // if TargetTier and IsReadyForMove params are present
            {
                if ((recoveryPointList[0].GetType() == typeof(AzureVmRecoveryPoint) && ((AzureVmRecoveryPoint)recoveryPointList[0]).RecoveryPointMoveReadinessInfo == null) ||
                    (recoveryPointList[0].GetType() == typeof(AzureWorkloadRecoveryPoint) && ((AzureWorkloadRecoveryPoint)recoveryPointList[0]).RecoveryPointMoveReadinessInfo == null))
                {
                    throw new ArgumentException(Resources.MoveReadinessInfoUndefined);
                }

                recoveryPointList = recoveryPointList.Where(
                    recoveryPoint =>
                {
                    if (targetTier == RecoveryPointTier.VaultArchive)
                    {
                        if (recoveryPoint.GetType() == typeof(AzureVmRecoveryPoint) &&
                            ((AzureVmRecoveryPoint)recoveryPoint).RecoveryPointMoveReadinessInfo.ContainsKey(ServiceClientModel.RecoveryPointTierType.ArchivedRP.ToString()))
                        {
                            return(((AzureVmRecoveryPoint)recoveryPoint).RecoveryPointMoveReadinessInfo[ServiceClientModel.RecoveryPointTierType.ArchivedRP.ToString()].IsReadyForMove == isReadyForMove);
                        }

                        if (recoveryPoint.GetType() == typeof(AzureWorkloadRecoveryPoint) &&
                            ((AzureWorkloadRecoveryPoint)recoveryPoint).RecoveryPointMoveReadinessInfo.ContainsKey(ServiceClientModel.RecoveryPointTierType.ArchivedRP.ToString()))
                        {
                            return(((AzureWorkloadRecoveryPoint)recoveryPoint).RecoveryPointMoveReadinessInfo[ServiceClientModel.RecoveryPointTierType.ArchivedRP.ToString()].IsReadyForMove == isReadyForMove);
                        }
                        else
                        {
                            throw new ArgumentException(Resources.ArchiveNotSupported);
                        }
                    }

                    return(false);
                }).ToList();
            }
            return(recoveryPointList);
        }
        /// <summary>
        /// filter RPs based on tier
        /// </summary>
        /// <param name="recoveryPointList"></param>
        /// <param name="Tier"></param>
        /// <returns></returns>
        public static List <RecoveryPointBase> FilterRPsBasedOnTier(List <RecoveryPointBase> recoveryPointList, RecoveryPointTier Tier)
        {
            if (Tier != 0)
            {
                recoveryPointList = recoveryPointList.Where(
                    recoveryPoint =>
                {
                    if (recoveryPoint.GetType() == typeof(AzureVmRecoveryPoint))
                    {
                        return(((AzureVmRecoveryPoint)recoveryPoint).RecoveryPointTier == Tier);
                    }

                    if (recoveryPoint.GetType() == typeof(AzureWorkloadRecoveryPoint))
                    {
                        return(((AzureWorkloadRecoveryPoint)recoveryPoint).RecoveryPointTier == Tier);
                    }

                    return(false);
                }).ToList();
            }
            return(recoveryPointList);
        }
        /// <summary>
        /// Gets Service Client Recovery Point Tier
        /// </summary>
        public static ServiceClientModel.RecoveryPointTierType GetServiceClientRecoveryPointTier(RecoveryPointTier rpTier)
        {
            ServiceClientModel.RecoveryPointTierType recoveryPointTierType = ServiceClientModel.RecoveryPointTierType.Invalid;

            switch (rpTier)
            {
            case RecoveryPointTier.VaultArchive:
                recoveryPointTierType = ServiceClientModel.RecoveryPointTierType.ArchivedRP;
                break;

            case RecoveryPointTier.VaultStandard:
                recoveryPointTierType = ServiceClientModel.RecoveryPointTierType.HardenedRP;
                break;

            case RecoveryPointTier.Snapshot:
                recoveryPointTierType = ServiceClientModel.RecoveryPointTierType.InstantRP;
                break;

            default:
                break;
            }

            return(recoveryPointTierType);
        }