/** * Create a Quandl session without an authorization token (authToken). An attempt will be made to read the java property * <em>quandl.auth.token</em> and use that if available. Any resulting SecurityException is logged at debug level, otherwise it is ignored * and no auth token is used. Using a token means you can make more requests. Note creating this object does not make any actual API * requests, the token is used in subsequent requests. * * @return an instance of the Quandl session, not null. */ public static QuandlSession create() { try { String authToken = System.getProperty(GenericQuandlSession.QUANDL_AUTH_TOKEN_PROPERTY_NAME); if (authToken != null) { return new QuandlSession(SessionOptions.Builder.withAuthToken(authToken).build()); } } catch (SecurityException se) { s_logger.debug("Error accessing system property " + GenericQuandlSession.QUANDL_AUTH_TOKEN_PROPERTY_NAME + ", falling back to not using an auth token", se); } return new QuandlSession(SessionOptions.Builder.withoutAuthToken().build()); }
/** * Create a Quandl session without an authorization token (authToken). An attempt will be made to read the java property * <em>quandl.auth.token</em> and use that if available. Any resulting SecurityException is logged at debug level, otherwise it is ignored * and no auth token is used. Using a token means you can make more requests. Note creating this object does not make any actual API * requests, the token is used in subsequent requests. * * @return an instance of the Quandl session, not null. */ public static ClassicQuandlSession create() { try { String authToken = System.getProperty(QUANDL_AUTH_TOKEN_PROPERTY_NAME); if (authToken != null) { return new ClassicQuandlSession( SessionOptions.Builder.withAuthToken(authToken).build(), new JSONTabularResultRESTDataProvider(), new ClassicMetaDataPackager()); } } catch (SecurityException se) { LOGGER.debug("Error accessing system property " + QUANDL_AUTH_TOKEN_PROPERTY_NAME + ", falling back to not using an auth token", se); } return new ClassicQuandlSession(SessionOptions.Builder.withoutAuthToken().build(), new JSONTabularResultRESTDataProvider(), new ClassicMetaDataPackager()); }
/** * Create a Quandl session without an authorization token (authToken). An attempt will be made to read the java property * <em>quandl.auth.token</em> and use that if available. Any resulting SecurityException is logged at debug level, otherwise it is ignored * and no auth token is used. Using a token means you can make more requests. Note creating this object does not make any actual API * requests, the token is used in subsequent requests. * * @return an instance of the Quandl session, not null. */ public static TableSawQuandlSession create() { try { String authToken = System.getProperty(QUANDL_AUTH_TOKEN_PROPERTY_NAME); if (authToken != null) { return new TableSawQuandlSession( SessionOptions.Builder.withAuthToken(authToken).build(), new JSONTableSawRESTDataProvider(), new ClassicMetaDataPackager()); } } catch (SecurityException se) { LOGGER.debug("Error accessing system property " + QUANDL_AUTH_TOKEN_PROPERTY_NAME + ", falling back to not using an auth token", se); } return new TableSawQuandlSession(SessionOptions.Builder.withoutAuthToken().build(), new JSONTableSawRESTDataProvider(), new ClassicMetaDataPackager()); }
private void runTests(final ClassicRESTDataProvider restDataProvider, final ResultProcessor resultProcessor, final RetryPolicy retryPolicy) { SessionOptions options; if (_apiKey != null) { s_logger.info("Creating Quandl Session using API key {}", _apiKey); options = SessionOptions.Builder .withAuthToken(_apiKey) .withRetryPolicy(retryPolicy) .build(); } else { s_logger.warn("Creating Quandl Session without an API key"); options = SessionOptions.Builder .withoutAuthToken() .withRetryPolicy(retryPolicy) .build(); } ClassicQuandlSessionInterface session = ClassicQuandlSession.create(options, restDataProvider); Set<String> quandlCodes = sampleSearch(session, resultProcessor); fuzzDataSetRequests(session, resultProcessor, quandlCodes); //fuzzDataSetsRequests(session, resultProcessor, quandlCodes); runMetaDataRequests(session, resultProcessor, quandlCodes); //runMultiMetaDataRequests(session, resultProcessor, quandlCodes); if (restDataProvider instanceof RecordingRESTDataProvider) { RecordingRESTDataProvider recordingRESTDataProvider = (RecordingRESTDataProvider) restDataProvider; recordingRESTDataProvider.close(); // a somewhat unpleasant special-case hack, // probably not even necessary as each entry // is flushed to disk, but being careful. } }
private ClassicQuandlSessionInterface getTestSession(final String expectedURL) { return ClassicQuandlSession.create( SessionOptions.Builder.withoutAuthToken().build(), new TestRESTDataProvider(expectedURL)); }
/** * Create a Quandl session to use a specific authorization token (authToken) with all requests. Using a token means you can make more * requests. Note that this method does not check the quandl.auth.token property. Creating this object does not make any actual API * requests, the token is used in subsequent requests. * * @param authToken a Quandl API authorization token * @return an instance of the Quandl session with an embedded authorization token */ public static QuandlSession create(final String authToken) { ArgumentChecker.notNull(authToken, "authToken"); return new QuandlSession(SessionOptions.Builder.withAuthToken(authToken).build()); }
private QuandlSession getTestSession(final String expectedURL) { return QuandlSession.create( SessionOptions.Builder.withoutAuthToken() .withRESTDataProvider( new TestRESTDataProvider(expectedURL)) .build()); }