Skip to content

Commit 675a9e9

Browse files
committed
API docs: driver page
1 parent dd3225d commit 675a9e9

File tree

4 files changed

+59
-42
lines changed

4 files changed

+59
-42
lines changed

docs/source/driver.rst

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ A `Driver` object holds the detail of a Neo4j database including server URIs, cr
66
It also manages a pool of connections which are used to power :class:`.Session` instances.
77

88
The scheme of the URI passed to the `Driver` constructor determines the type of `Driver` object constructed.
9-
Two types are currently available: the :class:`.DirectDriver` and the :class:`.RoutingDriver`.
10-
These are described in more detail below.
9+
For example, the ``bolt`` scheme generates a :class:`.DirectDriver` instance::
10+
11+
from neo4j.v1 import GraphDatabase
12+
uri = "bolt://localhost:7687"
13+
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
1114

1215

1316
.. autoclass:: neo4j.v1.GraphDatabase
1417
:members:
1518

19+
.. autoclass:: neo4j.v1.Driver
20+
:members:
21+
:inherited-members:
22+
1623
.. autoclass:: neo4j.v1.DirectDriver
1724
:members:
1825
:inherited-members:
@@ -29,21 +36,21 @@ These are described in more detail below.
2936
.. autofunction:: neo4j.v1.custom_auth
3037

3138

32-
Encryption Settings
33-
-------------------
34-
.. py:attribute:: neo4j.v1.ENCRYPTION_OFF
35-
.. py:attribute:: neo4j.v1.ENCRYPTION_ON
36-
.. py:attribute:: neo4j.v1.ENCRYPTION_DEFAULT
39+
Trust Options
40+
-------------
41+
.. py:attribute:: neo4j.v1.TRUST_ALL_CERTIFICATES
3742
43+
Trust any server certificate (default). This ensures that communication
44+
is encrypted but does not verify the server certificate against a
45+
certificate authority. This option is primarily intended for use with
46+
the default auto-generated server certificate.
3847

39-
Trust Settings
40-
--------------
41-
.. py:attribute:: neo4j.v1.TRUST_ALL_CERTIFICATES
42-
.. py:attribute:: neo4j.v1.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES
4348
.. py:attribute:: neo4j.v1.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
44-
.. py:attribute:: neo4j.v1.TRUST_DEFAULT
4549
46-
Deprecated
47-
~~~~~~~~~~
48-
.. py:attribute:: neo4j.v1.TRUST_ON_FIRST_USE
49-
.. py:attribute:: neo4j.v1.TRUST_SIGNED_CERTIFICATES
50+
Trust server certificates that can be verified against the system
51+
certificate authority. This option is primarily intended for use with
52+
full certificates.
53+
54+
.. NOTE:: The option :attr:`.TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` is not yet available for Python
55+
56+
.. NOTE:: The options :attr:`.TRUST_ON_FIRST_USE` and :attr:`.TRUST_SIGNED_CERTIFICATES` are deprecated.

docs/source/index.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
Neo4j Bolt Driver for Python
33
****************************
44

5-
The Official Neo4j Driver for Python supports Neo4j 3.0 and above and Python versions 2.7, 3.4 and 3.5.
5+
The Official Neo4j Driver for Python supports Neo4j 3.0 and above and Python versions 2.7, 3.4, 3.5 and 3.6.
66

77

88
Quick Example
99
=============
1010

1111
.. code-block:: python
1212
13-
from neo4j.v1 import GraphDatabase, basic_auth
13+
from neo4j.v1 import GraphDatabase
1414
1515
uri = "bolt://localhost:7687"
16-
auth_token = basic_auth("neo4j", "password")
17-
driver = GraphDatabase.driver(uri, auth=auth_token)
16+
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
1817
1918
def print_friends_of(name):
2019
with driver.session() as session:

neo4j/v1/api.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def hydrate(self, values):
3939

4040

4141
class GraphDatabase(object):
42-
""" The :class:`.GraphDatabase` class provides access to all graph
43-
database functionality. This is primarily used to construct a driver
44-
instance, using the :meth:`.driver` method.
42+
""" The `GraphDatabase` class provides access to all graph
43+
database functionality. This class is primarily used to construct a
44+
:class:`.Driver` instance, using the :meth:`.driver` method.
4545
"""
4646

4747
uri_schemes = {}
@@ -50,31 +50,33 @@ class GraphDatabase(object):
5050

5151
@classmethod
5252
def driver(cls, uri, **config):
53-
""" Acquire a :class:`.Driver` instance for the given URL and
54-
configuration:
53+
""" Acquire a :class:`.Driver` instance for the given URI and
54+
configuration. The URI scheme determines the Driver implementation
55+
that will be returned. Options are:
5556
56-
>>> from neo4j.v1 import GraphDatabase
57-
>>> driver = GraphDatabase.driver("bolt://localhost:7687")
57+
``bolt``
58+
Returns a :class:`.DirectDriver`.
5859
59-
:param uri: URI for a graph database
60+
``bolt+routing``
61+
Returns a :class:`.RoutingDriver`.
62+
63+
:param uri: URI for a graph database service
6064
:param config: configuration and authentication details (valid keys are listed below)
6165
6266
`auth`
6367
An authentication token for the server, for example
64-
``basic_auth("neo4j", "password")``.
68+
``("neo4j", "password")``.
6569
6670
`der_encoded_server_certificate`
6771
The server certificate in DER format, if required.
6872
6973
`encrypted`
70-
Encryption level: one of :attr:`.ENCRYPTION_ON`, :attr:`.ENCRYPTION_OFF`
71-
or :attr:`.ENCRYPTION_NON_LOCAL`. The default setting varies
72-
depending on whether SSL is available or not. If it is,
73-
:attr:`.ENCRYPTION_NON_LOCAL` is the default.
74+
A boolean flag to determine whether encryption should be used.
75+
Defaults to :const:`True`.
7476
7577
`trust`
76-
Trust level: one of :attr:`.TRUST_ON_FIRST_USE` (default) or
77-
:attr:`.TRUST_SIGNED_CERTIFICATES`.
78+
Trust level: one of :attr:`.TRUST_ALL_CERTIFICATES` (default) or
79+
:attr:`.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES`.
7880
7981
`user_agent`
8082
A custom user agent string, if required.
@@ -90,12 +92,12 @@ def driver(cls, uri, **config):
9092

9193

9294
class Driver(object):
93-
""" A :class:`.Driver` is an accessor for a specific graph database
94-
resource. It is thread-safe, acts as a template for sessions and hosts
95-
a connection pool.
95+
""" The base class for all `Driver` implementations. A Driver is an accessor for
96+
a specific graph database. It is typically thread-safe, acts as a template for
97+
:class:`.Session` creation and hosts a connection pool.
9698
9799
All configuration and authentication settings are held immutably by the
98-
`Driver`. Should different settings be required, a new `Driver` instance
100+
Driver. Should different settings be required, a new Driver instance
99101
should be created via the :meth:`.GraphDatabase.driver` method.
100102
"""
101103

@@ -118,10 +120,16 @@ def session(self, access_mode=None):
118120
pool. Session creation is a lightweight operation and sessions are
119121
not thread safe, therefore a session should generally be short-lived
120122
within a single thread.
123+
124+
:param access_mode:
125+
:return: new :class:`.Session` object
121126
"""
122127
pass
123128

124129
def close(self):
130+
""" Shut down, closing any open connections that were spawned by
131+
this Driver.
132+
"""
125133
if self.pool:
126134
self.pool.close()
127135
self.pool = None

neo4j/v1/bolt.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333

3434

3535
class DirectDriver(Driver):
36-
""" A :class:`.DirectDriver` is created from a `bolt` URI and addresses
37-
a single database instance.
36+
""" A :class:`.DirectDriver` is created from a ``bolt`` URI and addresses
37+
a single database instance. This provides basic connectivity to any
38+
database service topology.
3839
"""
3940

4041
def __init__(self, uri, **config):
@@ -58,7 +59,9 @@ def session(self, access_mode=None):
5859

5960

6061
class RoutingDriver(Driver):
61-
""" A :class:`.RoutingDriver` is created from a `bolt+routing` URI.
62+
""" A :class:`.RoutingDriver` is created from a ``bolt+routing`` URI. The
63+
routing behaviour works in tandem with Neo4j's causal clustering feature
64+
by directing read and write behaviour to appropriate cluster members.
6265
"""
6366

6467
def __init__(self, uri, **config):

0 commit comments

Comments
 (0)