docs/v3/api-ref/python/prefect-server-models-block_schemas.mdx
prefect.server.models.block_schemasFunctions for interacting with block schema ORM objects. Intended for internal use by the Prefect REST API.
create_block_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L33" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_block_schema(db: PrefectDBInterface, session: AsyncSession, block_schema: Union[schemas.actions.BlockSchemaCreate, schemas.core.BlockSchema, 'ClientBlockSchemaCreate', 'ClientBlockSchema'], override: bool = False, definitions: Optional[dict[str, Any]] = None) -> Union[BlockSchema, orm_models.BlockSchema]
Create a new block schema.
Args:
session: A database sessionblock_schema: a block schema objectdefinitions: Definitions of fields from block schema fields
attribute. Used when recursively creating nested block schemasReturns:
delete_block_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L286" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete_block_schema(db: PrefectDBInterface, session: AsyncSession, block_schema_id: UUID) -> bool
Delete a block schema by id.
Args:
session: A database sessionblock_schema_id: a block schema idReturns:
read_block_schema <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L307" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_block_schema(db: PrefectDBInterface, session: AsyncSession, block_schema_id: UUID) -> Union[BlockSchema, None]
Reads a block schema by id. Will reconstruct the block schema's fields attribute to include block schema references.
Args:
session: A database sessionblock_schema_id: a block_schema idReturns:
read_block_schemas <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L624" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_block_schemas(db: PrefectDBInterface, session: AsyncSession, block_schema_filter: Optional[schemas.filters.BlockSchemaFilter] = None, limit: Optional[int] = None, offset: Optional[int] = None) -> List[BlockSchema]
Reads block schemas, optionally filtered by type or name.
Args:
session: A database sessionblock_schema_filter: a block schema filter objectlimit: query limitoffset: query offsetReturns:
read_block_schema_by_checksum <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L742" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_block_schema_by_checksum(db: PrefectDBInterface, session: AsyncSession, checksum: str, version: Optional[str] = None) -> Optional[BlockSchema]
Reads a block_schema by checksum. Will reconstruct the block schema's fields attribute to include block schema references.
Args:
session: A database sessionchecksum: a block_schema checksumversion: A block_schema versionReturns:
read_available_block_capabilities <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L823" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_available_block_capabilities(db: PrefectDBInterface, session: AsyncSession) -> List[str]
Retrieves a list of all available block capabilities.
Args:
session: A database session.Returns:
create_block_schema_reference <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L848" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_block_schema_reference(db: PrefectDBInterface, session: AsyncSession, block_schema_reference: schemas.core.BlockSchemaReference) -> Union[orm_models.BlockSchemaReference, None]
Retrieves a list of all available block capabilities.
Args:
session: A database session.block_schema_reference: A block schema reference object.Returns:
MissingBlockTypeException <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/block_schemas.py#L28" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Raised when the block type corresponding to a block schema cannot be found