暂无描述

user.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (C) 2023 - DFIR-IRIS
  2. # contact@dfir-iris.org
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 3 of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # Lesser General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public License
  15. # along with this program; if not, write to the Free Software Foundation,
  16. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. from graphql_api import GraphQLApi
  18. from rest_api import RestApi
  19. class User:
  20. def __init__(self, iris_url, api_key, identifier):
  21. self._graphql_api = GraphQLApi(iris_url + '/graphql', api_key)
  22. self._api = RestApi(iris_url, api_key)
  23. self._identifier = identifier
  24. def get_identifier(self):
  25. return self._identifier
  26. def execute_graphql_query(self, payload):
  27. response = self._graphql_api.execute(payload)
  28. body = response.json()
  29. print(f'{payload} => {body}')
  30. return body
  31. def create(self, path, payload):
  32. return self._api.post(path, payload)
  33. def get(self, path):
  34. return self._api.get(path)
  35. def delete(self, path):
  36. return self._api.delete(path)