@@ -2318,23 +2318,59 @@ def get_item_metadata(
23182318 self ,
23192319 project : NotEmptyStr ,
23202320 item_name : NotEmptyStr ,
2321+ include_custom_metadata : bool = False ,
23212322 ):
23222323 """Returns item metadata
23232324
23242325 :param project: project name or folder path (e.g., “project1/folder1”)
23252326 :type project: str
23262327
2327- :param item_name: item name
2328+ :param item_name: item name.
23282329 :type item_name: str
23292330
2331+ :param include_custom_metadata: include custom metadata that has been attached to an asset.
2332+ :type include_custom_metadata: bool
2333+
23302334 :return: metadata of item
23312335 :rtype: dict
2336+
2337+ Request Example:
2338+ ::
2339+ client.get_item_metadata(
2340+ project="Medical Annotations",
2341+ item_name = "image_1.png",
2342+ include_custom_metadata=True
2343+ )
2344+
2345+
2346+ Response Example:
2347+ ::
2348+ {
2349+ "name": "image_1.jpeg",
2350+ "path": "Medical Annotations/Study",
2351+ "url": "https://sa-public-files.s3.../image_1.png",
2352+ "annotation_status": "NotStarted",
2353+ "annotator_email": None,
2354+ "qa_email": None,
2355+ "entropy_value": None,
2356+ "createdAt": "2022-02-15T20:46:44.000Z",
2357+ "updatedAt": "2022-02-15T20:46:44.000Z",
2358+ "custom_metadata": {
2359+ "study_date": "2021-12-31",
2360+ "patient_id": "62078f8a756ddb2ca9fc9660",
2361+ "patient_sex": "female",
2362+ "medical_specialist": "robertboxer@ms.com",
2363+ }
2364+ }
23322365 """
23332366 project_name , folder_name = extract_project_folder (project )
2334- response = self .controller .get_item (project_name , folder_name , item_name )
2367+ response = self .controller .get_item (
2368+ project_name , folder_name , item_name , include_custom_metadata
2369+ )
2370+ exclude = {"custom_metadata" } if not include_custom_metadata else {}
23352371 if response .errors :
23362372 raise AppException (response .errors )
2337- return BaseSerializer (response .data ).serialize ()
2373+ return BaseSerializer (response .data ).serialize (exclude = exclude )
23382374
23392375 def search_items (
23402376 self ,
@@ -2344,6 +2380,7 @@ def search_items(
23442380 annotator_email : Optional [NotEmptyStr ] = None ,
23452381 qa_email : Optional [NotEmptyStr ] = None ,
23462382 recursive : bool = False ,
2383+ include_custom_metadata : bool = False ,
23472384 ):
23482385 """Search items by filtering criteria.
23492386
@@ -2365,8 +2402,6 @@ def search_items(
23652402 ♦ “Completed” \n
23662403 ♦ “Skippe
23672404 :type annotation_status: str
2368- :type annotation_status: str
2369-
23702405
23712406 :param annotator_email: returns those items’ names that are assigned to the specified annotator.
23722407 If None, all items are returned. Strict equal.
@@ -2380,8 +2415,41 @@ def search_items(
23802415 If False search only in the project’s root or given directory.
23812416 :type recursive: bool
23822417
2383- :return: items' metadata
2418+ :param include_custom_metadata: include custom metadata that has been attached to an asset.
2419+ :type include_custom_metadata: bool
2420+
2421+ :return: metadata of item
23842422 :rtype: list of dicts
2423+
2424+ Request Example:
2425+ ::
2426+ client.search_items(
2427+ project="Medical Annotations",
2428+ name_contains="image_1",
2429+ include_custom_metadata=True
2430+ )
2431+
2432+ Response Example:
2433+ ::
2434+ [
2435+ {
2436+ "name": "image_1.jpeg",
2437+ "path": "Medical Annotations/Study",
2438+ "url": "https://sa-public-files.s3.../image_1.png",
2439+ "annotation_status": "NotStarted",
2440+ "annotator_email": None,
2441+ "qa_email": None,
2442+ "entropy_value": None,
2443+ "createdAt": "2022-02-15T20:46:44.000Z",
2444+ "updatedAt": "2022-02-15T20:46:44.000Z",
2445+ "custom_metadata": {
2446+ "study_date": "2021-12-31",
2447+ "patient_id": "62078f8a756ddb2ca9fc9660",
2448+ "patient_sex": "female",
2449+ "medical_specialist": "robertboxer@ms.com",
2450+ }
2451+ }
2452+ ]
23852453 """
23862454 project_name , folder_name = extract_project_folder (project )
23872455 response = self .controller .list_items (
@@ -2392,10 +2460,12 @@ def search_items(
23922460 annotator_email = annotator_email ,
23932461 qa_email = qa_email ,
23942462 recursive = recursive ,
2463+ include_custom_metadata = include_custom_metadata ,
23952464 )
2465+ exclude = {"custom_metadata" } if not include_custom_metadata else {}
23962466 if response .errors :
23972467 raise AppException (response .errors )
2398- return BaseSerializer .serialize_iterable (response .data )
2468+ return BaseSerializer .serialize_iterable (response .data , exclude = exclude )
23992469
24002470 def attach_items (
24012471 self ,
0 commit comments