// // IResponse.cs // // Author: // MiNG // // Copyright (c) 2018 Alibaba Cloud // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; using System.Collections.Generic; using System.IO; using System.Net.Mime; using System.Threading.Tasks; using Aliyun.Api.LogService.Domain; namespace Aliyun.Api.LogService.Infrastructure.Protocol { /// /// 服务响应包装对象,包含未反序列化的原始数据,可通过 ReadXxxAsync() 方法读取原始报文。 /// public interface IResponse { /// /// 当前响应是否为一个成功的响应。 /// Boolean IsSuccess { get; } /// /// 服务端产生的标示该请求的唯一 ID。 /// 该响应头与具体应用无关,主要用于跟踪和调查问题。 /// 如果用户希望调查出现问题的 API 请求,可以向 Log Service 团队提供该 ID。 /// String RequestId { get; } /// /// 当前响应的元数据。 /// IDictionary Headers { get; } /// /// 当前响应包含的错误信息,在false时存在。 /// Error Error { get; } /// /// 确保当前响应是成功的,否则将抛出包含错误码及错误消息的 。 /// /// 当前响应实例。 /// 当前响应的 不为true IResponse EnsureSuccess(); /// /// 读取原始数据并反序列化为 。 /// 反序列化过程会根据确定原始数据类型。 /// /// 反序列化结果的类型。 /// 反序列化对象异步结果。 Task ReadAsAsync(); /// /// 读取原始数据并且作为字节流的形式返回。 /// /// 异步字节数据流。 Task ReadAsByteStreamAsync(); /// /// 读取原始数据并且作为字节数组的形式返回。 /// /// 异步字节数组。 Task ReadAsByteArrayAsync(); } /// /// 服务响应包装对象,此类型包含一个已反序列化为 结果对象。 /// /// 响应包含结果的类型。 public interface IResponse : IResponse where TResult : class { /// /// 已反序列化的结果对象,在true时存在。 /// TResult Result { get; } /// /// 确保当前响应是成功的,否则将抛出包含错误码及错误消息的 。 /// /// 当前响应实例。 /// 当前响应的 不为true new IResponse EnsureSuccess(); } }