#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
{
///
/// RemoveSFGroupSnapshot is used to delete a group snapshot. The saveMembers parameter can be used to preserve all the snapshots
/// that were made for the volumes in the group but the group association will be removed.
///
[Cmdlet(VerbsCommon.Remove, "SFGroupSnapshot", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)]
public class RemoveSFGroupSnapshot : SFCmdlet
{
#region Parameters
///
/// An array of unique volume IDs to query. If this parameter is not specified, all group snapshots on the cluster will be included.
///
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ValueFromRemainingArguments = false, HelpMessage = "Group snapshot ID(s) to remove")]
[ValidatePattern(SolidFireValidations.Numeric)]
public Int64[] GroupSnapshotID { get; set; }
///
/// Specifies whether or not to keep the individual snapshots associate with the group
/// snapshot being removed.
///
[Parameter(Position = 1, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ValueFromRemainingArguments = false, HelpMessage = "Save the individual snapshots for the specified group snapshot ID(s), Default False - Both the group and individual snapshots are removed.")]
public SwitchParameter SaveMembers { get; set; }
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection();
}
///
/// Implementation to remove the group snapshots by id with
/// each call to ProcessRecord. ProcessRecord can be called more
/// than once per execution of the CmdLet.
///
protected override void ProcessRecord()
{
base.ProcessRecord();
foreach (var groupSnapId in this.GroupSnapshotID)
{
var request = new DeleteGroupSnapshotRequest();
request.GroupSnapshotID = groupSnapId;
request.SaveMembers = SaveMembers.IsPresent;
SendRequest("DeleteGroupSnapshot", request);
}
}
#endregion
}
}