Skip to content

Commit 5724735

Browse files
committed
Merge branch 'main' into DE-752
2 parents 6e5bc34 + d5d867c commit 5724735

29 files changed

+520
-122
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ workflows:
1515
python_version: ["3.8", "3.9", "3.10", "3.11"] # "3.12"
1616
arangodb_config: ["single", "cluster"]
1717
arangodb_license: ["community", "enterprise"]
18-
arangodb_version: ["3.10.10", "3.11.4", "latest"]
18+
arangodb_version: ["3.11", "latest"]
1919

2020
jobs:
2121
lint:

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
![Logo](https://user-images.githubusercontent.com/2701938/108583516-c3576680-72ee-11eb-883f-2d9b52e74e45.png)
22

3-
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/ArangoDB-Community/python-arango/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/ArangoDB-Community/python-arango/tree/main)
4-
[![CodeQL](https://github.com/ArangoDB-Community/python-arango/actions/workflows/codeql.yaml/badge.svg)](https://github.com/ArangoDB-Community/python-arango/actions/workflows/codeql.yaml)
5-
[![Docs](https://github.com/ArangoDB-Community/python-arango/actions/workflows/docs.yaml/badge.svg)](https://github.com/ArangoDB-Community/python-arango/actions/workflows/docs.yaml)
6-
[![Coverage Status](https://codecov.io/gh/ArangoDB-Community/python-arango/branch/main/graph/badge.svg?token=M8zrjrzsUY)](https://codecov.io/gh/ArangoDB-Community/python-arango)
7-
[![Last commit](https://img.shields.io/github/last-commit/ArangoDB-Community/python-arango)](https://github.com/ArangoDB-Community/python-arango/commits/master)
3+
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/arangodb/python-arango/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/arangodb/python-arango/tree/main)
4+
[![CodeQL](https://github.com/arangodb/python-arango/actions/workflows/codeql.yaml/badge.svg)](https://github.com/arangodb/python-arango/actions/workflows/codeql.yaml)
5+
[![Docs](https://github.com/arangodb/python-arango/actions/workflows/docs.yaml/badge.svg)](https://github.com/arangodb/python-arango/actions/workflows/docs.yaml)
6+
[![Coverage Status](https://codecov.io/gh/arangodb/python-arango/branch/main/graph/badge.svg?token=M8zrjrzsUY)](https://codecov.io/gh/arangodb/python-arango)
7+
[![Last commit](https://img.shields.io/github/last-commit/arangodb/python-arango)](https://github.com/arangodb/python-arango/commits/master)
88

99
[![PyPI version badge](https://img.shields.io/pypi/v/python-arango?color=3775A9&style=for-the-badge&logo=pypi&logoColor=FFD43B)](https://pypi.org/project/python-arango/)
1010
[![Python versions badge](https://img.shields.io/badge/3.8%2B-3776AB?style=for-the-badge&logo=python&logoColor=FFD43B&label=Python)](https://pypi.org/project/python-arango/)
1111

12-
[![License](https://img.shields.io/github/license/ArangoDB-Community/python-arango?color=9E2165&style=for-the-badge)](https://github.com/ArangoDB-Community/python-arango/blob/master/LICENSE)
12+
[![License](https://img.shields.io/github/license/arangodb/python-arango?color=9E2165&style=for-the-badge)](https://github.com/arangodb/python-arango/blob/master/LICENSE)
1313
[![Code style: black](https://img.shields.io/static/v1?style=for-the-badge&label=code%20style&message=black&color=black)](https://github.com/psf/black)
1414
[![Downloads](https://img.shields.io/pepy/dt/python-arango?style=for-the-badge&color=282661
1515
)](https://pepy.tech/project/python-arango)
@@ -21,7 +21,7 @@ database natively supporting documents, graphs and search.
2121

2222
## Requirements
2323

24-
- ArangoDB version 3.9+
24+
- ArangoDB version 3.11+
2525
- Python version 3.8+
2626

2727
## Installation

arango/client.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
)
1414
from arango.database import StandardDatabase
1515
from arango.exceptions import ServerConnectionError
16-
from arango.http import DEFAULT_REQUEST_TIMEOUT, DefaultHTTPClient, HTTPClient
16+
from arango.http import (
17+
DEFAULT_REQUEST_TIMEOUT,
18+
DefaultHTTPClient,
19+
HTTPClient,
20+
RequestCompression,
21+
)
1722
from arango.resolver import (
1823
FallbackHostResolver,
1924
HostResolver,
@@ -33,7 +38,7 @@ def default_serializer(x: Any) -> str:
3338
:return: The object serialized as a JSON string
3439
:rtype: str
3540
"""
36-
return dumps(x)
41+
return dumps(x, separators=(",", ":"))
3742

3843

3944
def default_deserializer(x: str) -> Any:
@@ -85,6 +90,12 @@ class ArangoClient:
8590
None: No timeout.
8691
int: Timeout value in seconds.
8792
:type request_timeout: int | float
93+
:param request_compression: Will compress requests to the server according to
94+
the given algorithm. No compression happens by default.
95+
:type request_compression: arango.http.RequestCompression | None
96+
:param response_compression: Tells the server what compression algorithm is
97+
acceptable for the response. No compression happens by default.
98+
:type response_compression: str | None
8899
"""
89100

90101
def __init__(
@@ -97,6 +108,8 @@ def __init__(
97108
deserializer: Callable[[str], Any] = default_deserializer,
98109
verify_override: Union[bool, str, None] = None,
99110
request_timeout: Union[int, float, None] = DEFAULT_REQUEST_TIMEOUT,
111+
request_compression: Optional[RequestCompression] = None,
112+
response_compression: Optional[str] = None,
100113
) -> None:
101114
if isinstance(hosts, str):
102115
self._hosts = [host.strip("/") for host in hosts.split(",")]
@@ -133,6 +146,9 @@ def __init__(
133146
for session in self._sessions:
134147
session.verify = verify_override
135148

149+
self._request_compression = request_compression
150+
self._response_compression = response_compression
151+
136152
def __repr__(self) -> str:
137153
return f"<ArangoClient {','.join(self._hosts)}>"
138154

@@ -231,6 +247,8 @@ def db(
231247
serializer=self._serializer,
232248
deserializer=self._deserializer,
233249
superuser_token=superuser_token,
250+
request_compression=self._request_compression,
251+
response_compression=self._response_compression,
234252
)
235253
elif user_token is not None:
236254
connection = JwtConnection(
@@ -242,6 +260,8 @@ def db(
242260
serializer=self._serializer,
243261
deserializer=self._deserializer,
244262
user_token=user_token,
263+
request_compression=self._request_compression,
264+
response_compression=self._response_compression,
245265
)
246266
elif auth_method.lower() == "basic":
247267
connection = BasicConnection(
@@ -254,6 +274,8 @@ def db(
254274
http_client=self._http,
255275
serializer=self._serializer,
256276
deserializer=self._deserializer,
277+
request_compression=self._request_compression,
278+
response_compression=self._response_compression,
257279
)
258280
elif auth_method.lower() == "jwt":
259281
connection = JwtConnection(
@@ -266,6 +288,8 @@ def db(
266288
http_client=self._http,
267289
serializer=self._serializer,
268290
deserializer=self._deserializer,
291+
request_compression=self._request_compression,
292+
response_compression=self._response_compression,
269293
)
270294
else:
271295
raise ValueError(f"invalid auth_method: {auth_method}")

arango/collection.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,7 @@ def insert_many(
17581758
keep_none: Optional[bool] = None,
17591759
merge: Optional[bool] = None,
17601760
refill_index_caches: Optional[bool] = None,
1761+
version_attribute: Optional[str] = None,
17611762
) -> Result[Union[bool, List[Union[Json, ArangoServerError]]]]:
17621763
"""Insert multiple documents.
17631764
@@ -1812,6 +1813,9 @@ def insert_many(
18121813
index caches if document insertions affect the edge index or
18131814
cache-enabled persistent indexes.
18141815
:type refill_index_caches: bool | None
1816+
:param version_attribute: support for simple external versioning to
1817+
document operations.
1818+
:type version_attribute: str
18151819
:return: List of document metadata (e.g. document keys, revisions) and
18161820
any exception, or True if parameter **silent** was set to True.
18171821
:rtype: [dict | ArangoServerError] | bool
@@ -1834,6 +1838,8 @@ def insert_many(
18341838
params["keepNull"] = keep_none
18351839
if merge is not None:
18361840
params["mergeObjects"] = merge
1841+
if version_attribute is not None:
1842+
params["versionAttribute"] = version_attribute
18371843

18381844
# New in ArangoDB 3.9.6 and 3.10.2
18391845
if refill_index_caches is not None:
@@ -1880,6 +1886,7 @@ def update_many(
18801886
silent: bool = False,
18811887
refill_index_caches: Optional[bool] = None,
18821888
raise_on_document_error: bool = False,
1889+
version_attribute: Optional[str] = None,
18831890
) -> Result[Union[bool, List[Union[Json, ArangoServerError]]]]:
18841891
"""Update multiple documents.
18851892
@@ -1932,6 +1939,9 @@ def update_many(
19321939
as opposed to returning the error as an object in the result list.
19331940
Defaults to False.
19341941
:type raise_on_document_error: bool
1942+
:param version_attribute: support for simple external versioning to
1943+
document operations.
1944+
:type version_attribute: str
19351945
:return: List of document metadata (e.g. document keys, revisions) and
19361946
any exceptions, or True if parameter **silent** was set to True.
19371947
:rtype: [dict | ArangoError] | bool
@@ -1948,6 +1958,8 @@ def update_many(
19481958
}
19491959
if sync is not None:
19501960
params["waitForSync"] = sync
1961+
if version_attribute is not None:
1962+
params["versionAttribute"] = version_attribute
19511963

19521964
# New in ArangoDB 3.9.6 and 3.10.2
19531965
if refill_index_caches is not None:
@@ -2084,6 +2096,7 @@ def replace_many(
20842096
sync: Optional[bool] = None,
20852097
silent: bool = False,
20862098
refill_index_caches: Optional[bool] = None,
2099+
version_attribute: Optional[str] = None,
20872100
) -> Result[Union[bool, List[Union[Json, ArangoServerError]]]]:
20882101
"""Replace multiple documents.
20892102
@@ -2125,6 +2138,9 @@ def replace_many(
21252138
index caches if document operations affect the edge index or
21262139
cache-enabled persistent indexes.
21272140
:type refill_index_caches: bool | None
2141+
:param version_attribute: support for simple external versioning to
2142+
document operations.
2143+
:type version_attribute: str
21282144
:return: List of document metadata (e.g. document keys, revisions) and
21292145
any exceptions, or True if parameter **silent** was set to True.
21302146
:rtype: [dict | ArangoServerError] | bool
@@ -2139,6 +2155,8 @@ def replace_many(
21392155
}
21402156
if sync is not None:
21412157
params["waitForSync"] = sync
2158+
if version_attribute is not None:
2159+
params["versionAttribute"] = version_attribute
21422160

21432161
# New in ArangoDB 3.9.6 and 3.10.2
21442162
if refill_index_caches is not None:
@@ -2613,6 +2631,7 @@ def insert(
26132631
keep_none: Optional[bool] = None,
26142632
merge: Optional[bool] = None,
26152633
refill_index_caches: Optional[bool] = None,
2634+
version_attribute: Optional[str] = None,
26162635
) -> Result[Union[bool, Json]]:
26172636
"""Insert a new document.
26182637
@@ -2651,6 +2670,9 @@ def insert(
26512670
index caches if document insertions affect the edge index or
26522671
cache-enabled persistent indexes.
26532672
:type refill_index_caches: bool | None
2673+
:param version_attribute: support for simple external versioning to
2674+
document operations.
2675+
:type version_attribute: str
26542676
:return: Document metadata (e.g. document key, revision) or True if
26552677
parameter **silent** was set to True.
26562678
:rtype: bool | dict
@@ -2672,6 +2694,8 @@ def insert(
26722694
params["keepNull"] = keep_none
26732695
if merge is not None:
26742696
params["mergeObjects"] = merge
2697+
if version_attribute is not None:
2698+
params["versionAttribute"] = version_attribute
26752699

26762700
# New in ArangoDB 3.9.6 and 3.10.2
26772701
if refill_index_caches is not None:
@@ -2710,6 +2734,7 @@ def update(
27102734
sync: Optional[bool] = None,
27112735
silent: bool = False,
27122736
refill_index_caches: Optional[bool] = None,
2737+
version_attribute: Optional[str] = None,
27132738
) -> Result[Union[bool, Json]]:
27142739
"""Update a document.
27152740
@@ -2740,6 +2765,9 @@ def update(
27402765
index caches if document insertions affect the edge index or
27412766
cache-enabled persistent indexes.
27422767
:type refill_index_caches: bool | None
2768+
:param version_attribute: support for simple external versioning
2769+
to document operations.
2770+
:type version_attribute: str
27432771
:return: Document metadata (e.g. document key, revision) or True if
27442772
parameter **silent** was set to True.
27452773
:rtype: bool | dict
@@ -2758,6 +2786,9 @@ def update(
27582786
if sync is not None:
27592787
params["waitForSync"] = sync
27602788

2789+
if version_attribute is not None:
2790+
params["versionAttribute"] = version_attribute
2791+
27612792
# New in ArangoDB 3.9.6 and 3.10.2
27622793
if refill_index_caches is not None:
27632794
params["refillIndexCaches"] = refill_index_caches
@@ -2793,6 +2824,7 @@ def replace(
27932824
sync: Optional[bool] = None,
27942825
silent: bool = False,
27952826
refill_index_caches: Optional[bool] = None,
2827+
version_attribute: Optional[str] = None,
27962828
) -> Result[Union[bool, Json]]:
27972829
"""Replace a document.
27982830
@@ -2818,6 +2850,9 @@ def replace(
28182850
index caches if document insertions affect the edge index or
28192851
cache-enabled persistent indexes.
28202852
:type refill_index_caches: bool | None
2853+
:param version_attribute: support for simple external versioning to
2854+
document operations.
2855+
:type version_attribute: str
28212856
:return: Document metadata (e.g. document key, revision) or True if
28222857
parameter **silent** was set to True.
28232858
:rtype: bool | dict
@@ -2834,6 +2869,9 @@ def replace(
28342869
if sync is not None:
28352870
params["waitForSync"] = sync
28362871

2872+
if version_attribute is not None:
2873+
params["versionAttribute"] = version_attribute
2874+
28372875
# New in ArangoDB 3.9.6 and 3.10.2
28382876
if refill_index_caches is not None:
28392877
params["refillIndexCaches"] = refill_index_caches

0 commit comments

Comments
 (0)