1.9 KiB
1.9 KiB
Step documents (cp-docs-token)
This step can read and write planner documents through python3 -m lib.cp_cli
in step-docs mode (PLN-CLI-16). The mode is active because CP_DOCS_TOKEN_FILE
and CP_DOCS_CA_FILE are set and the listener URL is in CP_DOCS_URL.
Credential
- The token is a file at
$CP_DOCS_TOKEN_FILE. cp-cli reads it on every call. - Never print, copy, log or pass the token on a command line.
- Do not use
~/.cpconfig; step-docs mode does not read it.
Allowed commands
Only these commands work; anything else exits 2 cp_docs_mode_command_not_allowed:
python3 -m lib.cp_cli planner items documents list <item-uuid>
python3 -m lib.cp_cli planner items documents get <item-uuid> <name> [--json]
python3 -m lib.cp_cli planner items documents put <item-uuid> <name> --file <path> (--create-only | --if-match <rev>)
python3 -m lib.cp_cli planner items documents related [--json]
Item arguments are full UUIDs. Do not pass a project id.
Scope
- You may write only documents on this step's own item.
- You may read documents on this step's item, its parent and its siblings.
relatedprintsitem_uuid,parent_uuid,sibling_uuidsandsiblings_truncated.
Writes need a precondition
Exactly one of these is required on every put (neither or both exits 2):
--create-onlycreates a new document (sendsIf-None-Match: *).--if-match <rev>updates an existing one (sendsIf-Match). Take<rev>fromget --json(the ETag revision); surrounding quotes are stripped.
Errors
- 412
precondition_failed: the document changed or already exists. Re-runget --json, merge your change into the current content, andputagain with the new revision. - 428 (precondition missing): add
--create-onlyor--if-match. - 429
step_docs_write_budget_exhaustedorstep_docs_rate_limited: stop writing; do not retry in a loop. - 404
not_found, 400invalid_document_name: fix the item uuid or name.