/// <summary> /// Execute a query agains a database. /// </summary> /// <param name="database">the name of the database</param> /// <param name="query"> /// the query to execute, for language specification please see /// <a href="http://influxdb.org/docs/query_language">http://influxdb.org/docs/query_language</a> /// </param> /// <param name="precision">the precision used for the values.</param> /// <returns>A list of Series which matched the query.</returns> public async Task <List <Serie> > QueryAsync(string database, string query, TimeUnit precision) { InfluxDbApiResponse response = await _influxDbClient.Query(NoErrorHandlers, database, query, ToTimePrecision(precision)); return(response.ReadAs <List <Serie> >()); }
/// <summary>Execute a query against a database.</summary> /// <param name="database">The name of the database.</param> /// <param name="query">The query to execute. For language specification please see /// <a href="https://influxdb.com/docs/v0.9/concepts/reading_and_writing_data.html">InfluxDb documentation</a>.</param> /// <returns>A list of Series which matched the query.</returns> /// <exception cref="InfluxDbApiException"></exception> public async Task <List <Serie> > QueryAsync(string database, string query) { InfluxDbApiResponse response = await _influxDbClient.Query(NoErrorHandlers, database, query); var queryResult = response.ReadAs <QueryResult>(); Validate.NotNull(queryResult, "queryResult"); Validate.NotNull(queryResult.Results, "queryResult.Results"); // Apparently a 200 OK can return an error in the results // https://github.com/influxdb/influxdb/pull/1813 var error = queryResult.Results.Single().Error; if (error != null) { throw new InfluxDbApiException(System.Net.HttpStatusCode.BadRequest, error); } var result = queryResult.Results.Single().Series; return(result != null?result.ToList() : new List <Serie>()); }
public async Task <InfluxDbApiResponse> Query(IEnumerable <ApiResponseErrorHandlingDelegate> errorHandlers, string name, string query) { return(await _influxDbClient.Query(errorHandlers, name, query)); }