Updates to latest

This commit is contained in:
Ben 2024-10-29 14:02:00 +01:00
parent 8fe0bd6307
commit acb0bf4f29
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
5 changed files with 88 additions and 22 deletions

View File

@ -10,7 +10,7 @@ namespace CodexPlugin
public class ApiChecker
{
// <INSERT-OPENAPI-YAML-HASH>
private const string OpenApiYamlHash = "C1-50-18-D5-73-64-1C-D8-74-DB-75-0D-C1-3D-AB-82-D6-A3-05-3E-49-2B-82-0B-0F-92-BC-DC-32-BE-56-C9";
private const string OpenApiYamlHash = "39-0C-32-A3-EA-90-4F-29-1C-67-12-F1-D5-BE-31-67-8D-90-43-1E-F2-02-63-5B-0C-49-F7-1E-E5-EC-F7-00";
private const string OpenApiFilePath = "/codex/openapi.yaml";
private const string DisableEnvironmentVariable = "CODEXPLUGIN_DISABLE_APICHECK";

View File

@ -82,7 +82,7 @@ namespace CodexPlugin
public LocalDatasetList LocalFiles()
{
return mapper.Map(OnCodex(api => api.ListDataAsync()));
return mapper.Map(OnCodex(api => api.ListDataAsync("", "")));
}
public StorageAvailability SalesAvailability(StorageAvailability request)

View File

@ -7,7 +7,7 @@ namespace CodexPlugin
{
public class CodexContainerRecipe : ContainerRecipeFactory
{
private const string DefaultDockerImage = "codexstorage/nim-codex:0.1.7-dist-tests";
private const string DefaultDockerImage = "codexstorage/nim-codex:latest-dist-tests";
public const string ApiPortTag = "codex_api_port";
public const string ListenPortTag = "codex_listen_port";
public const string MetricsPortTag = "codex_metrics_port";

View File

@ -16,8 +16,8 @@ namespace CodexPlugin
Spr = debugInfo.Spr,
Addrs = debugInfo.Addrs.ToArray(),
AnnounceAddresses = JArray(debugInfo.AdditionalProperties, "announceAddresses").Select(x => x.ToString()).ToArray(),
Version = MapDebugInfoVersion(JObject(debugInfo.AdditionalProperties, "codex")),
Table = MapDebugInfoTable(JObject(debugInfo.AdditionalProperties, "table"))
Version = Map(debugInfo.Codex),
Table = Map(debugInfo.Table)
};
}
@ -136,47 +136,45 @@ namespace CodexPlugin
};
}
private DebugInfoVersion MapDebugInfoVersion(JObject obj)
private DebugInfoVersion Map(CodexVersion obj)
{
return new DebugInfoVersion
{
Version = StringOrEmpty(obj, "version"),
Revision = StringOrEmpty(obj, "revision")
Version = obj.Version,
Revision = obj.Revision
};
}
private DebugInfoTable MapDebugInfoTable(JObject obj)
private DebugInfoTable Map(PeersTable obj)
{
return new DebugInfoTable
{
LocalNode = MapDebugInfoTableNode(obj.GetValue("localNode")),
Nodes = MapDebugInfoTableNodeArray(obj.GetValue("nodes") as JArray)
LocalNode = Map(obj.LocalNode),
Nodes = Map(obj.Nodes)
};
}
private DebugInfoTableNode MapDebugInfoTableNode(JToken? token)
private DebugInfoTableNode Map(Node? token)
{
var obj = token as JObject;
if (obj == null) return new DebugInfoTableNode();
if (token == null) return new DebugInfoTableNode();
return new DebugInfoTableNode
{
Address = StringOrEmpty(obj, "address"),
NodeId = StringOrEmpty(obj, "nodeId"),
PeerId = StringOrEmpty(obj, "peerId"),
Record = StringOrEmpty(obj, "record"),
Seen = Bool(obj, "seen")
Address = token.Address,
NodeId = token.NodeId,
PeerId = token.PeerId,
Record = token.Record,
Seen = token.Seen
};
}
private DebugInfoTableNode[] MapDebugInfoTableNodeArray(JArray? nodes)
private DebugInfoTableNode[] Map(ICollection<Node> nodes)
{
if (nodes == null || nodes.Count == 0)
{
return new DebugInfoTableNode[0];
}
return nodes.Select(MapDebugInfoTableNode).ToArray();
return nodes.Select(Map).ToArray();
}
private Manifest MapManifest(CodexOpenApi.ManifestItem manifest)

View File

@ -90,6 +90,40 @@ components:
cid:
$ref: "#/components/schemas/Cid"
Node:
type: object
properties:
nodeId:
type: string
peerId:
type: string
record:
type: string
address:
type: string
seen:
type: boolean
CodexVersion:
type: object
properties:
version:
type: string
example: v0.1.7
revision:
type: string
example: 0c647d8
PeersTable:
type: object
properties:
localNode:
$ref: "#/components/schemas/Node"
nodes:
type: array
items:
$ref: "#/components/schemas/Node"
DebugInfo:
type: object
properties:
@ -104,6 +138,10 @@ components:
description: Path of the data repository where all nodes data are stored
spr:
$ref: "#/components/schemas/SPR"
table:
$ref: "#/components/schemas/PeersTable"
codex:
$ref: "#/components/schemas/CodexVersion"
SalesAvailability:
type: object
@ -319,6 +357,19 @@ components:
protected:
type: boolean
description: "Indicates if content is protected by erasure-coding"
filename:
type: string
description: "The original name of the uploaded content (optional)"
example: codex.png
mimetype:
type: string
description: "The original mimetype of the uploaded content (optional)"
example: image/png
uploadedAt:
type: integer
format: int64
description: "The UTC upload timestamp in seconds"
example: 1729244192
Space:
type: object
@ -392,6 +443,21 @@ paths:
summary: "Lists manifest CIDs stored locally in node."
tags: [ Data ]
operationId: listData
parameters:
- name: content-type
in: header
required: false
description: The content type of the file. Must be valid.
schema:
type: string
example: "image/png"
- name: content-disposition
in: header
required: false
description: The content disposition used to send the filename.
schema:
type: string
example: "attachment; filename=\"codex.png\""
responses:
"200":
description: Retrieved list of content CIDs
@ -404,6 +470,8 @@ paths:
description: Invalid CID is specified
"404":
description: Content specified by the CID is not found
"422":
description: The content type is not a valid content type or the filename is not valid
"500":
description: Well it was bad-bad
post: