/// <summary> /// Captures the most recent serial console data (up to a megabyte) for the specified instance. /// The CaptureConsoleHistory operation works with the other console history operations as described below. /// 1. Use CaptureConsoleHistory to request the capture of up to a megabyte of the most recent console history. /// This call returns a ConsoleHistory object. The object will have a state of REQUESTED. /// 2. Wait for the capture operation to succeed by polling GetConsoleHistory with the identifier of the console history metadata. /// The state of the ConsoleHistory object will go from REQUESTED to GETTING-HISTORY and then SUCCEEDED (or FAILED). /// 3. Use GetConsoleHistoryContent to get the actual console history data (not the metadata). /// 4. Optionally, use DeleteConsoleHistory to delete the console history metadata and the console history data. /// </summary> /// <param name="param"></param> /// <returns></returns> public CaptureConsoleHistoryResponse CaptureConsoleHistory(CaptureConsoleHistoryRequest param) { var uri = new Uri($"{GetEndPoint(CoreServices.InstanceConsoleHistory, this.Region)}"); using (var webResponse = this.RestClient.Post(uri, param.CaptureConsoleHistoryDetails, new HttpRequestHeaderParam { OpcRetryToken = param.OpcRetryToken })) using (var stream = webResponse.GetResponseStream()) using (var reader = new StreamReader(stream)) { var response = reader.ReadToEnd(); return(new CaptureConsoleHistoryResponse() { ConsoleHistory = this.JsonSerializer.Deserialize <ConsoleHistory>(response), ETag = webResponse.Headers.Get("etag"), OpcRequestId = webResponse.Headers.Get("opc-request-id") }); } }
protected override void ProcessRecord() { base.ProcessRecord(); CaptureConsoleHistoryRequest request; try { request = new CaptureConsoleHistoryRequest { CaptureConsoleHistoryDetails = CaptureConsoleHistoryDetails, OpcRetryToken = OpcRetryToken }; response = client.CaptureConsoleHistory(request).GetAwaiter().GetResult(); WriteOutput(response, response.ConsoleHistory); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }