base.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. class BaseFlowAPI:
  17. def __init__(self, client=None):
  18. self._client = client
  19. def _get(self, url, handle_result=True, **kwargs):
  20. if handle_result:
  21. return self._handle_result(self._client.get(url, **kwargs))
  22. else:
  23. return self._client.get(url, **kwargs)
  24. def _post(self, url, handle_result=True, **kwargs):
  25. if handle_result:
  26. return self._handle_result(self._client.post(url, **kwargs))
  27. else:
  28. return self._client.post(url, **kwargs)
  29. def _handle_result(self, response):
  30. return self._client._handle_result(response)
  31. @property
  32. def session(self):
  33. return self._client.session
  34. @property
  35. def ip(self):
  36. return self._client.ip
  37. @property
  38. def port(self):
  39. return self._client.port
  40. @property
  41. def version(self):
  42. return self._client.version