notion-py
notion-py copied to clipboard
Support adding a row from a template
Hey :wave: This pull request implements a naive way to add a new row to a collection where its origin is a template (another block_id).
The implementation is based on a sequence of API calls:
- Enqueue a new task of type
duplicateBlock(API:v3/enqueueTask) - Loop
Ntimes everyXseconds (or milliseconds) and check the status of the task (API:v3/getTasks)
The usage is very straightforward:
cv = client.get_collection_view("...")
cv.collection.add_row(sourceBlockId="75dd203a-EXAMPLE-a12b-ba492c37a1f6")
And of course, more parameters can be added:
cv.collection.add_row(
sourceBlockId="75dd203a-EXAMPLE-a12b-ba492c37a1f6",
name="The Hen House: Episode #123",
type="Podcast"
)
Note:
The v3/getTasks actually supports getting the status of multiple tasks. I used it to get the status of a single one. We can consider improving it to support multiple tasks but didn't find it useful in the current design.
closes #194
Hi there!
My next step is use template on creation, did some CR, if u don't mind. ;)