Schemas¶
As ftrack supports customising entity types and attributes, the API makes use of schemas to describe which entity types and attributes are available for a particular server.
A schema definition roughly follows the JSON-schema specification and provides an easy way to build a dynamic client that can adapt to differing setups.
To retrieve a list of schemas for a particular server, connect to that server and issue a Query schemas operation. Each entry in the returned list will be a schema definition whose id corresponds to the unique entity type. Here is an example of an Asset schema definition:
{
"id": "Asset",
"type": "object",
"properties": {
"id": {
"alias_for": "assetid",
"type": "string",
"default": "{uid}"
},
"name": {
"type": "string"
},
"context_id": {
"type": "string",
"format": "foreign_key",
"description": "Foreign key(s): Context.id"
},
"type_id": {
"alias_for": "typeid",
"type": "string",
"format": "foreign_key",
"description": "Foreign key(s): AssetType.id"
},
"parent": {
"$ref": "Context"
},
"type": {
"$ref": "AssetType"
},
"versions": {
"type": "array",
"items": {
"$ref": "AssetVersion"
}
},
"metadata": {
"alias_for": "meta",
"type": "mapped_array",
"items": {
"$ref": "Metadata"
}
}
},
"immutable": [
"id"
],
"primary_key": [
"id"
],
"required": [
"id"
],
"default_projections": [
"id"
]
}
Properties¶
Each schema has a properties section that describes the known attributes for that entity type.
A property is keyed by its unique name against a configuration that may contain entries for:
type: | The type of the attribute. Can be used for validation and hinting.
Standard types include
|
---|---|
format: | Describes format of value for some types. Can be used for validation and
hinting. For example, a |
description: | Describes the attribute with a human readable string. Useful for hinting in interfaces and providing users with more information. |
default: | A default value that should be used for the attribute primarily when
creating entities. If the value is surrounded by braces ( |
$ref: | A reference to another entity type. When this field is encountered it should
be expected that the attribute can hold a reference to an instance of
another entity of the specified type. Can also be used in conjunction with
items for |
alias_for: | Describes the internal attribute name that the public attribute maps to. This data is primarily used by the server and should not be relevant for most clients. |
Additional metadata¶
A schema also provides additional metadata about the entity type that can be useful to a client:
primary_key: | A list of properties that make up the unique identity for an instance of the entity type. The values of these properties are useful when performing certain operations like updating an entity. |
---|---|
immutable: | Properties that, once set, should not be altered. |
required: | Properties that are required to be set in order to successfully create an instance of the entity type. Can be useful when building a dynamic UI that displays feedback to the user on required values. |
default_projections: | List of properties that should be used as projections when none are supplied in a query for the entity type. |
system_projections: | List of properties that are required by internals and will always be loaded for that entity type. |