diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a63be3..137b81b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ -# 0.0.4-beta # 0.0.4-beta 2023-02-20 +# 0.0.5-beta 2023-04-14 + +### G42Cloud SDK Core + +- _Features_ + - None +- _Bug Fix_ + - None +- _Change_ + - Optimize the code structure. + +# 0.0.4-beta 2023-02-20 ### G42Cloud SDK CBR diff --git a/Core/Auth/IamService.cs b/Core/Auth/IamService.cs index 4b8f898..6d09cc8 100755 --- a/Core/Auth/IamService.cs +++ b/Core/Auth/IamService.cs @@ -82,7 +82,7 @@ public static string KeystoneListProjects(SdkHttpClient client, HttpRequest requ var message = client.InitHttpRequest(request, true); try { - var response = client.DoHttpRequest(message).Result; + var response = TaskUtils.RunSync(() => client.DoHttpRequest(message)); if ((int)response.StatusCode >= 400) { throw ExceptionUtils.GetException(response); @@ -105,7 +105,7 @@ public static string KeystoneListProjects(SdkHttpClient client, HttpRequest requ } catch (AggregateException aggregateException) { - throw new ConnectionException(ExceptionUtils.GetMessageFromAggregateException(aggregateException)); + throw ExceptionUtils.HandleException(aggregateException); } } @@ -129,7 +129,7 @@ public static string KeystoneListAuthDomains(SdkHttpClient client, HttpRequest r var message = client.InitHttpRequest(request, true); try { - var response = client.DoHttpRequest(message).Result; + var response = TaskUtils.RunSync(() => client.DoHttpRequest(message)); if ((int)response.StatusCode >= 400) { throw ExceptionUtils.GetException(response); @@ -148,7 +148,7 @@ public static string KeystoneListAuthDomains(SdkHttpClient client, HttpRequest r } catch (AggregateException aggregateException) { - throw new ConnectionException(ExceptionUtils.GetMessageFromAggregateException(aggregateException)); + throw ExceptionUtils.HandleException(aggregateException); } } } diff --git a/Core/Client.cs b/Core/Client.cs index 8b79f5e..2932081 100755 --- a/Core/Client.cs +++ b/Core/Client.cs @@ -22,7 +22,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Net.Http; +using System.Runtime.CompilerServices; +using System.Threading; using System.Threading.Tasks; using G42Cloud.SDK.Core.Auth; using Microsoft.Extensions.Logging; @@ -34,7 +37,10 @@ public class Client { public class ClientBuilder where T : Client { - private string[] CredentialType { get; } = {nameof(BasicCredentials)}; + private string[] CredentialType { get; } = + { + nameof(BasicCredentials) + }; public ClientBuilder() { @@ -48,7 +54,7 @@ public ClientBuilder(string credentialType) private Credentials _credentials; private HttpConfig _httpConfig; private Region _region; - private string _endPoint; + private List _endpoints; private bool _enableLogging; private LogLevel _logLevel = LogLevel.Information; private HttpHandler _httpHandler; @@ -74,10 +80,19 @@ public ClientBuilder WithRegion(Region region) this._region = region; return this; } + + [Obsolete("As of 3.1.26, because of the support of the multi-endpoint feature, use WithEndPoints instead")] + public ClientBuilder WithEndPoint(string endpoint) + { + return this.WithEndPoints(new List + { + endpoint + }); + } - public ClientBuilder WithEndPoint(string endPoint) + public ClientBuilder WithEndPoints(List endpoints) { - this._endPoint = endPoint; + this._endpoints = endpoints; return this; } @@ -120,24 +135,29 @@ public T Build() if (this._region != null) { - this._endPoint = _region.Endpoint; + this._endpoints = this._region.Endpoints; this._credentials = _credentials.ProcessAuthParams(client._sdkHttpClient, _region.Id); this._credentials.ProcessDerivedAuthParams(_derivedAuthServiceName, _region.Id); } - if (!_endPoint.StartsWith(HttpScheme)) + for (var i = 0; i < _endpoints.Count; i++) { - _endPoint = HttpsScheme + "://" + _endPoint; + var endpoint = _endpoints[i]; + if (!endpoint.StartsWith(HttpScheme)) + { + _endpoints[i] = HttpsScheme + "://" + endpoint; + } } client.WithCredential(this._credentials) - .WithEndPoint(this._endPoint); + .WithEndPoints(this._endpoints); - return (T) client; + return (T)client; } } - private string _endpoint; + private List _endpoints; + private volatile int _endpointIndex; private HttpConfig _httpConfig; private Credentials _credential; @@ -158,12 +178,13 @@ private Client WithHttpConfig(HttpConfig httpConfig) return this; } - private Client WithEndPoint(string endPoint) + private Client WithEndPoints(List endpoints) { - this._endpoint = endPoint; + this._endpoints = endpoints; return this; } + private void InitSdkHttpClient(HttpHandler httpHandler, bool enableLogging, LogLevel logLevel) { this._sdkHttpClient = @@ -194,16 +215,33 @@ private async Task _async_http(string url, string method, S } catch (AggregateException aggregateException) { - throw new ConnectionException(ExceptionUtils.GetMessageFromAggregateException(aggregateException)); + throw ExceptionUtils.HandleException(aggregateException); } } + [MethodImpl(MethodImplOptions.Synchronized)] protected HttpResponseMessage DoHttpRequestSync(string methodType, SdkRequest request) { - var url = GetRealEndpoint(request) - + HttpUtils.AddUrlPath(request.Path, _credential.GetPathParamDictionary()) - + (IsNullOrEmpty(request.QueryParams) ? "" : "?" + request.QueryParams); - return _sync_http(url, methodType.ToUpper(), request); + while (true) + { + var url = GetRealEndpoint(request) + HttpUtils.AddUrlPath(request.Path, _credential.GetPathParamDictionary()) + + (IsNullOrEmpty(request.QueryParams) ? "" : "?" + request.QueryParams); + try + { + return _sync_http(url, methodType.ToUpper(), request); + } + catch (HostUnreachableException hostUnreachableException) + { + if (this._endpointIndex < this._endpoints.Count - 1) + { + Interlocked.Increment(ref _endpointIndex); + } + else + { + throw hostUnreachableException; + } + } + } } private HttpResponseMessage _sync_http(string url, string method, SdkRequest sdkRequest) @@ -222,23 +260,24 @@ private HttpResponseMessage _sync_http(string url, string method, SdkRequest sdk } catch (AggregateException aggregateException) { - throw new ConnectionException(ExceptionUtils.GetMessageFromAggregateException(aggregateException)); + throw ExceptionUtils.HandleException(aggregateException); } } private string GetRealEndpoint(SdkRequest request) { + var endpoint = this._endpoints[_endpointIndex]; if (String.IsNullOrEmpty(request.Cname)) { - return _endpoint; + return endpoint; } - return _endpoint.Insert(8, request.Cname + "."); - } + return endpoint.Insert(8, request.Cname + "."); + } private HttpResponseMessage GetResult(HttpResponseMessage responseMessage) { - if ((int) responseMessage.StatusCode < 400) + if ((int)responseMessage.StatusCode < 400) { return responseMessage; } @@ -274,4 +313,4 @@ private void UpdateHeaders(HttpRequest request, Dictionary heade request.Headers.Add(XRequestAgent, "g42cloud-usdk-net/3.0"); } } -} \ No newline at end of file +} diff --git a/Core/Exception/ConnectionException.cs b/Core/Exception/ConnectionException.cs index 6683af3..3ed4716 100755 --- a/Core/Exception/ConnectionException.cs +++ b/Core/Exception/ConnectionException.cs @@ -19,15 +19,20 @@ * under the License. */ +using System; + namespace G42Cloud.SDK.Core { public class ConnectionException : SdkException { - public string ErrorMessage { get; set; } - public ConnectionException(string errorMessage) { this.ErrorMessage = errorMessage; } + + public ConnectionException(string errorMessage, Exception innerException) : base(errorMessage, innerException) + { + this.ErrorMessage = errorMessage; + } } } \ No newline at end of file diff --git a/Core/Exception/HostUnreachableException.cs b/Core/Exception/HostUnreachableException.cs index 06992bd..bb9f3d3 100755 --- a/Core/Exception/HostUnreachableException.cs +++ b/Core/Exception/HostUnreachableException.cs @@ -19,13 +19,20 @@ * under the License. */ +using System; + namespace G42Cloud.SDK.Core { public class HostUnreachableException : ConnectionException { - public HostUnreachableException(string errorMessage):base(errorMessage) + public HostUnreachableException(string errorMessage) : base(errorMessage) + { + this.ErrorMessage = errorMessage; + } + + public HostUnreachableException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { this.ErrorMessage = errorMessage; } } -} \ No newline at end of file +} diff --git a/Core/Exception/RequestTimeoutException.cs b/Core/Exception/RequestTimeoutException.cs index 96ce405..6b60083 100755 --- a/Core/Exception/RequestTimeoutException.cs +++ b/Core/Exception/RequestTimeoutException.cs @@ -19,15 +19,20 @@ * under the License. */ +using System; + namespace G42Cloud.SDK.Core { public class RequestTimeoutException : SdkException { - public string ErrorMessage { get; set; } - public RequestTimeoutException(string errorMessage) { this.ErrorMessage = errorMessage; } + + public RequestTimeoutException(string errorMessage, Exception innerException) : base(errorMessage, innerException) + { + this.ErrorMessage = errorMessage; + } } } \ No newline at end of file diff --git a/Core/Exception/SdkError.cs b/Core/Exception/SdkError.cs index 8371758..c5af701 100755 --- a/Core/Exception/SdkError.cs +++ b/Core/Exception/SdkError.cs @@ -31,14 +31,15 @@ public class SdkError : SdkResponse [XmlElement("Message")] public string ErrorMsg { get; set; } - [JsonProperty("error_code", NullValueHandling = NullValueHandling.Ignore)] - [XmlElement("Code")] + [JsonProperty("error_code", NullValueHandling = NullValueHandling.Ignore)] [XmlElement("Code")] public string ErrorCode; - [JsonProperty("request_id", NullValueHandling = NullValueHandling.Ignore)] - [XmlElement("RequestId")] + [JsonProperty("request_id", NullValueHandling = NullValueHandling.Ignore)] [XmlElement("RequestId")] public string RequestId; + [JsonProperty("encoded_authorization_message", NullValueHandling = NullValueHandling.Ignore)] [XmlElement("EncodedAuthorizationMessage")] + public string EncodedAuthorizationMessage; + public SdkError() { } @@ -49,16 +50,16 @@ public SdkError(string errorCode, string errorMsg, string requestId) this.ErrorMsg = errorMsg; this.RequestId = requestId; } - + public SdkError(string errorCode, string errorMsg) { this.ErrorCode = errorCode; this.ErrorMsg = errorMsg; } - + public SdkError(string errorMsg) { this.ErrorMsg = errorMsg; } } -} \ No newline at end of file +} diff --git a/Core/Exception/SdkException.cs b/Core/Exception/SdkException.cs index a646055..9fcceb2 100755 --- a/Core/Exception/SdkException.cs +++ b/Core/Exception/SdkException.cs @@ -25,5 +25,20 @@ namespace G42Cloud.SDK.Core { public class SdkException : Exception { + protected SdkException() + { + + } + public string ErrorMessage { get; set; } + + public SdkException(string errorMessage) : base(errorMessage) + { + this.ErrorMessage = errorMessage; + } + + public SdkException(string errorMessage, Exception innerException) : base(errorMessage, innerException) + { + this.ErrorMessage = errorMessage; + } } } \ No newline at end of file diff --git a/Core/Exception/ServiceResponseException.cs b/Core/Exception/ServiceResponseException.cs index 220933a..4e192cc 100755 --- a/Core/Exception/ServiceResponseException.cs +++ b/Core/Exception/ServiceResponseException.cs @@ -31,12 +31,15 @@ public class ServiceResponseException : SdkException public string RequestId { get; set; } + public string EncodedAuthorizationMessage { get; set; } + public ServiceResponseException(int? httpStatusCode, SdkError sdkError) { this.HttpStatusCode = httpStatusCode; this.ErrorCode = sdkError.ErrorCode; this.ErrorMsg = sdkError.ErrorMsg; this.RequestId = sdkError.RequestId; + this.EncodedAuthorizationMessage = sdkError.EncodedAuthorizationMessage; } public static ServiceResponseException MapException(int? httpStatusCode, SdkError sdkError) @@ -54,4 +57,4 @@ public static ServiceResponseException MapException(int? httpStatusCode, SdkErro return new ServiceResponseException(httpStatusCode, sdkError); } } -} \ No newline at end of file +} diff --git a/Core/Exception/SslHandShakeException.cs b/Core/Exception/SslHandShakeException.cs index aac88aa..d592d99 100755 --- a/Core/Exception/SslHandShakeException.cs +++ b/Core/Exception/SslHandShakeException.cs @@ -19,13 +19,20 @@ * under the License. */ +using System; + namespace G42Cloud.SDK.Core { public class SslHandShakeException : ConnectionException { - public SslHandShakeException(string errorMessage):base(errorMessage) + public SslHandShakeException(string errorMessage) : base(errorMessage) + { + this.ErrorMessage = errorMessage; + } + + public SslHandShakeException(string errorMessage, Exception innerException) : base(errorMessage, innerException) { this.ErrorMessage = errorMessage; } } -} \ No newline at end of file +} diff --git a/Core/Http/HttpRequest.cs b/Core/Http/HttpRequest.cs index 82c7aad..fd67d86 100755 --- a/Core/Http/HttpRequest.cs +++ b/Core/Http/HttpRequest.cs @@ -23,7 +23,6 @@ using System.Collections.Generic; using System.IO; using System.Net; -using System.Web; namespace G42Cloud.SDK.Core { @@ -87,11 +86,11 @@ private void ParseQueryParam() foreach (var kv in Url.Query.Substring(1).Split('&')) { var spl = kv.Split(new char[] {'='}, 2); - var key = HttpUtility.UrlDecode(spl[0]); + var key = WebUtility.UrlDecode(spl[0]); var value = ""; if (spl.Length > 1) { - value = HttpUtility.UrlDecode(spl[1]); + value = WebUtility.UrlDecode(spl[1]); } if (QueryParam.ContainsKey(key)) diff --git a/Core/Region/Region.cs b/Core/Region/Region.cs index e6df1d9..8602a66 100755 --- a/Core/Region/Region.cs +++ b/Core/Region/Region.cs @@ -1,21 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; + namespace G42Cloud.SDK.Core { public class Region { public string Id { get; set; } - public string Endpoint { get; set; } + private List _endpoints; + + [Obsolete("As of 3.1.26, because of the support of the multi-endpoint feature, use Endpoints instead")] + public string Endpoint + { + get { return _endpoints == null || _endpoints.Count == 0 ? null : _endpoints[0]; } + set + { + Endpoints = new List + { + value + }; + } + } - public Region(string id, string endpoint) + public List Endpoints + { + get { return _endpoints; } + set { _endpoints = value; } + } + + + public Region(string id, params string[] endpoints) { Id = id; - Endpoint = endpoint; + Endpoints = endpoints.ToList(); } + [Obsolete("As of 3.1.26, because of the support of the multi-endpoint feature, use WithEndpointsOverride instead")] public Region WithEndpointOverride(string newEndpoint) { - Endpoint = newEndpoint; + return WithEndpointsOverride(new List + { + newEndpoint + }); + } + + public Region WithEndpointsOverride(List endpoints) + { + Endpoints = endpoints; return this; } } -} \ No newline at end of file +} diff --git a/Core/Signer/DerivedSigner.cs b/Core/Signer/DerivedSigner.cs index da21d1a..7918277 100755 --- a/Core/Signer/DerivedSigner.cs +++ b/Core/Signer/DerivedSigner.cs @@ -12,13 +12,14 @@ public class DerivedSigner : Signer public void Sign(HttpRequest request, string regionId, string derivedAuthServiceName) { + verifyAkSk(); if (string.IsNullOrEmpty(regionId)) { - throw new ArgumentException("regionId in credential is required when using derived auth"); + throw new ArgumentException("regionId is required in credentials when using derived auth"); } if (string.IsNullOrEmpty(derivedAuthServiceName)) { - throw new ArgumentException("derivedAuthServiceName in credential is required when using derived auth"); + throw new ArgumentException("derivedAuthServiceName is required in credentials when using derived auth"); } // Add X-Sdk-Date var time = request.Headers.GetValues(HeaderXDate); diff --git a/Core/Signer/Signer.cs b/Core/Signer/Signer.cs index 8338bf9..fff1552 100755 --- a/Core/Signer/Signer.cs +++ b/Core/Signer/Signer.cs @@ -38,13 +38,18 @@ public partial class Signer protected const string HeaderHost = "host"; protected const string HeaderAuthorization = "Authorization"; const string HeaderContentSha256 = "X-Sdk-Content-Sha256"; - private readonly HashSet _unsignedHeaders = new HashSet {"content-type"}; + + private readonly HashSet _unsignedHeaders = new HashSet + { + "content-type" + }; public string Key { get; set; } public string Secret { get; set; } public void Sign(HttpRequest request) { + verifyAkSk(); var time = request.Headers.GetValues(HeaderXDate); DateTime t; if (time == null) @@ -73,6 +78,18 @@ public void Sign(HttpRequest request) request.Headers.Set(HeaderAuthorization, authValue); } + protected void verifyAkSk() + { + if (string.IsNullOrEmpty(Key)) + { + throw new ArgumentException("Ak is required in credentials"); + } + if (string.IsNullOrEmpty(Secret)) + { + throw new ArgumentException("Sk is required in credentials"); + } + } + /// /// Build a CanonicalRequest from a regular request string /// CanonicalRequest consists of several parts: @@ -145,9 +162,9 @@ private string CanonicalHeaders(HttpRequest request) protected List ProcessSignedHeaders(HttpRequest request) { var signedHeaders = (from key in request.Headers.AllKeys - let keyLower = key.ToLower() - where !_unsignedHeaders.Contains(keyLower) - select key.ToLower()).ToList(); + let keyLower = key.ToLower() + where !_unsignedHeaders.Contains(keyLower) + select key.ToLower()).ToList(); signedHeaders.Sort(CompareOrdinal); return signedHeaders; @@ -201,10 +218,10 @@ private static char GetHexValue(int i) { if (i < 10) { - return (char) (i + '0'); + return (char)(i + '0'); } - return (char) (i - 10 + 'a'); + return (char)(i - 10 + 'a'); } protected string StringToSign(string canonicalRequest, DateTime t) @@ -232,4 +249,4 @@ private byte[] HMacSha256(byte[] keyByte, string message) } } } -} \ No newline at end of file +} diff --git a/Core/Utils/ExceptionUtils.cs b/Core/Utils/ExceptionUtils.cs index 2fc3e70..0ccf938 100755 --- a/Core/Utils/ExceptionUtils.cs +++ b/Core/Utils/ExceptionUtils.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Net.Http; using System.Text; using Newtonsoft.Json; @@ -33,6 +34,11 @@ namespace G42Cloud.SDK.Core public static class ExceptionUtils { private const string XRequestId = "X-Request-Id"; + private const string EncodedAuthorizationMessage = "encoded_authorization_message"; + private const string ErrorCode = "error_code"; + private const string ErrorMsg = "error_msg"; + private const string Code = "code"; + private const string Message = "message"; public static string GetMessageFromAggregateException(AggregateException aggregateException) { @@ -45,11 +51,51 @@ public static string GetMessageFromAggregateException(AggregateException aggrega return messages.ToString(); } + public static SdkException HandleException(Exception exception) + { + if (exception is AggregateException) + { + if (exception.InnerException is SdkException sdkException) + { + return sdkException; + } + + if (exception.InnerException is HttpRequestException httpRequestException) + { + if (httpRequestException.InnerException == null) + { + return new ConnectionException(httpRequestException.Message, exception); + } + + if (httpRequestException.InnerException is WebException webException) + { + switch (webException.Status) + { + case WebExceptionStatus.NameResolutionFailure: + return new HostUnreachableException(webException.Message, exception); + case WebExceptionStatus.TrustFailure: + return new SslHandShakeException(webException.Message, exception); + case WebExceptionStatus.Timeout: + return new RequestTimeoutException(webException.Message, exception); + default: + return new ConnectionException(webException.Message, exception); + } + } + } + + if (exception.InnerException != null) + { + return new SdkException(exception.InnerException.Message, exception.InnerException); + } + } + return new SdkException(exception.Message, exception); + } + public static ServiceResponseException GetException(HttpResponseMessage responseMessage) { var result = new SdkResponse { - HttpStatusCode = (int) responseMessage.StatusCode, + HttpStatusCode = (int)responseMessage.StatusCode, HttpHeaders = responseMessage.Headers.ToString(), HttpBody = Encoding.UTF8.GetString(responseMessage.Content.ReadAsByteArrayAsync().Result) }; @@ -64,16 +110,19 @@ public static ServiceResponseException GetException(HttpResponseMessage response try { sdkError = responseMessage.Content.Headers.ContentType.MediaType.Equals("application/xml") - ? XmlUtils.DeSerialize(result) + ? XmlUtils.DeSerialize(result) : GetSdkErrorFromResponse(requestId, result); } catch (Exception exception) { throw new ServerResponseException(result.HttpStatusCode, - new SdkError {ErrorMsg = exception.Message}); + new SdkError + { + ErrorMsg = exception.Message + }); } - throw ServiceResponseException.MapException((int) responseMessage.StatusCode, sdkError); + throw ServiceResponseException.MapException((int)responseMessage.StatusCode, sdkError); } private static SdkError GetSdkErrorFromResponse(string requestId, SdkResponse response) @@ -87,14 +136,18 @@ private static SdkError GetSdkErrorFromResponse(string requestId, SdkResponse re sdkError = HandleServiceCommonException(response); } } - catch (Exception) + catch (JsonReaderException) { - sdkError = new SdkError(); + sdkError = new SdkError(response.HttpBody); + } + catch (Exception e) + { + sdkError = new SdkError(e.Message); } if (IsNullOrEmpty(sdkError.ErrorMsg)) { - sdkError = HandleServiceSpecException(response); + sdkError = new SdkError(response.HttpBody); } if (IsNullOrEmpty(sdkError.RequestId)) @@ -105,38 +158,51 @@ private static SdkError GetSdkErrorFromResponse(string requestId, SdkResponse re return sdkError; } - private static SdkError HandleServiceSpecException(SdkResponse response) + private static void ProcessSdkError(JObject jObject, SdkError sdkError) { - return new SdkError(); - } + if (jObject.ContainsKey(EncodedAuthorizationMessage)) + { + sdkError.EncodedAuthorizationMessage = jObject[EncodedAuthorizationMessage].ToString(); + } - private static SdkError HandleServiceCommonException(SdkResponse response) - { - var exception = JsonConvert.DeserializeObject>(response.HttpBody); - if (exception.ContainsKey("code") && exception.ContainsKey("message")) + if (jObject.ContainsKey(ErrorCode) && jObject.ContainsKey(ErrorMsg)) { - return new SdkError(exception["code"].ToString(), exception["message"].ToString()); + sdkError.ErrorCode = jObject[ErrorCode].ToString(); + sdkError.ErrorMsg = jObject[ErrorMsg].ToString(); + return; } - foreach (var item in exception) + if (jObject.ContainsKey(Code) && jObject.ContainsKey(Message)) { - var jValue = JObject.Parse(item.Value.ToString()); - var errorCode = jValue["error_code"]; - var errorMsg = jValue["error_msg"]; - if (errorCode != null && errorMsg != null) - { - return new SdkError(errorCode.ToString(), errorMsg.ToString()); - } + sdkError.ErrorCode = jObject[Code].ToString(); + sdkError.ErrorMsg = jObject[Message].ToString(); + return; + } - var message = jValue["message"]; - var code = jValue["code"]; - if (message != null && code != null) + foreach (var pair in jObject) + { + if (pair.Value is JObject value) { - return new SdkError(code.ToString(), message.ToString()); + ProcessSdkError(value, sdkError); } } + } + + private static SdkError HandleServiceCommonException(SdkResponse response) + { + var errorDict = JsonConvert.DeserializeObject(response.HttpBody); + if (errorDict == null) + { + return new SdkError(response.HttpBody); + } - return new SdkError(response.HttpBody); + var sdkError = new SdkError(); + ProcessSdkError(errorDict, sdkError); + if (sdkError.ErrorMsg == null) + { + sdkError.ErrorMsg = response.HttpBody; + } + return sdkError; } } -} \ No newline at end of file +} diff --git a/Core/Utils/TaskUtils.cs b/Core/Utils/TaskUtils.cs new file mode 100755 index 0000000..68ab087 --- /dev/null +++ b/Core/Utils/TaskUtils.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace G42Cloud.SDK.Core +{ + public static class TaskUtils + { + public static T RunSync(Func> task) + { + var oldContext = SynchronizationContext.Current; + if (oldContext == null) + { + return task.Invoke().Result; + } + + var exclusiveContext = new ExclusiveSynchronizationContext(); + SynchronizationContext.SetSynchronizationContext(exclusiveContext); + var result = default(T); + exclusiveContext.Post(async _ => + { + try + { + result = await task(); + } + catch (Exception e) + { + exclusiveContext.InnerException = e; + throw; + } + finally + { + exclusiveContext.EndMessageLoop(); + } + }, null); + exclusiveContext.BeginMessageLoop(); + SynchronizationContext.SetSynchronizationContext(oldContext); + return result; + } + + private class ExclusiveSynchronizationContext : SynchronizationContext + { + public Exception InnerException { get; set; } + + private bool _done; + + private readonly AutoResetEvent _workItemsWaiting = new AutoResetEvent(false); + + private readonly Queue> _items = new Queue>(); + + public override void Send(SendOrPostCallback d, object state) + { + throw new NotSupportedException("Cannot send to the same thread"); + } + + public override void Post(SendOrPostCallback d, object state) + { + lock (_items) + { + _items.Enqueue(Tuple.Create(d, state)); + } + _workItemsWaiting.Set(); + } + + public void EndMessageLoop() + { + Post(_ => _done = true, null); + } + + public void BeginMessageLoop() + { + while (!_done) + { + Tuple task = null; + lock (_items) + { + if (_items.Count > 0) + { + task = _items.Dequeue(); + } + } + if (task != null) + { + task.Item1(task.Item2); + if (InnerException != null) + { + throw new AggregateException(InnerException); + } + } + else + { + _workItemsWaiting.WaitOne(); + } + } + } + + public override SynchronizationContext CreateCopy() + { + return this; + } + } + } +} diff --git a/Core/obj/Core.csproj.nuget.cache b/Core/obj/Core.csproj.nuget.cache index 7065053..ab7b764 100644 --- a/Core/obj/Core.csproj.nuget.cache +++ b/Core/obj/Core.csproj.nuget.cache @@ -1,5 +1,5 @@ { "version": 1, - "dgSpecHash": "jMlS+vAjPG5B7D2lhHQAyXo/t0SQxMYlIjZEHM/1wdRrviXrfEzd9Pgx5nD5J9fbLwGDob3nVvNQCWAjGA2+LA==", + "dgSpecHash": "ni+h4mW2edx+EFg4KH0Mp+ym7+P9OvG1mggreTiYLE4kXYEpbQaDt++JEUapSOMlibFYboN1p8YL5vvJDxf61A==", "success": true } \ No newline at end of file diff --git a/Core/obj/Core.csproj.nuget.dgspec.json b/Core/obj/Core.csproj.nuget.dgspec.json index 89b9784..195fb2d 100644 --- a/Core/obj/Core.csproj.nuget.dgspec.json +++ b/Core/obj/Core.csproj.nuget.dgspec.json @@ -1,17 +1,17 @@ { "format": 1, "restore": { - "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/Core.csproj": {} + "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/Core.csproj": {} }, "projects": { - "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/Core.csproj": { + "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/Core.csproj": { "version": "1.0.0", "restore": { - "projectUniqueName": "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/Core.csproj", + "projectUniqueName": "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/Core.csproj", "projectName": "G42Cloud.SDK.Core", - "projectPath": "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/Core.csproj", + "projectPath": "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/Core.csproj", "packagesPath": "/root/.nuget/packages/", - "outputPath": "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/obj/", + "outputPath": "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/obj/", "projectStyle": "PackageReference", "fallbackFolders": [ "/usr/dotnet2/sdk/NuGetFallbackFolder" @@ -23,7 +23,7 @@ "netstandard2.0" ], "sources": { - "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/package": {} + "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/package": {} }, "frameworks": { "netstandard2.0": { diff --git a/Core/obj/Core.csproj.nuget.g.props b/Core/obj/Core.csproj.nuget.g.props index 8d8e258..f3dd1a3 100644 --- a/Core/obj/Core.csproj.nuget.g.props +++ b/Core/obj/Core.csproj.nuget.g.props @@ -3,7 +3,7 @@ True NuGet - /data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/obj/project.assets.json + /data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/obj/project.assets.json /root/.nuget/packages/ /root/.nuget/packages/;/usr/dotnet2/sdk/NuGetFallbackFolder PackageReference diff --git a/Core/obj/project.assets.json b/Core/obj/project.assets.json index 0cc5a51..694455b 100644 --- a/Core/obj/project.assets.json +++ b/Core/obj/project.assets.json @@ -1051,11 +1051,11 @@ "project": { "version": "1.0.0", "restore": { - "projectUniqueName": "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/Core.csproj", + "projectUniqueName": "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/Core.csproj", "projectName": "G42Cloud.SDK.Core", - "projectPath": "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/Core.csproj", + "projectPath": "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/Core.csproj", "packagesPath": "/root/.nuget/packages/", - "outputPath": "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/Core/obj/", + "outputPath": "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/Core/obj/", "projectStyle": "PackageReference", "fallbackFolders": [ "/usr/dotnet2/sdk/NuGetFallbackFolder" @@ -1067,7 +1067,7 @@ "netstandard2.0" ], "sources": { - "/data/fuxi_ci_workspace/63f2dfbecb305611defe8e46/package": {} + "/data/fuxi_ci_workspace/6438ba837f701874a66183c8/package": {} }, "frameworks": { "netstandard2.0": { diff --git a/G42Cloud.sln b/G42Cloud.sln index a90343e..6e17e89 100644 --- a/G42Cloud.sln +++ b/G42Cloud.sln @@ -5,27 +5,27 @@ VisualStudioVersion = 15.0.26124.0 MinimumVisualStudioVersion = 15.0.26124.0 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{863F0212-886F-42E1-89D6-D05075529D8A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{5BEDE243-F387-4427-8FDE-12B9AEB5DF9C}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{11A091EC-8F2C-453F-A201-D34916CF05F6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cdn", "Services\Cdn\Cdn.csproj", "{456c6dc7-f610-410e-85a1-189ba73f1e43}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elb", "Services\Elb\Elb.csproj", "{e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cce", "Services\Cce\Cce.csproj", "{a4aaea74-f41e-4c56-b64e-7a2496ff4351}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ims", "Services\Ims\Ims.csproj", "{5B7BFA6B-B85E-4222-8988-16CCF9558393}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ecs", "Services\Ecs\Ecs.csproj", "{c3aaea74-f41e-4c56-b64e-7a2496ff6551}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evs", "Services\Evs\Evs.csproj", "{B6D999F9-9335-433F-BCD2-1E07409AFA39}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ims", "Services\Ims\Ims.csproj", "{5B7BFA6B-B85E-4222-8988-16CCF9558393}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ecs", "Services\Ecs\Ecs.csproj", "{c3aaea74-f41e-4c56-b64e-7a2496ff6551}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vpc", "Services\Vpc\Vpc.csproj", "{96f50236-7030-47ab-af32-bb76484fadec}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Smn", "Services\Smn\Smn.csproj", "{ced0cfa7-3d43-457f-9f81-f1695a6c65cd}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ces", "Services\Ces\Ces.csproj", "{ef66723c-296f-90fe-1bd4-6684bbb02913}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cbr", "Services\Cbr\Cbr.csproj", "{d5af20cc-1577-e1eb-419c-1d1c08a09995}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vpc", "Services\Vpc\Vpc.csproj", "{96f50236-7030-47ab-af32-bb76484fadec}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evs", "Services\Evs\Evs.csproj", "{B6D999F9-9335-433F-BCD2-1E07409AFA39}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cce", "Services\Cce\Cce.csproj", "{a4aaea74-f41e-4c56-b64e-7a2496ff4351}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ces", "Services\Ces\Ces.csproj", "{ef66723c-296f-90fe-1bd4-6684bbb02913}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cbr", "Services\Cbr\Cbr.csproj", "{d5af20cc-1577-e1eb-419c-1d1c08a09995}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elb", "Services\Elb\Elb.csproj", "{e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -64,42 +64,18 @@ Global {456c6dc7-f610-410e-85a1-189ba73f1e43}.Release|x64.Build.0 = Release|Any CPU {456c6dc7-f610-410e-85a1-189ba73f1e43}.Release|x86.ActiveCfg = Release|Any CPU {456c6dc7-f610-410e-85a1-189ba73f1e43}.Release|x86.Build.0 = Release|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|Any CPU.Build.0 = Debug|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x64.ActiveCfg = Debug|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x64.Build.0 = Debug|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x86.ActiveCfg = Debug|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x86.Build.0 = Debug|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|Any CPU.ActiveCfg = Release|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|Any CPU.Build.0 = Release|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x64.ActiveCfg = Release|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x64.Build.0 = Release|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x86.ActiveCfg = Release|Any CPU - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x86.Build.0 = Release|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x64.ActiveCfg = Debug|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x64.Build.0 = Debug|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x86.ActiveCfg = Debug|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x86.Build.0 = Debug|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|Any CPU.Build.0 = Release|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x64.ActiveCfg = Release|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x64.Build.0 = Release|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x86.ActiveCfg = Release|Any CPU - {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x86.Build.0 = Release|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x64.ActiveCfg = Debug|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x64.Build.0 = Debug|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x86.ActiveCfg = Debug|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x86.Build.0 = Debug|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|Any CPU.Build.0 = Release|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x64.ActiveCfg = Release|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x64.Build.0 = Release|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x86.ActiveCfg = Release|Any CPU - {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x86.Build.0 = Release|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|Any CPU.Build.0 = Debug|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x64.ActiveCfg = Debug|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x64.Build.0 = Debug|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x86.ActiveCfg = Debug|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x86.Build.0 = Debug|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|Any CPU.ActiveCfg = Release|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|Any CPU.Build.0 = Release|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x64.ActiveCfg = Release|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x64.Build.0 = Release|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x86.ActiveCfg = Release|Any CPU + {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x86.Build.0 = Release|Any CPU {c3aaea74-f41e-4c56-b64e-7a2496ff6551}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {c3aaea74-f41e-4c56-b64e-7a2496ff6551}.Debug|Any CPU.Build.0 = Debug|Any CPU {c3aaea74-f41e-4c56-b64e-7a2496ff6551}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -112,30 +88,18 @@ Global {c3aaea74-f41e-4c56-b64e-7a2496ff6551}.Release|x64.Build.0 = Release|Any CPU {c3aaea74-f41e-4c56-b64e-7a2496ff6551}.Release|x86.ActiveCfg = Release|Any CPU {c3aaea74-f41e-4c56-b64e-7a2496ff6551}.Release|x86.Build.0 = Release|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x64.ActiveCfg = Debug|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x64.Build.0 = Debug|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x86.ActiveCfg = Debug|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x86.Build.0 = Debug|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|Any CPU.Build.0 = Release|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x64.ActiveCfg = Release|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x64.Build.0 = Release|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x86.ActiveCfg = Release|Any CPU - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x86.Build.0 = Release|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x64.ActiveCfg = Debug|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x64.Build.0 = Debug|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x86.ActiveCfg = Debug|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x86.Build.0 = Debug|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|Any CPU.Build.0 = Release|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x64.ActiveCfg = Release|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x64.Build.0 = Release|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x86.ActiveCfg = Release|Any CPU - {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x86.Build.0 = Release|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x64.ActiveCfg = Debug|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x64.Build.0 = Debug|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x86.ActiveCfg = Debug|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Debug|x86.Build.0 = Debug|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|Any CPU.Build.0 = Release|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x64.ActiveCfg = Release|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x64.Build.0 = Release|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x86.ActiveCfg = Release|Any CPU + {5B7BFA6B-B85E-4222-8988-16CCF9558393}.Release|x86.Build.0 = Release|Any CPU {96f50236-7030-47ab-af32-bb76484fadec}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {96f50236-7030-47ab-af32-bb76484fadec}.Debug|Any CPU.Build.0 = Debug|Any CPU {96f50236-7030-47ab-af32-bb76484fadec}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -148,18 +112,18 @@ Global {96f50236-7030-47ab-af32-bb76484fadec}.Release|x64.Build.0 = Release|Any CPU {96f50236-7030-47ab-af32-bb76484fadec}.Release|x86.ActiveCfg = Release|Any CPU {96f50236-7030-47ab-af32-bb76484fadec}.Release|x86.Build.0 = Release|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|Any CPU.Build.0 = Debug|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x64.ActiveCfg = Debug|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x64.Build.0 = Debug|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x86.ActiveCfg = Debug|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Debug|x86.Build.0 = Debug|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|Any CPU.ActiveCfg = Release|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|Any CPU.Build.0 = Release|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x64.ActiveCfg = Release|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x64.Build.0 = Release|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x86.ActiveCfg = Release|Any CPU - {a4aaea74-f41e-4c56-b64e-7a2496ff4351}.Release|x86.Build.0 = Release|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x64.ActiveCfg = Debug|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x64.Build.0 = Debug|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x86.ActiveCfg = Debug|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Debug|x86.Build.0 = Debug|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|Any CPU.Build.0 = Release|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x64.ActiveCfg = Release|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x64.Build.0 = Release|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x86.ActiveCfg = Release|Any CPU + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd}.Release|x86.Build.0 = Release|Any CPU {d5af20cc-1577-e1eb-419c-1d1c08a09995}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {d5af20cc-1577-e1eb-419c-1d1c08a09995}.Debug|Any CPU.Build.0 = Debug|Any CPU {d5af20cc-1577-e1eb-419c-1d1c08a09995}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -172,17 +136,53 @@ Global {d5af20cc-1577-e1eb-419c-1d1c08a09995}.Release|x64.Build.0 = Release|Any CPU {d5af20cc-1577-e1eb-419c-1d1c08a09995}.Release|x86.ActiveCfg = Release|Any CPU {d5af20cc-1577-e1eb-419c-1d1c08a09995}.Release|x86.Build.0 = Release|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x64.ActiveCfg = Debug|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x64.Build.0 = Debug|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x86.ActiveCfg = Debug|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Debug|x86.Build.0 = Debug|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|Any CPU.Build.0 = Release|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x64.ActiveCfg = Release|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x64.Build.0 = Release|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x86.ActiveCfg = Release|Any CPU + {B6D999F9-9335-433F-BCD2-1E07409AFA39}.Release|x86.Build.0 = Release|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x64.ActiveCfg = Debug|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x64.Build.0 = Debug|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x86.ActiveCfg = Debug|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Debug|x86.Build.0 = Debug|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|Any CPU.Build.0 = Release|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x64.ActiveCfg = Release|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x64.Build.0 = Release|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x86.ActiveCfg = Release|Any CPU + {ef66723c-296f-90fe-1bd4-6684bbb02913}.Release|x86.Build.0 = Release|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|Any CPU.Build.0 = Debug|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x64.ActiveCfg = Debug|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x64.Build.0 = Debug|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x86.ActiveCfg = Debug|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Debug|x86.Build.0 = Debug|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|Any CPU.ActiveCfg = Release|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|Any CPU.Build.0 = Release|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x64.ActiveCfg = Release|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x64.Build.0 = Release|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x86.ActiveCfg = Release|Any CPU + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution - {456c6dc7-f610-410e-85a1-189ba73f1e43} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {5B7BFA6B-B85E-4222-8988-16CCF9558393} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {B6D999F9-9335-433F-BCD2-1E07409AFA39} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {c3aaea74-f41e-4c56-b64e-7a2496ff6551} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {ced0cfa7-3d43-457f-9f81-f1695a6c65cd} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {ef66723c-296f-90fe-1bd4-6684bbb02913} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {96f50236-7030-47ab-af32-bb76484fadec} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {a4aaea74-f41e-4c56-b64e-7a2496ff4351} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} - {d5af20cc-1577-e1eb-419c-1d1c08a09995} = {5BEDE243-F387-4427-8FDE-12B9AEB5DF9C} + {456c6dc7-f610-410e-85a1-189ba73f1e43} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {a4aaea74-f41e-4c56-b64e-7a2496ff4351} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {c3aaea74-f41e-4c56-b64e-7a2496ff6551} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {5B7BFA6B-B85E-4222-8988-16CCF9558393} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {96f50236-7030-47ab-af32-bb76484fadec} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {ced0cfa7-3d43-457f-9f81-f1695a6c65cd} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {d5af20cc-1577-e1eb-419c-1d1c08a09995} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {B6D999F9-9335-433F-BCD2-1E07409AFA39} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {ef66723c-296f-90fe-1bd4-6684bbb02913} = {11A091EC-8F2C-453F-A201-D34916CF05F6} + {e15b6d96-3026-44f3-6e15-a7bb7f8f1ebb} = {11A091EC-8F2C-453F-A201-D34916CF05F6} EndGlobalSection EndGlobal diff --git a/README.md b/README.md index b6a2b3c..d0589e9 100755 --- a/README.md +++ b/README.md @@ -18,8 +18,10 @@ This document introduces how to obtain and use G42 Cloud .Net SDK. service in [G42 Cloud console](https://console.g42cloud.com/console/) if needed. - The .NET SDK requires: - - **.NET Standard 2.0** or above - - **C# 4.0** or above + - **.NET and .NET Core 2.0** or above + - **.NET Framework 4.6.2** or above + +For more version maintenance information, please refer to **Lifecycle FAQ** - [.NET Core](https://learn.microsoft.com/en-us/lifecycle/faq/dotnet-core), [.NET Framework](https://learn.microsoft.com/en-us/lifecycle/faq/dotnet-framework) ## Install .Net SDK @@ -234,7 +236,7 @@ There are two ways to initialize the {Service}Client, you could choose one you p #### 3.1 Initialize the {Service}Client with specified Endpoint [:top:](#user-manual-top) ``` csharp -// Specify the endpoint, take the endpoint of VPC service in region of cn-north-4 for example +// Specify the endpoint, take the endpoint of VPC service in region of ae-ad-1 for example String endpoint = "https://vpc.ae-ad-1.g42cloud.com"; // Initialize the credentials, you should provide projectId or domainId in this way, take initializing BasicCredentials for example @@ -297,21 +299,18 @@ catch (ServiceResponseException serviceResponseException) ```csharp // Initialize asynchronous client instance, take VpcAsyncClient for example -var vpcClient = VpcAsyncClient.NewBuilder() +var vpcAsyncClient = VpcAsyncClient.NewBuilder() .WithCredential(auth) .WithEndPoint(endpoint) .WithHttpConfig(config) .Build(); -// send asynchronous request -var future = vpcClient.ListVpcsAsync(new ListVpcsRequest() -{ - Limit = 1 -}); -// get asynchronous response -var response = future.Result; -Console.WriteLine(JsonUtils.Serialize(response.Vpcs)); +var request = new ListVpcsRequest(); + +// Send the request asynchronously and get the response +var response = await vpcAsyncClient.ListVpcsAsync(request); +Console.WriteLine(JsonUtils.Serialize(response)); ``` ### 6. Troubleshooting [:top:](#user-manual-top) @@ -382,15 +381,152 @@ HttpHandler supports method `AddRequestHandler` and `AddResponseHandler`. ### 7. FAQ [:top:](#user-manual-top) -Use .Net Framework 4.7 to integrate .Net SDK, a dead lock occurs +1 Using .NET Framework 4.7 to integrate .NET SDK, an exception throws - ProtocolViolationException: Cannot send a content-body with this verb-type + +**[Cause]**: .NET Framework does not support generating GET requests with content-body. + +**[Solution]**: Configuration parameter `IgnoreBodyForGetRequest` makes GET request without content-body, as follows: + +```c# +var httpConfig = HttpConfig.GetDefaultConfig(); +httpConfig.IgnoreBodyForGetRequest = true; + +var client = VpcClient.NewBuilder() + .WithCredential(auth) + .WithHttpConfig(httpConfig) + .WithRegion(VpcRegion.ValueOf("ae-ad-1")) + .Build(); +``` + +2 Use .NET Framework 4.7 to integrate .NET SDK, a dead lock occurs **[Symptom]**: When using synchronized client to call an interface, and the program has been started, but where is no error message or timeout occurs. **[Cause]**: The inner implementation of sending requests in synchronized client of SDK is to use an asynchronous task, -and SDK will await this task. In such scenario, **deadlock** occurs between the context of the .Net Framework UI and the +and SDK will await this task. In such scenario, **deadlock** occurs between the context of the .NET Framework UI and the asynchronous task context of the SDK. As a result, the asynchronous task of the SDK cannot be activated. [Original article](https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html) **[Solution]**: **Switch the synchronous client to the asynchronous client**. If the UI events and API requests are both -asynchronous, there will be no deadlock. +asynchronous, there will be no deadlock. The following are examples of MVC and WPF solutions: + +MVC + +```c# +using System; +using System.Threading.Tasks; +using System.Web.Mvc; +using G42Cloud.SDK.Core.Auth; +using G42Cloud.SDK.Core; +using G42Cloud.SDK.Vpc.V2; +using G42Cloud.SDK.Vpc.V2.Model; + +namespace WebApplication1.Controllers +{ + public class HomeController : Controller + { + private readonly VpcAsyncClient _vpcAsyncClient = InitAsyncClient(); + + private static VpcAsyncClient InitAsyncClient() + { + const string ak = "{your ak string}"; + const string sk = "{your sk string}"; + + var auth = new BasicCredentials(ak, sk); + + // Use asynchronous client + var client = VpcAsyncClient.NewBuilder() + .WithCredential(auth) + .WithRegion(VpcRegion.ValueOf("ae-ad-1")) + .Build(); + return client; + } + + private async Task ListVpcsAsync() + { + var req = new ListVpcsRequest(); + + // Send the request asynchronously, using await will not block the thread + var resp = await _vpcAsyncClient.ListVpcsAsync(req); + Console.WriteLine(resp.GetHttpStatusCode()); + return resp; + } + + public ActionResult Index() + { + return View(); + } + + // Replace synchronous methods with asynchronous methods + public async Task About() + { + var resp = await ListVpcsAsync(); + var respString = JsonUtils.Serialize(resp); + + ViewBag.Message = respString; + return View(); + } + } +} +``` + +WPF + +```c# +using System; +using System.Threading.Tasks; +using System.Windows; +using G42Cloud.SDK.Core; +using G42Cloud.SDK.Core.Auth; +using G42Cloud.SDK.Vpc.V2; +using G42Cloud.SDK.Vpc.V2.Model; + +namespace WpfApp1 +{ + public partial class MainWindow : Window + { + + private readonly VpcAsyncClient _asyncClient = InitAsyncClient(); + + public MainWindow() + { + InitializeComponent(); + } + + private static VpcAsyncClient InitAsyncClient() + { + const string ak = "{your ak string}"; + const string sk = "{your sk string}"; + + var auth = new BasicCredentials(ak, sk); + + // Use asynchronous client + var client = VpcAsyncClient.NewBuilder() + .WithCredential(auth) + .WithRegion(VpcRegion.ValueOf("ae-ad-1")) + .Build(); + + return client; + } + + private async Task ListVpcs() + { + var req = new ListVpcsRequest(); + + // Send the request asynchronously, using await will not block the thread + var resp = await _asyncClient.ListVpcsAsync(req); + Console.WriteLine(resp.GetHttpStatusCode()); + return resp; + } + + // Replace synchronous methods with asynchronous methods + private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) + { + var resp = await ListVpcs(); + var respString = JsonUtils.Serialize(resp); + MessageBox.Show(respString); + } + } +} +``` diff --git a/Services/Cbr/Cbr.csproj b/Services/Cbr/Cbr.csproj index 9390f37..93753db 100755 --- a/Services/Cbr/Cbr.csproj +++ b/Services/Cbr/Cbr.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Cbr - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Cbr/V1/CbrAsyncClient.cs b/Services/Cbr/V1/CbrAsyncClient.cs index 4672042..f8bc4dc 100755 --- a/Services/Cbr/V1/CbrAsyncClient.cs +++ b/Services/Cbr/V1/CbrAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Cbr/V1/CbrClient.cs b/Services/Cbr/V1/CbrClient.cs index 33d25b9..70e483e 100755 --- a/Services/Cbr/V1/CbrClient.cs +++ b/Services/Cbr/V1/CbrClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Cce/Cce.csproj b/Services/Cce/Cce.csproj index 980bb73..b066375 100755 --- a/Services/Cce/Cce.csproj +++ b/Services/Cce/Cce.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Cce - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Cce/V3/CceAsyncClient.cs b/Services/Cce/V3/CceAsyncClient.cs index 73345c5..a3d794c 100755 --- a/Services/Cce/V3/CceAsyncClient.cs +++ b/Services/Cce/V3/CceAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Cce/V3/CceClient.cs b/Services/Cce/V3/CceClient.cs index 88ff202..08af844 100755 --- a/Services/Cce/V3/CceClient.cs +++ b/Services/Cce/V3/CceClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Cdn/Cdn.csproj b/Services/Cdn/Cdn.csproj index eff90ba..465ac97 100755 --- a/Services/Cdn/Cdn.csproj +++ b/Services/Cdn/Cdn.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Cdn - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Cdn/V1/CdnAsyncClient.cs b/Services/Cdn/V1/CdnAsyncClient.cs index 9340a14..e4a83b8 100755 --- a/Services/Cdn/V1/CdnAsyncClient.cs +++ b/Services/Cdn/V1/CdnAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Cdn/V1/CdnClient.cs b/Services/Cdn/V1/CdnClient.cs index d609c2d..eb37bd0 100755 --- a/Services/Cdn/V1/CdnClient.cs +++ b/Services/Cdn/V1/CdnClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Cdn/V2/CdnAsyncClient.cs b/Services/Cdn/V2/CdnAsyncClient.cs index 07f28d9..7e2c4c7 100755 --- a/Services/Cdn/V2/CdnAsyncClient.cs +++ b/Services/Cdn/V2/CdnAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Cdn/V2/CdnClient.cs b/Services/Cdn/V2/CdnClient.cs index 7ed82eb..07c7066 100755 --- a/Services/Cdn/V2/CdnClient.cs +++ b/Services/Cdn/V2/CdnClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Ces/Ces.csproj b/Services/Ces/Ces.csproj index 6c3dad5..6819cf3 100755 --- a/Services/Ces/Ces.csproj +++ b/Services/Ces/Ces.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Ces - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Ces/V1/CesAsyncClient.cs b/Services/Ces/V1/CesAsyncClient.cs index 9ce85d3..037a428 100755 --- a/Services/Ces/V1/CesAsyncClient.cs +++ b/Services/Ces/V1/CesAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Ces/V1/CesClient.cs b/Services/Ces/V1/CesClient.cs index 5dcb917..b44c657 100755 --- a/Services/Ces/V1/CesClient.cs +++ b/Services/Ces/V1/CesClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Ces/V2/CesAsyncClient.cs b/Services/Ces/V2/CesAsyncClient.cs index 4217e1c..6cad5ab 100755 --- a/Services/Ces/V2/CesAsyncClient.cs +++ b/Services/Ces/V2/CesAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Ces/V2/CesClient.cs b/Services/Ces/V2/CesClient.cs index 610b9a9..6c25044 100755 --- a/Services/Ces/V2/CesClient.cs +++ b/Services/Ces/V2/CesClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Ecs/Ecs.csproj b/Services/Ecs/Ecs.csproj index 9a5bdb2..2d6f308 100755 --- a/Services/Ecs/Ecs.csproj +++ b/Services/Ecs/Ecs.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Ecs - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Ecs/V2/EcsAsyncClient.cs b/Services/Ecs/V2/EcsAsyncClient.cs index a19a461..7e25bbe 100755 --- a/Services/Ecs/V2/EcsAsyncClient.cs +++ b/Services/Ecs/V2/EcsAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Ecs/V2/EcsClient.cs b/Services/Ecs/V2/EcsClient.cs index b681988..b4306cd 100755 --- a/Services/Ecs/V2/EcsClient.cs +++ b/Services/Ecs/V2/EcsClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Elb/Elb.csproj b/Services/Elb/Elb.csproj index b24fa64..c7bce52 100755 --- a/Services/Elb/Elb.csproj +++ b/Services/Elb/Elb.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Elb - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Elb/V3/ElbAsyncClient.cs b/Services/Elb/V3/ElbAsyncClient.cs index 5965c6c..5c175ac 100755 --- a/Services/Elb/V3/ElbAsyncClient.cs +++ b/Services/Elb/V3/ElbAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Elb/V3/ElbClient.cs b/Services/Elb/V3/ElbClient.cs index 29098a5..34ef232 100755 --- a/Services/Elb/V3/ElbClient.cs +++ b/Services/Elb/V3/ElbClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Evs/Evs.csproj b/Services/Evs/Evs.csproj index 31cc399..dbc8daf 100755 --- a/Services/Evs/Evs.csproj +++ b/Services/Evs/Evs.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Evs - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Evs/V2/EvsAsyncClient.cs b/Services/Evs/V2/EvsAsyncClient.cs index e1f46f4..88b7057 100755 --- a/Services/Evs/V2/EvsAsyncClient.cs +++ b/Services/Evs/V2/EvsAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Evs/V2/EvsClient.cs b/Services/Evs/V2/EvsClient.cs index 1b77e2d..7bbdd60 100755 --- a/Services/Evs/V2/EvsClient.cs +++ b/Services/Evs/V2/EvsClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Ims/Ims.csproj b/Services/Ims/Ims.csproj index 9f04356..00db1a2 100755 --- a/Services/Ims/Ims.csproj +++ b/Services/Ims/Ims.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Ims - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Ims/V2/ImsAsyncClient.cs b/Services/Ims/V2/ImsAsyncClient.cs index a3a0e01..8f692f3 100755 --- a/Services/Ims/V2/ImsAsyncClient.cs +++ b/Services/Ims/V2/ImsAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Ims/V2/ImsClient.cs b/Services/Ims/V2/ImsClient.cs index 98e3edd..95df5fd 100755 --- a/Services/Ims/V2/ImsClient.cs +++ b/Services/Ims/V2/ImsClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Smn/Smn.csproj b/Services/Smn/Smn.csproj index 41428a2..004d1c6 100755 --- a/Services/Smn/Smn.csproj +++ b/Services/Smn/Smn.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Smn - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd. diff --git a/Services/Smn/V2/SmnAsyncClient.cs b/Services/Smn/V2/SmnAsyncClient.cs index 4e470f0..2cebe58 100755 --- a/Services/Smn/V2/SmnAsyncClient.cs +++ b/Services/Smn/V2/SmnAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Smn/V2/SmnClient.cs b/Services/Smn/V2/SmnClient.cs index df77866..46d65cc 100755 --- a/Services/Smn/V2/SmnClient.cs +++ b/Services/Smn/V2/SmnClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Vpc/V2/VpcAsyncClient.cs b/Services/Vpc/V2/VpcAsyncClient.cs index 3e01e92..f13608b 100755 --- a/Services/Vpc/V2/VpcAsyncClient.cs +++ b/Services/Vpc/V2/VpcAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Vpc/V2/VpcClient.cs b/Services/Vpc/V2/VpcClient.cs index 698397f..e325067 100755 --- a/Services/Vpc/V2/VpcClient.cs +++ b/Services/Vpc/V2/VpcClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Vpc/V3/VpcAsyncClient.cs b/Services/Vpc/V3/VpcAsyncClient.cs index 2ae4105..efa17a4 100755 --- a/Services/Vpc/V3/VpcAsyncClient.cs +++ b/Services/Vpc/V3/VpcAsyncClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using System.Threading.Tasks; diff --git a/Services/Vpc/V3/VpcClient.cs b/Services/Vpc/V3/VpcClient.cs index 3e3c172..028f2f4 100755 --- a/Services/Vpc/V3/VpcClient.cs +++ b/Services/Vpc/V3/VpcClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Collections.Generic; using G42Cloud.SDK.Core; diff --git a/Services/Vpc/Vpc.csproj b/Services/Vpc/Vpc.csproj index 482d67b..c81e80f 100755 --- a/Services/Vpc/Vpc.csproj +++ b/Services/Vpc/Vpc.csproj @@ -15,7 +15,7 @@ false false G42Cloud.SDK.Vpc - 0.0.4-beta + 0.0.5-beta G42Cloud Copyright 2020 G42 Technologies Co., Ltd. G42 Technologies Co., Ltd.