from __future__ import unicode_literals import sys import json from thehive4py.api import TheHiveApi from thehive4py.models import Case, CaseTemplate api = TheHiveApi('http://127.0.0.1:9000', 'username', 'password', { 'http': '', 'https': '' }) # Get the template by it's name print('Fetch case template') print('-----------------------------') template = api.get_case_template('Phishing') caseTemplate = CaseTemplate(json=template) print(caseTemplate.jsonify()) print('') print('Create case from template') print('-----------------------------') case = Case(title='From TheHive4Py based on the Phishing template', description='N/A', tlp=2, template=caseTemplate) print(case.jsonify()) print('Create Case') print('-----------------------------')
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function from __future__ import unicode_literals import sys import json from thehive4py.api import TheHiveApi from thehive4py.models import CaseTemplate from thehive4py.exceptions import CaseTemplateException api = TheHiveApi('http://127.0.0.1:9000', '**YOUR_API_KEY**') print('Find existing case template') print('-----------------------------') template = api.get_case_template('Demo') print(json.dumps(template, indent=4)) print('Find unknown case template') print('-----------------------------') try: template = api.get_case_template('Unknown') print(json.dumps(template, indent=4)) except CaseTemplateException as e: print(str(e))