Skip to content

Commit cdbe2f4

Browse files
committed
Improve Influxdb-python client inlines docs for reuse on Sphinx
1 parent d73dd1d commit cdbe2f4

File tree

2 files changed

+64
-38
lines changed

2 files changed

+64
-38
lines changed

docs/source/api-documentation.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ ports. The below instantiation statements are all equivalent::
2424
.. note:: Only when using UDP (use_udp=True) the connections is established.
2525

2626

27-
.. module:: influxdb.InfluxDBClient
28-
2927

3028
.. _InfluxDBClient-api:
3129

3230
-----------------------
3331
:class:`InfluxDBClient`
3432
-----------------------
3533

34+
35+
.. currentmodule:: influxdb.InfluxDBClient
3636
.. autoclass:: influxdb.InfluxDBClient
3737
:members:
3838
:undoc-members:
39-
40-
.. automethod:: __init__

influxdb/client.py

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
python client for influxdb
3+
Python client for InfluxDB
44
"""
55
import json
66
import socket
@@ -18,8 +18,31 @@ def __init__(self, content, code):
1818

1919

2020
class InfluxDBClient(object):
21+
2122
"""
22-
InfluxDB Client
23+
The ``InfluxDBClient`` object holds information necessary to connect
24+
to InfluxDB. Requests can be made to InfluxDB directly through the client.
25+
26+
:param host: hostname to connect to InfluxDB, defaults to 'localhost'
27+
:type host: string
28+
:param port: port to connect to InfluxDB, defaults to 'localhost'
29+
:type port: int
30+
:param username: user to connect, defaults to 'root'
31+
:type username: string
32+
:param password: password of the user, defaults to 'root'
33+
:type password: string
34+
:param database: database name to connect to, defaults is None
35+
:type database: string
36+
:param ssl: use https instead of http to connect to InfluxDB, defaults is False
37+
:type ssl: boolean
38+
:param verify_ssl: verify SSL certificates for HTTPS requests, defaults is False
39+
:type verify_ssl: boolean
40+
:param timeout: number of seconds Requests will wait for your client to establish a connection, defaults to None
41+
:type timeout: int
42+
:param use_udp: use UDP to connect to InfluxDB, defaults is False
43+
:type use_udp: int
44+
:param udp_port: UDP port to connect to InfluxDB, defaults is 4444
45+
:type udp_port: int
2346
"""
2447

2548
def __init__(self,
@@ -34,7 +57,7 @@ def __init__(self,
3457
use_udp=False,
3558
udp_port=4444):
3659
"""
37-
Initialize client
60+
Construct a new InfluxDBClient object.
3861
"""
3962
self._host = host
4063
self._port = port
@@ -68,22 +91,25 @@ def __init__(self,
6891

6992
def switch_db(self, database):
7093
"""
71-
Change client database
94+
switch_db()
95+
96+
Change client database.
7297
73-
Parameters
74-
----------
75-
database : string
98+
:param database: the new database name to switch to
99+
:type database: string
76100
"""
77101
self._database = database
78102

79103
def switch_user(self, username, password):
80104
"""
81-
Change client username
105+
switch_user()
82106
83-
Parameters
84-
----------
85-
username : string
86-
password : string
107+
Change client username.
108+
109+
:param username: the new username to switch to
110+
:type username: string
111+
:param password: the new password to switch to
112+
:type password: string
87113
"""
88114
self._username = username
89115
self._password = password
@@ -131,14 +157,13 @@ def request(self, url, method='GET', params=None, data=None,
131157

132158
def write_points(self, *args, **kwargs):
133159
"""
134-
Write to multiple time series names
160+
write_points()
135161
136-
Parameters
137-
----------
138-
batch_size : Optional. Int value to write the points in batches instead
139-
of all at one time.
140-
Useful for when doing data dumps from one database to another or
141-
when doing a massive write operation
162+
Write to multiple time series names.
163+
164+
:param batch_size: [Optional] Value to write the points in batches instead of all at one time.
165+
Useful for when doing data dumps from one database to another or when doing a massive write operation
166+
:type batch_size: int
142167
"""
143168

144169
def list_chunks(l, n):
@@ -300,12 +325,13 @@ def query(self, query, time_precision='s', chunked=False):
300325

301326
def create_database(self, database):
302327
"""
303-
Create a database
328+
create_database()
329+
330+
Create a database on the InfluxDB server.
304331
305-
Parameters
306-
----------
307-
database: string
308-
database name
332+
:param database: the name of the database to create
333+
:type database: string
334+
:rtype: boolean
309335
"""
310336
url = "db"
311337

@@ -322,12 +348,13 @@ def create_database(self, database):
322348

323349
def delete_database(self, database):
324350
"""
325-
Drop a database
351+
delete_database()
326352
327-
Parameters
328-
----------
329-
database: string
330-
database name
353+
Drop a database on the InfluxDB server.
354+
355+
:param database: the name of the database to delete
356+
:type database: string
357+
:rtype: boolean
331358
"""
332359
url = "db/{0}".format(database)
333360

@@ -358,12 +385,13 @@ def get_database_list(self):
358385

359386
def delete_series(self, series):
360387
"""
361-
Drop a series
388+
delete_series()
389+
390+
Drop a series on the InfluxDB server.
362391
363-
Parameters
364-
----------
365-
series: string
366-
series name
392+
:param series: the name of the series to delete
393+
:type series: string
394+
:rtype: boolean
367395
"""
368396
url = "db/{0}/series/{1}".format(
369397
self._database,

0 commit comments

Comments
 (0)