Coverage for /usr/local/lib/python3.12/site-packages/prefect/client/schemas/filters.py: 100%

275 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 11:21 +0000

1""" 

2Schemas that define Prefect REST API filtering operations. 

3""" 

4 

5from typing import List, Optional 1a

6from uuid import UUID 1a

7 

8from pydantic import Field 1a

9 

10from prefect._internal.schemas.bases import PrefectBaseModel 1a

11from prefect.client.schemas.objects import StateType 1a

12from prefect.types import DateTime 1a

13from prefect.utilities.collections import AutoEnum 1a

14 

15 

16class Operator(AutoEnum): 1a

17 """Operators for combining filter criteria.""" 

18 

19 and_ = AutoEnum.auto() 1a

20 or_ = AutoEnum.auto() 1a

21 

22 

23class OperatorMixin: 1a

24 """Base model for Prefect filters that combines criteria with a user-provided operator""" 

25 

26 operator: Operator = Field( 1a

27 default=Operator.and_, 

28 description="Operator for combining filter criteria. Defaults to 'and_'.", 

29 ) 

30 

31 

32class FlowFilterId(PrefectBaseModel): 1a

33 """Filter by `Flow.id`.""" 

34 

35 any_: Optional[List[UUID]] = Field( 1a

36 default=None, description="A list of flow ids to include" 

37 ) 

38 

39 

40class FlowFilterName(PrefectBaseModel): 1a

41 """Filter by `Flow.name`.""" 

42 

43 any_: Optional[List[str]] = Field( 1a

44 default=None, 

45 description="A list of flow names to include", 

46 examples=[["my-flow-1", "my-flow-2"]], 

47 ) 

48 

49 like_: Optional[str] = Field( 1a

50 default=None, 

51 description=( 

52 "A case-insensitive partial match. For example, " 

53 " passing 'marvin' will match " 

54 "'marvin', 'sad-Marvin', and 'marvin-robot'." 

55 ), 

56 examples=["marvin"], 

57 ) 

58 

59 

60class FlowFilterTags(PrefectBaseModel, OperatorMixin): 1a

61 """Filter by `Flow.tags`.""" 

62 

63 all_: Optional[List[str]] = Field( 1a

64 default=None, 

65 examples=[["tag-1", "tag-2"]], 

66 description=( 

67 "A list of tags. Flows will be returned only if their tags are a superset" 

68 " of the list" 

69 ), 

70 ) 

71 is_null_: Optional[bool] = Field( 1a

72 default=None, description="If true, only include flows without tags" 

73 ) 

74 

75 

76class FlowFilter(PrefectBaseModel, OperatorMixin): 1a

77 """Filter for flows. Only flows matching all criteria will be returned.""" 

78 

79 id: Optional[FlowFilterId] = Field( 1a

80 default=None, description="Filter criteria for `Flow.id`" 

81 ) 

82 name: Optional[FlowFilterName] = Field( 1a

83 default=None, description="Filter criteria for `Flow.name`" 

84 ) 

85 tags: Optional[FlowFilterTags] = Field( 1a

86 default=None, description="Filter criteria for `Flow.tags`" 

87 ) 

88 

89 

90class FlowRunFilterId(PrefectBaseModel): 1a

91 """Filter by FlowRun.id.""" 

92 

93 any_: Optional[List[UUID]] = Field( 1a

94 default=None, description="A list of flow run ids to include" 

95 ) 

96 not_any_: Optional[List[UUID]] = Field( 1a

97 default=None, description="A list of flow run ids to exclude" 

98 ) 

99 

100 

101class FlowRunFilterName(PrefectBaseModel): 1a

102 """Filter by `FlowRun.name`.""" 

103 

104 any_: Optional[List[str]] = Field( 1a

105 default=None, 

106 description="A list of flow run names to include", 

107 examples=[["my-flow-run-1", "my-flow-run-2"]], 

108 ) 

109 

110 like_: Optional[str] = Field( 1a

111 default=None, 

112 description=( 

113 "A case-insensitive partial match. For example, " 

114 " passing 'marvin' will match " 

115 "'marvin', 'sad-Marvin', and 'marvin-robot'." 

116 ), 

117 examples=["marvin"], 

118 ) 

119 

120 

121class FlowRunFilterTags(PrefectBaseModel, OperatorMixin): 1a

122 """Filter by `FlowRun.tags`.""" 

123 

124 all_: Optional[List[str]] = Field( 1a

125 default=None, 

126 examples=[["tag-1", "tag-2"]], 

127 description=( 

128 "A list of tags. Flow runs will be returned only if their tags are a" 

129 " superset of the list" 

130 ), 

131 ) 

132 any_: Optional[List[str]] = Field( 1a

133 default=None, 

134 examples=[["tag-1", "tag-2"]], 

135 description="A list of tags to include", 

136 ) 

137 is_null_: Optional[bool] = Field( 1a

138 default=None, description="If true, only include flow runs without tags" 

139 ) 

140 

141 

142class FlowRunFilterDeploymentId(PrefectBaseModel, OperatorMixin): 1a

143 """Filter by `FlowRun.deployment_id`.""" 

144 

145 any_: Optional[List[UUID]] = Field( 1a

146 default=None, description="A list of flow run deployment ids to include" 

147 ) 

148 is_null_: Optional[bool] = Field( 1a

149 default=None, 

150 description="If true, only include flow runs without deployment ids", 

151 ) 

152 

153 

154class FlowRunFilterWorkQueueName(PrefectBaseModel, OperatorMixin): 1a

155 """Filter by `FlowRun.work_queue_name`.""" 

