Documents API¶
Service: $client->documents()
List documents¶
$options = new DocumentListOptions(
projectId: $projectId,
status: DocumentStatus::Published,
query: 'production',
tags: ['runbook', 'production'],
perPage: 50,
page: 1,
);
$page = $client->documents()->list($organizationId, $options)->pagination();
Route GET /organizations/{organization}/documents; scope documents:read.
Create¶
$request = new CreateDocumentRequest(
title: 'Production Runbook',
projectId: $projectId,
caption: 'Deployment and rollback procedures',
contentHtml: '<h2>Deploy</h2><p>...</p>',
status: DocumentStatus::Draft,
editorIds: [$operatorId, $reviewerId],
tagNames: ['production', 'runbook'],
);
$response = $client->documents()->create($organizationId, $request);
$document = Document::fromResponse($response);
Read¶
Update and publish¶
$client->documents()->update(
$documentId,
UpdateDocumentRequest::create()
->contentHtml($reviewedHtml)
->status(DocumentStatus::Published),
);
PATCH can also update project scope, title, caption, archive state, editor IDs, and tag names.
Comment¶
$client->documents()->comment(
$documentId,
new DocumentCommentRequest('<p>Reviewed and approved.</p>'),
);
Delete¶
Deletion is a soft delete.