2023-04-12 11:53:55 +00:00
|
|
|
|
using KubernetesWorkflow;
|
|
|
|
|
|
|
|
|
|
namespace DistTestCore.Codex
|
|
|
|
|
{
|
|
|
|
|
public class CodexAccess
|
|
|
|
|
{
|
|
|
|
|
public CodexAccess(RunningContainer runningContainer)
|
|
|
|
|
{
|
2023-04-13 07:33:10 +00:00
|
|
|
|
Container = runningContainer;
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public RunningContainer Container { get; }
|
|
|
|
|
|
2023-04-12 11:53:55 +00:00
|
|
|
|
public CodexDebugResponse GetDebugInfo()
|
|
|
|
|
{
|
|
|
|
|
var response = Http().HttpGetJson<CodexDebugResponse>("debug/info");
|
|
|
|
|
//Log($"Got DebugInfo with id: '{response.id}'.");
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public string UploadFile(FileStream fileStream)
|
|
|
|
|
{
|
|
|
|
|
return Http().HttpPostStream("upload", fileStream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Stream DownloadFile(string contentId)
|
|
|
|
|
{
|
|
|
|
|
return Http().HttpGetStream("download/" + contentId);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 11:53:55 +00:00
|
|
|
|
private Http Http()
|
|
|
|
|
{
|
2023-04-13 08:11:33 +00:00
|
|
|
|
var ip = Container.Pod.Cluster.IP;
|
2023-04-13 07:33:10 +00:00
|
|
|
|
var port = Container.ServicePorts[0].Number;
|
2023-04-12 11:53:55 +00:00
|
|
|
|
return new Http(ip, port, baseUrl: "/api/codex/v1");
|
|
|
|
|
}
|
2023-04-13 07:33:10 +00:00
|
|
|
|
|
|
|
|
|
public string ConnectToPeer(string peerId, string peerMultiAddress)
|
|
|
|
|
{
|
|
|
|
|
return Http().HttpGetString($"connect/{peerId}?addrs={peerMultiAddress}");
|
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CodexDebugResponse
|
|
|
|
|
{
|
|
|
|
|
public string id { get; set; } = string.Empty;
|
|
|
|
|
public string[] addrs { get; set; } = new string[0];
|
|
|
|
|
public string repo { get; set; } = string.Empty;
|
|
|
|
|
public string spr { get; set; } = string.Empty;
|
|
|
|
|
public CodexDebugVersionResponse codex { get; set; } = new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class CodexDebugVersionResponse
|
|
|
|
|
{
|
|
|
|
|
public string version { get; set; } = string.Empty;
|
|
|
|
|
public string revision { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|