#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.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Management.Automation;
using SolidFire.Core.Validation;
using SolidFire.Core;
using SolidFire.Element.Api;
using SolidFire.Core.Helpers;
#endregion
namespace SolidFire.Volume.Get
{
///
/// Used to return information about one or more scheduled snapshots that have been created.
///
[Cmdlet(VerbsCommon.Get, "SFSchedule")]
public class GetSFSchedule : SFCmdlet
{
#region Parameters
[Parameter(Position = 0, Mandatory = false, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Please enter a schedule ID or list of schedule IDs")]
[ValidateNotNullOrEmpty]
[ValidatePattern(SolidFireValidations.Numeric)]
public long[] ScheduleID { get; set; }
#endregion
#region Cmdlet Overrides
protected override void BeginProcessing()
{
base.BeginProcessing();
CheckConnection(minVersionNumber: 8.0f);
}
protected override void ProcessRecord()
{
base.ProcessRecord();
var schedules = new List();
List results = new List();
var objsFromApi = SendRequest("ListSchedules");
foreach (var result in objsFromApi)
{
schedules.AddRange(ScheduleID == null ? result.Result.Schedules : result.Result.Schedules.Where(s => ScheduleID.ToList().Contains(s.ScheduleID.Value)));
}
WriteObject(schedules, true);
}
#endregion
}
}