private IObservable<Droplet> PowerOffDroplet(Droplet droplet) { var client = new DigitalOceanClient(_userSettings.ApiKey); return Observable.StartAsync(ct => Task.Run(async () => { var power = await client.DropletActions.PowerOff(droplet.Id); await WaitForAction(client, power.Id); return droplet; }, ct)); }
private IObservable<List<Droplet>> GetDroplets() { var client = new DigitalOceanClient(_userSettings.ApiKey); return Observable.StartAsync(async () => { var droplets = await client.Droplets.GetAll(); return droplets.Select(droplet => new Droplet { Id = droplet.Id, Name = droplet.Name, Address = droplet.Networks.v4[0].IpAddress, Region = droplet.Region.Name, Size = droplet.SizeSlug, Image = droplet.Image.Name, Status = droplet.Status == "active" ? DropletStatus.On : DropletStatus.Off }).ToList(); }); }