diff --git a/influxdb/client.py b/influxdb/client.py index 608e8dbc..68261ece 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -457,6 +457,19 @@ def write_points(self, retention_policy=retention_policy, tags=tags, protocol=protocol) + def ping(self): + """Check connectivity to InfluxDB. + + :returns: The version of the InfluxDB the client is connected to + """ + response = self.request( + url="ping", + method='GET', + expected_response_code=204 + ) + + return response.headers['X-Influxdb-Version'] + @staticmethod def _batches(iterable, size): for i in xrange(0, len(iterable), size): diff --git a/influxdb/tests/client_test.py b/influxdb/tests/client_test.py index 3413c0bf..ff325907 100644 --- a/influxdb/tests/client_test.py +++ b/influxdb/tests/client_test.py @@ -418,6 +418,18 @@ def test_query_fail(self): with _mocked_session(self.cli, 'get', 401): self.cli.query('select column_one from foo;') + def test_ping(self): + """Test ping querying InfluxDB version.""" + with requests_mock.Mocker() as m: + m.register_uri( + requests_mock.GET, + "http://localhost:8086/ping", + status_code=204, + headers={'X-Influxdb-Version': '1.2.3'} + ) + version = self.cli.ping() + self.assertEqual(version, '1.2.3') + def test_create_database(self): """Test create database for TestInfluxDBClient object.""" with requests_mock.Mocker() as m: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy