Skip to content

Commit 0163b01

Browse files
committed
Add schema error codes, documentation and other misc things
1 parent 7112d6a commit 0163b01

File tree

8 files changed

+90
-12
lines changed

8 files changed

+90
-12
lines changed

README.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ To install a stable version from PyPi_:
6060
~$ pip install python-arango
6161
6262
63-
To install the latest version directly from GitHub_:
63+
To install the latest version from GitHub_:
6464

6565
.. code-block:: bash
6666
6767
~$ pip install -e git+git@github.com:joowani/python-arango.git@master#egg=python-arango
6868
69+
To install experimental version from GitHub_:
70+
71+
.. code-block:: bash
72+
73+
~$ pip install -e git+git@github.com:joowani/python-arango.git@dev#egg=python-arango
74+
6975
You may need to use ``sudo`` depending on your environment.
7076

7177
Getting Started
@@ -172,4 +178,4 @@ Please take a look at this page_ before submitting a pull request. Thanks!
172178
http://python-driver-for-arangodb.readthedocs.io/en/master/index.html
173179
.. _page:
174180
http://python-driver-for-arangodb.readthedocs.io/en/master/contributing.html
175-
.. _aioarangodb: https://github.com/bloodbare/aioarangodb
181+
.. _aioarangodb: https://github.com/bloodbare/aioarangodb

arango/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def db(self,
131131
deserializer=self._deserializer,
132132
superuser_token=superuser_token
133133
)
134-
elif auth_method == 'basic':
134+
elif auth_method.lower() == 'basic':
135135
connection = BasicConnection(
136136
hosts=self._hosts,
137137
host_resolver=self._host_resolver,
@@ -143,7 +143,7 @@ def db(self,
143143
serializer=self._serializer,
144144
deserializer=self._deserializer,
145145
)
146-
elif auth_method == 'jwt':
146+
elif auth_method.lower() == 'jwt':
147147
connection = JWTConnection(
148148
hosts=self._hosts,
149149
host_resolver=self._host_resolver,

arango/errno.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,16 @@
682682
# Concurrent request still using the cursor.
683683
CURSOR_BUSY = 1601
684684

685+
##############################
686+
# ArangoDB Validation Errors #
687+
##############################
688+
689+
# Document does not pass schema validation.
690+
VALIDATION_FAILED = 1620
691+
692+
# Schema description is invalid.
693+
VALIDATION_BAD_PARAMETER = 1621
694+
685695
###############################
686696
# ArangoDB Transaction Errors #
687697
###############################

docs/admin.rst

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,31 @@ database.
6161
sys_db.metrics()
6262

6363

64-
You can also access or hot-reload JWT secrets (enterprise edition only):
64+
Features available in enterprise edition only:
6565

6666
.. code-block:: python
6767
68-
# Retrieve JWT secrets
68+
from arango import ArangoClient
69+
70+
# Initialize the ArangoDB client.
71+
client = ArangoClient()
72+
73+
# Connect to "_system" database as root user using JWT authentication.
74+
sys_db = client.db(
75+
'_system',
76+
username='root',
77+
password='passwd',
78+
auth_method='jwt'
79+
)
80+
81+
# Retrieve JWT secrets.
6982
sys_db.jwt_secrets()
7083
71-
# Hot-reload JWT secrets
84+
# Hot-reload JWT secrets.
7285
sys_db.reload_jwt_secrets()
7386
74-
See :ref:`StandardDatabase` for API specification.
87+
# Rotate the user-supplied keys for encryption.
88+
sys_db.encryption()
89+
90+
91+
See :ref:`StandardDatabase` for API specification.

docs/async.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ In **asynchronous execution**, python-arango sends API requests to ArangoDB in
55
fire-and-forget style. The server processes the requests in the background, and
66
the results can be retrieved once available via :ref:`AsyncJob` objects.
77

8-
**Example
9-
:**
8+
**Example:**
109

1110
.. testcode::
1211

docs/cluster.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ Below is an example on how to manage clusters using python-arango.
8080
# Get the cluster health.
8181
cluster.health()
8282
83-
# Get details for a specific server in the cluster.
83+
# Get cluster server details.
84+
cluster.server_count()
8485
server_id = cluster.server_id()
8586
cluster.server_engine(server_id)
8687
cluster.server_version(server_id)

docs/index.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ To install a stable version from PyPi_:
2424
~$ pip install python-arango
2525
2626
27-
To install the latest version directly from GitHub_:
27+
To install the latest version from GitHub_:
2828

2929
.. code-block:: bash
3030
3131
~$ pip install -e git+git@github.com:joowani/python-arango.git@master#egg=python-arango
3232
33+
To install experimental version from GitHub_:
34+
35+
.. code-block:: bash
36+
37+
~$ pip install -e git+git@github.com:joowani/python-arango.git@dev#egg=python-arango
38+
3339
3440
You may need to use ``sudo`` depending on your environment.
3541

@@ -48,6 +54,7 @@ Contents
4854
database
4955
collection
5056
document
57+
schema
5158
indexes
5259
graph
5360
aql

docs/schema.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Schema Validation
2+
-----------------
3+
4+
ArangoDB supports document validation using JSON schemas. You can use this
5+
feature by providing a schema during collection creation using the ``schema``
6+
parameter.
7+
8+
**Example:**
9+
10+
.. testcode::
11+
12+
from arango import ArangoClient
13+
14+
# Initialize the ArangoDB client.
15+
client = ArangoClient()
16+
17+
# Connect to "test" database as root user.
18+
db = client.db('test', username='root', password='passwd')
19+
20+
# Create a new collection named "employees".
21+
if db.has_collection('employees'):
22+
db.delete_collection('employees')
23+
24+
employees = db.create_collection(
25+
name='employees',
26+
schema={
27+
'rule': {
28+
'type': 'object',
29+
'properties': {
30+
'name': {'type': 'string'},
31+
'email': {'type': 'string'}
32+
},
33+
'required': ['name', 'email']
34+
},
35+
'level': 'moderate',
36+
'message': 'Schema Validation Failed.'
37+
}
38+
)

0 commit comments

Comments
 (0)