Наследование: IDigitalOceanClient
Пример #1
0
 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));
 }
Пример #2
0
 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();
     });
 }