@@ -65,25 +65,23 @@ def create(self, name: str, color: Optional[int] = None, description: Optional[s
6565 response .raise_for_status ()
6666 return response .json ()
6767
68- def delete (self , tag_id : str ):
68+ def delete (self , tag_id : str ) -> dict :
6969 """
7070 Delete a tag by tag ID (tid).
7171
7272 Args:
7373 tag_id (str): Tag ID (tid) to delete (e.g., /tags/5).
7474
7575 Returns:
76- bool: True if deletion was successful, False otherwise .
76+ dict: The response from the Darktrace API .
7777 """
7878 endpoint = f'/tags/{ tag_id } '
7979 url = f"{ self .client .host } { endpoint } "
8080 headers , _ = self ._get_headers (endpoint )
8181 self .client ._debug (f"DELETE { url } " )
8282 response = requests .delete (url , headers = headers , verify = False )
83- if response .status_code == 200 :
84- return True
8583 response .raise_for_status ()
86- return False
84+ return response . json ()
8785
8886
8987 #TAGS/ENTITIES ENDPOINT
@@ -141,7 +139,7 @@ def post_entities(self, did: int, tag: str, duration: Optional[int] = None):
141139 response .raise_for_status ()
142140 return response .json ()
143141
144- def delete_entities (self , did : int , tag : str ):
142+ def delete_entities (self , did : int , tag : str ) -> dict :
145143 """
146144 Remove a tag from a device via /tags/entities (DELETE).
147145
@@ -150,18 +148,16 @@ def delete_entities(self, did: int, tag: str):
150148 tag (str): Name of the tag to remove.
151149
152150 Returns:
153- bool: True if deletion was successful, False otherwise .
151+ dict: The response from the Darktrace API .
154152 """
155153 endpoint = '/tags/entities'
156154 url = f"{ self .client .host } { endpoint } "
157155 params = {'did' : did , 'tag' : tag }
158156 headers , sorted_params = self ._get_headers (endpoint , params )
159157 self .client ._debug (f"DELETE { url } params={ sorted_params } " )
160158 response = requests .delete (url , headers = headers , params = sorted_params , verify = False )
161- if response .status_code == 200 :
162- return True
163159 response .raise_for_status ()
164- return False
160+ return response . json ()
165161
166162 # /tags/[tid]/entities ENDPOINT
167163 def get_tag_entities (self , tid : int , responsedata : Optional [str ] = None , fulldevicedetails : Optional [bool ] = None ):
@@ -213,7 +209,7 @@ def post_tag_entities(self, tid: int, entityType: str, entityValue, expiryDurati
213209 response .raise_for_status ()
214210 return response .json ()
215211
216- def delete_tag_entity (self , tid : int , teid : int ):
212+ def delete_tag_entity (self , tid : int , teid : int ) -> dict :
217213 """
218214 Remove a tag from an entity via /tags/[tid]/entities/[teid] (DELETE).
219215
@@ -222,14 +218,12 @@ def delete_tag_entity(self, tid: int, teid: int):
222218 teid (int): Tag entity ID (teid) representing the tag-to-entity relationship.
223219
224220 Returns:
225- bool: True if deletion was successful, False otherwise .
221+ dict: The response from the Darktrace API .
226222 """
227223 endpoint = f"/tags/{ tid } /entities/{ teid } "
228224 url = f"{ self .client .host } { endpoint } "
229225 headers , _ = self ._get_headers (endpoint )
230226 self .client ._debug (f"DELETE { url } " )
231227 response = requests .delete (url , headers = headers , verify = False )
232- if response .status_code == 200 :
233- return True
234228 response .raise_for_status ()
235- return False
229+ return response . json ()
0 commit comments