156 

157 any_: Optional[List[str]] = Field( 1a

158 default=None, 

159 description="A list of work queue names to include", 

160 examples=[["work_queue_1", "work_queue_2"]], 

161 ) 

162 is_null_: Optional[bool] = Field( 1a

163 default=None, 

164 description="If true, only include flow runs without work queue names", 

165 ) 

166 

167 

168class FlowRunFilterStateType(PrefectBaseModel): 1a

169 """Filter by `FlowRun.state_type`.""" 

170 

171 any_: Optional[List[StateType]] = Field( 1a

172 default=None, description="A list of flow run state types to include" 

173 ) 

174 not_any_: Optional[List[StateType]] = Field( 1a

175 default=None, description="A list of flow run state types to exclude" 

176 ) 

177 

178 

179class FlowRunFilterStateName(PrefectBaseModel): 1a

180 any_: Optional[List[str]] = Field( 1a

181 default=None, description="A list of flow run state names to include" 

182 ) 

183 not_any_: Optional[List[str]] = Field( 1a

184 default=None, description="A list of flow run state names to exclude" 

185 ) 

186 

187 

188class FlowRunFilterState(PrefectBaseModel, OperatorMixin): 1a

189 type: Optional[FlowRunFilterStateType] = Field( 1a

190 default=None, description="Filter criteria for `FlowRun` state type" 

191 ) 

192 name: Optional[FlowRunFilterStateName] = Field( 1a

193 default=None, description="Filter criteria for `FlowRun` state name" 

194 ) 

195 

196 

197class FlowRunFilterFlowVersion(PrefectBaseModel): 1a

198 """Filter by `FlowRun.flow_version`.""" 

199 

200 any_: Optional[List[str]] = Field( 1a

201 default=None, description="A list of flow run flow_versions to include" 

202 ) 

203 

204 

205class FlowRunFilterStartTime(PrefectBaseModel): 1a

206 """Filter by `FlowRun.start_time`.""" 

207 

208 before_: Optional[DateTime] = Field( 1a

209 default=None, 

210 description="Only include flow runs starting at or before this time", 

211 ) 

212 after_: Optional[DateTime] = Field( 1a

213 default=None, 

214 description="Only include flow runs starting at or after this time", 

215 ) 

216 is_null_: Optional[bool] = Field( 1a

217 default=None, description="If true, only return flow runs without a start time" 

218 ) 

219 

220 

221class FlowRunFilterExpectedStartTime(PrefectBaseModel): 1a

222 """Filter by `FlowRun.expected_start_time`.""" 

223 

224 before_: Optional[DateTime] = Field( 1a

225 default=None, 

226 description="Only include flow runs scheduled to start at or before this time", 

227 ) 

228 after_: Optional[DateTime] = Field( 1a

229 default=None, 

230 description="Only include flow runs scheduled to start at or after this time", 

231 ) 

232 

233 

234class FlowRunFilterNextScheduledStartTime(PrefectBaseModel): 1a

235 """Filter by `FlowRun.next_scheduled_start_time`.""" 

236 

237 before_: Optional[DateTime] = Field( 1a

238 default=None, 

239 description=( 

240 "Only include flow runs with a next_scheduled_start_time or before this" 

241 " time" 

242 ), 

243 ) 

244 after_: Optional[DateTime] = Field( 1a

245 default=None, 

246 description=( 

247 "Only include flow runs with a next_scheduled_start_time at or after this" 

248 " time" 

249 ), 

250 ) 

251 

252 

253class FlowRunFilterParentFlowRunId(PrefectBaseModel, OperatorMixin): 1a

254 """Filter for subflows of the given flow runs""" 

255 

256 any_: Optional[List[UUID]] = Field( 1a

257 default=None, description="A list of flow run parents to include" 

258 ) 

259 

260 

261class FlowRunFilterParentTaskRunId(PrefectBaseModel, OperatorMixin): 1a

262 """Filter by `FlowRun.parent_task_run_id`.""" 

263 

264 any_: Optional[List[UUID]] = Field( 1a

265 default=None, description="A list of flow run parent_task_run_ids to include" 

266 ) 

267 is_null_: Optional[bool] = Field( 1a

268 default=None, 

269 description="If true, only include flow runs without parent_task_run_id", 

270 ) 

271 

272 

273class FlowRunFilterIdempotencyKey(PrefectBaseModel): 1a

274 """Filter by FlowRun.idempotency_key.""" 

275 

276 any_: Optional[List[str]] = Field( 1a

277 default=None, description="A list of flow run idempotency keys to include" 

278 ) 

279 not_any_: Optional[List[str]] = Field( 1a

280 default=None, description="A list of flow run idempotency keys to exclude" 

281 ) 

282 

283 

284class FlowRunFilter(PrefectBaseModel, OperatorMixin): 1a

285 """Filter flow runs. Only flow runs matching all criteria will be returned""" 

286 

287 id: Optional[FlowRunFilterId] = Field( 1a

288 default=None, description="Filter criteria for `FlowRun.id`" 

289 ) 

290 name: Optional[FlowRunFilterName] = Field( 1a

291 default=None, description="Filter criteria for `FlowRun.name`" 

292 ) 

293 tags: Optional[FlowRunFilterTags] = Field( 1a

294 default=None, description="Filter criteria for `FlowRun.tags`" 

295 ) 

296 deployment_id: Optional[FlowRunFilterDeploymentId] = Field( 1a

297 default=None, description="Filter criteria for `FlowRun.deployment_id`" 

298 ) 

