Skip to content

Commit 6babb63

Browse files
Improve API sort documentation (apache#56617)
(cherry picked from commit deec385)
1 parent 443cc17 commit 6babb63

File tree

9 files changed

+93
-81
lines changed

9 files changed

+93
-81
lines changed

airflow-core/src/airflow/api_fastapi/common/parameters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,15 @@ def depends(cls, *args: Any, **kwargs: Any) -> Self:
283283
raise NotImplementedError("Use dynamic_depends, depends not implemented.")
284284

285285
def dynamic_depends(self, default: str | None = None) -> Callable:
286+
to_replace_attrs = list(self.to_replace.keys()) if self.to_replace else []
287+
288+
all_attrs = self.allowed_attrs + to_replace_attrs
289+
286290
def inner(
287291
order_by: list[str] = Query(
288292
default=[default] if default is not None else [self.get_primary_key_string()],
289293
description=f"Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. "
290-
f"Supported attributes: `{', '.join(self.allowed_attrs) if self.allowed_attrs else self.get_primary_key_string()}`",
294+
f"Supported attributes: `{', '.join(all_attrs) if all_attrs else self.get_primary_key_string()}`",
291295
),
292296
) -> SortParam:
293297
return self.set_value(order_by)

airflow-core/src/airflow/api_fastapi/core_api/openapi/_private_ui.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ paths:
253253
type: string
254254
description: 'Attributes to order by, multi criteria sort is supported.
255255
Prefix with `-` for descending order. Supported attributes: `dag_id, dag_display_name,
256-
next_dagrun, state, start_date`'
256+
next_dagrun, state, start_date, last_run_state, last_run_start_date`'
257257
default:
258258
- dag_id
259259
title: Order By
260260
description: 'Attributes to order by, multi criteria sort is supported. Prefix
261261
with `-` for descending order. Supported attributes: `dag_id, dag_display_name,
262-
next_dagrun, state, start_date`'
262+
next_dagrun, state, start_date, last_run_state, last_run_start_date`'
263263
- name: is_favorite
264264
in: query
265265
required: false

airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,13 +1473,13 @@ paths:
14731473
type: string
14741474
description: 'Attributes to order by, multi criteria sort is supported.
14751475
Prefix with `-` for descending order. Supported attributes: `conn_id,
1476-
conn_type, description, host, port, id`'
1476+
conn_type, description, host, port, id, connection_id`'
14771477
default:
14781478
- id
14791479
title: Order By
14801480
description: 'Attributes to order by, multi criteria sort is supported. Prefix
14811481
with `-` for descending order. Supported attributes: `conn_id, conn_type,
1482-
description, host, port, id`'
1482+
description, host, port, id, connection_id`'
14831483
- name: connection_id_pattern
14841484
in: query
14851485
required: false
@@ -2235,14 +2235,14 @@ paths:
22352235
description: 'Attributes to order by, multi criteria sort is supported.
22362236
Prefix with `-` for descending order. Supported attributes: `id, state,
22372237
dag_id, run_id, logical_date, run_after, start_date, end_date, updated_at,
2238-
conf, duration`'
2238+
conf, duration, dag_run_id`'
22392239
default:
22402240
- id
22412241
title: Order By
22422242
description: 'Attributes to order by, multi criteria sort is supported. Prefix
22432243
with `-` for descending order. Supported attributes: `id, state, dag_id,
22442244
run_id, logical_date, run_after, start_date, end_date, updated_at, conf,
2245-
duration`'
2245+
duration, dag_run_id`'
22462246
- name: run_id_pattern
22472247
in: query
22482248
required: false
@@ -3127,13 +3127,13 @@ paths:
31273127
type: string
31283128
description: 'Attributes to order by, multi criteria sort is supported.
31293129
Prefix with `-` for descending order. Supported attributes: `dag_id, dag_display_name,
3130-
next_dagrun, state, start_date`'
3130+
next_dagrun, state, start_date, last_run_state, last_run_start_date`'
31313131
default:
31323132
- dag_id
31333133
title: Order By
31343134
description: 'Attributes to order by, multi criteria sort is supported. Prefix
31353135
with `-` for descending order. Supported attributes: `dag_id, dag_display_name,
3136-
next_dagrun, state, start_date`'
3136+
next_dagrun, state, start_date, last_run_state, last_run_start_date`'
31373137
- name: is_favorite
31383138
in: query
31393139
required: false
@@ -3706,13 +3706,13 @@ paths:
37063706
type: string
37073707
description: 'Attributes to order by, multi criteria sort is supported.
37083708
Prefix with `-` for descending order. Supported attributes: `id, dttm,
3709-
dag_id, task_id, run_id, event, logical_date, owner, extra`'
3709+
dag_id, task_id, run_id, event, logical_date, owner, extra, when, event_log_id`'
37103710
default:
37113711
- id
37123712
title: Order By
37133713
description: 'Attributes to order by, multi criteria sort is supported. Prefix
37143714
with `-` for descending order. Supported attributes: `id, dttm, dag_id,
3715-
task_id, run_id, event, logical_date, owner, extra`'
3715+
task_id, run_id, event, logical_date, owner, extra, when, event_log_id`'
37163716
- name: dag_id
37173717
in: query
37183718
required: false
@@ -4044,13 +4044,13 @@ paths:
40444044
type: string
40454045
description: 'Attributes to order by, multi criteria sort is supported.
40464046
Prefix with `-` for descending order. Supported attributes: `id, timestamp,
4047-
filename, bundle_name, stacktrace`'
4047+
filename, bundle_name, stacktrace, import_error_id`'
40484048
default:
40494049
- id
40504050
title: Order By
40514051
description: 'Attributes to order by, multi criteria sort is supported. Prefix
40524052
with `-` for descending order. Supported attributes: `id, timestamp, filename,
4053-
bundle_name, stacktrace`'
4053+
bundle_name, stacktrace, import_error_id`'
40544054
- name: filename_pattern
40554055
in: query
40564056
required: false
@@ -4556,12 +4556,13 @@ paths:
45564556
items:
45574557
type: string
45584558
description: 'Attributes to order by, multi criteria sort is supported.
4559-
Prefix with `-` for descending order. Supported attributes: `id, pool`'
4559+
Prefix with `-` for descending order. Supported attributes: `id, pool,
4560+
name`'
45604561
default:
45614562
- id
45624563
title: Order By
45634564
description: 'Attributes to order by, multi criteria sort is supported. Prefix
4564-
with `-` for descending order. Supported attributes: `id, pool`'
4565+
with `-` for descending order. Supported attributes: `id, pool, name`'
45654566
- name: pool_name_pattern
45664567
in: query
45674568
required: false
@@ -5770,14 +5771,16 @@ paths:
57705771
description: 'Attributes to order by, multi criteria sort is supported.
57715772
Prefix with `-` for descending order. Supported attributes: `id, state,
57725773
duration, start_date, end_date, map_index, try_number, logical_date, run_after,
5773-
data_interval_start, data_interval_end, rendered_map_index, operator`'
5774+
data_interval_start, data_interval_end, rendered_map_index, operator,
5775+
run_after, logical_date, data_interval_start, data_interval_end`'
57745776
default:
57755777
- map_index
57765778
title: Order By
57775779
description: 'Attributes to order by, multi criteria sort is supported. Prefix
57785780
with `-` for descending order. Supported attributes: `id, state, duration,
57795781
start_date, end_date, map_index, try_number, logical_date, run_after, data_interval_start,
5780-
data_interval_end, rendered_map_index, operator`'
5782+
data_interval_end, rendered_map_index, operator, run_after, logical_date,
5783+
data_interval_start, data_interval_end`'
57815784
responses:
57825785
'200':
57835786
description: Successful Response
@@ -6586,14 +6589,16 @@ paths:
65866589
description: 'Attributes to order by, multi criteria sort is supported.
65876590
Prefix with `-` for descending order. Supported attributes: `id, state,
65886591
duration, start_date, end_date, map_index, try_number, logical_date, run_after,
6589-
data_interval_start, data_interval_end, rendered_map_index, operator`'
6592+
data_interval_start, data_interval_end, rendered_map_index, operator,
6593+
logical_date, run_after, data_interval_start, data_interval_end`'
65906594
default:
65916595
- map_index
65926596
title: Order By
65936597
description: 'Attributes to order by, multi criteria sort is supported. Prefix
65946598
with `-` for descending order. Supported attributes: `id, state, duration,
65956599
start_date, end_date, map_index, try_number, logical_date, run_after, data_interval_start,
6596-
data_interval_end, rendered_map_index, operator`'
6600+
data_interval_end, rendered_map_index, operator, logical_date, run_after,
6601+
data_interval_start, data_interval_end`'
65976602
responses:
65986603
'200':
65996604
description: Successful Response
@@ -8226,13 +8231,16 @@ paths:
82268231
type: string
82278232
description: 'Attributes to order by, multi criteria sort is supported.
82288233
Prefix with `-` for descending order. Supported attributes: `ti_id, subject,
8229-
responded_at, created_at, responded_by_user_id, responded_by_user_name`'
8234+
responded_at, created_at, responded_by_user_id, responded_by_user_name,
8235+
dag_id, run_id, run_after, rendered_map_index, task_instance_operator,
8236+
task_instance_state`'
82308237
default:
82318238
- ti_id
82328239
title: Order By
82338240
description: 'Attributes to order by, multi criteria sort is supported. Prefix
82348241
with `-` for descending order. Supported attributes: `ti_id, subject, responded_at,
8235-
created_at, responded_by_user_id, responded_by_user_name`'
8242+
created_at, responded_by_user_id, responded_by_user_name, dag_id, run_id,
8243+
run_after, rendered_map_index, task_instance_operator, task_instance_state`'
82368244
- name: dag_id_pattern
82378245
in: query
82388246
required: false

airflow-core/src/airflow/ui/openapi-gen/queries/ensureQueryData.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const ensureUseConnectionServiceGetConnectionData = (queryClient: QueryCl
211211
* @param data The data for the request.
212212
* @param data.limit
213213
* @param data.offset
214-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `conn_id, conn_type, description, host, port, id`
214+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `conn_id, conn_type, description, host, port, id, connection_id`
215215
* @param data.connectionIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
216216
* @returns ConnectionCollectionResponse Successful Response
217217
* @throws ApiError
@@ -286,7 +286,7 @@ export const ensureUseDagRunServiceGetUpstreamAssetEventsData = (queryClient: Qu
286286
* @param data.runType
287287
* @param data.state
288288
* @param data.dagVersion
289-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, state, dag_id, run_id, logical_date, run_after, start_date, end_date, updated_at, conf, duration`
289+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, state, dag_id, run_id, logical_date, run_after, start_date, end_date, updated_at, conf, duration, dag_run_id`
290290
* @param data.runIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
291291
* @param data.triggeringUserNamePattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
292292
* @returns DAGRunCollectionResponse Successful Response
@@ -463,7 +463,7 @@ export const ensureUseDagWarningServiceListDagWarningsData = (queryClient: Query
463463
* @param data.dagRunEndDateLte
464464
* @param data.dagRunEndDateLt
465465
* @param data.dagRunState
466-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, dag_display_name, next_dagrun, state, start_date`
466+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, dag_display_name, next_dagrun, state, start_date, last_run_state, last_run_start_date`
467467
* @param data.isFavorite
468468
* @returns DAGCollectionResponse Successful Response
469469
* @throws ApiError
@@ -554,7 +554,7 @@ export const ensureUseDagServiceGetDagTagsData = (queryClient: QueryClient, { li
554554
* @param data.lastDagRunState
555555
* @param data.bundleName
556556
* @param data.bundleVersion
557-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, dag_display_name, next_dagrun, state, start_date`
557+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, dag_display_name, next_dagrun, state, start_date, last_run_state, last_run_start_date`
558558
* @param data.isFavorite
559559
* @param data.hasAssetSchedule Filter Dags with asset-based scheduling
560560
* @param data.assetDependency Filter Dags by asset dependency (name or URI)
@@ -611,7 +611,7 @@ export const ensureUseEventLogServiceGetEventLogData = (queryClient: QueryClient
611611
* @param data The data for the request.
612612
* @param data.limit
613613
* @param data.offset
614-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dttm, dag_id, task_id, run_id, event, logical_date, owner, extra`
614+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, dttm, dag_id, task_id, run_id, event, logical_date, owner, extra, when, event_log_id`
615615
* @param data.dagId
616616
* @param data.taskId
617617
* @param data.runId
@@ -742,7 +742,7 @@ export const ensureUseTaskInstanceServiceGetTaskInstanceData = (queryClient: Que
742742
* @param data.mapIndex
743743
* @param data.limit
744744
* @param data.offset
745-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, state, duration, start_date, end_date, map_index, try_number, logical_date, run_after, data_interval_start, data_interval_end, rendered_map_index, operator`
745+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, state, duration, start_date, end_date, map_index, try_number, logical_date, run_after, data_interval_start, data_interval_end, rendered_map_index, operator, run_after, logical_date, data_interval_start, data_interval_end`
746746
* @returns TaskInstanceCollectionResponse Successful Response
747747
* @throws ApiError
748748
*/
@@ -915,7 +915,7 @@ export const ensureUseTaskInstanceServiceGetMappedTaskInstanceData = (queryClien
915915
* @param data.mapIndex
916916
* @param data.limit
917917
* @param data.offset
918-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, state, duration, start_date, end_date, map_index, try_number, logical_date, run_after, data_interval_start, data_interval_end, rendered_map_index, operator`
918+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, state, duration, start_date, end_date, map_index, try_number, logical_date, run_after, data_interval_start, data_interval_end, rendered_map_index, operator, logical_date, run_after, data_interval_start, data_interval_end`
919919
* @returns TaskInstanceCollectionResponse Successful Response
920920
* @throws ApiError
921921
*/
@@ -1066,7 +1066,7 @@ export const ensureUseTaskInstanceServiceGetHitlDetailData = (queryClient: Query
10661066
* @param data.dagRunId
10671067
* @param data.limit
10681068
* @param data.offset
1069-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `ti_id, subject, responded_at, created_at, responded_by_user_id, responded_by_user_name`
1069+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `ti_id, subject, responded_at, created_at, responded_by_user_id, responded_by_user_name, dag_id, run_id, run_after, rendered_map_index, task_instance_operator, task_instance_state`
10701070
* @param data.dagIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
10711071
* @param data.taskId
10721072
* @param data.taskIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
@@ -1122,7 +1122,7 @@ export const ensureUseImportErrorServiceGetImportErrorData = (queryClient: Query
11221122
* @param data The data for the request.
11231123
* @param data.limit
11241124
* @param data.offset
1125-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, timestamp, filename, bundle_name, stacktrace`
1125+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, timestamp, filename, bundle_name, stacktrace, import_error_id`
11261126
* @param data.filenamePattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
11271127
* @returns ImportErrorCollectionResponse Successful Response
11281128
* @throws ApiError
@@ -1209,7 +1209,7 @@ export const ensureUsePoolServiceGetPoolData = (queryClient: QueryClient, { pool
12091209
* @param data The data for the request.
12101210
* @param data.limit
12111211
* @param data.offset
1212-
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, pool`
1212+
* @param data.orderBy Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `id, pool, name`
12131213
* @param data.poolNamePattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
12141214
* @returns PoolCollectionResponse Successful Response
12151215
* @throws ApiError

0 commit comments

Comments
 (0)