@ SuppressWarnings ( "nls" ) public void listDatabases ( final IAsyncResultHandler < List < String > > handler ) { IHttpClientRequest request = httpClient . request ( queryUrl . toString ( ) , HttpMethod . GET , result -> { try { if ( result . isError ( ) || result . getResult ( ) . getResponseCode ( ) != 200 ) { handleError ( result , handler ) ; return ; } List < String > results = new ArrayList <> ( ) ; // {"results": JsonNode arrNode = objectMapper . readTree ( result . getResult ( ) . getBody ( ) ) . path ( "results" ) . elements ( ) . next ( ) // results: [ first-elem . path ( "series" ) . elements ( ) . next ( ) ; // series: [ first-elem // values: [[db1], [db2], [...]] => db1, db2 flattenArrays ( arrNode . get ( "values" ) , results ) ; // send results handler . handle ( AsyncResultImpl . create ( results ) ) ; } catch ( IOException e ) { AsyncResultImpl . create ( new RuntimeException ( "Unable to parse Influx JSON response" , e ) ) ; } } ) ; request . end ( ) ; }
List all databases