299 work_queue_name: Optional[FlowRunFilterWorkQueueName] = Field( 1a

300 default=None, description="Filter criteria for `FlowRun.work_queue_name" 

301 ) 

302 state: Optional[FlowRunFilterState] = Field( 1a

303 default=None, description="Filter criteria for `FlowRun.state`" 

304 ) 

305 flow_version: Optional[FlowRunFilterFlowVersion] = Field( 1a

306 default=None, description="Filter criteria for `FlowRun.flow_version`" 

307 ) 

308 start_time: Optional[FlowRunFilterStartTime] = Field( 1a

309 default=None, description="Filter criteria for `FlowRun.start_time`" 

310 ) 

311 expected_start_time: Optional[FlowRunFilterExpectedStartTime] = Field( 1a

312 default=None, description="Filter criteria for `FlowRun.expected_start_time`" 

313 ) 

314 next_scheduled_start_time: Optional[FlowRunFilterNextScheduledStartTime] = Field( 1a

315 default=None, 

316 description="Filter criteria for `FlowRun.next_scheduled_start_time`", 

317 ) 

318 parent_flow_run_id: Optional[FlowRunFilterParentFlowRunId] = Field( 1a

319 default=None, description="Filter criteria for subflows of the given flow runs" 

320 ) 

321 parent_task_run_id: Optional[FlowRunFilterParentTaskRunId] = Field( 1a

322 default=None, description="Filter criteria for `FlowRun.parent_task_run_id`" 

323 ) 

324 idempotency_key: Optional[FlowRunFilterIdempotencyKey] = Field( 1a

325 default=None, description="Filter criteria for `FlowRun.idempotency_key`" 

326 ) 

327 

328 

329class TaskRunFilterFlowRunId(PrefectBaseModel): 1a

330 """Filter by `TaskRun.flow_run_id`.""" 

331 

332 any_: Optional[List[UUID]] = Field( 1a

333 default=None, description="A list of flow run ids to include" 

334 ) 

335 

336 is_null_: bool = Field( 1a

337 default=False, 

338 description="If true, only include task runs without a flow run id", 

339 ) 

340 

341 

342class TaskRunFilterId(PrefectBaseModel): 1a

343 """Filter by `TaskRun.id`.""" 

344 

345 any_: Optional[List[UUID]] = Field( 1a

346 default=None, description="A list of task run ids to include" 

347 ) 

348 

349 

350class TaskRunFilterName(PrefectBaseModel): 1a

351 """Filter by `TaskRun.name`.""" 

352 

353 any_: Optional[List[str]] = Field( 1a

354 default=None, 

355 description="A list of task run names to include", 

356 examples=[["my-task-run-1", "my-task-run-2"]], 

357 ) 

358 

359 like_: Optional[str] = Field( 1a

360 default=None, 

361 description=( 

362 "A case-insensitive partial match. For example, " 

363 " passing 'marvin' will match " 

364 "'marvin', 'sad-Marvin', and 'marvin-robot'." 

365 ), 

366 examples=["marvin"], 

367 ) 

368 

369 

370class TaskRunFilterTags(PrefectBaseModel, OperatorMixin): 1a

371 """Filter by `TaskRun.tags`.""" 

372 

373 all_: Optional[List[str]] = Field( 1a

374 default=None, 

375 examples=[["tag-1", "tag-2"]], 

376 description=( 

377 "A list of tags. Task runs will be returned only if their tags are a" 

378 " superset of the list" 

379 ), 

380 ) 

381 is_null_: Optional[bool] = Field( 1a

382 default=None, description="If true, only include task runs without tags" 

383 ) 

384 

385 

386class TaskRunFilterStateType(PrefectBaseModel): 1a

387 """Filter by `TaskRun.state_type`.""" 

388 

389 any_: Optional[List[StateType]] = Field( 1a

390 default=None, description="A list of task run state types to include" 

391 ) 

392 

393 

394class TaskRunFilterStateName(PrefectBaseModel): 1a

395 any_: Optional[List[str]] = Field( 1a

396 default=None, description="A list of task run state names to include" 

397 ) 

398 

399 

400class TaskRunFilterState(PrefectBaseModel, OperatorMixin): 1a

401 type: Optional[TaskRunFilterStateType] 1a

402 name: Optional[TaskRunFilterStateName] 1a

403 

404 

405class TaskRunFilterSubFlowRuns(PrefectBaseModel): 1a

406 """Filter by `TaskRun.subflow_run`.""" 

407 

408 exists_: Optional[bool] = Field( 1a

409 default=None, 

410 description=( 

411 "If true, only include task runs that are subflow run parents; if false," 

412 " exclude parent task runs" 

413 ), 

414 ) 

415 

416 

417class TaskRunFilterStartTime(PrefectBaseModel): 1a

418 """Filter by `TaskRun.start_time`.""" 

419 

420 before_: Optional[DateTime] = Field( 1a

421 default=None, 

422 description="Only include task runs starting at or before this time", 

423 ) 

424 after_: Optional[DateTime] = Field( 1a

425 default=None, 

426 description="Only include task runs starting at or after this time", 

427 ) 

428 is_null_: Optional[bool] = Field( 1a

429 default=None, description="If true, only return task runs without a start time" 

430 ) 

431 

432 

433class TaskRunFilter(PrefectBaseModel, OperatorMixin): 1a

434 """Filter task runs. Only task runs matching all criteria will be returned""" 

435 

436 id: Optional[TaskRunFilterId] = Field( 1a

437 default=None, description="Filter criteria for `TaskRun.id`" 

438 ) 

439 name: Optional[TaskRunFilterName] = Field( 1a

440 default=None, description="Filter criteria for `TaskRun.name`" 

441 ) 

