@Test public void getEc2HourRate() throws Exception { System.out.println("getEc2HourRate"); Ec2PriceList instance = new Ec2PriceList(); Price hourRate = instance.getEc2HourRate("eu-west-1", "t1.micro", null); System.out.println("t1.micro: " + hourRate); Price hourRate2 = instance.getEc2HourRate("eu-west-1", "m1.small", null); System.out.println("m1.small: " + hourRate2); }
public Price getEc2HourRate(String regionName, String instanceType, String platform) throws IOException { getEc2OnDemandPrices(); Map<String, Object> region = getRegion(regionName, onDemandPrices); if (region != null) { Map<String, Object> size = getEx2InstanceSize(region, instanceType); if (size != null) { List<Map<String, Object>> valueColumns = getSubList(size,"valueColumns"); for (Map<String, Object> column : valueColumns) { String name = (String) column.get("name"); Map<String,String> prices = (Map<String,String>) column.get("prices"); String price = prices.get("USD"); if (name.equals("linux")){ if (platform == null || !platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } else { if (platform != null && platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } } } } return null; }
Ec2PriceList extends AbstractPriceList { public Price getEc2HourRate(String regionName, String instanceType, String platform) throws IOException { getEc2OnDemandPrices(); Map<String, Object> region = getRegion(regionName, onDemandPrices); if (region != null) { Map<String, Object> size = getEx2InstanceSize(region, instanceType); if (size != null) { List<Map<String, Object>> valueColumns = getSubList(size,"valueColumns"); for (Map<String, Object> column : valueColumns) { String name = (String) column.get("name"); Map<String,String> prices = (Map<String,String>) column.get("prices"); String price = prices.get("USD"); if (name.equals("linux")){ if (platform == null || !platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } else { if (platform != null && platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } } } } return null; } }
Ec2PriceList extends AbstractPriceList { public Price getEc2HourRate(String regionName, String instanceType, String platform) throws IOException { getEc2OnDemandPrices(); Map<String, Object> region = getRegion(regionName, onDemandPrices); if (region != null) { Map<String, Object> size = getEx2InstanceSize(region, instanceType); if (size != null) { List<Map<String, Object>> valueColumns = getSubList(size,"valueColumns"); for (Map<String, Object> column : valueColumns) { String name = (String) column.get("name"); Map<String,String> prices = (Map<String,String>) column.get("prices"); String price = prices.get("USD"); if (name.equals("linux")){ if (platform == null || !platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } else { if (platform != null && platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } } } } return null; } Ec2PriceList(); }
Ec2PriceList extends AbstractPriceList { public Price getEc2HourRate(String regionName, String instanceType, String platform) throws IOException { getEc2OnDemandPrices(); Map<String, Object> region = getRegion(regionName, onDemandPrices); if (region != null) { Map<String, Object> size = getEx2InstanceSize(region, instanceType); if (size != null) { List<Map<String, Object>> valueColumns = getSubList(size,"valueColumns"); for (Map<String, Object> column : valueColumns) { String name = (String) column.get("name"); Map<String,String> prices = (Map<String,String>) column.get("prices"); String price = prices.get("USD"); if (name.equals("linux")){ if (platform == null || !platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } else { if (platform != null && platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } } } } return null; } Ec2PriceList(); Price getVolumeGigabyteRate(String regionName); Price getVolumeSnapshotGigabyteRate(String regionName); Price getLbHourRate(String regionName); Price getEc2HourRate(String regionName, String instanceType, String platform); }
Ec2PriceList extends AbstractPriceList { public Price getEc2HourRate(String regionName, String instanceType, String platform) throws IOException { getEc2OnDemandPrices(); Map<String, Object> region = getRegion(regionName, onDemandPrices); if (region != null) { Map<String, Object> size = getEx2InstanceSize(region, instanceType); if (size != null) { List<Map<String, Object>> valueColumns = getSubList(size,"valueColumns"); for (Map<String, Object> column : valueColumns) { String name = (String) column.get("name"); Map<String,String> prices = (Map<String,String>) column.get("prices"); String price = prices.get("USD"); if (name.equals("linux")){ if (platform == null || !platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } else { if (platform != null && platform.equals("windows")){ return Price.createUsdHourly(new BigDecimal(price)); } } } } } return null; } Ec2PriceList(); Price getVolumeGigabyteRate(String regionName); Price getVolumeSnapshotGigabyteRate(String regionName); Price getLbHourRate(String regionName); Price getEc2HourRate(String regionName, String instanceType, String platform);  }