Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 69 additions & 37 deletions src/CoreApi/AddFileOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,41 @@ public class AddFileOptions
/// </summary>
/// <value>
/// If <b>true</b> the data is pinned to local storage and will not be
/// garbage collected. The default is <b>true</b>.
/// garbage collected. Required: no. The default is <b>true</b>.
/// </value>
public bool Pin { get; set; } = true;
public bool? Pin { get; set; }

/// <summary>
/// The maximum number of data bytes in a block.
/// Chunking algorithm, size-[bytes], rabin-[min]-[avg]-[max] or buzhash. Required: no.
/// </summary>
/// <value>
/// The default is 256 * 1024 (‭262,144) bytes.‬
/// Required: no. The default is 256 * 1024 (size-‭262144) bytes.‬
/// </value>
public int ChunkSize { get; set; } = 256 * 1024;
public string? Chunker { get; set; }

/// <summary>
/// Determines if the trickle-dag format is used for dag generation.
/// </summary>
/// <value>
/// The default is <b>false</b>.
/// Required: no. The default is <b>false</b>.
/// </value>
public bool Trickle { get; set; } = false;
public bool? Trickle { get; set; }

/// <summary>
/// Determines if added file(s) are wrapped in a directory object.
/// </summary>
/// <value>
/// The default is <b>false</b>.
/// Required: no. The default is <b>false</b>.
/// </value>
public bool Wrap { get; set; } = false;
public bool? Wrap { get; set; }

/// <summary>
/// Determines if raw blocks are used for leaf data blocks.
/// Determines if raw blocks are used for leaf nodes.
/// </summary>
/// <value>
/// The default is <b>false</b>.
/// Required: no. The default is <b>false</b>.
/// </value>
/// <remarks>
/// <b>RawLeaves</b> and <see cref="ProtectionKey"/> are mutually exclusive.
/// </remarks>
public bool RawLeaves { get; set; } = false;
public bool? RawLeaves { get; set; }

/// <summary>
/// The hashing algorithm name to use.
Expand All @@ -60,41 +57,76 @@ public class AddFileOptions
/// Defaults to <see cref="MultiHash.DefaultAlgorithmName"/>.
/// </value>
/// <seealso cref="MultiHash"/>
public string Hash { get; set; } = MultiHash.DefaultAlgorithmName;
public string? Hash { get; set; }

/// <summary>
/// The encoding algorithm name to use.
/// Determines if only file information is produced.
/// </summary>
/// <value>
/// The <see cref="MultiBase"/> algorithm name used to produce the <see cref="Cid"/>.
/// Defaults to <see cref="MultiBase.DefaultAlgorithmName"/>.
/// If <b>true</b> no data is added to IPFS. Required: no. The default is <b>false</b>.
/// </value>
/// <seealso cref="MultiBase"/>
public string Encoding { get; set; } = MultiBase.DefaultAlgorithmName;
public bool? OnlyHash { get; set; }

/// <summary>
/// Determines if only file information is produced.
/// Used to report the progress of a file transfer.
/// </summary>
/// <value>
/// If <b>true</b> no data is added to IPFS. The default is <b>false</b>.
/// </value>
public bool OnlyHash { get; set; } = false;
public IProgress<TransferProgress>? Progress { get; set; }

/// <summary>
/// The key name used to protect (encrypt) the file contents.
/// Add the file using filestore. Implies raw-leaves.
/// </summary>
/// <value>
/// The name of an existing key.
/// </value>
/// <remarks>
/// <b>ProtectionKey</b> and <see cref="RawLeaves"/> are mutually exclusive.
/// </remarks>
/// <seealso cref="IKeyApi"/>
public string? ProtectionKey { get; set; }
public bool? NoCopy { get; set; }

/// <summary>
/// Used to report the progress of a file transfer.
/// Check the filestore for pre-existing blocks.
/// </summary>
public IProgress<TransferProgress>? Progress { get; set; }
public bool? FsCache { get; set; }

/// <summary>
/// Defaults to 0 unless an option that depends on CIDv1 is passed.
/// Passing version 1 will cause the raw-leaves option to default to true.
/// Required: no.
/// </summary>
public int? CidVersion { get; set; }

/// <summary>
/// Inline small blocks into CIDs. (experimental). Required: no.
/// </summary>
public bool? Inline { get; set; }

/// <summary>
/// Maximum block size to inline. (experimental). Default: 32. Required: no.
/// </summary>
public int? InlineLimit { get; set; }

/// <summary>
/// Add reference to Files API (MFS) at the provided path. Required: no.
/// </summary>
public string? ToFiles { get; set; }

/// <summary>
/// Apply existing POSIX permissions to created UnixFS entries. Disables raw-leaves. (experimental). Required: no.
/// </summary>
public bool? PreserveMode { get; set; }

/// <summary>
/// Apply existing POSIX modification time to created UnixFS entries. Disables raw-leaves. (experimental). Required: no.
/// </summary>
public bool? PreserveMtime { get; set; }

/// <summary>
/// Custom POSIX file mode to store in created UnixFS entries. Disables raw-leaves. (experimental). Required: no.
/// </summary>
public uint? Mode { get; set; }

/// <summary>
/// Custom POSIX modification time to store in created UnixFS entries (seconds before or after the Unix Epoch). Disables raw-leaves. (experimental). Required: no.
/// </summary>
public long? Mtime { get; set; }