442 tags: Optional[TaskRunFilterTags] = Field( 1a

443 default=None, description="Filter criteria for `TaskRun.tags`" 

444 ) 

445 state: Optional[TaskRunFilterState] = Field( 1a

446 default=None, description="Filter criteria for `TaskRun.state`" 

447 ) 

448 start_time: Optional[TaskRunFilterStartTime] = Field( 1a

449 default=None, description="Filter criteria for `TaskRun.start_time`" 

450 ) 

451 subflow_runs: Optional[TaskRunFilterSubFlowRuns] = Field( 1a

452 default=None, description="Filter criteria for `TaskRun.subflow_run`" 

453 ) 

454 flow_run_id: Optional[TaskRunFilterFlowRunId] = Field( 1a

455 default=None, description="Filter criteria for `TaskRun.flow_run_id`" 

456 ) 

457 

458 

459class DeploymentFilterId(PrefectBaseModel): 1a

460 """Filter by `Deployment.id`.""" 

461 

462 any_: Optional[List[UUID]] = Field( 1a

463 default=None, description="A list of deployment ids to include" 

464 ) 

465 not_any_: Optional[List[UUID]] = Field( 1a

466 default=None, description="A list of deployment ids to exclude" 

467 ) 

468 

469 

470class DeploymentFilterName(PrefectBaseModel): 1a

471 """Filter by `Deployment.name`.""" 

472 

473 any_: Optional[List[str]] = Field( 1a

474 default=None, 

475 description="A list of deployment names to include", 

476 examples=[["my-deployment-1", "my-deployment-2"]], 

477 ) 

478 

479 like_: Optional[str] = Field( 1a

480 default=None, 

481 description=( 

482 "A case-insensitive partial match. For example, " 

483 " passing 'marvin' will match " 

484 "'marvin', 'sad-Marvin', and 'marvin-robot'." 

485 ), 

486 examples=["marvin"], 

487 ) 

488 

489 

490class DeploymentFilterWorkQueueName(PrefectBaseModel): 1a

491 """Filter by `Deployment.work_queue_name`.""" 

492 

493 any_: Optional[List[str]] = Field( 1a

494 default=None, 

495 description="A list of work queue names to include", 

496 examples=[["work_queue_1", "work_queue_2"]], 

497 ) 

498 

499 

500class DeploymentFilterTags(PrefectBaseModel, OperatorMixin): 1a

501 """Filter by `Deployment.tags`.""" 

502 

503 all_: Optional[List[str]] = Field( 1a

504 default=None, 

505 examples=[["tag-1", "tag-2"]], 

506 description=( 

507 "A list of tags. Deployments will be returned only if their tags are a" 

508 " superset of the list" 

509 ), 

510 ) 

511 any_: Optional[list[str]] = Field( 1a

512 default=None, 

513 examples=[["tag-1", "tag-2"]], 

514 description="A list of tags to include", 

515 ) 

516 is_null_: Optional[bool] = Field( 1a

517 default=None, description="If true, only include deployments without tags" 

518 ) 

519 

520 

521class DeploymentFilterConcurrencyLimit(PrefectBaseModel): 1a

522 """DEPRECATED: Prefer `Deployment.concurrency_limit_id` over `Deployment.concurrency_limit`.""" 

523 

524 ge_: Optional[int] = Field( 1a

525 default=None, 

526 description="Only include deployments with a concurrency limit greater than or equal to this value", 

527 ) 

528 le_: Optional[int] = Field( 1a

529 default=None, 

530 description="Only include deployments with a concurrency limit less than or equal to this value", 

531 ) 

532 is_null_: Optional[bool] = Field( 1a

533 default=None, 

534 description="If true, only include deployments without a concurrency limit", 

535 ) 

536 

537 

538class DeploymentFilter(PrefectBaseModel, OperatorMixin): 1a

539 """Filter for deployments. Only deployments matching all criteria will be returned.""" 

540 

541 id: Optional[DeploymentFilterId] = Field( 1a

542 default=None, description="Filter criteria for `Deployment.id`" 

543 ) 

544 name: Optional[DeploymentFilterName] = Field( 1a

545 default=None, description="Filter criteria for `Deployment.name`" 

546 ) 

547 tags: Optional[DeploymentFilterTags] = Field( 1a

548 default=None, description="Filter criteria for `Deployment.tags`" 

549 ) 

550 work_queue_name: Optional[DeploymentFilterWorkQueueName] = Field( 1a

551 default=None, description="Filter criteria for `Deployment.work_queue_name`" 

552 ) 

553 concurrency_limit: Optional[DeploymentFilterConcurrencyLimit] = Field( 1a

554 default=None, 

555 description="DEPRECATED: Prefer `Deployment.concurrency_limit_id` over `Deployment.concurrency_limit`. If provided, will be ignored for backwards-compatibility. Will be removed after December 2024.", 

556 deprecated=True, 

557 ) 

558 

559 

560class LogFilterName(PrefectBaseModel): 1a

561 """Filter by `Log.name`.""" 

562 

563 any_: Optional[List[str]] = Field( 1a

564 default=None, 

565 description="A list of log names to include", 

566 examples=[["prefect.logger.flow_runs", "prefect.logger.task_runs"]], 

567 ) 

568 

569 

570class LogFilterLevel(PrefectBaseModel): 1a

571 """Filter by `Log.level`.""" 

572 

573 ge_: Optional[int] = Field( 1a

574 default=None, 

575 description="Include logs with a level greater than or equal to this level", 

576 examples=[20], 

577 ) 

578 

