Example #1
0
  private static void updateFeed(int feed, int series, double value) throws Exception {

    Pachube p = new Pachube(API_KEY);
    // HACK ALERT!!!
    Feed f = p.getFeed(feed);
    DecimalFormat format = new DecimalFormat();
    format.setMaximumFractionDigits(1);
    // stinks so bad..
    double roundedValue = Double.parseDouble(format.format(value));
    f.updateDatastream(series, roundedValue);
  }
Example #2
0
  static void printFeedForId(int feedId) {
    Pachube pachubeClient = new Pachube(API_KEY);

    try {
      Feed feed = pachubeClient.getFeed(feedId);

      HttpResponse data = pachubeClient.getDatastream(feed.getId(), 1);

      System.out.println(data.getBody());
    } catch (PachubeException e) {
      System.err.println(e.getMessage());
    }
  }
Example #3
0
  private static Feed addSeries(int feed, String friendlyName, double minValue, double maxValue)
      throws Exception {
    // Creates a Pachube object authenicated using the provided API KEY

    Pachube p = new Pachube(API_KEY);
    Feed f = p.getFeed(feed);
    Data a = new Data();
    a.setId(3);
    a.setMaxValue(maxValue);
    a.setMinValue(minValue);
    a.setTag(friendlyName);
    a.setValue(0);
    f.addData(a);
    Feed g = p.createFeed(f);

    // The Feed 'f' is does not represent the feed on pachube any
    // Changes made to this object will not alter the online feed.
    logger.debug("The id of the new feed is:");
    logger.debug(g.getId());

    return g;
  }