Skip to content

ObjectReference

fastagency.studio.models.base.ObjectReference #

Bases: BaseModel

name class-attribute instance-attribute #

name: str = ''

type class-attribute instance-attribute #

type: str = ''

uuid instance-attribute #

uuid: UUID

check_type #

check_type() -> ObjectReference
Source code in fastagency/studio/models/base.py
@model_validator(mode="after")
def check_type(self) -> "ObjectReference":
    if self.type == "" or self.name == "":
        raise ValueError("type and name must be set")
    return self

create classmethod #

create(uuid: UUID) -> ObjectReference

Factory method to create a new instance of the class.

This method is used to create a new instance of the class with the given UUID. It is exactly the same as calling ObjectReference(uuid=uuid), but without type checking failing because of the missing type and name arguments.

PARAMETER DESCRIPTION
uuid

The unique identifier of the object

TYPE: UUID

RETURNS DESCRIPTION
ObjectReference

The new instance of the class

TYPE: ObjectReference

Source code in fastagency/studio/models/base.py
@classmethod
def create(cls, uuid: UUID) -> "ObjectReference":
    """Factory method to create a new instance of the class.

    This method is used to create a new instance of the class with the given UUID. It
    is exactly the same as calling `ObjectReference(uuid=uuid)`, but without type
    checking failing because of the missing `type` and `name` arguments.

    Args:
        uuid (UUID): The unique identifier of the object

    Returns:
        ObjectReference: The new instance of the class
    """
    return cls(uuid=uuid)  # type: ignore[call-arg]

get_data_model classmethod #

get_data_model() -> Type[Model]

Get the data class for the reference.

This method returns the data class that is associated with the reference class.

RETURNS DESCRIPTION
Type[Model]

Type[BM]: The data class for the reference

RAISES DESCRIPTION
ValueError

If the data class is not set

Source code in fastagency/studio/models/base.py
@classmethod
def get_data_model(cls) -> "Type[Model]":
    """Get the data class for the reference.

    This method returns the data class that is associated with the reference class.

    Returns:
        Type[BM]: The data class for the reference

    Raises:
        ValueError: If the data class is not set

    """
    if cls._data_class is None:
        raise RuntimeError("data class not set")

    return cls._data_class