private List <AHAItem> InvokeSearch(SearchStreamOptionsRecord options, PaginationRecord pg) { try { log.Debug("Search options: " + options.ToJson()); log.Debug("Search page: " + pg.ToJson()); this.options = options; ObjectApi objectApi = new ObjectApi(session.GetApiClient()); log.Debug("Calling SearchObjects API"); SearchObjectsResult result = objectApi.SearchObjects(options.ToJson(), pg.ToJson()); if (result.Hdr.Rc == 0) { pager = result.Pager; List <AHAItem> items = new List <AHAItem>(); List <Record> records = result.Records; log.Debug(records.Count + " records returned"); foreach (var record in records) { String jsonString = record.Json; log.Debug("Record: " + jsonString); log.Debug("Creating AHA item"); AHAItem item = itemFromJson(jsonString); log.Debug("AHAItem: " + JsonConvert.SerializeObject(item)); if (item.Type.Equals(FILE_TYPE)) { log.Debug("Getting additional info for file"); FileApi fileApi = new FileApi(session.GetApiClient()); ViewFileResult viewFileResult = fileApi.ViewFile(item.Key); if (viewFileResult.Hdr.Rc == 0) { FileRecord fileRecord = viewFileResult.File; item.LastUpdater = fileRecord.LastUpdater.DisplayName; item.Version = fileRecord.UiVersion; log.Debug("Last updater: " + item.LastUpdater); log.Debug("Version: " + item.Version); } else { log.Error("Vmoso error getting additional info for file. Rc=" + viewFileResult.Hdr.Rc); } } items.Add(item); } return(items); } else { throw new Exception("Vmoso error searching objects. Rc=" + result.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Error searching objects from Vmoso", ex); } }
/// <summary> /// Creates a new instance of the <see cref="IpfsEngine"/> class. /// </summary> public IpfsEngine() { // Init the core api inteface. Bitswap = new BitswapApi(this); Block = new BlockApi(this); Config = new ConfigApi(this); Dag = new DagApi(this); Dht = new DhtApi(this); FileSystem = new FileSystemApi(this); Generic = new GenericApi(this); Key = new KeyApi(this); Name = new NameApi(this); Object = new ObjectApi(this); Pin = new PinApi(this); PubSub = new PubSubApi(this); Swarm = new SwarmApi(this); }
public void MarkTilesRead(StreamItem streamItem) { ObjectApi objectApi = new ObjectApi(session.GetApiClient()); try { MarkAllTilesReadResult result = objectApi.MarkAllTilesRead(streamItem.Key); if (result.Hdr.Rc == 0) { } else { throw new Exception("Error updating read info for contentKey " + streamItem.Key); } } catch (Exception ex) { throw new Exception("Error updating read info for contentKey " + streamItem.Key, ex); } }
void Init() { // Init the core api inteface. Bitswap = new BitswapApi(this); Block = new BlockApi(this); BlockRepository = new BlockRepositoryApi(this); Bootstrap = new BootstrapApi(this); Config = new ConfigApi(this); Dag = new DagApi(this); Dht = new DhtApi(this); Dns = new DnsApi(this); FileSystem = new FileSystemApi(this); Generic = new GenericApi(this); Key = new KeyApi(this); Name = new NameApi(this); Object = new ObjectApi(this); Pin = new PinApi(this); PubSub = new PubSubApi(this); Stats = new StatsApi(this); Swarm = new SwarmApi(this); // Async properties LocalPeer = new AsyncLazy <Peer>(async() => { log.Debug("Building local peer"); var keyChain = await KeyChain().ConfigureAwait(false); log.Debug("Getting key info about self"); var self = await keyChain.FindKeyByNameAsync("self").ConfigureAwait(false); var localPeer = new Peer { Id = self.Id, PublicKey = await keyChain.GetPublicKeyAsync("self").ConfigureAwait(false), ProtocolVersion = "ipfs/0.1.0" }; var version = typeof(IpfsEngine).GetTypeInfo().Assembly.GetName().Version; localPeer.AgentVersion = $"net-ipfs/{version.Major}.{version.Minor}.{version.Revision}"; log.Debug("Built local peer"); return(localPeer); }); SwarmService = new AsyncLazy <Swarm>(async() => { log.Debug("Building swarm service"); if (Options.Swarm.PrivateNetworkKey == null) { var path = Path.Combine(Options.Repository.Folder, "swarm.key"); if (File.Exists(path)) { using (var x = File.OpenText(path)) { Options.Swarm.PrivateNetworkKey = new PreSharedKey(); Options.Swarm.PrivateNetworkKey.Import(x); } } } var peer = await LocalPeer.ConfigureAwait(false); var keyChain = await KeyChain().ConfigureAwait(false); var self = await keyChain.GetPrivateKeyAsync("self").ConfigureAwait(false); var swarm = new Swarm { LocalPeer = peer, LocalPeerKey = PeerTalk.Cryptography.Key.CreatePrivateKey(self), NetworkProtector = Options.Swarm.PrivateNetworkKey == null ? null : new Psk1Protector { Key = Options.Swarm.PrivateNetworkKey } }; if (Options.Swarm.PrivateNetworkKey != null) { log.Debug($"Private network {Options.Swarm.PrivateNetworkKey.Fingerprint().ToHexString()}"); } log.Debug("Built swarm service"); return(swarm); }); BitswapService = new AsyncLazy <BlockExchange.Bitswap>(async() => { log.Debug("Building bitswap service"); var bitswap = new BlockExchange.Bitswap { Swarm = await SwarmService.ConfigureAwait(false), BlockService = Block }; log.Debug("Built bitswap service"); return(bitswap); }); DhtService = new AsyncLazy <PeerTalk.Routing.Dht1>(async() => { log.Debug("Building DHT service"); var dht = new PeerTalk.Routing.Dht1 { Swarm = await SwarmService.ConfigureAwait(false) }; dht.Swarm.Router = dht; log.Debug("Built DHT service"); return(dht); }); PubSubService = new AsyncLazy <PeerTalk.PubSub.NotificationService>(async() => { log.Debug("Building PubSub service"); var pubsub = new PeerTalk.PubSub.NotificationService { LocalPeer = await LocalPeer.ConfigureAwait(false) }; pubsub.Routers.Add(new PeerTalk.PubSub.FloodRouter { Swarm = await SwarmService.ConfigureAwait(false) }); log.Debug("Built PubSub service"); return(pubsub); }); }
void Init() { // Init the core api inteface. Bitswap = new BitswapApi(this); Block = new BlockApi(this); Bootstrap = new BootstrapApi(this); Config = new ConfigApi(this); Dag = new DagApi(this); Dht = new DhtApi(this); Dns = new DnsApi(this); FileSystem = new FileSystemApi(this); Generic = new GenericApi(this); Key = new KeyApi(this); Name = new NameApi(this); Object = new ObjectApi(this); Pin = new PinApi(this); PubSub = new PubSubApi(this); Stats = new StatsApi(this); Swarm = new SwarmApi(this); // Async properties LocalPeer = new AsyncLazy <Peer>(async() => { log.Debug("Building local peer"); var keyChain = await KeyChain(); log.Debug("Getting key info about self"); var self = await keyChain.FindKeyByNameAsync("self"); var localPeer = new Peer(); localPeer.Id = self.Id; localPeer.PublicKey = await keyChain.GetPublicKeyAsync("self"); localPeer.ProtocolVersion = "ipfs/0.1.0"; var version = typeof(IpfsEngine).GetTypeInfo().Assembly.GetName().Version; localPeer.AgentVersion = $"net-ipfs/{version.Major}.{version.Minor}.{version.Revision}"; log.Debug("Built local peer"); return(localPeer); }); SwarmService = new AsyncLazy <Swarm>(async() => { log.Debug("Building swarm service"); var peer = await LocalPeer; var keyChain = await KeyChain(); var self = await keyChain.GetPrivateKeyAsync("self"); var swarm = new Swarm { LocalPeer = peer, LocalPeerKey = PeerTalk.Cryptography.Key.CreatePrivateKey(self) }; log.Debug("Built swarm service"); return(swarm); }); BitswapService = new AsyncLazy <BlockExchange.Bitswap>(async() => { log.Debug("Building bitswap service"); var bitswap = new BlockExchange.Bitswap { Swarm = await SwarmService, BlockService = Block }; log.Debug("Built bitswap service"); return(bitswap); }); DhtService = new AsyncLazy <PeerTalk.Routing.Dht1>(async() => { log.Debug("Building DHT service"); var dht = new PeerTalk.Routing.Dht1 { Swarm = await SwarmService }; dht.Swarm.Router = dht; log.Debug("Built DHT service"); return(dht); }); }