Skip to content

Commit 3769989

Browse files
authored
API Updates (#372)
* Updated API * Bumping up driver version * Updating docs
1 parent 863d4cd commit 3769989

File tree

6 files changed

+149
-170
lines changed

6 files changed

+149
-170
lines changed

arango/collection.py

Lines changed: 30 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,9 +3008,8 @@ def insert(
30083008
self,
30093009
vertex: Json,
30103010
sync: Optional[bool] = None,
3011-
silent: bool = False,
30123011
return_new: bool = False,
3013-
) -> Result[Union[bool, Json]]:
3012+
) -> Result[Json]:
30143013
"""Insert a new vertex document.
30153014
30163015
:param vertex: New vertex document to insert. If it has "_key" or "_id"
@@ -3019,20 +3018,16 @@ def insert(
30193018
:type vertex: dict
30203019
:param sync: Block until operation is synchronized to disk.
30213020
:type sync: bool | None
3022-
:param silent: If set to True, no document metadata is returned. This
3023-
can be used to save resources.
3024-
:type silent: bool
30253021
:param return_new: Include body of the new document in the returned
30263022
metadata. Ignored if parameter **silent** is set to True.
30273023
:type return_new: bool
3028-
:return: Document metadata (e.g. document key, revision), or True if
3029-
parameter **silent** was set to True.
3030-
:rtype: bool | dict
3024+
:return: Document metadata (e.g. document key, revision).
3025+
:rtype: dict
30313026
:raise arango.exceptions.DocumentInsertError: If insert fails.
30323027
"""
30333028
vertex = self._ensure_key_from_id(vertex)
30343029

3035-
params: Params = {"silent": silent, "returnNew": return_new}
3030+
params: Params = {"returnNew": return_new}
30363031
if sync is not None:
30373032
params["waitForSync"] = sync
30383033

@@ -3044,11 +3039,9 @@ def insert(
30443039
write=self.name,
30453040
)
30463041

3047-
def response_handler(resp: Response) -> Union[bool, Json]:
3042+
def response_handler(resp: Response) -> Json:
30483043
if not resp.is_success:
30493044
raise DocumentInsertError(resp, request)
3050-
if silent:
3051-
return True
30523045
return format_vertex(resp.body)
30533046

