@@ -118,6 +118,20 @@ class Attachment(TypedDict, total=False):
118118
119119
120120class ItemContext :
121+ """
122+ A context manager for handling annotations and metadata of an item.
123+
124+ The ItemContext class provides methods to retrieve and manage metadata and component
125+ values for items in the specified context. Below are the descriptions and usage examples for each method.
126+
127+ Example:
128+ ::
129+
130+ with sa_client.item_context("project_name/folder_name", "item_name") as context:
131+ metadata = context.get_metadata()
132+ print(metadata)
133+ """
134+
121135 def __init__ (
122136 self ,
123137 controller : Controller ,
@@ -171,9 +185,26 @@ def annotation(self):
171185 return self .annotation_adapter .annotation
172186
173187 def __enter__ (self ):
188+ """
189+ Enters the context manager.
190+
191+ Returns:
192+ ItemContext: The instance itself.
193+ """
174194 return self
175195
176196 def __exit__ (self , exc_type , exc_val , exc_tb ):
197+ """
198+ Exits the context manager, saving changes if no exception occurred.
199+
200+ Args:
201+ exc_type (Optional[Type[BaseException]]): Exception type if raised.
202+ exc_val (Optional[BaseException]): Exception instance if raised.
203+ exc_tb (Optional[TracebackType]): Traceback if an exception occurred.
204+
205+ Returns:
206+ bool: True if no exception occurred, False otherwise.
207+ """
177208 if exc_type :
178209 return False
179210
@@ -188,12 +219,62 @@ def save(self):
188219 self ._annotation_adapter .save ()
189220
190221 def get_metadata (self ):
222+ """
223+ Retrieves the metadata associated with the current item context.
224+
225+ :return: A dictionary containing metadata for the current item.
226+ :rtype: dict
227+
228+ Request Example:
229+ ::
230+
231+ with client.item_context(("project_name", "folder_name"), 12345) as context:
232+ metadata = context.get_metadata()
233+ print(metadata)
234+ """
191235 return self .annotation ["metadata" ]
192236
193237 def get_component_value (self , component_id : str ):
238+ """
239+ Retrieves the value of a specific component within the item context.
240+
241+ :param component_id: The name of the component whose value is to be retrieved.
242+ :type component_id: str
243+
244+ :return: The value of the specified component.
245+ :rtype: Any
246+
247+ Request Example:
248+ ::
249+
250+ with client.item_context((101, 202), "item_name") as context: # (101, 202) project and folder IDs
251+ value = context.get_component_value("component_id")
252+ print(value)
253+ """
194254 return self .annotation_adapter .get_component_value (component_id )
195255
196256 def set_component_value (self , component_id : str , value : Any ):
257+ """
258+ Updates the value of a specific component within the item context.
259+
260+ :param component_id: The component identifier.
261+ :type component_id: str
262+
263+ :param value: The new value to set for the specified component.
264+ :type value: Any
265+
266+ :return: The instance itself to allow method chaining.
267+ :rtype: ItemContext
268+
269+ Request Example:
270+ ::
271+
272+ with client.item_context("project_name/folder_name", "item_name") as item_context:
273+ metadata = item_context.get_metadata()
274+ value = item_context.get_component_value("component_id")
275+ item_context.set_component_value("component_id", value)
276+
277+ """
197278 self .annotation_adapter .set_component_value (component_id , value )
198279 return self
199280
@@ -381,6 +462,7 @@ def list_users(
381462 ):
382463 """
383464 Search users by filtering criteria
465+
384466 :param project: Project name or ID, if provided, results will be for project-level,
385467 otherwise results will be for team level.
386468 :type project: str or int
@@ -4357,6 +4439,10 @@ def item_context(
43574439 :return: An `ItemContext` object to manage the specified item's annotations and metadata.
43584440 :rtype: ItemContext
43594441
4442+ .. seealso::
4443+ For more details, see :class:`ItemContext`.
4444+
4445+
43604446 **Examples:**
43614447
43624448 Create an `ItemContext` using a string path and item name:
0 commit comments