#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; using System.Collections; #endregion namespace SolidFire.Async { /// /// GetAsyncResult is used to retrieve the result of asynchronous method calls. Some method calls are long running and do not /// complete when the initial response is sent. To obtain the result of the method call, polling with GetAsyncResult is required. /// GetAsyncResult returns the overall status of the operation (in progress, completed, or error) in a standard fashion, but the actual /// data returned for the operation depends on the original method call and the return data is documented with each method. /// The result for a completed asynchronous method call can only be retrieved once. Once the final result has been returned, later /// attempts returns an error. /// [Cmdlet(VerbsCommon.Get, "SFASyncResult")] public class GetSFASyncResult : SFCmdlet { #region Private Data /// /// /// private Int64 aSyncResultID; #endregion #region Parameters [Parameter(Mandatory = true, Position = 1, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Async Handle from a previous method call")] public Int64 ASyncResultID { get { return aSyncResultID; } set { aSyncResultID = value; } } [Parameter(HelpMessage = "Should the result be kept after this command retrieves it?")] public SwitchParameter KeepResult { get; set; } #endregion #region Cmdlet Overrides protected override void BeginProcessing() { base.BeginProcessing(); CheckConnection(); } /// /// /// protected override void ProcessRecord() { base.ProcessRecord(); var request = new GetAsyncResultRequest(); request.AsyncHandle = aSyncResultID; request.KeepResult = KeepResult.IsPresent; var objsFromAPI = SendRequest("GetAsyncResult", request); foreach (var obj in objsFromAPI) { WriteObject(obj.Result, true); } } #endregion } }