#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
{
///
/// DeleteVolume marks an active volume for deletion. It is purged (permanently deleted) after the cleanup interval elapses. After
/// making a request to delete a volume, any active iSCSI connections to the volume is immediately terminated and no further
/// connections are allowed while the volume is in this state. It is not returned in target discovery requests.
///
[Cmdlet(VerbsCommon.Remove, "SFVolume", DefaultParameterSetName = "VolumeId", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class RemoveSFVolume : SFCmdlet
{
#region Private Data
///
///
///
private Int64[] _volumeId;
#endregion
#region Parameters
[Parameter(Position = 0, ParameterSetName = "VolumeId", Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ValueFromRemainingArguments = false, HelpMessage = "Please enter a volume ID")]
[ValidateNotNullOrEmpty]
[ValidatePattern(SolidFireValidations.Numeric)]
public Int64[] VolumeID
{
get
{
return _volumeId;
}
set
{
_volumeId = value;
}
}
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection();
}
///
///
///
protected override void ProcessRecord()
{
base.ProcessRecord();
switch (ParameterSetName)
{
case "VolumeId":
ProcessByVolumeId();
break;
default:
throw new ArgumentException("Invalid parameter set.");
}
}
private void ProcessByVolumeId()
{
foreach (var id in _volumeId)
{
var request = new DeleteVolumeRequest();
request.VolumeID = id;
SendRequest("DeleteVolume", request);
}
}
#endregion
}
}