/* * Copyright (C) Alibaba Cloud Computing * All rights reserved. * * 版权所有 (C)阿里云计算有限公司 */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using Aliyun.Api.LOG.Data; using Aliyun.Api.LOG.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Aliyun.Api.LOG.Response { /// /// The response of the GetLog API from sls server /// public class GetLogsResponse : LogResponse { private Int64 _count; private String _progress; private List _logs; /// /// constructor with http header and body from response /// /// http header from response /// http body (in json) from response public GetLogsResponse(IDictionary headers, JArray jsonBody) :base(headers) { String count; if(headers.TryGetValue(LogConsts.NAME_HEADER_X_LOG_COUNT, out count)) { _count = Int64.Parse(count); } headers.TryGetValue(LogConsts.NAME_HEADER_X_LOG_PROGRESS, out _progress); ParseResponseBody(jsonBody); } /// /// The count of logs /// public Int64 Count { get { return _count; } } /// /// detect whether response are complete or not. /// /// true if response is complete. otherwise return false public bool IsCompleted() { return _progress == LogConsts.STATUS_COMPLETE; } /// /// List of logs /// public List Logs { get { return _logs; } } internal override void DeserializeFromJsonInternal(JArray json) { _logs = QueriedLog.DeserializeFromJson(json); } //used only in testing project internal String Print() { StringBuilder strBuilder = new StringBuilder(); strBuilder.Append("{count:" + _count + "," + "progress:" + _progress + ","); if (_logs != null) { strBuilder.Append("{"); foreach (QueriedLog log in _logs) strBuilder.Append("[" + log.Print() + "]"); strBuilder.Append("}"); } strBuilder.Append("}"); return strBuilder.ToString(); } } }