579 le_: Optional[int] = Field( 1a

580 default=None, 

581 description="Include logs with a level less than or equal to this level", 

582 examples=[50], 

583 ) 

584 

585 

586class LogFilterTimestamp(PrefectBaseModel): 1a

587 """Filter by `Log.timestamp`.""" 

588 

589 before_: Optional[DateTime] = Field( 1a

590 default=None, 

591 description="Only include logs with a timestamp at or before this time", 

592 ) 

593 after_: Optional[DateTime] = Field( 1a

594 default=None, 

595 description="Only include logs with a timestamp at or after this time", 

596 ) 

597 

598 

599class LogFilterFlowRunId(PrefectBaseModel): 1a

600 """Filter by `Log.flow_run_id`.""" 

601 

602 any_: Optional[List[UUID]] = Field( 1a

603 default=None, description="A list of flow run IDs to include" 

604 ) 

605 

606 

607class LogFilterTaskRunId(PrefectBaseModel): 1a

608 """Filter by `Log.task_run_id`.""" 

609 

610 any_: Optional[List[UUID]] = Field( 1a

611 default=None, description="A list of task run IDs to include" 

612 ) 

613 

614 

615class LogFilterTextSearch(PrefectBaseModel): 1a

616 """Filter by text search across log content.""" 

617 

618 query: str = Field( 1a

619 description="Text search query string", 

620 examples=[ 

621 "error", 

622 "error -debug", 

623 '"connection timeout"', 

624 "+required -excluded", 

625 ], 

626 max_length=200, 

627 ) 

628 

629 

630class LogFilter(PrefectBaseModel, OperatorMixin): 1a

631 """Filter logs. Only logs matching all criteria will be returned""" 

632 

633 level: Optional[LogFilterLevel] = Field( 1a

634 default=None, description="Filter criteria for `Log.level`" 

635 ) 

636 timestamp: Optional[LogFilterTimestamp] = Field( 1a

637 default=None, description="Filter criteria for `Log.timestamp`" 

638 ) 

639 flow_run_id: Optional[LogFilterFlowRunId] = Field( 1a

640 default=None, description="Filter criteria for `Log.flow_run_id`" 

641 ) 

642 task_run_id: Optional[LogFilterTaskRunId] = Field( 1a

643 default=None, description="Filter criteria for `Log.task_run_id`" 

644 ) 

645 text: Optional[LogFilterTextSearch] = Field( 1a

646 default=None, description="Filter criteria for text search across log content" 

647 ) 

648 

649 

650class FilterSet(PrefectBaseModel): 1a

651 """A collection of filters for common objects""" 

652 

653 flows: FlowFilter = Field( 1a

654 default_factory=FlowFilter, description="Filters that apply to flows" 

655 ) 

656 flow_runs: FlowRunFilter = Field( 1a

657 default_factory=FlowRunFilter, description="Filters that apply to flow runs" 

658 ) 

659 task_runs: TaskRunFilter = Field( 1a

660 default_factory=TaskRunFilter, description="Filters that apply to task runs" 

661 ) 

662 deployments: DeploymentFilter = Field( 1a

663 default_factory=DeploymentFilter, 

664 description="Filters that apply to deployments", 

665 ) 

666 

667 

668class BlockTypeFilterName(PrefectBaseModel): 1a

669 """Filter by `BlockType.name`""" 

670 

671 like_: Optional[str] = Field( 1a

672 default=None, 

673 description=( 

674 "A case-insensitive partial match. For example, " 

675 " passing 'marvin' will match " 

676 "'marvin', 'sad-Marvin', and 'marvin-robot'." 

677 ), 

678 examples=["marvin"], 

679 ) 

680 

681 

682class BlockTypeFilterSlug(PrefectBaseModel): 1a

683 """Filter by `BlockType.slug`""" 

684 

685 any_: Optional[List[str]] = Field( 1a

686 default=None, description="A list of slugs to match" 

687 ) 

688 

689 

690class BlockTypeFilter(PrefectBaseModel): 1a

691 """Filter BlockTypes""" 

692 

693 name: Optional[BlockTypeFilterName] = Field( 1a

694 default=None, description="Filter criteria for `BlockType.name`" 

695 ) 

696 

697 slug: Optional[BlockTypeFilterSlug] = Field( 1a

698 default=None, description="Filter criteria for `BlockType.slug`" 

699 ) 

700 

701 

702class BlockSchemaFilterBlockTypeId(PrefectBaseModel): 1a

703 """Filter by `BlockSchema.block_type_id`.""" 

704 

705 any_: Optional[List[UUID]] = Field( 1a

706 default=None, description="A list of block type ids to include" 

707 ) 

708 

709 

710class BlockSchemaFilterId(PrefectBaseModel): 1a

711 """Filter by BlockSchema.id""" 

712 

713 any_: Optional[List[UUID]] = Field( 1a

714 default=None, description="A list of IDs to include" 

715 ) 

716 

717 

718class BlockSchemaFilterCapabilities(PrefectBaseModel): 1a

719 """Filter by `BlockSchema.capabilities`""" 

720 

721 all_: Optional[List[str]] = Field( 1a

722 default=None, 

723 examples=[["write-storage", "read-storage"]], 

724 description=( 

725 "A list of block capabilities. Block entities will be returned only if an" 

726 " associated block schema has a superset of the defined capabilities." 

727 ), 

728 ) 

729 

730 

731class BlockSchemaFilterVersion(PrefectBaseModel): 1a

732 """Filter by `BlockSchema.capabilities`""" 

733 

