From b871ea2bf0fc56c96243ff4ce11c9e5217dc65da Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Mon, 17 Jun 2019 10:36:49 +0900 Subject: [PATCH] new: [example] Added edit_organisation examples. --- examples/edit_organisation.py | 26 ++++++++++++++++++++++++++ examples/edit_organisation_json.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 examples/edit_organisation.py create mode 100755 examples/edit_organisation_json.py diff --git a/examples/edit_organisation.py b/examples/edit_organisation.py new file mode 100755 index 0000000..9037988 --- /dev/null +++ b/examples/edit_organisation.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from pymisp import PyMISP +from keys import misp_url, misp_key, misp_verifycert +import argparse + +# For python2 & 3 compat, a bit dirty, but it seems to be the least bad one +try: + input = raw_input +except NameError: + pass + + +def init(url, key): + return PyMISP(url, key, misp_verifycert, 'json') + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Edit the email of the organisation designed by the organisation_id.') + parser.add_argument("-i", "--organisation_id", required=True, help="The name of the json file describing the organisation you want to modify.") + parser.add_argument("-e", "--email", help="Email linked to the organisation.") + args = parser.parse_args() + + misp = init(misp_url, misp_key) + + print(misp.edit_organisation(args.organisation_id, email=args.email)) diff --git a/examples/edit_organisation_json.py b/examples/edit_organisation_json.py new file mode 100755 index 0000000..50aa3f5 --- /dev/null +++ b/examples/edit_organisation_json.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from pymisp import PyMISP +from keys import misp_url, misp_key, misp_verifycert +import argparse + +# For python2 & 3 compat, a bit dirty, but it seems to be the least bad one +try: + input = raw_input +except NameError: + pass + + +def init(url, key): + return PyMISP(url, key, misp_verifycert, 'json') + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Edit the organisation designed by the organisation_id. If no file is provided, returns a json listing all the fields used to describe an organisation.') + parser.add_argument("-i", "--organisation_id", required=True, help="The name of the json file describing the organisation you want to modify.") + parser.add_argument("-f", "--json_file", help="The name of the json file describing your modifications.") + args = parser.parse_args() + + misp = init(misp_url, misp_key) + + if args.json_file is None: + print (misp.get_edit_organisation_fields_list(args.organisation_id)) + else: + print(misp.edit_organisation_json(args.json_file, args.organisation_id))