airflow.sensors.http_sensor
¶
Module Contents¶
-
class
airflow.sensors.http_sensor.
HttpSensor
(endpoint, http_conn_id='http_default', method='GET', request_params=None, headers=None, response_check=None, provide_context=False, extra_options=None, *args, **kwargs)[source]¶ Bases:
airflow.sensors.base_sensor_operator.BaseSensorOperator
Executes a HTTP GET statement and returns False on failure caused by 404 Not Found or response_check returning False.
HTTP Error codes other than 404 (like 403) or Connection Refused Error would fail the sensor itself directly (no more poking).
The response check can access the template context by passing
provide_context=True
to the operator:def response_check(response, **context): # Can look at context['ti'] etc. return True HttpSensor(task_id='my_http_sensor', ..., provide_context=True, response_check=response_check)
- Parameters
http_conn_id (str) – The connection to run the sensor against
method (str) – The HTTP request method to use
endpoint (str) – The relative part of the full url
request_params (a dictionary of string key/value pairs) – The parameters to be added to the GET url
headers (a dictionary of string key/value pairs) – The HTTP headers to be added to the GET request
provide_context (bool) – if set to true, Airflow will pass a set of keyword arguments that can be used in your function. This set of kwargs correspond exactly to what you can use in your jinja templates. For this to work, you need to define context in your function header.
response_check (A lambda or defined function.) – A check against the ‘requests’ response object. Returns True for ‘pass’ and False otherwise.
extra_options (A dictionary of options, where key is string and value depends on the option that's being modified.) – Extra options for the ‘requests’ library, see the ‘requests’ documentation (options to modify timeout, ssl, etc.)