2 * This Sample test program is useful in getting started with using Arvados Java SDK.
3 * This program creates an Arvados instance using the configured environment variables.
4 * It then provides a prompt to input method name and input parameters.
5 * The program them invokes the API server to execute the specified method.
10 import org.arvados.sdk.java.Arvados;
13 import java.util.HashMap;
14 import java.util.List;
17 import java.io.BufferedReader;
18 import java.io.InputStreamReader;
20 public class ArvadosSDKJavaExampleWithPrompt {
22 * Make sure the following environment variables are set before using Arvados:
23 * ARVADOS_API_TOKEN, ARVADOS_API_HOST and ARVADOS_API_HOST_INSECURE Set
24 * ARVADOS_API_HOST_INSECURE to true if you are using self-singed certificates
25 * in development and want to bypass certificate validations.
27 * Please refer to http://doc.arvados.org/api/index.html for a complete list
28 * of the available API methods.
30 public static void main(String[] args) throws Exception {
31 String apiName = "arvados";
32 String apiVersion = "v1";
34 System.out.print("Welcome to Arvados Java SDK");
35 System.out.println("You can use this example to call API methods");
36 System.out.println("Enter ^C when you want to quit");
38 // use configured env variables for API TOKEN, HOST and HOST_INSECURE
39 Arvados arv = new Arvados(apiName, apiVersion);
42 // prompt for resource
43 System.out.println("\n\nEnter Resource name (for example users): ");
46 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
47 String resourceName = in.readLine().trim();
50 System.out.println("\nEnter method name (for example get): ");
51 String methodName = in.readLine().trim();
53 // read method parameters
55 .println("\nEnter parameter name, value (for example uuid, uuid-value): ");
56 Map paramsMap = new HashMap();
60 param = in.readLine();
64 String[] params = param.split(",");
65 paramsMap.put(params[0].trim(), params[1].trim());
67 System.out.println("\nEnter parameter name, value (for example uuid, uuid-value): ");
68 } while (!param.isEmpty());
69 } catch (Exception e) {
70 System.out.println (e.getMessage());
71 System.out.println ("\nStart over");
75 // Make a "call" for the given resource name and method name
77 System.out.println ("Making a call for " + resourceName + " " + methodName);
78 Map response = arv.call(resourceName, methodName, paramsMap);
79 System.out.println(response);
80 } catch (Exception e){
81 System.out.println (e.getMessage());
82 System.out.println ("\nStart over");