Utility functions

flame_hub._base_client._get_annotated_property_names(model: type[ResourceT], sentinel: object) tuple[str, ...]

Returns the names of all properties for a given model that are annotated with a specific sentinel.

This function traverses a given model and all of its bases using the method resolution order. While traversing, all attributes are checked if they are annotated with a sentinel object. The names of all annotated attributes are returned as a tuple.

Parameters:
modeltype[ResourceT]

A resource model for which the property names should be retrieved. Note that fields are not consequently annotated for Create and Update models due to inheritance.

sentinelobject

Only names of properties that are annotated with sentinel are returned.

Returns:
tuple[str, …]

Returns a tuple of all attribute names that are annotated with sentinel.

flame_hub.get_field_names(model: type[ResourceT]) tuple[str, ...]

This function is a wrapper which calls _get_annotated_property_names() with sentinel set to IsOptionalField.

See also

_get_annotated_property_names(), IsOptionalField
flame_hub.get_includable_names(model: type[ResourceT]) tuple[str, ...]

This function is a wrapper which calls _get_annotated_property_names() with sentinel set to IsIncludable.

See also

_get_annotated_property_names(), IsIncludable
flame_hub._base_client.obtain_uuid_from(uuid_identifiable: UuidModel | UUID | str) UUID

Extract a UUID from a model containing an id property, UUID object or a string.

Raises:
ValueError

If uuid_identifiable is neither an instance of BaseModel, str nor UUID.

See also

UuidIdentifiable, UuidModel, ResourceT
flame_hub._base_client.uuid_validator(value: Any, handler: ValidatorFunctionWrapHandler) UUID

Callable for Pydantic’s wrap validator WrapValidator to cast resource type instances and strings to UUID.

This function tries to validate value with handler and if this raises a validation error, it tries to cast value to a UUID with obtain_from_uuid().

Raises:
ValidationError

If obtain_from_uuid() raises a ValueError, the original ValidationError is raised.

See also

UuidIdentifiable, UuidModel, ResourceT, obtain_from_uuid()