Skip to content

Commit 4ae23c8

Browse files
committed
PYCBC-1648: Add update_collection and missing collection settings to API docs
Changes ======= Added to API docs: * CreateCollectionSettings * update_collection and relevant classes (UpdateCollectionSettings, UpdateCollectionOptions) * max_expiry & history CollectionSpec properties Change-Id: I9bace3898f5184abe29a1e5a2f37dd80bd4cd4b2 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/221999 Tested-by: Build Bot <[email protected]> Reviewed-by: Jared Casey <[email protected]>
1 parent 0dbe460 commit 4ae23c8

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

couchbase/management/collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def create_collection(self, # noqa: F811
164164
Args:
165165
scope_name (str): The name of the scope the collection will be created in.
166166
collection_name (str): The name of the collection to be created
167-
settings (:class:`~couchbase.management.options.CreateCollectionSettings`, optional): Settings to apply for the collection
167+
settings (:class:`~.CreateCollectionSettings`, optional): Settings to apply for the collection
168168
options (:class:`~couchbase.management.options.CreateCollectionOptions`): Optional parameters for this operation.
169169
**kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters for this operation.
170170
@@ -254,7 +254,7 @@ def update_collection(self,
254254
Args:
255255
scope_name (str): The name of the scope the collection is in.
256256
collection_name (str): The name of the collection that will be updated
257-
settings (:class:`~couchbase.management.options.UpdateCollectionSettings`, optional): Settings to apply for the collection
257+
settings (:class:`~.UpdateCollectionSettings`, optional): Settings to apply for the collection
258258
options (:class:`~couchbase.management.options.UpdateCollectionOptions`): Optional parameters for this operation.
259259
**kwargs (Dict[str, Any]): keyword arguments that can be used as optional parameters for this operation.
260260

couchbase/management/logic/collections_logic.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ def update_collection(self,
265265

266266

267267
class CreateCollectionSettings:
268+
"""
269+
Specifies settings for a collection that will be created.
270+
"""
271+
268272
def __init__(self,
269273
max_expiry=None, # type: Optional[timedelta]
270274
history=None, # type: Optional[bool]
@@ -275,7 +279,7 @@ def __init__(self,
275279
@property
276280
def max_expiry(self) -> Optional[timedelta]:
277281
"""
278-
Optional[timedelta]: The expiry for documents in the collection.
282+
Optional[timedelta]: The maximum expiry for documents in the collection.
279283
"""
280284
return self._max_expiry
281285

@@ -289,6 +293,10 @@ def history(self) -> Optional[bool]:
289293

290294

291295
class UpdateCollectionSettings:
296+
"""
297+
Specifies settings for a collection that will be updated.
298+
"""
299+
292300
def __init__(self,
293301
max_expiry=None, # type: Optional[timedelta]
294302
history=None, # type: Optional[bool]
@@ -299,7 +307,7 @@ def __init__(self,
299307
@property
300308
def max_expiry(self) -> Optional[timedelta]:
301309
"""
302-
Optional[timedelta]: The expiry for documents in the collection.
310+
Optional[timedelta]: The maximum expiry for documents in the collection.
303311
"""
304312
return self._max_expiry
305313

@@ -339,14 +347,19 @@ def max_expiry(self) -> Optional[timedelta]:
339347
@property
340348
def max_ttl(self) -> Optional[timedelta]:
341349
"""
342-
**DEPRECATED**
343350
Optional[timedelta]: The expiry for documents in the collection.
351+
352+
**DEPRECATED** Use :attr:`max_expiry` instead.
344353
"""
345354
Supportability.class_property_deprecated('max_ttl', 'max_expiry')
346355
return self._max_expiry
347356

348357
@property
349358
def history(self) -> Optional[bool]:
359+
"""
360+
Optional[bool]: Whether history retention is enabled in the collection. None represents the bucket-level
361+
setting.
362+
"""
350363
return self._history
351364

352365
@property

docs/couchbase_api/couchbase_management.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Collection Management
2828

2929
.. autoclass:: CollectionManager
3030

31+
.. automethod:: create_collection
32+
3133
.. py:method:: create_collection(collection: CollectionSpec, *options: CreateCollectionOptions, **kwargs: Dict[str, Any]) -> None
3234
:noindex:
3335

@@ -45,9 +47,12 @@ Collection Management
4547
:raises `~couchbase.exceptions.CollectionAlreadyExistsException`: If the collection already exists.
4648
:raises `~couchbase.exceptions.ScopeNotFoundException`: If the scope does not exist.
4749

48-
.. automethod:: create_collection
4950
.. automethod:: create_scope
5051

52+
.. automethod:: update_collection
53+
54+
.. automethod:: drop_collection
55+
5156
.. py:method:: drop_collection(collection: CollectionSpec, *options: DropCollectionOptions, **kwargs: Dict[str, Any]) -> None
5257
:noindex:
5358

@@ -64,15 +69,26 @@ Collection Management
6469
:type \*\*kwargs: Dict[str, Any]
6570
:raises `~couchbase.exceptions.CollectionNotFoundException`: If the collection does not exist.
6671

67-
.. automethod:: drop_collection
6872
.. automethod:: drop_scope
6973
.. automethod:: get_all_scopes
7074

75+
.. autoclass:: CreateCollectionSettings
76+
77+
.. autoproperty:: max_expiry
78+
.. autoproperty:: history
79+
80+
.. autoclass:: UpdateCollectionSettings
81+
82+
.. autoproperty:: max_expiry
83+
.. autoproperty:: history
84+
7185
.. autoclass:: CollectionSpec
7286

7387
.. autoproperty:: name
7488
.. autoproperty:: scope_name
89+
.. autoproperty:: max_expiry
7590
.. autoproperty:: max_ttl
91+
.. autoproperty:: history
7692

7793
.. autoclass:: ScopeSpec
7894

docs/couchbase_api/management_options.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ CreateScopeOptions
4848
++++++++++++++++++++++++
4949
.. autoclass:: CreateScopeOptions
5050

51+
UpdateCollectionOptions
52+
++++++++++++++++++++++++
53+
.. autoclass:: UpdateCollectionOptions
54+
5155
DropCollectionOptions
5256
++++++++++++++++++++++++
5357
.. autoclass:: DropCollectionOptions

0 commit comments

Comments
 (0)