/// <summary>
/// Custom POSIX modification time (optional time fraction in nanoseconds).
/// </summary>
public uint? MtimeNsecs { get; set; }
}
}
59 changes: 59 additions & 0 deletions src/CoreApi/CarImportOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Newtonsoft.Json;

namespace Ipfs.CoreApi
{
/// <summary>
/// CarImportOutput is the output type of the 'dag import' commands
/// </summary>
/// <remarks>See also <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L63"/></remarks>
public class CarImportOutput
{
/// <summary>
/// Root is the metadata for a root pinning response
/// </summary>
[JsonProperty("Root", NullValueHandling = NullValueHandling.Ignore)]
public RootMeta? Root { get; set; }

/// <summary>
/// Stats contains statistics about the imported CAR file, if requested.
/// </summary>
[JsonProperty("Stats", NullValueHandling = NullValueHandling.Ignore)]
public CarImportStats? Stats { get; set; }

/// <summary>
/// RootMeta is the metadata for a root pinning response
/// </summary>
public record RootMeta
{
/// <summary>
/// The CID of the root of the imported DAG.
/// </summary>
public required DagCid Cid { get; set; }

/// <summary>
/// The error message if pinning failed
/// </summary>
public string? PinErrorMsg { get; set; }
}

/// <summary>
/// Statistics about an imported CAR file.
/// </summary>
public record CarImportStats
{
/// <summary>
/// The number of blocks in the CAR file.
/// </summary>
[JsonProperty("BlockCount")]
public ulong BlockCount { get; set; }

/// <summary>
/// The number of block bytes in the CAR file.
/// </summary>
[JsonProperty("BlockBytesCount")]
public ulong BlockBytesCount { get; set; }
}
}


}
9 changes: 9 additions & 0 deletions src/CoreApi/DagResolveOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Ipfs.CoreApi
{
/// <summary>
/// The result of a DAG resolve operation.
/// </summary>
/// <param name="Id">The cid of the resolved dag path.</param>
/// <param name="RemPath">Unknown usage. See <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L54"/></param>
public record DagResolveOutput(DagCid Id, string RemPath);
}
27 changes: 27 additions & 0 deletions src/CoreApi/DagStat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Newtonsoft.Json;

namespace Ipfs.CoreApi
{
/// <summary>
/// Statistics about a DAG block.
/// </summary>
public record DagStat
{
/// <summary>
/// The CID of the block.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public DagCid? Cid { get; set; }

/// <summary>
/// The size of the block.
/// </summary>
public ulong? Size { get; set; }

/// <summary>
/// The number of links in the block.
/// </summary>
public long NumBlocks { get; set; }
}

}
63 changes: 63 additions & 0 deletions src/CoreApi/DagStatSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Ipfs.CoreApi
{
/// <summary>
/// The output of a DAG stat operation.
/// </summary>
/// <remarks>
/// Adapted from <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L326"/>
/// </remarks>
public record DagStatSummary
{
/// <summary>
/// The size of redundant nodes in this Dag tree.
/// </summary>
/// <remarks>
/// Docs sourced from <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/stat.go#L60-L70"/>
/// </remarks>
[JsonIgnore]
public ulong RedundantSize { get; set; }

/// <summary>
/// The number of unique CIDs in this Dag tree.
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public int? UniqueBlocks { get; set; }

/// <summary>
/// The total size of all unique dag blocks in this tree.
/// </summary>
/// <remarks>
/// Docs sourced from <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/stat.go#L58"/>
/// </remarks>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public ulong? TotalSize { get; set; }

/// <summary>
/// The difference between <see cref="RedundantSize"/> and <see cref="TotalSize"/>.
/// </summary>
/// <remarks>
/// Docs sourced from code <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L351" />
/// </remarks>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public ulong? SharedSize { get; set; }

/// <summary>
/// The ratio of <see cref="RedundantSize"/> to <see cref="TotalSize"/>.
/// </summary>
/// <remarks>
/// Docs sourced from code <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L351" />
/// </remarks>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public float? Ratio { get; set; }

/// <summary>
/// If requested, the stats for each DAG in the tree.
/// </summary>
[JsonProperty("DagStats", NullValueHandling = NullValueHandling.Ignore)]
public IEnumerable<DagStat>? DagStatsArray { get; set; }
}

}
28 changes: 28 additions & 0 deletions src/CoreApi/FilePart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.IO;

namespace Ipfs.CoreApi
{
/// <summary>
/// Represents a file to be added to IPFS.
/// </summary>
public class FilePart
{
/// <summary>
/// The name of the file or the relative path to the file in a folder.
/// </summary>
public required string Name { get; set; }

/// <summary>
/// A stream containing the file's data.
/// </summary>
public required Stream? Data { get; set; }

/// <summary>
/// Can be set to the location of the file in the filesystem (within the IPFS root), or to its full web URL.
/// </summary>
/// <remarks>
/// Included for filestore/urlstore features that are enabled with the nocopy option
/// </remarks>
public string? AbsolutePath { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/CoreApi/FilestoreDuplicate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Ipfs.CoreApi
{
/// <summary>
/// The response object for the <see cref="IFilestoreApi.DupsAsync"/> method.
/// </summary>
public record FilestoreDuplicate
{
/// <summary>
/// Any error in the <see cref="IFilestoreApi"/> Dups response.
/// </summary>
public required string Err { get; set; }

/// <summary>
/// The cid in the <see cref="IFilestoreApi"/> Dups response.
/// </summary>
public required Cid Ref { get; set; }
}
}
Loading