Skip to content

Commit

Permalink
release 0.0.7-beta source code for net
Browse files Browse the repository at this point in the history
  • Loading branch information
unionsdk committed Jun 16, 2023
1 parent d32e11b commit f9e2a63
Show file tree
Hide file tree
Showing 54 changed files with 1,829 additions and 266 deletions.
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
# 0.0.7-beta 2023-06-16

### G42Cloud SDK CCE

- _Features_
- None
- _Bug Fix_
- None
- _Change_
- **ShowNode**
- changes of response param
- `+ status.lastProbeTime`
- **UpdateNode**
- changes of response param
- `+ status.lastProbeTime`
- **DeleteNode**
- changes of response param
- `+ status.lastProbeTime`
- **CreateNode**
- changes of response param
- `+ status.lastProbeTime`
- **ListNodes**
- changes of response param
- `+ items.status.lastProbeTime`

### G42Cloud SDK ECS

- _Features_
- None
- _Bug Fix_
- None
- _Change_
- **CreateServers**
- changes of request param
- `+ server.data_volumes.delete_on_termination`
- **CreatePostPaidServers**
- changes of request param
- `+ server.data_volumes.delete_on_termination`

### G42Cloud SDK SMN

- _Features_
- Support the following interfaces:
- `UpdateSubscription`
- `ListLogtank`
- `CreateLogtank`
- `UpdateLogtank`
- `DeleteLogtank`
- _Bug Fix_
- None
- _Change_
- **ListTopicDetails**
- changes of response param
- `+ topic_id`
- **ListTopics**
- changes of request param
- `+ topic_id`
- changes of response param
- `+ topics.topic_id`
- **ListTopicAttributes**
- changes of response param
- `+ attributes.access_policy`
- `+ attributes.introduction`
- `- attributes.Version`
- `- attributes.Id`
- `- attributes.Statement`
- **AddSubscription**
- changes of request param
- `+ extension`

# 0.0.6-beta 2023-05-12

### G42Cloud SDK CBR
Expand Down
22 changes: 19 additions & 3 deletions Core/Http/HttpConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ public class HttpConfig
{
public int? Timeout = 120;

public bool IgnoreSslVerification = false;
public bool IgnoreSslVerification;

public bool IgnoreBodyForGetRequest = false;
public bool IgnoreBodyForGetRequest;

/// <summary>
/// Experimental configuration, the default value is false.
/// Automatic redirection is allowed when turns on, which may cause some request exceptions.
/// </summary>
public bool AllowRedirects;

public string ProxyUsername { get; set; }

Expand Down Expand Up @@ -62,6 +68,16 @@ public HttpConfig WithIgnoreBodyForGetRequest(bool ignore)
return this;
}

/// <summary>
/// Experimental configuration, the default value is false.
/// Automatic redirection is allowed when turns on, which may cause some request exceptions.
/// </summary>
public HttpConfig WithAllowRedirects(bool allowRedirects)
{
this.AllowRedirects = allowRedirects;
return this;
}

public HttpConfig WithIgnoreProxyUsername(string username)
{
this.ProxyUsername = username;
Expand Down Expand Up @@ -92,4 +108,4 @@ public HttpConfig WithProxyPort(int port)
return this;
}
}
}
}
1 change: 0 additions & 1 deletion Core/Http/SdkHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Polly;

