@@ -793,10 +793,11 @@ def delete(self, items: list) -> None:
793
793
----------
794
794
items : list
795
795
List of objects to delete. The objects can be of one of these types:
796
- ``"Item"``, ``"Session"``, or ``Dataset``.
796
+ ``"Item"``, ``Report``, `` "Session"`` or ``Dataset``.
797
797
798
798
.. note:: Deleting a session or a dataset also deletes all items
799
- associated with the session or dataset.
799
+ associated with the session or dataset. Deleting a Report also
800
+ deletes all its children.
800
801
801
802
Examples
802
803
--------
@@ -807,13 +808,21 @@ def delete(self, items: list) -> None:
807
808
adr_service.connect(url='http://localhost:8020')
808
809
all_items = adr_service.query(type='Item')
809
810
adr_service.delete(all_items)
811
+ my_report = adr_service.get_report(report_name='My Report')
812
+ adr_service.delete([my_report])
810
813
"""
811
814
if type (items ) is not list :
812
815
self .logger .error ("Error: passed argument is not a list" )
813
816
raise TypeError
814
817
items_to_delete = [x .item for x in items if type (x ) is Item ]
818
+ reports_to_delete = [x for x in items if type (x ) is Report ]
819
+ if reports_to_delete :
820
+ self .logger .warning (
821
+ "Warning: Report deletion will result in deletion of " "all its children templates"
822
+ )
823
+ items_to_delete .extend ([x .report for x in reports_to_delete ])
815
824
# Check the input
816
- not_items = [x for x in items if type (x ) is not Item ]
825
+ not_items = [x for x in items if ( type (x ) is not Item ) and ( type ( x ) is not Report ) ]
817
826
if not_items : # pragma: no cover
818
827
session = [x for x in not_items if type (x ) is report_objects .SessionREST ]
819
828
if session :
0 commit comments