def create_actor_identifier_type(username, identifier_type): """ Add a new Actor Identifier Type. :param username: The CRITs user adding the identifier type. :type username: str :param identifier_type: The Identifier Type. :type identifier_type: str :returns: dict with keys: "success" (boolean), "message" (str) if failed. """ identifier = ActorThreatIdentifier.objects(name=identifier_type).first() if identifier: return {'success': False, 'message': 'Identifier Type already exists!'} else: identifier = ActorThreatIdentifier() identifier.name = identifier_type identifier.save(username=username) return {'success': True, 'message': 'Identifier Type added successfully!'}
def create_actor_identifier_type(identifier_type, user): """ Add a new Actor Identifier Type. :param identifier_type: The Identifier Type. :type identifier_type: str :param user: The CRITs user adding the identifier type. :type user: :class:`crits.core.user.CRITsUser` :returns: dict with keys: "success" (boolean), "message" (str) if failed. """ identifier = ActorThreatIdentifier.objects(name=identifier_type).first() if identifier: return {'success': False, 'message': 'Identifier Type already exists!'} else: identifier = ActorThreatIdentifier() identifier.name = identifier_type identifier.save(username=user.username) return {'success': True, 'message': 'Identifier Type added successfully!'}