public async Task<List<AppModel>> GetApps(string token)
        {
            List<AppModel> apps = new List<AppModel>();

            IWebClient client = GetClient(token);
            
            string data = await client.DownloadStringTaskAsync(new Uri("https://api.appfog.com/apps"));

            JArray appsJson = JArray.Parse(data);
            
            AppModel newModel;

            foreach(JToken app in appsJson)
            {
                newModel = new AppModel
                               {
                                   Name = app["name"].ToString(),
                                   Instances = (int) app["instances"],
                                   Stack = app["staging"]["stack"].ToString(),
                                   Memory = (int) app["resources"][Memory],
                                   Created = DateUtils.TimeStampToDateTime((double) app["meta"]["created"])
                               };

                foreach (JToken uri in app["uris"])
                {
                    newModel.Uris.Add(uri.ToString());
                }

                apps.Add(newModel);
            }

            return apps;
        }
Exemplo n.º 2
0
 public void AppModelConstructionCreatesUriList()
 {
     AppModel appModel = new AppModel();
     Assert.AreEqual(0, appModel.Uris.Count);
 }