30543047
return self._execute(request, response_handler)
@@ -3059,10 +3052,9 @@ def update(
30593052
check_rev: bool = True,
30603053
keep_none: bool = True,
30613054
sync: Optional[bool] = None,
3062-
silent: bool = False,
30633055
return_old: bool = False,
30643056
return_new: bool = False,
3065-
) -> Result[Union[bool, Json]]:
3057+
) -> Result[Json]:
30663058
"""Update a vertex document.
30673059
30683060
:param vertex: Partial or full vertex document with updated values. It
@@ -3076,18 +3068,14 @@ def update(
30763068
:type keep_none: bool | None
30773069
:param sync: Block until operation is synchronized to disk.
30783070
:type sync: bool | None
3079-
:param silent: If set to True, no document metadata is returned. This
3080-
can be used to save resources.
3081-
:type silent: bool
30823071
:param return_old: Include body of the old document in the returned
30833072
metadata. Ignored if parameter **silent** is set to True.
30843073
:type return_old: bool
30853074
:param return_new: Include body of the new document in the returned
30863075
metadata. Ignored if parameter **silent** is set to True.
30873076
:type return_new: bool
3088-
:return: Document metadata (e.g. document key, revision) or True if
3089-
parameter **silent** was set to True.
3090-
:rtype: bool | dict
3077+
:return: Document metadata (e.g. document key, revision).
3078+
:rtype: dict
30913079
:raise arango.exceptions.DocumentUpdateError: If update fails.
30923080
:raise arango.exceptions.DocumentRevisionError: If revisions mismatch.
30933081
"""
@@ -3096,7 +3084,6 @@ def update(
30963084
params: Params = {
30973085
"keepNull": keep_none,
30983086
"overwrite": not check_rev,
3099-
"silent": silent,
31003087
"returnNew": return_new,
31013088
"returnOld": return_old,
31023089
}
@@ -3112,13 +3099,11 @@ def update(
31123099
write=self.name,
31133100
)
31143101

3115-
def response_handler(resp: Response) -> Union[bool, Json]:
3102+
def response_handler(resp: Response) -> Json:
31163103
if resp.status_code == 412: # pragma: no cover
31173104
raise DocumentRevisionError(resp, request)
31183105
elif not resp.is_success:
31193106
raise DocumentUpdateError(resp, request)
3120-
if silent is True:
3121-
return True
31223107
return format_vertex(resp.body)
31233108

31243109
return self._execute(request, response_handler)
@@ -3128,10 +3113,9 @@ def replace(
31283113
vertex: Json,
31293114
check_rev: bool = True,
31303115
sync: Optional[bool] = None,
3131-
silent: bool = False,
31323116
return_old: bool = False,
31333117
return_new: bool = False,
3134-
) -> Result[Union[bool, Json]]:
3118+
) -> Result[Json]:
31353119
"""Replace a vertex document.
31363120
31373121
:param vertex: New vertex document to replace the old one with. It must
@@ -3142,25 +3126,20 @@ def replace(
31423126
:type check_rev: bool
31433127
:param sync: Block until operation is synchronized to disk.
31443128
:type sync: bool | None
3145-
:param silent: If set to True, no document metadata is returned. This
3146-
can be used to save resources.
3147-
:type silent: bool
31483129
:param return_old: Include body of the old document in the returned
31493130
metadata. Ignored if parameter **silent** is set to True.
31503131
:type return_old: bool
31513132
:param return_new: Include body of the new document in the returned
31523133
metadata. Ignored if parameter **silent** is set to True.
31533134
:type return_new: bool
3154-
:return: Document metadata (e.g. document key, revision) or True if
3155-
parameter **silent** was set to True.
3156-
:rtype: bool | dict
3135+
:return: Document metadata (e.g. document key, revision).
3136+
:rtype: dict
31573137
:raise arango.exceptions.DocumentReplaceError: If replace fails.
31583138
:raise arango.exceptions.DocumentRevisionError: If revisions mismatch.
31593139
"""
31603140
vertex_id, headers = self._prep_from_body(vertex, check_rev)
31613141

31623142
params: Params = {
3163-
"silent": silent,
31643143
"returnNew": return_new,
31653144
"returnOld": return_old,
31663145
}
@@ -3176,13 +3155,11 @@ def replace(
31763155
write=self.name,
31773156
)
31783157

3179-
def response_handler(resp: Response) -> Union[bool, Json]:
3158+
def response_handler(resp: Response) -> Json:
31803159
if resp.status_code == 412: # pragma: no cover
31813160
raise DocumentRevisionError(resp, request)
31823161
elif not resp.is_success:
31833162
raise DocumentReplaceError(resp, request)
3184-
if silent is True:
3185-
return True
31863163
return format_vertex(resp.body)
31873164

31883165
return self._execute(request, response_handler)
@@ -3326,9 +3303,8 @@ def insert(
33263303
self,
33273304
edge: Json,
33283305
sync: Optional[bool] = None,
3329-
silent: bool = False,
33303306
return_new: bool = False,
3331-
) -> Result[Union[bool, Json]]:
3307+
) -> Result[Json]:
33323308
"""Insert a new edge document.
33333309
33343310
:param edge: New edge document to insert. It must contain "_from" and
@@ -3338,20 +3314,16 @@ def insert(
33383314
:type edge: dict
33393315
:param sync: Block until operation is synchronized to disk.
33403316
:type sync: bool | None
3341-
:param silent: If set to True, no document metadata is returned. This
3342-
can be used to save resources.
3343-
:type silent: bool
33443317
:param return_new: Include body of the new document in the returned
33453318
metadata. Ignored if parameter **silent** is set to True.
33463319
:type return_new: bool
3347-
:return: Document metadata (e.g. document key, revision) or True if
3348-
parameter **silent** was set to True.
3349-
:rtype: bool | dict
3320+
:return: Document metadata (e.g. document key, revision).
3321+
:rtype: dict
33503322
:raise arango.exceptions.DocumentInsertError: If insert fails.
33513323
"""
33523324
edge = self._ensure_key_from_id(edge)
33533325

