1- from typing import List , Dict
1+ from typing import List , Dict , Optional
22
33
44class Group :
@@ -187,17 +187,19 @@ def list(self, **kwargs) -> List[Dict]:
187187 return self .opencti .process_multiple (result ["data" ]["groups" ],
188188 withPagination )
189189
190- def read (self , ** kwargs ) -> Dict :
190+ def read (self , ** kwargs ) -> Optional [ Dict ] :
191191 """Fetch a given group from OpenCTI
192192
193+ One of id or filters is required.
194+
193195 :param id: ID of the group to fetch
194196 :type id: str, optional
195197 :param filters: Filters to apply to find single group
196198 :type filters: dict, optional
197199 :param customAttributes: Custom attributes to fetch for the group
198200 :type customAttributes: str
199201 :return: Representation of a group.
200- :rtype: dict
202+ :rtype: Optional[Dict]
201203 """
202204 id = kwargs .get ("id" , None )
203205 filters = kwargs .get ("filters" , None )
@@ -222,14 +224,15 @@ def read(self, **kwargs) -> Dict:
222224 return self .opencti .process_multiple_fields (
223225 result ["data" ]["group" ])
224226 elif filters is not None or search is not None :
225- results = self .list (filters = filters , search = search )
227+ results = self .list (filters = filters , search = search ,
228+ customAttributes = customAttributes )
226229 return results [0 ] if results else None
227230 else :
228231 self .opencti .admin_logger .error (
229232 "[opencti_group] Missing parameters: id or filters" )
230233 return None
231234
232- def create (self , ** kwargs ) -> dict :
235+ def create (self , ** kwargs ) -> Optional [ Dict ] :
233236 """Create a group with required details
234237
235238 Groups can be configured after creation using other functions.
@@ -257,7 +260,7 @@ def create(self, **kwargs) -> dict:
257260 :param customAttributes: Attributes to retrieve from the new group
258261 :type customAttributes: str, optional
259262 :return: Representation of the group.
260- :rtype: dict
263+ :rtype: Optional[Dict]
261264 """
262265 name = kwargs .get ("name" , None )
263266 group_confidence_level = kwargs .get ("group_confidence_level" , None )
@@ -325,7 +328,7 @@ def delete(self, id: str):
325328 """
326329 self .opencti .query (query , {"id" : id })
327330
328- def update_field (self , ** kwargs ) -> Dict :
331+ def update_field (self , ** kwargs ) -> Optional [ Dict ] :
329332 """Update a group using fieldPatch
330333
331334 :param id: ID of the group to update
@@ -335,7 +338,7 @@ def update_field(self, **kwargs) -> Dict:
335338 :param customAttributes: Custom attributes to retrieve from group
336339 :type customAttribues: str, optional
337340 :return: Representation of a group
338- :rtype: dict
341+ :rtype: Optional[Dict]
339342 """
340343 id = kwargs .get ("id" , None )
341344 input = kwargs .get ("input" , None )
@@ -366,15 +369,15 @@ def update_field(self, **kwargs) -> Dict:
366369 return self .opencti .process_multiple_fields (
367370 result ["data" ]["groupEdit" ]["fieldPatch" ])
368371
369- def add_member (self , ** kwargs ) -> dict :
372+ def add_member (self , ** kwargs ) -> Optional [ Dict ] :
370373 """Add a member to a given group.
371374
372375 :param id: ID of the group to add a member to
373376 :type id: str
374377 :param user_id: ID to add to the group
375378 :type user_id: str
376379 :return: Representation of the relationship
377- :rtype: dict
380+ :rtype: Optional[Dict]
378381 """
379382 id = kwargs .get ("id" , None )
380383 user_id = kwargs .get ("user_id" , None )
@@ -412,15 +415,15 @@ def add_member(self, **kwargs) -> dict:
412415 return self .opencti .process_multiple_fields (
413416 result ["data" ]["groupEdit" ]["relationAdd" ])
414417
415- def delete_member (self , ** kwargs ) -> dict :
418+ def delete_member (self , ** kwargs ) -> Optional [ Dict ] :
416419 """Remove a given user from a group
417420
418421 :param id: ID to remove a user from
419422 :type id: str
420423 :param user: ID to remove from the group
421424 :type user: str
422425 :return: Representation of the group after the member has been removed
423- :rtype: dict
426+ :rtype: Optional[Dict]
424427 """
425428 id = kwargs .get ("id" , None )
426429 user_id = kwargs .get ("user_id" , None )
@@ -450,15 +453,15 @@ def delete_member(self, **kwargs) -> dict:
450453 return self .opencti .process_multiple_fields (
451454 result ["data" ]["groupEdit" ]["relationDelete" ])
452455
453- def add_role (self , ** kwargs ) -> Dict :
456+ def add_role (self , ** kwargs ) -> Optional [ Dict ] :
454457 """Add a role to a given group
455458
456459 :param id: ID to add a role to
457460 :type id: str
458461 :param role_id: Role ID to add to the group
459462 :type role: str
460463 :return: Representation of the group after a role has been added
461- :rtype: dict
464+ :rtype: Optional[Dict]
462465 """
463466 id = kwargs .get ("id" , None )
464467 role_id = kwargs .get ("role_id" , None )
@@ -494,15 +497,15 @@ def add_role(self, **kwargs) -> Dict:
494497 return self .opencti .process_multiple_fields (
495498 result ["data" ]["groupEdit" ]["relationAdd" ])
496499
497- def delete_role (self , ** kwargs ) -> Dict :
500+ def delete_role (self , ** kwargs ) -> Optional [ Dict ] :
498501 """Removes a role from a given group
499502
500503 :param id: ID to remove role from
501504 :type id: str
502505 :param role_id: Role ID to remove from the group
503506 :type role_id: str
504507 :return: Representation of the group after role is removed
505- :rtype: dict
508+ :rtype: Optional[Dict]
506509 """
507510 id = kwargs .get ("id" , None )
508511 role_id = kwargs .get ("role_id" , None )
@@ -531,7 +534,7 @@ def delete_role(self, **kwargs) -> Dict:
531534 return self .opencti .process_multiple_fields (
532535 result ["data" ]["groupEdit" ]["relationDelete" ])
533536
534- def edit_default_marking (self , ** kwargs ) -> Dict :
537+ def edit_default_marking (self , ** kwargs ) -> Optional [ Dict ] :
535538 """Adds a default marking to the group.
536539
537540 :param id: ID of the group.
@@ -544,7 +547,7 @@ def edit_default_marking(self, **kwargs) -> Dict:
544547 defaults to "GLOBAL".
545548 :type entity: str, optional
546549 :return: Group after adding the default marking.
547- :rtype: dict
550+ :rtype: Optional[Dict]
548551 """
549552 id = kwargs .get ("id" , None )
550553 marking_ids = kwargs .get ("marking_ids" , None )
@@ -586,15 +589,15 @@ def edit_default_marking(self, **kwargs) -> Dict:
586589 return self .opencti .process_multiple_fields (
587590 result ["data" ]["groupEdit" ]["editDefaultMarking" ])
588591
589- def add_allowed_marking (self , ** kwargs ) -> Dict :
592+ def add_allowed_marking (self , ** kwargs ) -> Optional [ Dict ] :
590593 """Allow a group to access a marking
591594
592595 :param id: ID of group to authorise
593596 :type id: str
594597 :param marking_id: ID of marking to authorise
595598 :type marking_id: str
596599 :return: Relationship from the group to the marking definition
597- :rtype: dict
600+ :rtype: Optional[Dict]
598601 """
599602 id = kwargs .get ("id" , None )
600603 marking_id = kwargs .get ("marking_id" , None )
@@ -653,15 +656,15 @@ def add_allowed_marking(self, **kwargs) -> Dict:
653656 return self .opencti .process_multiple_fields (
654657 result ["data" ]["groupEdit" ]["relationAdd" ])
655658
656- def delete_allowed_marking (self , ** kwargs ) -> Dict :
659+ def delete_allowed_marking (self , ** kwargs ) -> Optional [ Dict ] :
657660 """Removes access to a marking for a group
658661
659662 :param id: ID of group to forbid
660663 :type id: str
661664 :param marking_id: ID of marking to deny
662665 :type marking_id: str
663666 :return: Group after denying access to marking definition
664- :rtype: dict
667+ :rtype: Optional[Dict]
665668 """
666669 id = kwargs .get ("id" , None )
667670 marking_id = kwargs .get ("marking_id" , None )
0 commit comments