namespace G42Cloud.SDK.Core
{
Expand Down
1 change: 1 addition & 0 deletions Core/Http/SdkHttpMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public DelegatingHandler GetHandler()
{
var handler = new HttpClientHandler
{
AllowAutoRedirect = _httpConfig.AllowRedirects,
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) =>
Expand Down
50 changes: 28 additions & 22 deletions Core/Utils/HttpUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,30 @@ namespace G42Cloud.SDK.Core
{
public static class HttpUtils
{

private static readonly List<string> HttpContentHeadersList = new List<string>
{
"Allow",
"Content-Disposition",
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-MD5",
"Content-Range",
"Content-Type",
"Content-Length",
"Expires",
"Last-Modified"
};

public static string AddUrlPath(string path, Dictionary<string, string> pathParams)
{
return pathParams.Aggregate(path,
(current, keyValuePair) => current.Replace("{" + keyValuePair.Key + "}",
keyValuePair.Value));
}

private static string GetQueryParameters(Object obj)
private static string GetQueryParameters(object obj)
{
var sb = new StringBuilder();
var t = obj.GetType();
Expand Down Expand Up @@ -270,13 +286,18 @@ private static string GetRequestBody(object obj, string contentType)
{
foreach (var elem in sdkPropertyList)
{
if (elem is string eleString)
{
return eleString;
}

return contentType == "application/xml" ? XmlUtils.Serialize(elem) : JsonUtils.Serialize(elem);
}
}

return "";
}

private static Dictionary<string, object> GetFormData(object obj)
{
var t = obj.GetType();
Expand Down Expand Up @@ -328,14 +349,14 @@ private static Dictionary<string, object> GetFormData(object obj)
}

return null;
}
}

public static SdkRequest InitSdkRequest(string path, object data = null)
{
return InitSdkRequest(path, null, data);
}

public static SdkRequest InitSdkRequest(string path, String contentType, object data = null)
public static SdkRequest InitSdkRequest(string path, string contentType, object data = null)
{
if (path != null && string.IsNullOrEmpty(path))
{
Expand All @@ -352,7 +373,7 @@ public static SdkRequest InitSdkRequest(string path, String contentType, object
}

var cname = GetCname(data);
if (!String.IsNullOrEmpty(cname))
if (!string.IsNullOrEmpty(cname))
{
request.Cname = cname;
}
Expand Down Expand Up @@ -385,7 +406,7 @@ public static SdkRequest InitSdkRequest(string path, String contentType, object
request.Body = bodyData;
}
}

if (!string.IsNullOrEmpty(contentType))
{
request.ContentType = contentType;
Expand All @@ -405,7 +426,7 @@ public static T DeSerializeStream<T>(HttpResponseMessage message)
var t = Activator.CreateInstance<T>();
t.GetType().GetProperty("HttpStatusCode")?.SetValue(t, (int)message.StatusCode, null);
t.GetType().GetProperty("HttpHeaders")?.SetValue(t, message.Headers.ToString(), null);
BindingFlags flag = BindingFlags.Public | BindingFlags.Instance;
var flag = BindingFlags.Public | BindingFlags.Instance;
t.GetType().GetMethod("SetStream")
?.Invoke(t, flag, Type.DefaultBinder,
new object[]
Expand All @@ -422,21 +443,6 @@ public static void SetAdditionalAttrs<T>(HttpResponseMessage message, T obj, str
obj.GetType().GetProperty("HttpBody")?.SetValue(obj, body, null);
}

private static readonly List<string> HttpContentHeadersList = new List<string>
{
"Allow",
"Content-Disposition",
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-MD5",
"Content-Range",
"Content-Type",
"Content-Length",
"Expires",
"Last-Modified"
};

public static void SetResponseHeaders<T>(HttpResponseMessage message, T obj)
{
const BindingFlags instanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
Expand Down
2 changes: 1 addition & 1 deletion Core/Utils/JsonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static List<T> DeSerializeList<T>(HttpResponseMessage message)
public static Dictionary<TK, TV> DeSerializeMap<TK, TV>(HttpResponseMessage message)
{
var body = Encoding.UTF8.GetString(message.Content.ReadAsByteArrayAsync().Result);
return JArray.Parse(body).ToObject<Dictionary<TK, TV>>(JsonSerializer.CreateDefault(GetJsonSettings()));
return JObject.Parse(body).ToObject<Dictionary<TK, TV>>(JsonSerializer.CreateDefault(GetJsonSettings()));
}

public static string Serialize(object item)
Expand Down
2 changes: 1 addition & 1 deletion Core/obj/Core.csproj.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"dgSpecHash": "/uxPzudilK7z2cmcr8LmLAMNuQ3d4mkPcnRYFwycy3PGe6bg0rL/aXKhMoaCKTAGOwJqw+661uZhyMwQHaDr9w==",
"dgSpecHash": "S5xIaIcGMIsBBCvQrx7vip2flFB4b0F9mOEKJ2ghOj/Uyi8yJyb0CBjWxVH/oIOL7gvCo7AP+srJgUB1oMr2lg==",
"success": true
}
12 changes: 6 additions & 6 deletions Core/obj/Core.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
"/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/Core.csproj": {}
"/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/Core.csproj": {}
},
"projects": {
"/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/Core.csproj": {
"/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/Core.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/Core.csproj",
"projectUniqueName": "/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/Core.csproj",
"projectName": "G42Cloud.SDK.Core",
"projectPath": "/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/Core.csproj",
"projectPath": "/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/Core.csproj",
"packagesPath": "/root/.nuget/packages/",
"outputPath": "/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/obj/",
"outputPath": "/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/dotnet2/sdk/NuGetFallbackFolder"
Expand All @@ -23,7 +23,7 @@
"netstandard2.0"
],
"sources": {
"/data/fuxi_ci_workspace/645dd8e482590b0998f24562/package": {}
"/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/package": {}
},
"frameworks": {
"netstandard2.0": {
Expand Down
2 changes: 1 addition & 1 deletion Core/obj/Core.csproj.nuget.g.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/obj/project.assets.json</ProjectAssetsFile>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/obj/project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/root/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/root/.nuget/packages/;/usr/dotnet2/sdk/NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
Expand Down
8 changes: 4 additions & 4 deletions Core/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1051,11 +1051,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/Core.csproj",
"projectUniqueName": "/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/Core.csproj",
"projectName": "G42Cloud.SDK.Core",
"projectPath": "/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/Core.csproj",
"projectPath": "/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/Core.csproj",
"packagesPath": "/root/.nuget/packages/",
"outputPath": "/data/fuxi_ci_workspace/645dd8e482590b0998f24562/Core/obj/",
"outputPath": "/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/Core/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/dotnet2/sdk/NuGetFallbackFolder"
Expand All @@ -1067,7 +1067,7 @@
"netstandard2.0"
],
"sources": {
"/data/fuxi_ci_workspace/645dd8e482590b0998f24562/package": {}
"/data/fuxi_ci_workspace/648bc163b7c5fa32ae3a3eb8/package": {}
},
"frameworks": {
"netstandard2.0": {
Expand Down
Loading

0 comments on commit f9e2a63

Please sign in to comment.