diff --git a/src/CoreApi/DupsResponse.cs b/src/CoreApi/DupsResponse.cs new file mode 100644 index 0000000..b983de4 --- /dev/null +++ b/src/CoreApi/DupsResponse.cs @@ -0,0 +1,21 @@ +using Ipfs.CoreApi; + +namespace Ipfs.Http.CoreApi +{ + /// + /// Model holding response from Dups command. + /// + public class DupsResponse : IDupsResponse + { + /// + /// Any error in the Dups response. + /// + public string Err { get; set; } + + /// + /// The error in the Dups response. + /// + public string Ref { get; set; } + } + +} diff --git a/src/CoreApi/FilestoreApi.cs b/src/CoreApi/FilestoreApi.cs new file mode 100644 index 0000000..9476ffe --- /dev/null +++ b/src/CoreApi/FilestoreApi.cs @@ -0,0 +1,50 @@ +using Ipfs.CoreApi; +using Ipfs.Http.CoreApi; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Ipfs.Http +{ + /// + public class FilestoreApi : IFilestoreApi + { + private IpfsClient ipfs; + + /// + internal FilestoreApi(IpfsClient ipfs) + { + this.ipfs = ipfs; + } + + /// + public async Task ListAsync(string cid, bool fileOrder, CancellationToken token) + { + var json = await ipfs.DoCommandAsync("filestore/ls", token, cid, fileOrder.ToString()); + + return JsonConvert.DeserializeObject(json); + } + + /// + public async Task VerifyObjectsAsync(string cid, bool fileOrder, CancellationToken token) + { + var json = await ipfs.DoCommandAsync("filestore/verify", token, cid, fileOrder.ToString()); + + return JsonConvert.DeserializeObject(json); + } + + /// + public async Task DupsAsync(CancellationToken token) + { + var json = await ipfs.DoCommandAsync("filestore/dups", token); + + return JsonConvert.DeserializeObject(json); + } + } + +} diff --git a/src/CoreApi/FilestoreKey.cs b/src/CoreApi/FilestoreKey.cs new file mode 100644 index 0000000..5267294 --- /dev/null +++ b/src/CoreApi/FilestoreKey.cs @@ -0,0 +1,18 @@ +using Ipfs.CoreApi; +using Newtonsoft.Json; + +namespace Ipfs.Http +{ + /// + /// Model for the hold filestore key + /// + public class FilestoreKey : IFilestoreKey + { + /// + /// Key value. + /// + [JsonProperty("/")] + public string _ { get; set; } + } + +} diff --git a/src/CoreApi/FilestoreObjectResponse.cs b/src/CoreApi/FilestoreObjectResponse.cs new file mode 100644 index 0000000..4332633 --- /dev/null +++ b/src/CoreApi/FilestoreObjectResponse.cs @@ -0,0 +1,41 @@ +using Ipfs.CoreApi; + +namespace Ipfs.Http +{ + /// + /// Model holding response to . + /// + public class FilestoreObjectResponse : IFilestoreApiObjectResponse + { + /// + /// Holds any error message. + /// + public string ErrorMsg { get; set; } + + /// + /// Path to the file + /// + public string FilePath { get; set; } + + /// + /// The key to the Filestore. + /// + public FilestoreKey Key { get; set; } + + /// + /// The response offset. + /// + public string Offset { get; set; } + + /// + /// The size of the object. + /// + public string Size { get; set; } + + /// + /// The object status.k + /// + public string Status { get; set; } + } + +} diff --git a/src/CoreApi/KeyApi.cs b/src/CoreApi/KeyApi.cs index a152542..3eae143 100644 --- a/src/CoreApi/KeyApi.cs +++ b/src/CoreApi/KeyApi.cs @@ -114,4 +114,4 @@ internal KeyApi(IpfsClient ipfs) throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/src/IpfsClient.cs b/src/IpfsClient.cs index 62b1c1c..43d357a 100644 --- a/src/IpfsClient.cs +++ b/src/IpfsClient.cs @@ -73,6 +73,7 @@ public IpfsClient() Dag = new DagApi(this); Object = new ObjectApi(this); FileSystem = new FileSystemApi(this); + FilestoreApi = new FilestoreApi(this); Mfs = new MfsApi(this); PubSub = new PubSubApi(this); Key = new KeyApi(this); @@ -163,6 +164,10 @@ public IpfsClient(string host) /// public IFileSystemApi FileSystem { get; private set; } + + /// + public IFilestoreApi FilestoreApi { get; private set; } + /// public IMfsApi Mfs { get; private set; }