Schema Property Objects
Classes:
|
Data class for all schema objects. |
- class SchemaProperty(**kwargs)[source]
Bases:
ABCData class for all schema objects.
- All schema objects have:
type (string)
name (string). Optional
id (string). Optional if name is specified
config (dict). Optional, type specific following Notion API
- For example, to create a ‘checkbox’ column called ‘In stock’:
>>> SchemaObject(type="checkbox", name="In stock") {'name': 'In stock', 'type': 'checkbox', 'checkbox': {}}
- To create a ‘select’ column called ‘Color’ with options ‘red’, ‘green’, ‘blue’:
>>> SchemaObject(type="select", name="Color", config={"options": ["red", "green", "blue"]}) {'name': 'Color', 'type': 'select', 'select': {'options': ['red', 'green', 'blue']}}
- To create a schema object from a notion response:
>>> notion_response { "id": "fk%5EY", "name": "In stock", "type": "checkbox", "checkbox": {} } >>> SchemaObject(**notion_response) {'id': 'fk%5EY', 'name': 'In stock', 'type': 'checkbox', 'checkbox': {}}
- To update the config of a schema object:
>>> schema_object = SchemaObject(type='number', name='Price') >>> schema_object.config = {"format": "number"} >>> schema_object {'name': 'Price', 'type': 'number', 'number': {'format': 'number'}}
- Or use:
>>> schema_object["format"] = "number" >>> schema_object {'name': 'Price', 'type': 'number', 'number': {'format': 'number'}}
Attributes:
Type of the column
Returns id if exists, otherwise name
ID of the column
Name of the column
Returns the configuration of the column
Returns the notion representation of the column
- property type
Type of the column
- property key
Returns id if exists, otherwise name
- property id
ID of the column
- property name
Name of the column
- property config
Returns the configuration of the column
- property notion
Returns the notion representation of the column