<commit_before><commit_msg>Added a sample file for creating and retrieving a case with the new CaseHelper class.<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
from __future__ import unicode_literals

import json
import time

from thehive4py.api import TheHiveApi
from thehive4py.models import CaseTask

thehive = TheHiveApi('http://127.0.0.1:9000', 'username', 'password', {'http': '', 'https': ''})


# Prepare the sample case
tasks = [
    CaseTask(title='Tracking'),
    CaseTask(title='Communication'),
    CaseTask(title='Investigation', status='Waiting', flag=True)
]
# tasks = []

# Create the case
print('Create Case')
print('-----------------------------')
case = thehive.case.create(title='From TheHive4Py', description='N/A', tlp=3, flag=True,
                           tags=['TheHive4Py', 'sample'], tasks=tasks)

# Print the details of the created case
print(case.jsonify())

# Add a new task to the created case
print('Add a task {}'.format(case.id))
print('-----------------------------')
response = thehive.create_case_task(case.id, CaseTask(
    title='Yet Another Task',
    status='InProgress',
    owner='nabil',
    flag=True,
    startDate=int(time.time())*1000))
if response.status_code == 201:
    print(json.dumps(response.json(), indent=4, sort_keys=True))
    print('')
else:
    print('ko: {}/{}'.format(response.status_code, response.text))
{'fraction_non_alphanumeric': 0.18846694796061886, 'fraction_numerical': 0.016877637130801686, 'mean_word_length': 3.727574750830565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4998801', 'n_tokens_mistral': 460, 'n_tokens_neox': 442, 'n_words': 112}