response stringlengths 1 33.1k | instruction stringlengths 22 582k |
|---|---|
Set the dag run's state to running.
Set for a specific execution date and its task instances to running. | def set_dag_run_state_to_running(
*,
dag: DAG,
execution_date: datetime | None = None,
run_id: str | None = None,
commit: bool = False,
session: SASession = NEW_SESSION,
) -> list[TaskInstance]:
"""
Set the dag run's state to running.
Set for a specific execution date and its task i... |
Set the dag run's state to queued.
Set for a specific execution date and its task instances to queued. | def set_dag_run_state_to_queued(
*,
dag: DAG,
execution_date: datetime | None = None,
run_id: str | None = None,
commit: bool = False,
session: SASession = NEW_SESSION,
) -> list[TaskInstance]:
"""
Set the dag run's state to queued.
Set for a specific execution date and its task ins... |
Triggers DAG run.
:param dag_id: DAG ID
:param dag_bag: DAG Bag model
:param run_id: ID of the dag_run
:param conf: configuration
:param execution_date: date of execution
:param replace_microseconds: whether microseconds should be zeroed
:return: list of triggered dags | def _trigger_dag(
dag_id: str,
dag_bag: DagBag,
run_id: str | None = None,
conf: dict | str | None = None,
execution_date: datetime | None = None,
replace_microseconds: bool = True,
) -> list[DagRun | None]:
"""Triggers DAG run.
:param dag_id: DAG ID
:param dag_bag: DAG Bag model
... |
Triggers execution of DAG specified by dag_id.
:param dag_id: DAG ID
:param run_id: ID of the dag_run
:param conf: configuration
:param execution_date: date of execution
:param replace_microseconds: whether microseconds should be zeroed
:return: first dag run triggered - even if more than one Dag Runs were triggered o... | def trigger_dag(
dag_id: str,
run_id: str | None = None,
conf: dict | str | None = None,
execution_date: datetime | None = None,
replace_microseconds: bool = True,
) -> DagRun | None:
"""Triggers execution of DAG specified by dag_id.
:param dag_id: DAG ID
:param run_id: ID of the dag_ru... |
Return python code of a given dag_id.
:param dag_id: DAG id
:return: code of the DAG | def get_code(dag_id: str) -> str:
"""Return python code of a given dag_id.
:param dag_id: DAG id
:return: code of the DAG
"""
dag = check_and_get_dag(dag_id=dag_id)
try:
return DagCode.get_code_by_fileloc(dag.fileloc)
except (OSError, DagCodeNotFound) as exception:
error_me... |
Return a list of Dag Runs for a specific DAG ID.
:param dag_id: String identifier of a DAG
:param state: queued|running|success...
:return: List of DAG runs of a DAG with requested state,
or all runs if the state is not specified | def get_dag_runs(dag_id: str, state: str | None = None) -> list[dict[str, Any]]:
"""
Return a list of Dag Runs for a specific DAG ID.
:param dag_id: String identifier of a DAG
:param state: queued|running|success...
:return: List of DAG runs of a DAG with requested state,
or all runs if the... |
Return the Dag Run state identified by the given dag_id and execution_date.
:param dag_id: DAG id
:param execution_date: execution date
:return: Dictionary storing state of the object | def get_dag_run_state(dag_id: str, execution_date: datetime) -> dict[str, str]:
"""Return the Dag Run state identified by the given dag_id and execution_date.
:param dag_id: DAG id
:param execution_date: execution date
:return: Dictionary storing state of the object
"""
dag = check_and_get_dag(... |
Get lineage information for dag specified. | def get_lineage(
dag_id: str, execution_date: datetime.datetime, *, session: Session = NEW_SESSION
) -> dict[str, dict[str, Any]]:
"""Get lineage information for dag specified."""
dag = check_and_get_dag(dag_id)
dagrun = check_and_get_dagrun(dag, execution_date)
inlets = XCom.get_many(dag_ids=dag_i... |
Return the task object identified by the given dag_id and task_id. | def get_task(dag_id: str, task_id: str) -> TaskInstance:
"""Return the task object identified by the given dag_id and task_id."""
dag = check_and_get_dag(dag_id, task_id)
# Return the task.
return dag.get_task(task_id) |
Return the task instance identified by the given dag_id, task_id and execution_date. | def get_task_instance(dag_id: str, task_id: str, execution_date: datetime) -> TaskInstance:
"""Return the task instance identified by the given dag_id, task_id and execution_date."""
dag = check_and_get_dag(dag_id, task_id)
dagrun = check_and_get_dagrun(dag=dag, execution_date=execution_date)
# Get tas... |
Get pool by a given name. | def get_pool(name, session: Session = NEW_SESSION):
"""Get pool by a given name."""
if not (name and name.strip()):
raise AirflowBadRequest("Pool name shouldn't be empty")
pool = session.scalar(select(Pool).filter_by(pool=name).limit(1))
if pool is None:
raise PoolNotFound(f"Pool '{nam... |
Get all pools. | def get_pools(session: Session = NEW_SESSION):
"""Get all pools."""
return session.scalars(select(Pool)).all() |
Create a pool with given parameters. | def create_pool(name, slots, description, session: Session = NEW_SESSION):
"""Create a pool with given parameters."""
if not (name and name.strip()):
raise AirflowBadRequest("Pool name shouldn't be empty")
try:
slots = int(slots)
except ValueError:
raise AirflowBadRequest(f"Bad ... |
Delete pool by a given name. | def delete_pool(name, session: Session = NEW_SESSION):
"""Delete pool by a given name."""
if not (name and name.strip()):
raise AirflowBadRequest("Pool name shouldn't be empty")
if name == Pool.DEFAULT_POOL_NAME:
raise AirflowBadRequest(f"{Pool.DEFAULT_POOL_NAME} cannot be deleted")
p... |
Check DAG existence and in case it is specified that Task exists. | def check_and_get_dag(dag_id: str, task_id: str | None = None) -> DagModel:
"""Check DAG existence and in case it is specified that Task exists."""
dag_model = DagModel.get_current(dag_id)
if dag_model is None:
raise DagNotFound(f"Dag id {dag_id} not found in DagModel")
dagbag = DagBag(dag_fold... |
Get DagRun object and check that it exists. | def check_and_get_dagrun(dag: DagModel, execution_date: datetime) -> DagRun:
"""Get DagRun object and check that it exists."""
dagrun = dag.get_dagrun(execution_date=execution_date)
if not dagrun:
error_message = f"Dag Run for date {execution_date} not found in dag {dag.dag_id}"
raise DagRun... |
Use to capture connexion exceptions and add link to the type field. | def common_error_handler(exception: BaseException) -> flask.Response:
"""Use to capture connexion exceptions and add link to the type field."""
if isinstance(exception, ProblemException):
link = EXCEPTIONS_LINK_MAP.get(exception.status)
if link:
response = problem(
s... |
Validate that a datetime is not naive. | def validate_istimezone(value: datetime) -> None:
"""Validate that a datetime is not naive."""
if not value.tzinfo:
raise BadRequest("Invalid datetime format", detail="Naive datetime is disallowed") |
Format datetime objects.
Datetime format parser for args since connexion doesn't parse datetimes
https://github.com/zalando/connexion/issues/476
This should only be used within connection views because it raises 400 | def format_datetime(value: str) -> datetime:
"""
Format datetime objects.
Datetime format parser for args since connexion doesn't parse datetimes
https://github.com/zalando/connexion/issues/476
This should only be used within connection views because it raises 400
"""
value = value.strip()... |
Check the limit does not exceed configured value.
This checks the limit passed to view and raises BadRequest if
limit exceed user configured value | def check_limit(value: int) -> int:
"""
Check the limit does not exceed configured value.
This checks the limit passed to view and raises BadRequest if
limit exceed user configured value
"""
max_val = conf.getint("api", "maximum_page_limit") # user configured max page limit
fallback = conf... |
Create a decorator to convert parameters using given formatters.
Using it allows you to separate parameter formatting from endpoint logic.
:param params_formatters: Map of key name and formatter function | def format_parameters(params_formatters: dict[str, Callable[[Any], Any]]) -> Callable[[T], T]:
"""
Create a decorator to convert parameters using given formatters.
Using it allows you to separate parameter formatting from endpoint logic.
:param params_formatters: Map of key name and formatter function... |
Apply sorting to query. | def apply_sorting(
query: Select,
order_by: str,
to_replace: dict[str, str] | None = None,
allowed_attrs: Container[str] | None = None,
) -> Select:
"""Apply sorting to query."""
lstriped_orderby = order_by.lstrip("-")
if allowed_attrs and lstriped_orderby not in allowed_attrs:
raise... |
Check that the request has valid authorization information. | def check_authentication() -> None:
"""Check that the request has valid authorization information."""
for auth in get_airflow_app().api_auth:
response = auth.requires_authentication(Response)()
if response.status_code == 200:
return
# Even if the current_user is anonymous, the ... |
Check current user's permissions against required permissions.
Deprecated. Do not use this decorator, use one of the decorator `has_access_*` defined in
airflow/api_connexion/security.py instead.
This decorator will only work with FAB authentication and not with other auth providers.
This decorator might be used in u... | def requires_access(permissions: Sequence[tuple[str, str]] | None = None) -> Callable[[T], T]:
"""
Check current user's permissions against required permissions.
Deprecated. Do not use this decorator, use one of the decorator `has_access_*` defined in
airflow/api_connexion/security.py instead.
This... |
Define the behavior whether the user is authorized to access the resource.
:param is_authorized_callback: callback to execute to figure whether the user is authorized to access
the resource
:param func: the function to call if the user is authorized
:param args: the arguments of ``func``
:param kwargs: the keyword... | def _requires_access(*, is_authorized_callback: Callable[[], bool], func: Callable, args, kwargs) -> bool:
"""
Define the behavior whether the user is authorized to access the resource.
:param is_authorized_callback: callback to execute to figure whether the user is authorized to access
the resourc... |
Convert config dict to a Config object. | def _conf_dict_to_config(conf_dict: dict) -> Config:
"""Convert config dict to a Config object."""
config = Config(
sections=[
ConfigSection(
name=section, options=[ConfigOption(key=key, value=value) for key, value in options.items()]
)
for section, op... |
Convert a single config option to text. | def _option_to_text(config_option: ConfigOption) -> str:
"""Convert a single config option to text."""
return f"{config_option.key} = {config_option.value}" |
Convert a single config section to text. | def _section_to_text(config_section: ConfigSection) -> str:
"""Convert a single config section to text."""
return (
f"[{config_section.name}]{LINE_SEP}"
f"{LINE_SEP.join(_option_to_text(option) for option in config_section.options)}{LINE_SEP}"
) |
Convert the entire config to text. | def _config_to_text(config: Config) -> str:
"""Convert the entire config to text."""
return LINE_SEP.join(_section_to_text(s) for s in config.sections) |
Convert a Config object to a JSON formatted string. | def _config_to_json(config: Config) -> str:
"""Convert a Config object to a JSON formatted string."""
return json.dumps(config_schema.dump(config), indent=4) |
Get current configuration. | def get_config(*, section: str | None = None) -> Response:
"""Get current configuration."""
serializer = {
"text/plain": _config_to_text,
"application/json": _config_to_json,
}
return_type = request.accept_mimetypes.best_match(serializer.keys())
if conf.get("webserver", "expose_confi... |
Delete a connection entry. | def delete_connection(*, connection_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Delete a connection entry."""
connection = session.scalar(select(Connection).filter_by(conn_id=connection_id))
if connection is None:
raise NotFound(
"Connection not found",
detail... |
Get a connection entry. | def get_connection(*, connection_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Get a connection entry."""
connection = session.scalar(select(Connection).where(Connection.conn_id == connection_id))
if connection is None:
raise NotFound(
"Connection not found",
de... |
Get all connection entries. | def get_connections(
*,
limit: int,
offset: int = 0,
order_by: str = "id",
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get all connection entries."""
to_replace = {"connection_id": "conn_id"}
allowed_sort_attrs = ["connection_id", "conn_type", "description", "host", "port", "id"... |
Update a connection entry. | def patch_connection(
*,
connection_id: str,
update_mask: UpdateMask = None,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Update a connection entry."""
try:
data = connection_schema.load(request.json, partial=True)
except ValidationError as err:
# If validation get to... |
Create connection entry. | def post_connection(*, session: Session = NEW_SESSION) -> APIResponse:
"""Create connection entry."""
body = request.json
try:
data = connection_schema.load(body)
except ValidationError as err:
raise BadRequest(detail=str(err.messages))
conn_id = data["conn_id"]
try:
help... |
Test an API connection.
This method first creates an in-memory transient conn_id & exports that to an
env var, as some hook classes tries to find out the conn from their __init__ method & errors out
if not found. It also deletes the conn id env variable after the test. | def test_connection() -> APIResponse:
"""
Test an API connection.
This method first creates an in-memory transient conn_id & exports that to an
env var, as some hook classes tries to find out the conn from their __init__ method & errors out
if not found. It also deletes the conn id env variable aft... |
Get basic information about a DAG. | def get_dag(
*, dag_id: str, fields: Collection[str] | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Get basic information about a DAG."""
dag = session.scalar(select(DagModel).where(DagModel.dag_id == dag_id))
if dag is None:
raise NotFound("DAG not found", detail=f"The DAG w... |
Get details of DAG. | def get_dag_details(
*, dag_id: str, fields: Collection[str] | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Get details of DAG."""
dag: DAG = get_airflow_app().dag_bag.get_dag(dag_id)
if not dag:
raise NotFound("DAG not found", detail=f"The DAG with dag_id: {dag_id} was not f... |
Get all DAGs. | def get_dags(
*,
limit: int,
offset: int = 0,
tags: Collection[str] | None = None,
dag_id_pattern: str | None = None,
only_active: bool = True,
paused: bool | None = None,
order_by: str = "dag_id",
fields: Collection[str] | None = None,
session: Session = NEW_SESSION,
) -> APIRes... |
Update the specific DAG. | def patch_dag(*, dag_id: str, update_mask: UpdateMask = None, session: Session = NEW_SESSION) -> APIResponse:
"""Update the specific DAG."""
try:
patch_body = dag_schema.load(request.json, session=session)
except ValidationError as err:
raise BadRequest(detail=str(err.messages))
if updat... |
Patch multiple DAGs. | def patch_dags(limit, session, offset=0, only_active=True, tags=None, dag_id_pattern=None, update_mask=None):
"""Patch multiple DAGs."""
try:
patch_body = dag_schema.load(request.json, session=session)
except ValidationError as err:
raise BadRequest(detail=str(err.messages))
if update_ma... |
Delete the specific DAG. | def delete_dag(dag_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Delete the specific DAG."""
from airflow.api.common import delete_dag as delete_dag_module
try:
delete_dag_module.delete_dag(dag_id, session=session)
except DagNotFound:
raise NotFound(f"Dag with id: '{dag_id... |
Delete a DAG Run. | def delete_dag_run(*, dag_id: str, dag_run_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Delete a DAG Run."""
deleted_count = session.execute(
delete(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == dag_run_id)
).rowcount
if deleted_count == 0:
raise NotFound(detail=... |
Get a DAG Run. | def get_dag_run(
*, dag_id: str, dag_run_id: str, fields: Collection[str] | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Get a DAG Run."""
dag_run = session.scalar(select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == dag_run_id))
if dag_run is None:
raise NotFound(
... |
If dag run is dataset-triggered, return the dataset events that triggered it. | def get_upstream_dataset_events(
*, dag_id: str, dag_run_id: str, session: Session = NEW_SESSION
) -> APIResponse:
"""If dag run is dataset-triggered, return the dataset events that triggered it."""
dag_run: DagRun | None = session.scalar(
select(DagRun).where(
DagRun.dag_id == dag_id,
... |
Get all DAG Runs. | def get_dag_runs(
*,
dag_id: str,
start_date_gte: str | None = None,
start_date_lte: str | None = None,
execution_date_gte: str | None = None,
execution_date_lte: str | None = None,
end_date_gte: str | None = None,
end_date_lte: str | None = None,
updated_at_gte: str | None = None,
... |
Get list of DAG Runs. | def get_dag_runs_batch(*, session: Session = NEW_SESSION) -> APIResponse:
"""Get list of DAG Runs."""
body = get_json_request_dict()
try:
data = dagruns_batch_form_schema.load(body)
except ValidationError as err:
raise BadRequest(detail=str(err.messages))
readable_dag_ids = get_auth... |
Trigger a DAG. | def post_dag_run(*, dag_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Trigger a DAG."""
dm = session.scalar(select(DagModel).where(DagModel.is_active, DagModel.dag_id == dag_id).limit(1))
if not dm:
raise NotFound(title="DAG not found", detail=f"DAG with dag_id: '{dag_id}' not found")
... |
Set a state of a dag run. | def update_dag_run_state(*, dag_id: str, dag_run_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Set a state of a dag run."""
dag_run: DagRun | None = session.scalar(
select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == dag_run_id)
)
if dag_run is None:
error_messag... |
Clear a dag run. | def clear_dag_run(*, dag_id: str, dag_run_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Clear a dag run."""
dag_run: DagRun | None = session.scalar(
select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == dag_run_id)
)
if dag_run is None:
error_message = f"Dag Run id... |
Set the note for a dag run. | def set_dag_run_note(*, dag_id: str, dag_run_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Set the note for a dag run."""
dag_run: DagRun | None = session.scalar(
select(DagRun).where(DagRun.dag_id == dag_id, DagRun.run_id == dag_run_id)
)
if dag_run is None:
error_message ... |
Get source code using file token. | def get_dag_source(*, file_token: str, session: Session = NEW_SESSION) -> Response:
"""Get source code using file token."""
secret_key = current_app.config["SECRET_KEY"]
auth_s = URLSafeSerializer(secret_key)
try:
path = auth_s.loads(file_token)
dag_ids = session.query(DagModel.dag_id).f... |
Get DAG warnings.
:param dag_id: the dag_id to optionally filter by
:param warning_type: the warning type to optionally filter by | def get_dag_warnings(
*,
limit: int,
dag_id: str | None = None,
warning_type: str | None = None,
offset: int | None = None,
order_by: str = "timestamp",
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get DAG warnings.
:param dag_id: the dag_id to optionally filter by
:para... |
Get a Dataset. | def get_dataset(*, uri: str, session: Session = NEW_SESSION) -> APIResponse:
"""Get a Dataset."""
dataset = session.scalar(
select(DatasetModel)
.where(DatasetModel.uri == uri)
.options(joinedload(DatasetModel.consuming_dags), joinedload(DatasetModel.producing_tasks))
)
if not da... |
Get datasets. | def get_datasets(
*,
limit: int,
offset: int = 0,
uri_pattern: str | None = None,
dag_ids: str | None = None,
order_by: str = "id",
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get datasets."""
allowed_attrs = ["id", "uri", "created_at", "updated_at"]
total_entries = ses... |
Get dataset events. | def get_dataset_events(
*,
limit: int,
offset: int = 0,
order_by: str = "timestamp",
dataset_id: int | None = None,
source_dag_id: str | None = None,
source_task_id: str | None = None,
source_run_id: str | None = None,
source_map_index: int | None = None,
session: Session = NEW_S... |
Get DatasetDagRunQueue where clause. | def _generate_queued_event_where_clause(
*,
dag_id: str | None = None,
dataset_id: int | None = None,
uri: str | None = None,
before: str | None = None,
permitted_dag_ids: set[str] | None = None,
) -> list:
"""Get DatasetDagRunQueue where clause."""
where_clause = []
if dag_id is not... |
Get a queued Dataset event for a DAG. | def get_dag_dataset_queued_event(
*, dag_id: str, uri: str, before: str | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Get a queued Dataset event for a DAG."""
where_clause = _generate_queued_event_where_clause(dag_id=dag_id, uri=uri, before=before)
ddrq = session.scalar(
sel... |
Delete a queued Dataset event for a DAG. | def delete_dag_dataset_queued_event(
*, dag_id: str, uri: str, before: str | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Delete a queued Dataset event for a DAG."""
where_clause = _generate_queued_event_where_clause(dag_id=dag_id, uri=uri, before=before)
delete_stmt = (
dele... |
Get queued Dataset events for a DAG. | def get_dag_dataset_queued_events(
*, dag_id: str, before: str | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Get queued Dataset events for a DAG."""
where_clause = _generate_queued_event_where_clause(dag_id=dag_id, before=before)
query = (
select(DatasetDagRunQueue, DatasetM... |
Delete queued Dataset events for a DAG. | def delete_dag_dataset_queued_events(
*, dag_id: str, before: str | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Delete queued Dataset events for a DAG."""
where_clause = _generate_queued_event_where_clause(dag_id=dag_id, before=before)
delete_stmt = delete(DatasetDagRunQueue).where(... |
Get queued Dataset events for a Dataset. | def get_dataset_queued_events(
*, uri: str, before: str | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Get queued Dataset events for a Dataset."""
permitted_dag_ids = get_auth_manager().get_permitted_dag_ids(methods=["GET"])
where_clause = _generate_queued_event_where_clause(
... |
Delete queued Dataset events for a Dataset. | def delete_dataset_queued_events(
*, uri: str, before: str | None = None, session: Session = NEW_SESSION
) -> APIResponse:
"""Delete queued Dataset events for a Dataset."""
permitted_dag_ids = get_auth_manager().get_permitted_dag_ids(methods=["GET"])
where_clause = _generate_queued_event_where_clause(
... |
Create dataset event. | def create_dataset_event(session: Session = NEW_SESSION) -> APIResponse:
"""Create dataset event."""
body = get_json_request_dict()
try:
json_body = create_dataset_event_schema.load(body)
except ValidationError as err:
raise BadRequest(detail=str(err))
uri = json_body["dataset_uri"]... |
Get a log entry. | def get_event_log(*, event_log_id: int, session: Session = NEW_SESSION) -> APIResponse:
"""Get a log entry."""
event_log = session.get(Log, event_log_id)
if event_log is None:
raise NotFound("Event Log not found")
return event_log_schema.dump(event_log) |
Get all log entries from event log. | def get_event_logs(
*,
dag_id: str | None = None,
task_id: str | None = None,
run_id: str | None = None,
owner: str | None = None,
event: str | None = None,
excluded_events: str | None = None,
included_events: str | None = None,
before: str | None = None,
after: str | None = None... |
Get extra links for task instance. | def get_extra_links(
*,
dag_id: str,
dag_run_id: str,
task_id: str,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get extra links for task instance."""
from airflow.models.taskinstance import TaskInstance
dagbag: DagBag = get_airflow_app().dag_bag
dag: DAG = dagbag.get_dag(da... |
Raise an HTTP error 400 if the auth manager is not FAB.
Intended to decorate endpoints that have been migrated from Airflow API to FAB API. | def _require_fab(func: Callable) -> Callable:
"""
Raise an HTTP error 400 if the auth manager is not FAB.
Intended to decorate endpoints that have been migrated from Airflow API to FAB API.
"""
def inner(*args, **kwargs):
from airflow.providers.fab.auth_manager.fab_auth_manager import FabA... |
Get role. | def get_role(**kwargs) -> APIResponse:
"""Get role."""
return role_and_permission_endpoint.get_role(**kwargs) |
Get roles. | def get_roles(**kwargs) -> APIResponse:
"""Get roles."""
return role_and_permission_endpoint.get_roles(**kwargs) |
Delete a role. | def delete_role(**kwargs) -> APIResponse:
"""Delete a role."""
return role_and_permission_endpoint.delete_role(**kwargs) |
Update a role. | def patch_role(**kwargs) -> APIResponse:
"""Update a role."""
kwargs.pop("body", None)
return role_and_permission_endpoint.patch_role(**kwargs) |
Create a new role. | def post_role(**kwargs) -> APIResponse:
"""Create a new role."""
kwargs.pop("body", None)
return role_and_permission_endpoint.post_role(**kwargs) |
Get permissions. | def get_permissions(**kwargs) -> APIResponse:
"""Get permissions."""
return role_and_permission_endpoint.get_permissions(**kwargs) |
Get a user. | def get_user(**kwargs) -> APIResponse:
"""Get a user."""
return user_endpoint.get_user(**kwargs) |
Get users. | def get_users(**kwargs) -> APIResponse:
"""Get users."""
return user_endpoint.get_users(**kwargs) |
Create a new user. | def post_user(**kwargs) -> APIResponse:
"""Create a new user."""
kwargs.pop("body", None)
return user_endpoint.post_user(**kwargs) |
Update a user. | def patch_user(**kwargs) -> APIResponse:
"""Update a user."""
kwargs.pop("body", None)
return user_endpoint.patch_user(**kwargs) |
Delete a user. | def delete_user(**kwargs) -> APIResponse:
"""Delete a user."""
return user_endpoint.delete_user(**kwargs) |
Return the health of the airflow scheduler, metadatabase and triggerer. | def get_health() -> APIResponse:
"""Return the health of the airflow scheduler, metadatabase and triggerer."""
airflow_health_status = get_airflow_health()
return health_schema.dump(airflow_health_status) |
Get an import error. | def get_import_error(*, import_error_id: int, session: Session = NEW_SESSION) -> APIResponse:
"""Get an import error."""
error = session.get(ParseImportError, import_error_id)
if error is None:
raise NotFound(
"Import error not found",
detail=f"The ImportError with import_err... |
Get all import errors. | def get_import_errors(
*,
limit: int,
offset: int | None = None,
order_by: str = "import_error_id",
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get all import errors."""
to_replace = {"import_error_id": "id"}
allowed_sort_attrs = ["import_error_id", "timestamp", "filename"]
... |
Get logs for specific task instance. | def get_log(
*,
dag_id: str,
dag_run_id: str,
task_id: str,
task_try_number: int,
full_content: bool = False,
map_index: int = -1,
token: str | None = None,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get logs for specific task instance."""
key = get_airflow_app().co... |
Get plugins endpoint. | def get_plugins(*, limit: int, offset: int = 0) -> APIResponse:
"""Get plugins endpoint."""
plugins_info = get_plugin_info()
collection = PluginCollection(plugins=plugins_info[offset:][:limit], total_entries=len(plugins_info))
return plugin_collection_schema.dump(collection) |
Delete a pool. | def delete_pool(*, pool_name: str, session: Session = NEW_SESSION) -> APIResponse:
"""Delete a pool."""
if pool_name == "default_pool":
raise BadRequest(detail="Default Pool can't be deleted")
affected_count = session.execute(delete(Pool).where(Pool.pool == pool_name)).rowcount
if affected_cou... |
Get a pool. | def get_pool(*, pool_name: str, session: Session = NEW_SESSION) -> APIResponse:
"""Get a pool."""
obj = session.scalar(select(Pool).where(Pool.pool == pool_name))
if obj is None:
raise NotFound(detail=f"Pool with name:'{pool_name}' not found")
return pool_schema.dump(obj) |
Get all pools. | def get_pools(
*,
limit: int,
order_by: str = "id",
offset: int | None = None,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get all pools."""
to_replace = {"name": "pool"}
allowed_sort_attrs = ["name", "slots", "id"]
total_entries = session.scalars(func.count(Pool.id)).one()
... |
Update a pool. | def patch_pool(
*,
pool_name: str,
update_mask: UpdateMask = None,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Update a pool."""
request_dict = get_json_request_dict()
# Only slots and include_deferred can be modified in 'default_pool'
if pool_name == Pool.DEFAULT_POOL_NAME and ... |
Create a pool. | def post_pool(*, session: Session = NEW_SESSION) -> APIResponse:
"""Create a pool."""
required_fields = {"name", "slots"} # Pool would require both fields in the post request
fields_diff = required_fields.difference(get_json_request_dict())
if fields_diff:
raise BadRequest(detail=f"Missing requ... |
Get providers. | def get_providers() -> APIResponse:
"""Get providers."""
providers = [_provider_mapper(d) for d in ProvidersManager().providers.values()]
total_entries = len(providers)
return provider_collection_schema.dump(
ProviderCollection(providers=providers, total_entries=total_entries)
) |
Cast request dictionary to JSON. | def get_json_request_dict() -> Mapping[str, Any]:
"""Cast request dictionary to JSON."""
from flask import request
return cast(Mapping[str, Any], request.get_json()) |
Get simplified representation of a task. | def get_task(*, dag_id: str, task_id: str) -> APIResponse:
"""Get simplified representation of a task."""
dag: DAG = get_airflow_app().dag_bag.get_dag(dag_id)
if not dag:
raise NotFound("DAG not found")
try:
task = dag.get_task(task_id=task_id)
except TaskNotFound:
raise Not... |
Get tasks for DAG. | def get_tasks(*, dag_id: str, order_by: str = "task_id") -> APIResponse:
"""Get tasks for DAG."""
dag: DAG = get_airflow_app().dag_bag.get_dag(dag_id)
if not dag:
raise NotFound("DAG not found")
tasks = dag.tasks
try:
tasks = sorted(tasks, key=attrgetter(order_by.lstrip("-")), rever... |
Get task instance. | def get_task_instance(
*,
dag_id: str,
dag_run_id: str,
task_id: str,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get task instance."""
query = (
select(TI)
.where(TI.dag_id == dag_id, TI.run_id == dag_run_id, TI.task_id == task_id)
.join(TI.dag_run)
... |
Get task instance. | def get_mapped_task_instance(
*,
dag_id: str,
dag_run_id: str,
task_id: str,
map_index: int,
session: Session = NEW_SESSION,
) -> APIResponse:
"""Get task instance."""
query = (
select(TI)
.where(TI.dag_id == dag_id, TI.run_id == dag_run_id, TI.task_id == task_id, TI.map_... |
Get list of task instances. | def get_mapped_task_instances(
*,
dag_id: str,
dag_run_id: str,
task_id: str,
execution_date_gte: str | None = None,
execution_date_lte: str | None = None,
start_date_gte: str | None = None,
start_date_lte: str | None = None,
end_date_gte: str | None = None,
end_date_lte: str | N... |
Get list of task instances. | def get_task_instances(
*,
limit: int,
dag_id: str | None = None,
dag_run_id: str | None = None,
execution_date_gte: str | None = None,
execution_date_lte: str | None = None,
start_date_gte: str | None = None,
start_date_lte: str | None = None,
end_date_gte: str | None = None,
en... |
Get list of task instances. | def get_task_instances_batch(session: Session = NEW_SESSION) -> APIResponse:
"""Get list of task instances."""
body = get_json_request_dict()
try:
data = task_instance_batch_form.load(body)
except ValidationError as err:
raise BadRequest(detail=str(err.messages))
dag_ids = data["dag_... |
Clear task instances. | def post_clear_task_instances(*, dag_id: str, session: Session = NEW_SESSION) -> APIResponse:
"""Clear task instances."""
body = get_json_request_dict()
try:
data = clear_task_instance_form.load(body)
except ValidationError as err:
raise BadRequest(detail=str(err.messages))
dag = ge... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.