-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.net 7 && update portainer api level
- Loading branch information
Binali Rustamov
committed
Sep 26, 2023
1 parent
d62c537
commit 1fac271
Showing
22 changed files
with
571 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Dockerfile | ||
**/*/ | ||
!PortainerClient/bin/release/netcoreapp3.1/linux-x64/publish/PortainerClient | ||
!PortainerClient/bin/Release/net7.0/linux-x64/publish/PortainerClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
FROM alpine:3.7 | ||
FROM ubuntu:20.04 | ||
|
||
WORKDIR / | ||
COPY PortainerClient/bin/release/netcoreapp3.1/linux-x64/publish/PortainerClient /usr/bin/portainerctl | ||
COPY "PortainerClient/bin/Release/net7.0/linux-x64/publish/PortainerClient" "/usr/bin/portainerctl" | ||
|
||
RUN chmod +x /usr/bin/portainerctl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
using System; | ||
using System.IO; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using RestSharp; | ||
|
||
namespace PortainerClient.Api.Base; | ||
|
||
/// <inheritdoc /> | ||
public class TraceRequest : RestRequest | ||
{ | ||
#region Properties | ||
|
||
private readonly bool _debug; | ||
|
||
#endregion | ||
|
||
#region Constructor | ||
|
||
/// <inheritdoc /> | ||
public TraceRequest(string pResource, bool debug = false) | ||
: base(pResource) | ||
{ | ||
_debug = debug; | ||
InitializeLogs(); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public TraceRequest(string pResource, Method method, bool debug = false) : base(pResource, method) | ||
{ | ||
_debug = debug; | ||
InitializeLogs(); | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
private void InitializeLogs() | ||
{ | ||
if (!_debug) | ||
return; | ||
OnBeforeRequest = OnBeforeRequestMethod; | ||
OnAfterRequest = OnAfterRequestMethod; | ||
} | ||
|
||
private ValueTask OnBeforeRequestMethod(HttpRequestMessage pMessage) | ||
{ | ||
var builder = new StringBuilder(); | ||
|
||
builder.AppendLine("------------------------------"); | ||
builder.AppendLine($"REQUEST [{pMessage.Method}] {pMessage.RequestUri}"); | ||
|
||
foreach (var header in pMessage.Headers) | ||
{ | ||
builder.AppendLine($" {header.Key}: {string.Join(';', header.Value)}"); | ||
} | ||
|
||
var stream = pMessage.Content?.ReadAsStream(); | ||
|
||
ReadStream(stream, builder); | ||
|
||
|
||
builder.AppendLine("------------------------------"); | ||
|
||
var content = builder.ToString(); | ||
|
||
Console.WriteLine(content); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
|
||
private void ReadContent(HttpContent? pContent, StringBuilder pBuilder) | ||
{ | ||
if (pContent == null) | ||
{ | ||
return; | ||
} | ||
|
||
foreach (var header in pContent.Headers) | ||
{ | ||
pBuilder.AppendLine($" {header.Key}: {string.Join(';', header.Value)}"); | ||
} | ||
|
||
ReadContent(pContent as StreamContent, pBuilder); | ||
ReadContent(pContent as StringContent, pBuilder); | ||
ReadContent(pContent as MultipartFormDataContent, pBuilder); | ||
|
||
Console.WriteLine(); | ||
} | ||
|
||
private void ReadContent(MultipartFormDataContent? pContent, StringBuilder pBuilder) | ||
{ | ||
if (pContent == null) return; | ||
foreach (var content in pContent) | ||
{ | ||
pBuilder.AppendLine(); | ||
ReadContent(content, pBuilder); | ||
} | ||
} | ||
|
||
private static void ReadContent(StreamContent? pContent, StringBuilder pBuilder) | ||
{ | ||
if (pContent == null) return; | ||
var stream = pContent.ReadAsStream(); | ||
pBuilder.AppendLine($" contains {stream.Length} bytes"); | ||
} | ||
|
||
private void ReadContent(StringContent? pContent, StringBuilder pBuilder) | ||
{ | ||
if (pContent == null) return; | ||
var stream = pContent.ReadAsStream(); | ||
pBuilder.Append(" "); | ||
ReadStream(stream, pBuilder); | ||
} | ||
|
||
private static void ReadStream(Stream? pStream, StringBuilder pBuilder) | ||
{ | ||
if (pStream == null) | ||
{ | ||
return; | ||
} | ||
|
||
var index = 0L; | ||
var length = pStream.Length; | ||
var buffer = new byte[1024]; | ||
|
||
while (index < length - 1) | ||
{ | ||
var read = pStream.Read(buffer, 0, 1024); | ||
var result = Encoding.UTF8.GetString(buffer, 0, read); | ||
|
||
pBuilder.Append(result); | ||
|
||
index += read; | ||
} | ||
|
||
pBuilder.AppendLine(); | ||
|
||
pStream.Seek(0L, SeekOrigin.Begin); | ||
} | ||
|
||
private ValueTask OnAfterRequestMethod(HttpResponseMessage pMessage) | ||
{ | ||
var builder = new StringBuilder(); | ||
|
||
builder.AppendLine("------------------------------"); | ||
builder.AppendLine( | ||
$"RESPONSE {pMessage.RequestMessage.Method} [{pMessage.RequestMessage.RequestUri}] {pMessage.StatusCode}"); | ||
|
||
foreach (var header in pMessage.Headers) | ||
{ | ||
builder.AppendLine($" {header.Key}: {string.Join(';', header.Value)}"); | ||
} | ||
|
||
var stream = pMessage.Content.ReadAsStream(); | ||
|
||
ReadStream(stream, builder); | ||
|
||
builder.AppendLine("------------------------------"); | ||
|
||
var content = builder.ToString(); | ||
|
||
Console.WriteLine(content); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
|
||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace PortainerClient.Api.Model; | ||
|
||
/// <summary> | ||
/// Represents authentication information for Git. | ||
/// </summary> | ||
public class Authentication | ||
{ | ||
/// <summary> | ||
/// Gets or sets the Git credential ID. | ||
/// </summary> | ||
public int GitCredentialID { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the Git password. | ||
/// </summary> | ||
public string Password { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the Git username. | ||
/// </summary> | ||
public string Username { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace PortainerClient.Api.Model; | ||
|
||
/// <summary> | ||
/// Represents auto-update information. | ||
/// </summary> | ||
public class AutoUpdate | ||
{ | ||
/// <summary> | ||
/// Gets or sets a value indicating whether to force pulling the image. | ||
/// </summary> | ||
public bool ForcePullImage { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether to force the update. | ||
/// </summary> | ||
public bool ForceUpdate { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the interval for updates in a human-readable format (e.g., "1m30s"). | ||
/// </summary> | ||
public string Interval { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the job ID associated with the auto-update. | ||
/// </summary> | ||
public string JobID { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the webhook URL for auto-updates. | ||
/// </summary> | ||
public string Webhook { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace PortainerClient.Api.Model; | ||
|
||
/// <summary> | ||
/// Represents an environment variable. | ||
/// </summary> | ||
public class Env | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name of the environment variable. | ||
/// </summary> | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the value of the environment variable. | ||
/// </summary> | ||
public string Value { get; set; } | ||
} |
Oops, something went wrong.