734 any_: Optional[List[str]] = Field( 1a

735 default=None, 

736 examples=[["2.0.0", "2.1.0"]], 

737 description="A list of block schema versions.", 

738 ) 

739 

740 

741class BlockSchemaFilter(PrefectBaseModel, OperatorMixin): 1a

742 """Filter BlockSchemas""" 

743 

744 block_type_id: Optional[BlockSchemaFilterBlockTypeId] = Field( 1a

745 default=None, description="Filter criteria for `BlockSchema.block_type_id`" 

746 ) 

747 block_capabilities: Optional[BlockSchemaFilterCapabilities] = Field( 1a

748 default=None, description="Filter criteria for `BlockSchema.capabilities`" 

749 ) 

750 id: Optional[BlockSchemaFilterId] = Field( 1a

751 default=None, description="Filter criteria for `BlockSchema.id`" 

752 ) 

753 version: Optional[BlockSchemaFilterVersion] = Field( 1a

754 default=None, description="Filter criteria for `BlockSchema.version`" 

755 ) 

756 

757 

758class BlockDocumentFilterIsAnonymous(PrefectBaseModel): 1a

759 """Filter by `BlockDocument.is_anonymous`.""" 

760 

761 eq_: Optional[bool] = Field( 1a

762 default=None, 

763 description=( 

764 "Filter block documents for only those that are or are not anonymous." 

765 ), 

766 ) 

767 

768 

769class BlockDocumentFilterBlockTypeId(PrefectBaseModel): 1a

770 """Filter by `BlockDocument.block_type_id`.""" 

771 

772 any_: Optional[List[UUID]] = Field( 1a

773 default=None, description="A list of block type ids to include" 

774 ) 

775 

776 

777class BlockDocumentFilterId(PrefectBaseModel): 1a

778 """Filter by `BlockDocument.id`.""" 

779 

780 any_: Optional[List[UUID]] = Field( 1a

781 default=None, description="A list of block ids to include" 

782 ) 

783 

784 

785class BlockDocumentFilterName(PrefectBaseModel): 1a

786 """Filter by `BlockDocument.name`.""" 

787 

788 any_: Optional[List[str]] = Field( 1a

789 default=None, description="A list of block names to include" 

790 ) 

791 like_: Optional[str] = Field( 1a

792 default=None, 

793 description=( 

794 "A string to match block names against. This can include " 

795 "SQL wildcard characters like `%` and `_`." 

796 ), 

797 examples=["my-block%"], 

798 ) 

799 

800 

801class BlockDocumentFilter(PrefectBaseModel, OperatorMixin): 1a

802 """Filter BlockDocuments. Only BlockDocuments matching all criteria will be returned""" 

803 

804 id: Optional[BlockDocumentFilterId] = Field( 1a

805 default=None, description="Filter criteria for `BlockDocument.id`" 

806 ) 

807 is_anonymous: Optional[BlockDocumentFilterIsAnonymous] = Field( 1a

808 # default is to exclude anonymous blocks 

809 BlockDocumentFilterIsAnonymous(eq_=False), 

810 description=( 

811 "Filter criteria for `BlockDocument.is_anonymous`. " 

812 "Defaults to excluding anonymous blocks." 

813 ), 

814 ) 

815 block_type_id: Optional[BlockDocumentFilterBlockTypeId] = Field( 1a

816 default=None, description="Filter criteria for `BlockDocument.block_type_id`" 

817 ) 

818 name: Optional[BlockDocumentFilterName] = Field( 1a

819 default=None, description="Filter criteria for `BlockDocument.name`" 

820 ) 

821 

822 

823class WorkQueueFilterId(PrefectBaseModel): 1a

824 """Filter by `WorkQueue.id`.""" 

825 

826 any_: Optional[List[UUID]] = Field( 1a

827 default=None, 

828 description="A list of work queue ids to include", 

829 ) 

830 

831 

832class WorkQueueFilterName(PrefectBaseModel): 1a

833 """Filter by `WorkQueue.name`.""" 

834 

835 any_: Optional[List[str]] = Field( 1a

836 default=None, 

837 description="A list of work queue names to include", 

838 examples=[["wq-1", "wq-2"]], 

839 ) 

840 

841 startswith_: Optional[List[str]] = Field( 1a

842 default=None, 

843 description=( 

844 "A list of case-insensitive starts-with matches. For example, " 

845 " passing 'marvin' will match " 

846 "'marvin', and 'Marvin-robot', but not 'sad-marvin'." 

847 ), 

848 examples=[["marvin", "Marvin-robot"]], 

849 ) 

850 

851 

852class WorkQueueFilter(PrefectBaseModel, OperatorMixin): 1a

853 """Filter work queues. Only work queues matching all criteria will be 

854 returned""" 

855 

856 id: Optional[WorkQueueFilterId] = Field( 1a

857 default=None, description="Filter criteria for `WorkQueue.id`" 

858 ) 

859 

860 name: Optional[WorkQueueFilterName] = Field( 1a

861 default=None, description="Filter criteria for `WorkQueue.name`" 

862 ) 

863 

864 

865class WorkPoolFilterId(PrefectBaseModel): 1a

866 """Filter by `WorkPool.id`.""" 

867 

868 any_: Optional[List[UUID]] = Field( 1a

869 default=None, description="A list of work pool ids to include" 

870 ) 

871 

872 

873class WorkPoolFilterName(PrefectBaseModel): 1a

874 """Filter by `WorkPool.name`.""" 

875 

876 any_: Optional[List[str]] = Field( 1a

877 default=None, description="A list of work pool names to include" 

878 ) 

879 

880 

881class WorkPoolFilterType(PrefectBaseModel): 1a

