astronomer.providers.http.hooks.http¶
Module Contents¶
Classes¶
Interact with HTTP servers using Python Async. |
- class astronomer.providers.http.hooks.http.HttpHookAsync(method='POST', http_conn_id=default_conn_name, auth_type=aiohttp.BasicAuth, retry_limit=3, retry_delay=1.0, *, keep_response=False)[source]¶
Bases:
airflow.hooks.base.BaseHookInteract with HTTP servers using Python Async.
- Parameters:
method (str) – the API method to be called
http_conn_id (str) – http connection id that has the base API url i.e https://www.google.com/ and optional authentication credentials. Default headers can also be specified in the Extra field in json format.
auth_type (AuthBase of python aiohttp lib) – The auth type for the service
keep_response (bool) – Keep the aiohttp response returned by run method without releasing it. Use it with caution. Without properly releasing response, it might cause “Unclosed connection” error. See https://github.com/astronomer/astronomer-providers/issues/909
- conn_name_attr = 'http_conn_id'¶
- default_conn_name = 'http_default'¶
- conn_type = 'http'¶
- hook_name = 'HTTP'¶
- async run(endpoint=None, data=None, headers=None, extra_options=None)[source]¶
Performs an asynchronous HTTP request call
- Parameters:
endpoint (str | None) – the endpoint to be called i.e. resource/v1/query?
data (dict[str, Any] | str | None) – payload to be uploaded or request parameters
headers (dict[str, Any] | None) – additional headers to be passed through as a dictionary
extra_options (dict[str, Any] | None) – Additional kwargs to pass when creating a request. For example,
run(json=obj)is passed asaiohttp.ClientSession().get(json=obj)