api_client.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. """Client for all the API clients."""
  19. from __future__ import annotations
  20. import httpx
  21. class Client:
  22. """Base API client for all API clients."""
  23. def __init__(self, api_base_url, auth=None, session: httpx.Client | None = None):
  24. self._api_base_url = api_base_url
  25. self._session: httpx.Client = session or httpx.Client()
  26. if auth:
  27. self._session.auth = auth
  28. def trigger_dag(self, dag_id, run_id=None, conf=None, execution_date=None, replace_microseconds=True):
  29. """
  30. Create a dag run for the specified dag.
  31. :param dag_id:
  32. :param run_id:
  33. :param conf:
  34. :param execution_date:
  35. :param replace_microseconds:
  36. :return:
  37. """
  38. raise NotImplementedError()
  39. def delete_dag(self, dag_id):
  40. """
  41. Delete all DB records related to the specified dag.
  42. :param dag_id:
  43. """
  44. raise NotImplementedError()
  45. def get_pool(self, name):
  46. """
  47. Get pool.
  48. :param name: pool name
  49. """
  50. raise NotImplementedError()
  51. def get_pools(self):
  52. """Get all pools."""
  53. raise NotImplementedError()
  54. def create_pool(self, name, slots, description, include_deferred):
  55. """
  56. Create a pool.
  57. :param name: pool name
  58. :param slots: pool slots amount
  59. :param description: pool description
  60. :param include_deferred: include deferred tasks in pool calculations
  61. """
  62. raise NotImplementedError()
  63. def delete_pool(self, name):
  64. """
  65. Delete pool.
  66. :param name: pool name
  67. """
  68. raise NotImplementedError()
  69. def get_lineage(self, dag_id: str, execution_date: str):
  70. """
  71. Return the lineage information for the dag on this execution date.
  72. :param dag_id:
  73. :param execution_date:
  74. :return:
  75. """
  76. raise NotImplementedError()