882 """Filter by `WorkPool.type`.""" 

883 

884 any_: Optional[List[str]] = Field( 1a

885 default=None, description="A list of work pool types to include" 

886 ) 

887 

888 

889class WorkPoolFilter(PrefectBaseModel, OperatorMixin): 1a

890 id: Optional[WorkPoolFilterId] = Field( 1a

891 default=None, description="Filter criteria for `WorkPool.id`" 

892 ) 

893 name: Optional[WorkPoolFilterName] = Field( 1a

894 default=None, description="Filter criteria for `WorkPool.name`" 

895 ) 

896 type: Optional[WorkPoolFilterType] = Field( 1a

897 default=None, description="Filter criteria for `WorkPool.type`" 

898 ) 

899 

900 

901class WorkerFilterWorkPoolId(PrefectBaseModel): 1a

902 """Filter by `Worker.worker_config_id`.""" 

903 

904 any_: Optional[List[UUID]] = Field( 1a

905 default=None, description="A list of work pool ids to include" 

906 ) 

907 

908 

909class WorkerFilterLastHeartbeatTime(PrefectBaseModel): 1a

910 """Filter by `Worker.last_heartbeat_time`.""" 

911 

912 before_: Optional[DateTime] = Field( 1a

913 default=None, 

914 description=( 

915 "Only include processes whose last heartbeat was at or before this time" 

916 ), 

917 ) 

918 after_: Optional[DateTime] = Field( 1a

919 default=None, 

920 description=( 

921 "Only include processes whose last heartbeat was at or after this time" 

922 ), 

923 ) 

924 

925 

926class WorkerFilterStatus(PrefectBaseModel): 1a

927 """Filter by `Worker.status`.""" 

928 

929 any_: Optional[List[str]] = Field( 1a

930 default=None, description="A list of worker statuses to include" 

931 ) 

932 not_any_: Optional[List[str]] = Field( 1a

933 default=None, description="A list of worker statuses to exclude" 

934 ) 

935 

936 

937class WorkerFilter(PrefectBaseModel, OperatorMixin): 1a

938 # worker_config_id: Optional[WorkerFilterWorkPoolId] = Field( 

939 # default=None, description="Filter criteria for `Worker.worker_config_id`" 

940 # ) 

941 

942 last_heartbeat_time: Optional[WorkerFilterLastHeartbeatTime] = Field( 1a

943 default=None, 

944 description="Filter criteria for `Worker.last_heartbeat_time`", 

945 ) 

946 status: Optional[WorkerFilterStatus] = Field( 1a

947 default=None, description="Filter criteria for `Worker.status`" 

948 ) 

949 

950 

951class ArtifactFilterId(PrefectBaseModel): 1a

952 """Filter by `Artifact.id`.""" 

953 

954 any_: Optional[List[UUID]] = Field( 1a

955 default=None, description="A list of artifact ids to include" 

956 ) 

957 

958 

959class ArtifactFilterKey(PrefectBaseModel): 1a

960 """Filter by `Artifact.key`.""" 

961 

962 any_: Optional[List[str]] = Field( 1a

963 default=None, description="A list of artifact keys to include" 

964 ) 

965 

966 like_: Optional[str] = Field( 1a

967 default=None, 

968 description=( 

969 "A string to match artifact keys against. This can include " 

970 "SQL wildcard characters like `%` and `_`." 

971 ), 

972 examples=["my-artifact-%"], 

973 ) 

974 

975 exists_: Optional[bool] = Field( 1a

976 default=None, 

977 description=( 

978 "If `true`, only include artifacts with a non-null key. If `false`, " 

979 "only include artifacts with a null key." 

980 ), 

981 ) 

982 

983 

984class ArtifactFilterFlowRunId(PrefectBaseModel): 1a

985 """Filter by `Artifact.flow_run_id`.""" 

986 

987 any_: Optional[List[UUID]] = Field( 1a

988 default=None, description="A list of flow run IDs to include" 

989 ) 

990 

991 

992class ArtifactFilterTaskRunId(PrefectBaseModel): 1a

993 """Filter by `Artifact.task_run_id`.""" 

994 

995 any_: Optional[List[UUID]] = Field( 1a

996 default=None, description="A list of task run IDs to include" 

997 ) 

998 

999 

1000class ArtifactFilterType(PrefectBaseModel): 1a

1001 """Filter by `Artifact.type`.""" 

1002 

1003 any_: Optional[List[str]] = Field( 1a

1004 default=None, description="A list of artifact types to include" 

1005 ) 

1006 not_any_: Optional[List[str]] = Field( 1a

1007 default=None, description="A list of artifact types to exclude" 

1008 ) 

1009 

1010 

1011class ArtifactFilter(PrefectBaseModel, OperatorMixin): 1a

1012 """Filter artifacts. Only artifacts matching all criteria will be returned""" 

1013 

1014 id: Optional[ArtifactFilterId] = Field( 1a

1015 default=None, description="Filter criteria for `Artifact.id`" 

1016 ) 

1017 key: Optional[ArtifactFilterKey] = Field( 1a

1018 default=None, description="Filter criteria for `Artifact.key`" 

1019 ) 

1020 flow_run_id: Optional[ArtifactFilterFlowRunId] = Field( 1a

1021 default=None, description="Filter criteria for `Artifact.flow_run_id`" 

1022 ) 

1023 task_run_id: Optional[ArtifactFilterTaskRunId] = Field( 1a

1024 default=None, description="Filter criteria for `Artifact.task_run_id`" 

1025 ) 

