예제 #1
0
        /// <summary>
        /// Updates the specified console history metadata.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public UpdateConsoleHistoryResponse UpdateConsoleHistory(UpdateConsoleHistoryRequest param)
        {
            var uri = new Uri($"{GetEndPoint(CoreServices.InstanceConsoleHistory, this.Region)}/{param.InstanceConsoleHistoryId}");

            using (var webResponse = this.RestClient.Put(uri, param.UpdateConsoleHistoryDetails, new HttpRequestHeaderParam()
            {
                IfMatch = param.IfMatch
            }))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = reader.ReadToEnd();

                        return(new UpdateConsoleHistoryResponse()
                        {
                            ConsoleHistory = this.JsonSerializer.Deserialize <ConsoleHistory>(response),
                            ETag = webResponse.Headers.Get("etag"),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id")
                        });
                    }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateConsoleHistoryRequest request;

            try
            {
                request = new UpdateConsoleHistoryRequest
                {
                    InstanceConsoleHistoryId    = InstanceConsoleHistoryId,
                    UpdateConsoleHistoryDetails = UpdateConsoleHistoryDetails,
                    IfMatch = IfMatch
                };

                response = client.UpdateConsoleHistory(request).GetAwaiter().GetResult();
                WriteOutput(response, response.ConsoleHistory);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }