Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

add ping method to the client #409

Merged
merged 8 commits into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 12 additions & 0 deletions influxdb/tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
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