#region Copyright
/*
* Copyright © 2014-2016 NetApp, Inc. All Rights Reserved.
*
* CONFIDENTIALITY NOTICE: THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION OF
* NETAPP, INC. USE, DISCLOSURE OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
* EXPRESS WRITTEN PERMISSION OF NETAPP, INC.
*/
#endregion
#region Using Directives
using System;
using System.ComponentModel;
using System.Management.Automation;
using SolidFire.Core.Validation;
using SolidFire.Core;
using SolidFire.Element.Api;
#endregion
namespace SolidFire.Volume.Remove
{
///
/// RemoveDeletedVolume immediately and permanently purges a volume which has been deleted. A volume must be deleted
/// using DeleteVolume before it can be purged. Volumes are purged automatically after a period of time, so usage of this method
/// is not typically required.
///
[Cmdlet(VerbsCommon.Remove, "SFDeletedVolume", DefaultParameterSetName = "VolumeId", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class RemoveSFDeletedVolume : SFCmdlet
{
#region Private Data
#endregion
#region Parameters
///
/// Array of VolumeIDs to be purged.
///
[Parameter(Position = 0, ParameterSetName = "VolumeID", Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Array of VolumeIDs to be purged.")]
[ValidatePattern(SolidFireValidations.Numeric)]
public Int64[] VolumeID { get; set; }
[Parameter(Position = 0, ParameterSetName = "AccountID", Mandatory = true, HelpMessage = "A list of accountIDs. All of the volumes from all of the specified accounts are purged from the system. Note well: you cannot use this parameter unless all the volumes in a given account have been deleted.")]
public Int64[] AccountID { get; set; }
[Parameter(Position = 0, ParameterSetName = "VolumeAccessGroupID", Mandatory = true, HelpMessage = "A list of volumeAccessGroupIDs. All of the volumes from all of the specified Volume Access Groups are purged from the system. Note well: you cannot use this parameter unless all the volumes in the given VAG have been deleted.")]
public Int64[] VolumeAccessGroupID { get; set; }
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
switch (ParameterSetName)
{
case "VolumeID":
CheckConnection();
break;
case "AccountID":
CheckConnection(9);
break;
case "VolumeAccessGroupID":
CheckConnection(9);
break;
}
}
///
/// Implementation for processing the execution of the cmdlet.
///
protected override void ProcessRecord()
{
switch (ParameterSetName)
{
case "VolumeID":
base.ProcessRecord();
foreach (var id in VolumeID)
{
var request = new PurgeDeletedVolumeRequest();
request.VolumeID = id;
SendRequest("PurgeDeletedVolume", request, false);
}
break;
case "AccountID":
var accountIDRequest = new PurgeDeletedVolumesRequest();
accountIDRequest.AccountIDs = AccountID;
SendRequest("PurgeDeletedVolumes", accountIDRequest);
break;
case "VolumeAccessGroupID":
var VolumeAccessGroupIDRequest = new PurgeDeletedVolumesRequest();
VolumeAccessGroupIDRequest.VolumeAccessGroupIDs = VolumeAccessGroupID;
SendRequest("PurgeDeletedVolumes", VolumeAccessGroupIDRequest);
break;
}
}
#endregion
}
}