package com.cloudbees.camaaloth;
import com.cloudbees.api.BeesClient;
import com.cloudbees.api.BeesClientConfiguration;
import com.cloudbees.sdk.cli.BeesClientFactory;
import net.sf.json.JSONObject;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
* <pre>
* ~
* ~ '
* ` (O) ~
* H '
* ~ H
* ` ____hHh____
* ~ `---------' ~
* ` | | | '
* | | |
* | | |
* | | |
* | | |
* | | |
* | | |
* | | |
* _____;~~~~~:____
* __' \
* / \ |
* | _\\_ | |\
* | \\ | | | ___
* __ / __ | | | _/ \
* /__\ |_____/__\____|_________|__\ /__\___\
*
* </pre>
* As Arthur's legendary sword, gives power to access CloudBees platform and accomplish Grails quest.
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
*/
public class Excalibur {
@Inject
BeesClientFactory beesClientFactory;
public JSONObject getMetaData(String appId) throws Exception {
BeesClient client = beesClientFactory.get(BeesClient.class);
Map<String, String> params = new HashMap<String, String>();
params.put("app_id", appId);
String url = client.getRequestURL("application.platform.metadata", params);
String response = client.executeRequest(url);
SAXBuilder sxb = new SAXBuilder();
Document document = sxb.build(new StringReader(response));
String js = document.getRootElement().getChild("message").getText();
return JSONObject.fromObject(js);
}
}