2525: Remove unused imports
[arvados.git] / sdk / java / ArvadosSDKJavaExample.java
1 /**
2  * This Sample test program is useful in getting started with working with Arvados Java SDK.
3  * Please also see arvadso 
4  * @author radhika
5  *
6  */
7
8 import org.arvados.sdk.java.Arvados;
9
10 import java.io.File;
11 import java.util.HashMap;
12 import java.util.List;
13 import java.util.Map;
14
15 public class ArvadosSDKJavaExample {
16   /** Make sure the following environment variables are set before using Arvados:
17    *      ARVADOS_API_TOKEN, ARVADOS_API_HOST, ARVADOS_API_HOST_INSECURE
18    */
19   public static void main(String[] args) throws Exception {
20     String apiName = "arvados";
21     String apiVersion = "v1";
22
23     Arvados arv = new Arvados(apiName, apiVersion);
24
25     // Make a users.list call
26     System.out.println("Making an arvados users.list api call");
27
28     Map<String, Object> params = new HashMap<String, Object>();
29
30     Map response = arv.call("users", "list", params);
31     System.out.println("Arvados users.list:\n" + response);
32
33     // get uuid of the first user from the response
34     List items = (List)response.get("items");
35
36     Map firstUser = (Map)items.get(0);
37     String userUuid = (String)firstUser.get("uuid");
38     
39     // Make a users.get call on the uuid obtained above
40     System.out.println("Making a users.get call for " + userUuid);
41     params = new HashMap<String, Object>();
42     params.put("uuid", userUuid);
43     response = arv.call("users", "get", params);
44     System.out.println("Arvados users.get:\n" + response);
45
46     // Make a users.create call
47     System.out.println("Making a users.create call.");
48     
49     params = new HashMap<String, Object>();
50     params.put("user", "{}");
51     response = arv.call("users", "create", params);
52     System.out.println("Arvados users.create:\n" + response);
53
54     // delete the newly created user
55     userUuid = (String)response.get("uuid");
56     params = new HashMap<String, Object>();
57     params.put("uuid", userUuid);
58     response = arv.call("users", "delete", params);
59
60     // Make a pipeline_templates.list call
61     System.out.println("Making a pipeline_templates.list call.");
62
63     params = new HashMap<String, Object>();
64     response = arv.call("pipeline_templates", "list", params);
65
66     System.out.println("Arvados pipelinetempates.list:\n" + response);
67   }
68 }