public RestAzureNS.AzureOperationResponse DisableProtectionWithDeleteData() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; bool deleteBackupData = ProviderData.ContainsKey(ItemParams.DeleteBackupData) ? (bool)ProviderData[ItemParams.DeleteBackupData] : false; ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item]; AzureFileShareItem item = (AzureFileShareItem)ProviderData[ItemParams.Item]; string containerUri = ""; string protectedItemUri = ""; AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem(); ValidateAzureFileShareDisableProtectionRequest(itemBase); Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id); containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id); protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id); return(ServiceClientAdapter.DeleteProtectedItem( containerUri, protectedItemUri, vaultName: vaultName, resourceGroupName: vaultResourceGroupName)); }
/// <summary> /// Constructor. Takes the service client object representing the protected item /// and converts it in to the PS protected item model /// </summary> /// <param name="protectedItemResource">Service client object representing the protected item resource</param> /// <param name="containerName">Name of the container associated with this protected item</param> /// <param name="containerType">Type of the container associated with this protected item</param> /// <param name="policyName">Name of the protection policy associated with this protected item</param> public AzureFileShareItem(ProtectedItemResource protectedItemResource, string containerName, ContainerType containerType, string policyName) : base(protectedItemResource, containerName, containerType, policyName) { AzureFileshareProtectedItem protectedItem = (AzureFileshareProtectedItem)protectedItemResource.Properties; LastBackupStatus = protectedItem.LastBackupStatus; LastBackupTime = protectedItem.LastBackupTime; ProtectionState = EnumUtils.GetEnum <ItemProtectionState>(protectedItem.ProtectionState.ToString()); ProtectionStatus = EnumUtils.GetEnum <ItemProtectionStatus>(protectedItem.ProtectionStatus); }
/// <summary> /// Triggers the disable protection operation for the given item /// </summary> /// <returns>The job response returned from the service</returns> public RestAzureNS.AzureOperationResponse <ProtectedItemResource> DisableProtection() { string vaultName = (string)ProviderData[VaultParams.VaultName]; string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; bool deleteBackupData = ProviderData.ContainsKey(ItemParams.DeleteBackupData) ? (bool)ProviderData[ItemParams.DeleteBackupData] : false; ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item]; AzureFileShareItem item = (AzureFileShareItem)ProviderData[ItemParams.Item]; AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem(); return(EnableOrModifyProtection(disableWithRetentionData: true)); }
/// <summary> /// Constructor. Takes the service client object representing the protected item /// and converts it in to the PS protected item model /// </summary> /// <param name="protectedItemResource">Service client object representing the protected item resource</param> /// <param name="containerName">Name of the container associated with this protected item</param> /// <param name="containerType">Type of the container associated with this protected item</param> /// <param name="policyName">Name of the protection policy associated with this protected item</param> public AzureFileShareItem(ProtectedItemResource protectedItemResource, string containerName, ContainerType containerType, string policyName) : base(protectedItemResource, containerName, containerType, policyName) { AzureFileshareProtectedItem protectedItem = (AzureFileshareProtectedItem)protectedItemResource.Properties; LastBackupStatus = protectedItem.LastBackupStatus; LastBackupTime = protectedItem.LastBackupTime; ProtectionState = EnumUtils.GetEnum <ItemProtectionState>(protectedItem.ProtectionState.ToString()); ProtectionStatus = EnumUtils.GetEnum <ItemProtectionStatus>(protectedItem.ProtectionStatus); FriendlyName = protectedItem.FriendlyName; ResourceState = ""; if (protectedItem.ExtendedInfo != null && protectedItem.ExtendedInfo.ResourceState != null) { ResourceState = protectedItem.ExtendedInfo.ResourceState; } }
private RestAzureNS.AzureOperationResponse <ProtectedItemResource> EnableOrModifyProtection(bool disableWithRetentionData = false) { string vaultName = (string)ProviderData[VaultParams.VaultName]; string vaultResourceGroupName = (string)ProviderData[VaultParams.ResourceGroupName]; string azureFileShareName = ProviderData.ContainsKey(ItemParams.ItemName) ? (string)ProviderData[ItemParams.ItemName] : null; string storageAccountName = ProviderData.ContainsKey(ItemParams.StorageAccountName) ? (string)ProviderData[ItemParams.StorageAccountName] : null; string parameterSetName = ProviderData.ContainsKey(ItemParams.ParameterSetName) ? (string)ProviderData[ItemParams.ParameterSetName] : null; PolicyBase policy = ProviderData.ContainsKey(ItemParams.Policy) ? (PolicyBase)ProviderData[ItemParams.Policy] : null; ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item]; AzureFileShareItem item = (AzureFileShareItem)ProviderData[ItemParams.Item]; string containerUri = ""; string protectedItemUri = ""; string sourceResourceId = null; AzureFileshareProtectedItem properties = new AzureFileshareProtectedItem(); if (itemBase == null) { //Enable protection ValidateAzureFilesWorkloadType(policy.WorkloadType); ValidateFileShareEnableProtectionRequest( azureFileShareName, storageAccountName); WorkloadProtectableItemResource protectableObjectResource = GetAzureFileShareProtectableObject( azureFileShareName, storageAccountName, vaultName: vaultName, vaultResourceGroupName: vaultResourceGroupName); Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(protectableObjectResource.Id); containerUri = HelperUtils.GetContainerUri( keyValueDict, protectableObjectResource.Id); protectedItemUri = HelperUtils.GetProtectableItemUri( keyValueDict, protectableObjectResource.Id); AzureFileShareProtectableItem azureFileShareProtectableItem = (AzureFileShareProtectableItem)protectableObjectResource.Properties; if (azureFileShareProtectableItem != null) { sourceResourceId = azureFileShareProtectableItem.ParentContainerFabricId; } // construct Service Client protectedItem request properties.PolicyId = policy.Id; properties.SourceResourceId = sourceResourceId; } else if (itemBase != null && !disableWithRetentionData) { //modify policy with new policy ValidateAzureFilesWorkloadType(item.WorkloadType, policy.WorkloadType); ValidateAzureFilesModifyProtectionRequest(itemBase, policy); Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id); containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id); protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id); sourceResourceId = item.SourceResourceId; // construct Service Client protectedItem request properties.PolicyId = policy.Id; properties.SourceResourceId = sourceResourceId; } else if (disableWithRetentionData) { //Disable protection while retaining backup data ValidateAzureFileShareDisableProtectionRequest(itemBase); Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(item.Id); containerUri = HelperUtils.GetContainerUri(keyValueDict, item.Id); protectedItemUri = HelperUtils.GetProtectedItemUri(keyValueDict, item.Id); properties.PolicyId = string.Empty; properties.ProtectionState = ProtectionState.ProtectionStopped; properties.SourceResourceId = item.SourceResourceId; } ProtectedItemResource serviceClientRequest = new ProtectedItemResource() { Properties = properties }; return(ServiceClientAdapter.CreateOrUpdateProtectedItem( containerUri, protectedItemUri, serviceClientRequest, vaultName: vaultName, resourceGroupName: vaultResourceGroupName)); }