public static StreamWrapper GetByStreamAndAccountId(string streamId, string accountId) { var account = AccountManager.GetAccounts().FirstOrDefault(x => x.id == accountId); var client = new Client(account); //Exists? Core.Api.Stream res = client.StreamGet(streamId).Result; return(new StreamWrapper(res.id, account.id, account.serverInfo.url)); }
public static object Details([ArbitraryDimensionArrayImport] object stream) { Tracker.TrackPageview(Tracker.STREAM_DETAILS); var streams = Utils.InputToStream(stream); if (!streams.Any()) { throw new SpeckleException("Please provide one or more Streams."); } if (streams.Count > 20) { throw new SpeckleException("Please provide less than 20 Streams."); } var details = new List <Dictionary <string, object> >(); foreach (var streamWrapper in streams) { var account = streamWrapper.GetAccount().Result; var client = new Client(account); try { Core.Api.Stream res = client.StreamGet(streamWrapper.StreamId).Result; details.Add(new Dictionary <string, object> { { "id", res.id }, { "name", res.name }, { "description", res.description }, { "createdAt", res.createdAt }, { "updatedAt", res.updatedAt }, { "isPublic", res.isPublic }, { "collaborators", res.collaborators }, { "branches", res.branches?.items } }); } catch (Exception ex) { Utils.HandleApiExeption(ex); return(details); } } if (details.Count() == 1) { return(details[0]); } return(details); }
public static object Get([ArbitraryDimensionArrayImport] object stream, [DefaultArgument("null")] Core.Credentials.Account account) { Tracker.TrackPageview(Tracker.STREAM_GET); var streams = Utils.InputToStream(stream); if (!streams.Any()) { throw new SpeckleException("Please provide one or more Stream Ids."); } else if (streams.Count > 20) { throw new SpeckleException("Please provide less than 20 Stream Ids."); } try { foreach (var s in streams) { //lets ppl override the account for the specified stream Core.Credentials.Account accountToUse = null; if (account != null) { accountToUse = account; } else { accountToUse = Task.Run(async() => await s.GetAccount()).Result; } var client = new Client(accountToUse); //Exists? Core.Api.Stream res = Task.Run(async() => await client.StreamGet(s.StreamId)).Result; s.UserId = accountToUse.userInfo.id; } } catch (Exception ex) { Utils.HandleApiExeption(ex); } if (streams.Count() == 1) { return(streams[0]); } return(streams); }
public static object GetAs([ArbitraryDimensionArrayImport] object stream, Core.Credentials.Account account = null) { Tracker.TrackPageview(Tracker.STREAM_GET); var streams = Utils.InputToStream(stream); if (!streams.Any()) { Log.CaptureAndThrow(new Exception("Please provide one or more Stream Ids.")); } else if (streams.Count > 20) { Log.CaptureAndThrow(new Exception("Please provide less than 20 Stream Ids.")); } try { var client = new Client(account); foreach (var s in streams) { //Exists? Core.Api.Stream res = client.StreamGet(s.StreamId).Result; s.AccountId = account.id; } } catch (Exception e) { if (e.InnerException != null) { if (e.InnerException is HttpRequestException) { throw new Exception("Could not reach the server, is it online?"); } throw e.InnerException; } } if (streams.Count() == 1) { return(streams[0]); } return(streams); }
public static StreamWrapper GetByStreamAndAccountId(string streamId, string accountId) { var account = AccountManager.GetAccounts().FirstOrDefault(x => x.id == accountId); var client = new Client(account); try { //Exists? Core.Api.Stream res = client.StreamGet(streamId).Result; return(new StreamWrapper(res.id, account.id, account.serverInfo.url)); } catch (Exception ex) { Utils.HandleApiExeption(ex); } return(null); }
public static object GetWithAccount([ArbitraryDimensionArrayImport] object stream, Core.Credentials.Account account = null) { Tracker.TrackPageview(Tracker.STREAM_GET); var streams = Utils.InputToStream(stream); if (!streams.Any()) { Log.CaptureAndThrow(new Exception("Please provide one or more Stream Ids.")); } else if (streams.Count > 20) { Log.CaptureAndThrow(new Exception("Please provide less than 20 Stream Ids.")); } try { var client = new Client(account); foreach (var s in streams) { //Exists? Core.Api.Stream res = client.StreamGet(s.StreamId).Result; s.AccountId = account.id; } } catch (Exception ex) { Utils.HandleApiExeption(ex); } if (streams.Count() == 1) { return(streams[0]); } return(streams); }