1026 type: Optional[ArtifactFilterType] = Field( 1a

1027 default=None, description="Filter criteria for `Artifact.type`" 

1028 ) 

1029 

1030 

1031class ArtifactCollectionFilterLatestId(PrefectBaseModel): 1a

1032 """Filter by `ArtifactCollection.latest_id`.""" 

1033 

1034 any_: Optional[List[UUID]] = Field( 1a

1035 default=None, description="A list of artifact ids to include" 

1036 ) 

1037 

1038 

1039class ArtifactCollectionFilterKey(PrefectBaseModel): 1a

1040 """Filter by `ArtifactCollection.key`.""" 

1041 

1042 any_: Optional[List[str]] = Field( 1a

1043 default=None, description="A list of artifact keys to include" 

1044 ) 

1045 

1046 like_: Optional[str] = Field( 1a

1047 default=None, 

1048 description=( 

1049 "A string to match artifact keys against. This can include " 

1050 "SQL wildcard characters like `%` and `_`." 

1051 ), 

1052 examples=["my-artifact-%"], 

1053 ) 

1054 

1055 exists_: Optional[bool] = Field( 1a

1056 default=None, 

1057 description=( 

1058 "If `true`, only include artifacts with a non-null key. If `false`, " 

1059 "only include artifacts with a null key. Should return all rows in " 

1060 "the ArtifactCollection table if specified." 

1061 ), 

1062 ) 

1063 

1064 

1065class ArtifactCollectionFilterFlowRunId(PrefectBaseModel): 1a

1066 """Filter by `ArtifactCollection.flow_run_id`.""" 

1067 

1068 any_: Optional[List[UUID]] = Field( 1a

1069 default=None, description="A list of flow run IDs to include" 

1070 ) 

1071 

1072 

1073class ArtifactCollectionFilterTaskRunId(PrefectBaseModel): 1a

1074 """Filter by `ArtifactCollection.task_run_id`.""" 

1075 

1076 any_: Optional[List[UUID]] = Field( 1a

1077 default=None, description="A list of task run IDs to include" 

1078 ) 

1079 

1080 

1081class ArtifactCollectionFilterType(PrefectBaseModel): 1a

1082 """Filter by `ArtifactCollection.type`.""" 

1083 

1084 any_: Optional[List[str]] = Field( 1a

1085 default=None, description="A list of artifact types to include" 

1086 ) 

1087 not_any_: Optional[List[str]] = Field( 1a

1088 default=None, description="A list of artifact types to exclude" 

1089 ) 

1090 

1091 

1092class ArtifactCollectionFilter(PrefectBaseModel, OperatorMixin): 1a

1093 """Filter artifact collections. Only artifact collections matching all criteria will be returned""" 

1094 

1095 latest_id: Optional[ArtifactCollectionFilterLatestId] = Field( 1a

1096 default=None, description="Filter criteria for `Artifact.id`" 

1097 ) 

1098 key: Optional[ArtifactCollectionFilterKey] = Field( 1a

1099 default=None, description="Filter criteria for `Artifact.key`" 

1100 ) 

1101 flow_run_id: Optional[ArtifactCollectionFilterFlowRunId] = Field( 1a

1102 default=None, description="Filter criteria for `Artifact.flow_run_id`" 

1103 ) 

1104 task_run_id: Optional[ArtifactCollectionFilterTaskRunId] = Field( 1a

1105 default=None, description="Filter criteria for `Artifact.task_run_id`" 

1106 ) 

1107 type: Optional[ArtifactCollectionFilterType] = Field( 1a

1108 default=None, description="Filter criteria for `Artifact.type`" 

1109 ) 

1110 

1111 

1112class VariableFilterId(PrefectBaseModel): 1a

1113 """Filter by `Variable.id`.""" 

1114 

1115 any_: Optional[List[UUID]] = Field( 1a

1116 default=None, description="A list of variable ids to include" 

1117 ) 

1118 

1119 

1120class VariableFilterName(PrefectBaseModel): 1a

1121 """Filter by `Variable.name`.""" 

1122 

1123 any_: Optional[List[str]] = Field( 1a

1124 default=None, description="A list of variables names to include" 

1125 ) 

1126 like_: Optional[str] = Field( 1a

1127 default=None, 

1128 description=( 

1129 "A string to match variable names against. This can include " 

1130 "SQL wildcard characters like `%` and `_`." 

1131 ), 

1132 examples=["my_variable_%"], 

1133 ) 

1134 

1135 

1136class VariableFilterTags(PrefectBaseModel, OperatorMixin): 1a

1137 """Filter by `Variable.tags`.""" 

1138 

1139 all_: Optional[List[str]] = Field( 1a

1140 default=None, 

1141 examples=[["tag-1", "tag-2"]], 

1142 description=( 

1143 "A list of tags. Variables will be returned only if their tags are a" 

1144 " superset of the list" 

1145 ), 

1146 ) 

1147 is_null_: Optional[bool] = Field( 1a

1148 default=None, description="If true, only include Variables without tags" 

1149 ) 

1150 

1151 

1152class VariableFilter(PrefectBaseModel, OperatorMixin): 1a

1153 """Filter variables. Only variables matching all criteria will be returned""" 

1154 

1155 id: Optional[VariableFilterId] = Field( 1a

1156 default=None, description="Filter criteria for `Variable.id`" 

1157 ) 

1158 name: Optional[VariableFilterName] = Field( 1a

1159 default=None, description="Filter criteria for `Variable.name`" 

1160 ) 

1161 tags: Optional[VariableFilterTags] = Field( 1a

1162 default=None, description="Filter criteria for `Variable.tags`" 

1163 )