prefect.server.models.block_schemas
Functions for interacting with block schema ORM objects. Intended for internal use by the Prefect REST API.
MissingBlockTypeException
Bases: Exception
Raised when the block type corresponding to a block schema cannot be found
Source code in src/prefect/server/models/block_schemas.py
30 31 |
|
create_block_schema(db, session, block_schema, override=False, definitions=None)
async
Create a new block schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
block_schema
|
Union[BlockSchemaCreate, BlockSchema, BlockSchemaCreate, BlockSchema]
|
a block schema object |
required |
definitions
|
Optional[Dict]
|
Definitions of fields from block schema fields attribute. Used when recursively creating nested block schemas |
None
|
Returns:
Name | Type | Description |
---|---|---|
block_schema |
Union[BlockSchema, BlockSchema]
|
an ORM block schema model |
Source code in src/prefect/server/models/block_schemas.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
create_block_schema_reference(db, session, block_schema_reference)
async
Retrieves a list of all available block capabilities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session. |
required |
block_schema_reference
|
BlockSchemaReference
|
A block schema reference object. |
required |
Returns:
Type | Description |
---|---|
Union[BlockSchemaReference, None]
|
orm_models.BlockSchemaReference: The created BlockSchemaReference |
Source code in src/prefect/server/models/block_schemas.py
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
|
delete_block_schema(session, block_schema_id)
async
Delete a block schema by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
block_schema_id
|
UUID
|
a block schema id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the block schema was deleted |
Source code in src/prefect/server/models/block_schemas.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
read_available_block_capabilities(db, session)
async
Retrieves a list of all available block capabilities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: List of all available block capabilities. |
Source code in src/prefect/server/models/block_schemas.py
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
|
read_block_schema(session, block_schema_id)
async
Reads a block schema by id. Will reconstruct the block schema's fields attribute to include block schema references.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
block_schema_id
|
UUID
|
a block_schema id |
required |
Returns:
Type | Description |
---|---|
Union[BlockSchema, None]
|
orm_models..BlockSchema: the block_schema |
Source code in src/prefect/server/models/block_schemas.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
read_block_schema_by_checksum(session, checksum, version=None)
async
Reads a block_schema by checksum. Will reconstruct the block schema's fields attribute to include block schema references.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
checksum
|
str
|
a block_schema checksum |
required |
version
|
Optional[str]
|
A block_schema version |
None
|
Returns:
Type | Description |
---|---|
Optional[BlockSchema]
|
orm_models.BlockSchema: the block_schema |
Source code in src/prefect/server/models/block_schemas.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 |
|
read_block_schemas(session, block_schema_filter=None, limit=None, offset=None)
async
Reads block schemas, optionally filtered by type or name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
block_schema_filter
|
Optional[BlockSchemaFilter]
|
a block schema filter object |
None
|
limit
|
int
|
query limit |
None
|
offset
|
int
|
query offset |
None
|
Returns:
Type | Description |
---|---|
List[BlockSchema]
|
List[orm_models.BlockSchema]: the block_schemas |
Source code in src/prefect/server/models/block_schemas.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 |
|