GetServiceClientBackupManagementType(
            CmdletModel.BackupManagementType?backupManagementType)
        {
            string providerType = null;

            switch (backupManagementType)
            {
            case CmdletModel.BackupManagementType.AzureVM:
                providerType = ServiceClientModel.BackupManagementType.AzureIaasVM.ToString();
                break;

            case CmdletModel.BackupManagementType.AzureSQL:
                providerType = ServiceClientModel.BackupManagementType.AzureSql.ToString();
                break;

            case CmdletModel.BackupManagementType.AzureStorage:
                providerType = ServiceClientModel.BackupManagementType.AzureStorage.ToString();
                break;

            default:
                break;
            }

            return(providerType);
        }
        public List <ContainerBase> ListProtectionContainers()
        {
            CmdletModel.BackupManagementType?backupManagementTypeNullable =
                (CmdletModel.BackupManagementType?)
                ProviderData[ContainerParams.BackupManagementType];

            if (backupManagementTypeNullable.HasValue)
            {
                ValidateAzureWorkloadBackupManagementType(backupManagementTypeNullable.Value);
            }

            return(AzureWorkloadProviderHelper.ListProtectionContainers(
                       ProviderData,
                       ServiceClientModel.BackupManagementType.AzureWorkload));
        }
        GetServiceClientBackupManagementType(
            CmdletModel.BackupManagementType? backupManagementType)
        {
            ServiceClientModel.BackupManagementType?providerType = null;

            switch (backupManagementType)
            {
            case CmdletModel.BackupManagementType.AzureVM:
                providerType = ServiceClientModel.BackupManagementType.AzureIaasVM;
                break;

            case CmdletModel.BackupManagementType.AzureSQL:
                providerType = ServiceClientModel.BackupManagementType.AzureSql;
                break;

            default:
                break;
            }

            return(providerType);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lists protection containers according to the provider data
        /// </summary>
        /// <returns>List of protection containers</returns>
        public List <ContainerBase> ListProtectionContainers()
        {
            ContainerType containerType =
                (ContainerType)ProviderData[ContainerParams.ContainerType];

            CmdletModel.BackupManagementType?backupManagementTypeNullable =
                (CmdletModel.BackupManagementType?)
                ProviderData[ContainerParams.BackupManagementType];
            string name                        = (string)ProviderData[ContainerParams.Name];
            string friendlyName                = (string)ProviderData[ContainerParams.FriendlyName];
            string resourceGroupName           = (string)ProviderData[ContainerParams.ResourceGroupName];
            ContainerRegistrationStatus status =
                (ContainerRegistrationStatus)ProviderData[ContainerParams.Status];

            if (backupManagementTypeNullable.HasValue)
            {
                ValidateAzureVMBackupManagementType(backupManagementTypeNullable.Value);
            }

            string nameQueryFilter = friendlyName;

            if (!string.IsNullOrEmpty(name))
            {
                Logger.Instance.WriteWarning(Resources.GetContainerNameParamDeprecated);

                if (string.IsNullOrEmpty(friendlyName))
                {
                    nameQueryFilter = name;
                }
            }

            ODataQuery <BMSContainerQueryObject> queryParams = null;

            if (status == 0)
            {
                queryParams = new ODataQuery <BMSContainerQueryObject>(
                    q => q.FriendlyName == nameQueryFilter &&
                    q.BackupManagementType == ServiceClientModel.BackupManagementType.AzureIaasVM);
            }
            else
            {
                var statusString = status.ToString();
                queryParams = new ODataQuery <BMSContainerQueryObject>(
                    q => q.FriendlyName == nameQueryFilter &&
                    q.BackupManagementType == ServiceClientModel.BackupManagementType.AzureIaasVM &&
                    q.Status == statusString);
            }

            var listResponse = ServiceClientAdapter.ListContainers(queryParams);

            List <ContainerBase> containerModels = ConversionHelpers.GetContainerModelList(listResponse);

            // 4. Filter by RG Name
            if (!string.IsNullOrEmpty(resourceGroupName))
            {
                containerModels = containerModels.Where(
                    containerModel =>
                {
                    return(string.Compare(
                               (containerModel as AzureVmContainer).ResourceGroupName,
                               resourceGroupName,
                               true) == 0);
                }).ToList();
            }

            return(containerModels);
        }