访问DigitalOcean droplet以使用JAVA API获取有关vcpus,网络和内存利用率的信息

时间:2014-09-12 08:28:10

标签: java digital-ocean

我正在尝试实现数字海洋但我没有获得CPU利用率,内存利用率,网络使用率。我已经添加了digitalocean-api-client-1.6.jar。但是它没有完全可用它已经丢失了一些classes.i遵循git上的主题,由jeevaktm.Link引用如下https://github.com/jeevatkm/digitalocean-api-java

package src.com.myjeeva.digitalocean;
import java.util.List;
import scala.collection.parallel.mutable.ParTrieMap.Size;

import com.myjeeva.digitalocean.DigitalOcean;
import com.myjeeva.digitalocean.exception.AccessDeniedException;
import com.myjeeva.digitalocean.exception.RequestUnsuccessfulException;
import com.myjeeva.digitalocean.impl.DigitalOceanClient;
import com.myjeeva.digitalocean.pojo.Droplet;
import com.myjeeva.digitalocean.pojo.DropletSize;

import digitalocean.size.*;


public class TestDroplet {

public static void main(String args[]) throws AccessDeniedException,   ResourceNotFoundException, RequestUnsuccessfulException {

         DigitalOcean apiClient = new DigitalOceanClient("XXXX", "XXXX");

         Integer dropletId=XXXX;
        // Fetch droplet information 
         Droplet droplet1 = apiClient.getDropletInfo(dropletId);
         System.out.println("ID: " + droplet1.getId());
            System.out.println("Name: " + droplet1.getName());
            System.out.println("Status: " + droplet1.getStatus());
            System.out.println("IP Address: " + droplet1.getIpAddress());
            System.out.println("Private Ip Address: " + droplet1.getPrivateIpAddress());
            System.out.println("Image Id: " + droplet1.getImageId());
            System.out.println("Region Id: " + droplet1.getRegionId());
            System.out.println("Created Date: " + droplet1.getCreatedDate());
            System.out.println("Event Id: " + droplet1.getEventId());
            System.out.println("Active: " + droplet1.isActive());
            System.out.println("Size Id: " + droplet1.getSizeId());
            System.out.println("OS Name:" + apiClient.getImageInfo(droplet1.getImageId()).getName());
            System.out.println("Available Domain:" +apiClient.getAvailableDomains());
            System.out.println("Available Domain:" +droplet1.getSizeId());

            List<DropletSize> availableSize= apiClient.getAvailableSizes();
            for(int i=0;i<availableSize.size();i++){
            System.out.println("name :"+availableSize.get(i).getName());
            }

            DropletSize s = new DropletSize();
            //System.out.println(droplet1.getSizeId().getSize());

            //System.out.println(((Size) droplet1).getSizes());

            /* Event in progress
            long event1=droplet1.getEventId();
            int event = (int) event1;
           System.out.println("Event In process" + apiClient.getEventProgress(event));*/


            /*Availble Domains
            List<Domain> availableDomains= apiClient.getAvailableDomains();
            for(int i=0;i<availableDomains.size();i++){
            System.out.println(availableDomains.get(i).getName());
            }*/


            /* Get all Available Droplets
            List<Droplet> availableDroplets= apiClient.getAvailableDroplets();
            for(int i=0;i<availableDroplets.size();i++){
            System.out.println(availableDroplets.get(i).getName());
            }*/

            /* All Available Regions
            List<Region> availableRegions= apiClient.getAvailableRegions();
            for(int i=0;i<availableRegions.size();i++){
            System.out.println(availableRegions.get(i).getName());
            }*/
}


}

0 个答案:

没有答案