3354-
params: Params = {"silent": silent, "returnNew": return_new}
3326+
params: Params = {"returnNew": return_new}
33553327
if sync is not None:
33563328
params["waitForSync"] = sync
33573329

@@ -3363,11 +3335,9 @@ def insert(
33633335
write=self.name,
33643336
)
33653337

3366-
def response_handler(resp: Response) -> Union[bool, Json]:
3338+
def response_handler(resp: Response) -> Json:
33673339
if not resp.is_success:
33683340
raise DocumentInsertError(resp, request)
3369-
if silent:
3370-
return True
33713341
return format_edge(resp.body)
33723342

33733343
return self._execute(request, response_handler)
@@ -3378,10 +3348,9 @@ def update(
33783348
check_rev: bool = True,
33793349
keep_none: bool = True,
33803350
sync: Optional[bool] = None,
3381-
silent: bool = False,
33823351
return_old: bool = False,
33833352
return_new: bool = False,
3384-
) -> Result[Union[bool, Json]]:
3353+
) -> Result[Json]:
33853354
"""Update an edge document.
33863355
33873356
:param edge: Partial or full edge document with updated values. It must
@@ -3395,18 +3364,14 @@ def update(
33953364
:type keep_none: bool | None
33963365
:param sync: Block until operation is synchronized to disk.
33973366
:type sync: bool | None
3398-
:param silent: If set to True, no document metadata is returned. This
3399-
can be used to save resources.
3400-
:type silent: bool
34013367
:param return_old: Include body of the old document in the returned
34023368
metadata. Ignored if parameter **silent** is set to True.
34033369
:type return_old: bool
34043370
:param return_new: Include body of the new document in the returned
34053371
metadata. Ignored if parameter **silent** is set to True.
34063372
:type return_new: bool
3407-
:return: Document metadata (e.g. document key, revision) or True if
3408-
parameter **silent** was set to True.
3409-
:rtype: bool | dict
3373+
:return: Document metadata (e.g. document key, revision).
3374+
:rtype: dict
34103375
:raise arango.exceptions.DocumentUpdateError: If update fails.
34113376
:raise arango.exceptions.DocumentRevisionError: If revisions mismatch.
34123377
"""
@@ -3415,7 +3380,6 @@ def update(
34153380
params: Params = {
34163381
"keepNull": keep_none,
34173382
"overwrite": not check_rev,
3418-
"silent": silent,
34193383
"returnNew": return_new,
34203384
"returnOld": return_old,
34213385
}
@@ -3431,13 +3395,11 @@ def update(
34313395
write=self.name,
34323396
)
34333397

3434-
def response_handler(resp: Response) -> Union[bool, Json]:
3398+
def response_handler(resp: Response) -> Json:
34353399
if resp.status_code == 412: # pragma: no cover
34363400
raise DocumentRevisionError(resp, request)
34373401
if not resp.is_success:
34383402
raise DocumentUpdateError(resp, request)
3439-
if silent is True:
3440-
return True
34413403
return format_edge(resp.body)
34423404

34433405
return self._execute(request, response_handler)
@@ -3447,10 +3409,9 @@ def replace(
34473409
edge: Json,
34483410
check_rev: bool = True,
34493411
sync: Optional[bool] = None,
3450-
silent: bool = False,
34513412
return_old: bool = False,
34523413
return_new: bool = False,
3453-
) -> Result[Union[bool, Json]]:
3414+
) -> Result[Json]:
34543415
"""Replace an edge document.
34553416
34563417
:param edge: New edge document to replace the old one with. It must
@@ -3462,25 +3423,20 @@ def replace(
34623423
:type check_rev: bool
34633424
:param sync: Block until operation is synchronized to disk.
34643425
:type sync: bool | None
3465-
:param silent: If set to True, no document metadata is returned. This
3466-
can be used to save resources.
3467-
:type silent: bool
34683426
:param return_old: Include body of the old document in the returned
34693427
metadata. Ignored if parameter **silent** is set to True.
34703428
:type return_old: bool
34713429
:param return_new: Include body of the new document in the returned
34723430
metadata. Ignored if parameter **silent** is set to True.
34733431
:type return_new: bool
3474-
:return: Document metadata (e.g. document key, revision) or True if
3475-
parameter **silent** was set to True.
3476-
:rtype: bool | dict
3432+
:return: Document metadata (e.g. document key, revision).
3433+
:rtype: dict
34773434
:raise arango.exceptions.DocumentReplaceError: If replace fails.
34783435
:raise arango.exceptions.DocumentRevisionError: If revisions mismatch.
34793436
"""
34803437
edge_id, headers = self._prep_from_body(edge, check_rev)
34813438

