feat(bookstack-api-5gi): implement Attachments CRUD

Add AttachmentsService with List, Get, Create, Update, Delete.
Support link attachments via JSON. Add Attachment type and request
types. Register service on Client. Add tests.
This commit is contained in:
Oliver Jakoubek 2026-01-30 09:55:02 +01:00
commit 256361e90b
6 changed files with 219 additions and 12 deletions

View file

@ -79,6 +79,34 @@ type PageUpdateRequest struct {
Markdown string `json:"markdown,omitempty"`
}
// Attachment represents a Bookstack attachment.
type Attachment struct {
ID int `json:"id"`
Name string `json:"name"`
Extension string `json:"extension"`
UploadedTo int `json:"uploaded_to"`
External bool `json:"external"`
Order int `json:"order"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
CreatedBy int `json:"created_by"`
UpdatedBy int `json:"updated_by"`
Content string `json:"content,omitempty"`
}
// AttachmentCreateRequest contains fields for creating an attachment.
type AttachmentCreateRequest struct {
Name string `json:"name"`
UploadedTo int `json:"uploaded_to"`
Link string `json:"link,omitempty"`
}
// AttachmentUpdateRequest contains fields for updating an attachment.
type AttachmentUpdateRequest struct {
Name string `json:"name,omitempty"`
Link string `json:"link,omitempty"`
}
// SearchResult represents a search result from Bookstack.
type SearchResult struct {
Type string `json:"type"` // "page", "chapter", "book", or "shelf"