Skip to content

Commit 3c12732

Browse files
authored
Merge pull request #47 from princessdaphie/feature/pinlistasync-type
Added new API entry point to be able to use the API call type parameter.
2 parents efc7464 + 8fad09a commit 3c12732

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/CoreApi/PinApi.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Ipfs.CoreApi;
1+
using Google.Protobuf;
2+
using Ipfs.CoreApi;
23
using Newtonsoft.Json.Linq;
34
using System.Collections.Generic;
45
using System.Linq;
@@ -33,6 +34,18 @@ internal PinApi(IpfsClient ipfs)
3334
.Select(p => (Cid)p.Name);
3435
}
3536

37+
public async Task<IEnumerable<Cid>> ListAsync(PinType type, CancellationToken cancel = default(CancellationToken))
38+
{
39+
var typeOpt = type.ToString().ToLowerInvariant();
40+
var json = await ipfs.DoCommandAsync("pin/ls", cancel,
41+
null,
42+
$"type={typeOpt}");
43+
var keys = (JObject)(JObject.Parse(json)["Keys"]);
44+
return keys
45+
.Properties()
46+
.Select(p => (Cid)p.Name);
47+
}
48+
3649
public async Task<IEnumerable<Cid>> RemoveAsync(Cid id, bool recursive = true, CancellationToken cancel = default(CancellationToken))
3750
{
3851
var opts = "recursive=" + recursive.ToString().ToLowerInvariant();

0 commit comments

Comments
 (0)