34823439
params: Params = {
3483-
"silent": silent,
34843440
"returnNew": return_new,
34853441
"returnOld": return_old,
34863442
}
@@ -3496,13 +3452,11 @@ def replace(
34963452
write=self.name,
34973453
)
34983454

3499-
def response_handler(resp: Response) -> Union[bool, Json]:
3455+
def response_handler(resp: Response) -> Json:
35003456
if resp.status_code == 412: # pragma: no cover
35013457
raise DocumentRevisionError(resp, request)
35023458
if not resp.is_success:
35033459
raise DocumentReplaceError(resp, request)
3504-
if silent is True:
3505-
return True
35063460
return format_edge(resp.body)
35073461

35083462
return self._execute(request, response_handler)
@@ -3575,9 +3529,8 @@ def link(
35753529
to_vertex: Union[str, Json],
35763530
data: Optional[Json] = None,
35773531
sync: Optional[bool] = None,
3578-
silent: bool = False,
35793532
return_new: bool = False,
3580-
) -> Result[Union[bool, Json]]:
3533+
) -> Result[Json]:
35813534
"""Insert a new edge document linking the given vertices.
35823535
35833536
:param from_vertex: "From" vertex document ID or body with "_id" field.
@@ -3590,21 +3543,17 @@ def link(
35903543
:type data: dict | None
35913544
:param sync: Block until operation is synchronized to disk.
35923545
:type sync: bool | None
3593-
:param silent: If set to True, no document metadata is returned. This
3594-
can be used to save resources.
3595-
:type silent: bool
35963546
:param return_new: Include body of the new document in the returned
35973547
metadata. Ignored if parameter **silent** is set to True.
35983548
:type return_new: bool
3599-
:return: Document metadata (e.g. document key, revision) or True if
3600-
parameter **silent** was set to True.
3601-
:rtype: bool | dict
3549+
:return: Document metadata (e.g. document key, revision).
3550+
:rtype: dict
36023551
:raise arango.exceptions.DocumentInsertError: If insert fails.
36033552
"""
36043553
edge = {"_from": get_doc_id(from_vertex), "_to": get_doc_id(to_vertex)}
36053554
if data is not None:
36063555
edge.update(self._ensure_key_from_id(data))
3607-
return self.insert(edge, sync=sync, silent=silent, return_new=return_new)
3556+
return self.insert(edge, sync=sync, return_new=return_new)
36083557

36093558
def edges(
36103559
self,

arango/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ class VertexCollectionDeleteError(ArangoServerError):
543543
"""Failed to delete vertex collection."""
544544

545545

546+
class EdgeCollectionListError(ArangoServerError):
547+
"""Failed to retrieve edge collections."""
548+
549+
546550
class EdgeDefinitionListError(ArangoServerError):
547551
"""Failed to retrieve edge definitions."""
548552

0 commit comments

Comments
 (0)