Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to close a case via API #67

Closed
mthlvt opened this issue Feb 6, 2018 · 2 comments
Closed

How to close a case via API #67

mthlvt opened this issue Feb 6, 2018 · 2 comments
Assignees
Milestone

Comments

@mthlvt
Copy link

mthlvt commented Feb 6, 2018

It may be obvious, but how do I close an existing case via thehive4py (v 1.4.2) please? I tried to update a case with the following fields without success:

api = TheHiveApi(....)

hiveCase = api.case(caseId)

hiveCase.status='Resolved'
hiveCase.resolutionStatus='TruePositive'
hiveCase.impactStatus='NoImpact'
hiveCase.summary='closed by api'
hiveCase.tags=['test']

hiveResponse = api.update_case(hiveCase)

if hiveResponse.status_code == 200:
    logging.warning(json.dumps(hiveResponse.json(), indent=4, sort_keys=True))
else:
    logging.warning('ko: {}/{}'.format(hiveResponse.status_code, hiveResponse.text))

Thanks in advance

@nadouani nadouani self-assigned this Feb 7, 2018
@nadouani nadouani added this to the 1.4.3 milestone Feb 7, 2018
@nadouani
Copy link
Contributor

nadouani commented Feb 7, 2018

Fixed by #57

you can specify the fields you can to update like below:

api.update_case(case, ['status', 'resolutionStatus', 'impactStatus', 'tags', 'summary'])

@nadouani nadouani closed this as completed Feb 7, 2018
@mthlvt
Copy link
Author

mthlvt commented Feb 7, 2018

Edit: that works, thanks a lot for the quick fix 👍

attaching example code

hiveCase = api.case(caseId)
hiveCase.status='Resolved'
hiveCase.resolutionStatus='TruePositive'
hiveCase.impactStatus='NoImpact'
hiveCase.tags=['mytag']
hiveCase.summary='my summary'

hiveResponse = api.update_case(hiveCase,['status', 'resolutionStatus', 'impactStatus', 'tags', 'summary'])

if hiveResponse.status_code == 200:
    logging.info(json.dumps(hiveResponse.json(), indent=4, sort_keys=True))
else:
    logging.warning('ko: {}/{}'.format(hiveResponse.status_code, hiveResponse.text))```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants