Documentation
¶
Index ¶
- Constants
- func ExitCode(err error) int
- type APIError
- type Client
- func (c *Client) CatalogGetProduct(ctx context.Context, contentID int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) CatalogUpsertProduct(ctx context.Context, contentID int, body map[string]any) (json.RawMessage, json.RawMessage, error)
- func (c *Client) CreateComment(ctx context.Context, contentID int, req CreateCommentRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) CreateContent(ctx context.Context, req CreateContentRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) DeleteComment(ctx context.Context, contentID int, commentID int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) DeleteContent(ctx context.Context, id int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) DeleteMedia(ctx context.Context, id int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) Do(ctx context.Context, method string, path string, query url.Values, body any) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ExportContent(ctx context.Context, output io.Writer, opts DownloadOptions) error
- func (c *Client) GenerateSite(ctx context.Context, output io.Writer, opts DownloadOptions) error
- func (c *Client) GenerateTheme(ctx context.Context, req GenerateThemeRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) GetContent(ctx context.Context, id int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) GetHugoImportStatus(ctx context.Context, jobID string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) GetImportStatus(ctx context.Context, jobID string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) GetMedia(ctx context.Context, id int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ImportHugo(ctx context.Context, req ImportHugoRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ImportWordPress(ctx context.Context, req ImportWordPressRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) InvoiceSettingsGet(ctx context.Context) (json.RawMessage, json.RawMessage, error)
- func (c *Client) InvoiceSettingsSet(ctx context.Context, body map[string]any) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ListComments(ctx context.Context, contentID int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ListContent(ctx context.Context, limit int, cursor string, filters ListContentFilters) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ListMedia(ctx context.Context, limit int, cursor string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) OrdersGet(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) OrdersList(ctx context.Context, status string, cursor string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) OrdersSetShipping(ctx context.Context, id int64, amount int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) OrdersTransition(ctx context.Context, id int64, status string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) PaymentsGet(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) PaymentsList(ctx context.Context, status string, cursor string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) PaymentsReject(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) PaymentsVerify(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) PublishContent(ctx context.Context, id int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ReencodeMedia(ctx context.Context) (json.RawMessage, json.RawMessage, error)
- func (c *Client) SetSystemFields(ctx context.Context, id int, systemFields map[string]any) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ThemeActivate(ctx context.Context, name string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ThemeDeactivate(ctx context.Context) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ThemeDelete(ctx context.Context, name string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) ThemeDownload(ctx context.Context, name string, output io.Writer, opts DownloadOptions) error
- func (c *Client) ThemesList(ctx context.Context) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UnpublishContent(ctx context.Context, id int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UpdateCommentStatus(ctx context.Context, contentID int, commentID int, status string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UpdateContent(ctx context.Context, id int, req UpdateContentRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UploadMedia(ctx context.Context, req UploadMediaRequest) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersApprove(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersList(ctx context.Context, status string, limit int, offset int) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersMarkSpam(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersPending(ctx context.Context) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersReject(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersSoftDelete(ctx context.Context, id int64, reason string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersSuspend(ctx context.Context, id int64, reason string) (json.RawMessage, json.RawMessage, error)
- func (c *Client) UsersUnsuspend(ctx context.Context, id int64) (json.RawMessage, json.RawMessage, error)
- type CreateCommentRequest
- type CreateContentRequest
- type DownloadOptions
- type GenerateThemeRequest
- type ImportHugoRequest
- type ImportJobStatus
- type ImportWordPressRequest
- type ListContentFilters
- type UpdateContentRequest
- type UploadMediaRequest
Constants ¶
const ( ExitOK = 0 ExitGeneric = 1 ExitUsage = 2 ExitAuth = 3 ExitNotFound = 4 ExitValidation = 5 ExitRateLimited = 6 ExitServer = 7 )
Documented CLI exit-code scheme (see docs/api-reference.md and the architecture). The cmd layer maps outcomes to these and os.Exit()s with them.
const ReencodeTimeout = 15 * time.Minute
ReencodeTimeout bounds one media re-encode run end to end. The run rewrites the whole library server-side and takes minutes on real libraries, so it cannot share the default 30s client timeout. Fifteen minutes covers large libraries while still failing loudly against a hung server or a dropped connection; the caller controls earlier cancellation via ctx.
const ThemeGenerateTimeout = 5 * time.Minute
ThemeGenerateTimeout bounds one theme generation run end to end. The run includes the repair loop (up to two model retries on validation failure), so it cannot share the default 30s client timeout. Five minutes covers the server's 180s template-override budget with headroom.
Variables ¶
This section is empty.
Functions ¶
func ExitCode ¶
ExitCode maps a Client error to the documented exit-code scheme. A nil error is success (0); an *APIError maps by HTTP status (401→auth, 404→not-found, 429→rate-limited, other 4xx→validation, 5xx→server, 0→generic); any other error is generic (1). Wrapped *APIErrors are unwrapped via errors.As.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Code string
Message string
Details json.RawMessage
}
APIError is returned by Client methods when the request fails or the server returns an error envelope. StatusCode carries the HTTP status (0 for a transport-level failure); Code/Message come from the server's error object. Details carries the raw error.details payload when the server sent one (e.g. the theme generator's validation findings on a failed gate) so callers can surface the reason, not just the code.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a typed HTTP client over the /api/v1 surface. It depends only on the JSON contract (stdlib) — it imports no server internals — which is what lets the lesstruct-cli and lesstruct-mcp binaries share it. Construct it with New.
func New ¶
New builds a Client targeting baseURL authenticated with apiKey. The base URL is normalized (trailing slash trimmed) and must be an http(s) scheme + host with no userinfo and no path (the client appends /api/v1/...); rejecting a path avoids a silent double-prefix when callers proxy under a path. The returned Client follows redirects but strips the API key on cross-host hops. A default 30s per-request timeout is applied so a hung server cannot block the caller indefinitely.
func NewWithClient ¶ added in v1.4.0
NewWithClient is New with a caller-supplied HTTP client, so a transport front-end can route /api/v1 calls without a network hop (the server's /mcp endpoint dispatches them into its own router). A nil httpClient applies the same redirect policy and 30s timeout as New; a supplied client is cloned and only gains the safe cross-host redirect policy when it has none, so the caller keeps its transport, timeout, and jar.
func (*Client) CatalogGetProduct ¶
func (c *Client) CatalogGetProduct( ctx context.Context, contentID int, ) (json.RawMessage, json.RawMessage, error)
CatalogGetProduct sends GET /api/v1/catalog/products/{contentID} and returns the decoded admin commerce data and meta payloads, or an *APIError on failure. Unknown content IDs read 404 NOT_FOUND; non-admin keys read 403.
func (*Client) CatalogUpsertProduct ¶
func (c *Client) CatalogUpsertProduct( ctx context.Context, contentID int, body map[string]any, ) (json.RawMessage, json.RawMessage, error)
CatalogUpsertProduct sends PUT /api/v1/catalog/products/{contentID} with the given commerce body (the admin wire shape: price, salePrice, sku, trackInventory, stock, weightGrams, lowStockThreshold, options, variants) and returns the decoded data and meta payloads, or an *APIError on failure. The call replaces the variant matrix; callers that only change scalars should read first and resend the stored axes.
func (*Client) CreateComment ¶
func (c *Client) CreateComment( ctx context.Context, contentID int, req CreateCommentRequest, ) (json.RawMessage, json.RawMessage, error)
CreateComment POSTs a comment to /api/v1/content/{id}/comments and returns the decoded data and meta payloads, or an *APIError on failure.
func (*Client) CreateContent ¶
func (c *Client) CreateContent( ctx context.Context, req CreateContentRequest, ) (json.RawMessage, json.RawMessage, error)
CreateContent POSTs a content-create request to /api/v1/content and returns the decoded data and meta payloads, or an *APIError on failure.
func (*Client) DeleteComment ¶
func (c *Client) DeleteComment( ctx context.Context, contentID int, commentID int, ) (json.RawMessage, json.RawMessage, error)
DeleteComment sends DELETE /api/v1/content/{id}/comments/{commentId}. A 204 No Content success returns (nil, nil, nil); a 404 or other 4xx/5xx returns an *APIError. An admin key may delete any comment; a non-admin key only its own (the server returns 404 for a comment the caller does not own, no disclosure).
func (*Client) DeleteContent ¶
func (c *Client) DeleteContent( ctx context.Context, id int, ) (json.RawMessage, json.RawMessage, error)
DeleteContent sends DELETE /api/v1/content/{id}. A 204 No Content success returns (nil, nil, nil); a 404 or other 4xx/5xx returns an *APIError.
func (*Client) DeleteMedia ¶
func (c *Client) DeleteMedia( ctx context.Context, id int, ) (json.RawMessage, json.RawMessage, error)
DeleteMedia sends DELETE /api/v1/media/{id} and returns nil data and meta on success (204 No Content carries no envelope), or an *APIError on failure. Non-owners read 403; ghost ids read 404.
func (*Client) Do ¶
func (c *Client) Do( ctx context.Context, method string, path string, query url.Values, body any, ) (json.RawMessage, json.RawMessage, error)
Do sends an arbitrary JSON request with the given method to path and returns the decoded data and meta payloads, or an *APIError on failure. It is the escape hatch behind the lesstruct-mcp generic api tool and ad-hoc callers: prefer the typed methods (CreateContent, OrdersList, ...) when one exists, since they encode the endpoint's contract. The path must be an /api/v1/... route; the body, when non-nil, is marshaled as JSON.
func (*Client) ExportContent ¶
ExportContent streams the export tar.gz from GET /api/v1/export into output. output receives the raw tar.gz bytes on success; any error is an *APIError. Bounds come from DownloadOptions; the caller controls the overall deadline via ctx as well.
func (*Client) GenerateSite ¶
GenerateSite streams the SSG tar.gz from GET /api/v1/ssg into output. output receives the raw tar.gz bytes on success; any error is an *APIError. Bounds come from DownloadOptions; the caller controls the overall deadline via ctx as well.
func (*Client) GenerateTheme ¶ added in v1.5.0
func (c *Client) GenerateTheme( ctx context.Context, req GenerateThemeRequest, ) (json.RawMessage, json.RawMessage, error)
GenerateTheme sends POST /api/v1/themegen/generate and returns the decoded data ({theme, validation}) and meta payloads, or an *APIError on failure. The call uses a dedicated client with ThemeGenerateTimeout instead of the shared 30s client. On a failed validation gate the *APIError carries the final findings in Details so the caller can report the reason.
func (*Client) GetContent ¶
func (c *Client) GetContent( ctx context.Context, id int, ) (json.RawMessage, json.RawMessage, error)
GetContent sends GET /api/v1/content/{id} and returns the decoded data and meta payloads, or an *APIError on failure.
func (*Client) GetHugoImportStatus ¶
func (c *Client) GetHugoImportStatus( ctx context.Context, jobID string, ) (json.RawMessage, json.RawMessage, error)
GetHugoImportStatus sends GET /api/v1/hugo/import/status/{jobId} and returns the decoded data (containing the job status) or an *APIError on failure. When jobId is empty it fetches the most recent job.
func (*Client) GetImportStatus ¶
func (c *Client) GetImportStatus( ctx context.Context, jobID string, ) (json.RawMessage, json.RawMessage, error)
GetImportStatus sends GET /api/v1/wordpress/import/status/{jobId} and returns the decoded data (containing the job status) or an *APIError on failure. When jobId is empty it fetches the most recent job.
func (*Client) GetMedia ¶
func (c *Client) GetMedia( ctx context.Context, id int, ) (json.RawMessage, json.RawMessage, error)
GetMedia sends GET /api/v1/media/{id} and returns the decoded data and meta payloads, or an *APIError on failure.
func (*Client) ImportHugo ¶
func (c *Client) ImportHugo( ctx context.Context, req ImportHugoRequest, ) (json.RawMessage, json.RawMessage, error)
ImportHugo sends POST /api/v1/hugo/import as multipart/form-data with a `file` part (the tar.gz archive) and an optional `skipMedia` field, then returns the decoded data (containing jobId and state) or an *APIError on failure. Uses its own HTTP client without a hard timeout so large uploads succeed; the caller controls the overall deadline via ctx.
func (*Client) ImportWordPress ¶
func (c *Client) ImportWordPress( ctx context.Context, req ImportWordPressRequest, ) (json.RawMessage, json.RawMessage, error)
ImportWordPress sends POST /api/v1/wordpress/import as multipart/form-data with a `file` part and an optional `skipMedia` field, then returns the decoded data (containing jobId and state) or an *APIError on failure. Uses its own HTTP client without a hard timeout so large uploads succeed; the caller controls the overall deadline via ctx.
func (*Client) InvoiceSettingsGet ¶
func (c *Client) InvoiceSettingsGet( ctx context.Context, ) (json.RawMessage, json.RawMessage, error)
InvoiceSettingsGet sends GET /api/v1/orders/invoice-settings and returns the decoded live block (seller identity plus PPN rate) and meta payloads, or an *APIError on failure.
func (*Client) InvoiceSettingsSet ¶
func (c *Client) InvoiceSettingsSet( ctx context.Context, body map[string]any, ) (json.RawMessage, json.RawMessage, error)
InvoiceSettingsSet sends PUT /api/v1/orders/invoice-settings with the given block and returns the decoded saved block and meta payloads, or an *APIError on failure. Missing, non-finite, or out-of-range taxRate reads 400; the save applies to the next rendered invoice without a restart.
func (*Client) ListComments ¶
func (c *Client) ListComments( ctx context.Context, contentID int, ) (json.RawMessage, json.RawMessage, error)
ListComments sends GET /api/v1/content/{id}/comments and returns the decoded data (a bare array of comment projections) and meta, or an *APIError on failure.
func (*Client) ListContent ¶
func (c *Client) ListContent( ctx context.Context, limit int, cursor string, filters ListContentFilters, ) (json.RawMessage, json.RawMessage, error)
ListContent sends GET /api/v1/content?limit=&cursor=&tag=&language=&status=&post_type=&author=&search= and returns the decoded data (a bare array of content projections) and meta (with pagination), or an *APIError on failure. A limit of 0 (or negative) is passed as "no limit" (the server uses its default); an empty cursor is passed as "no cursor" (the first page). Each non-empty filter field emits its query key; an empty field is omitted entirely so the wire stays minimal. Tags is expanded into repeated ?tag= keys (one per tag) so the server can AND-of-tags.
func (*Client) ListMedia ¶
func (c *Client) ListMedia( ctx context.Context, limit int, cursor string, ) (json.RawMessage, json.RawMessage, error)
ListMedia sends GET /api/v1/media?limit=&cursor= and returns the decoded data (a bare array of media projections) and meta (with pagination), or an *APIError on failure. A limit of 0 (or negative) is passed as "no limit" (the server uses its default); an empty cursor is passed as "no cursor" (the first page).
func (*Client) OrdersGet ¶
func (c *Client) OrdersGet( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
OrdersGet sends GET /api/v1/orders/{orderID} and returns the decoded order detail (full item snapshot) and meta payloads, or an *APIError on failure. Unknown IDs read 404 NOT_FOUND; non-admin keys read 403.
func (*Client) OrdersList ¶
func (c *Client) OrdersList( ctx context.Context, status string, cursor string, ) (json.RawMessage, json.RawMessage, error)
OrdersList sends GET /api/v1/orders with optional status and cursor filters and returns the decoded data (newest-first order summaries) and meta (with pagination), or an *APIError on failure. Empty filters are omitted so the default call lists everything.
func (*Client) OrdersSetShipping ¶
func (c *Client) OrdersSetShipping( ctx context.Context, id int64, amount int64, ) (json.RawMessage, json.RawMessage, error)
OrdersSetShipping sends POST /api/v1/orders/{orderID}/shipping with the shipping line in integer minor units and returns the decoded order and meta payloads, or an *APIError on failure. Only pending orders carry shipping; settled orders refuse with 409.
func (*Client) OrdersTransition ¶
func (c *Client) OrdersTransition( ctx context.Context, id int64, status string, ) (json.RawMessage, json.RawMessage, error)
OrdersTransition sends POST /api/v1/orders/{orderID}/status with the target lifecycle status and returns the decoded order and meta payloads, or an *APIError on failure. Illegal moves read 409; "paid" is refused outright — payment confirmation is the only path into paid.
func (*Client) PaymentsGet ¶
func (c *Client) PaymentsGet( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
PaymentsGet sends GET /api/v1/payments/{paymentID} and returns the decoded payment record with its order context and meta payloads, or an *APIError on failure.
func (*Client) PaymentsList ¶
func (c *Client) PaymentsList( ctx context.Context, status string, cursor string, ) (json.RawMessage, json.RawMessage, error)
PaymentsList sends GET /api/v1/payments with optional status and cursor filters and returns the decoded data (newest-first payment records) and meta (with pagination), or an *APIError on failure. Empty filters are omitted so the default call lists everything.
func (*Client) PaymentsReject ¶
func (c *Client) PaymentsReject( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
PaymentsReject sends POST /api/v1/payments/{paymentID}/reject with an empty body and returns the decoded rejected record and meta payloads, or an *APIError on failure. The order stays pending; proofs whose order already left pending read 409 with no rejection email.
func (*Client) PaymentsVerify ¶
func (c *Client) PaymentsVerify( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
PaymentsVerify sends POST /api/v1/payments/{paymentID}/verify with an empty body and returns the decoded verified record and meta payloads, or an *APIError on failure. Decided records read 409, as do proofs whose order already left pending.
func (*Client) PublishContent ¶
func (c *Client) PublishContent( ctx context.Context, id int, ) (json.RawMessage, json.RawMessage, error)
PublishContent sends POST /api/v1/content/{id}/publish with an empty body and returns the decoded data and meta payloads, or an *APIError on failure. The server endpoint is idempotent: publishing an already-published post returns 200 with the current projection. Ownership is enforced server-side; a non-admin non-owner call returns 404 (not 403, no disclosure).
func (*Client) ReencodeMedia ¶
func (c *Client) ReencodeMedia( ctx context.Context, ) (json.RawMessage, json.RawMessage, error)
ReencodeMedia sends POST /api/v1/media/reencode with an empty body and returns the decoded data ({processed, skipped, bytesBefore, bytesAfter}) and meta payloads, or an *APIError on failure. Admin only: the server returns 403 FORBIDDEN to a non-admin key.
The run takes minutes server-side, so this call uses a dedicated client with ReencodeTimeout instead of the shared 30s client.
func (*Client) SetSystemFields ¶
func (c *Client) SetSystemFields( ctx context.Context, id int, systemFields map[string]any, ) (json.RawMessage, json.RawMessage, error)
SetSystemFields sends PUT /api/v1/content/{id}/system-fields with the given system field key/value pairs and returns the decoded data and meta payloads, or an *APIError on failure. System fields are admin-managed metadata (e.g. editorial_status, internal_notes), so the server returns 403 FORBIDDEN unless the API key belongs to an Admin; an unknown key returns ErrUnknownSystemFieldKey and a value that fails the field schema returns ErrSystemFieldValidation, both surfaced as a 400 VALIDATION_ERROR.
func (*Client) ThemeActivate ¶ added in v1.5.0
func (c *Client) ThemeActivate( ctx context.Context, name string, ) (json.RawMessage, json.RawMessage, error)
ThemeActivate sends POST /api/v1/themegen/themes/{name}/activate and returns the decoded data ({activated, requiresRestart}) and meta payloads, or an *APIError on failure. A reload failure server-side reverts the config write and surfaces here as 500 activation_failed.
func (*Client) ThemeDeactivate ¶ added in v1.5.0
func (c *Client) ThemeDeactivate( ctx context.Context, ) (json.RawMessage, json.RawMessage, error)
ThemeDeactivate sends POST /api/v1/themegen/themes/deactivate and returns the decoded data and meta payloads, or an *APIError on failure.
func (*Client) ThemeDelete ¶ added in v1.5.0
func (c *Client) ThemeDelete( ctx context.Context, name string, ) (json.RawMessage, json.RawMessage, error)
ThemeDelete sends DELETE /api/v1/themegen/themes/{name} and returns the decoded data and meta payloads, or an *APIError on failure. Deleting the active theme reads 409 theme_active.
func (*Client) ThemeDownload ¶ added in v1.5.0
func (c *Client) ThemeDownload( ctx context.Context, name string, output io.Writer, opts DownloadOptions, ) error
ThemeDownload streams GET /api/v1/themegen/themes/{name}/download into output under the caller's download bounds. The server contract caps theme zips at 2 MiB, but the policy stays uniform with export/ssg: Timeout caps the whole pull and MaxBytes caps its bytes; tripping either fails loudly.
func (*Client) ThemesList ¶ added in v1.5.0
func (c *Client) ThemesList( ctx context.Context, ) (json.RawMessage, json.RawMessage, error)
ThemesList sends GET /api/v1/themegen/themes and returns the decoded data (installed themes) and meta payloads, or an *APIError on failure.
func (*Client) UnpublishContent ¶
func (c *Client) UnpublishContent( ctx context.Context, id int, ) (json.RawMessage, json.RawMessage, error)
UnpublishContent sends POST /api/v1/content/{id}/unpublish with an empty body and returns the decoded data and meta payloads, or an *APIError on failure. The server endpoint is idempotent: unpublishing an already-draft post returns 200 with the current projection. Same ownership contract as PublishContent.
func (*Client) UpdateCommentStatus ¶
func (c *Client) UpdateCommentStatus( ctx context.Context, contentID int, commentID int, status string, ) (json.RawMessage, json.RawMessage, error)
UpdateCommentStatus sends PUT /api/v1/content/{id}/comments/{commentId}/status with the given status (approved/rejected/spam) and returns the decoded data and meta payloads, or an *APIError on failure. Admin only: the server returns 403 FORBIDDEN to a non-admin key.
func (*Client) UpdateContent ¶
func (c *Client) UpdateContent( ctx context.Context, id int, req UpdateContentRequest, ) (json.RawMessage, json.RawMessage, error)
UpdateContent sends PUT /api/v1/content/{id} with the given request body and returns the decoded data and meta payloads, or an *APIError on failure. The request body is the same shape as CreateContent. The server's update handler preserves the server-managed fields (SEO metadata — metaDescription / ogTitle / ogDescription, allowComments, translationGroupId) from the existing item, so a partial update that omits them is safe; postType / tags / language are now settable and forwarded as-given (the server validates them).
func (*Client) UploadMedia ¶
func (c *Client) UploadMedia( ctx context.Context, req UploadMediaRequest, ) (json.RawMessage, json.RawMessage, error)
UploadMedia sends POST /api/v1/media as multipart/form-data with a `file` part and an optional `metadata` JSON part, then returns the decoded data and meta payloads (the server returns 200 with the media projection in the data envelope) or an *APIError on failure.
The multipart body is buffered in memory; the server enforces its own size limit at r.ParseMultipartForm. The 204/304+envelope defenses from doRequest apply unchanged.
func (*Client) UsersApprove ¶
func (c *Client) UsersApprove( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
UsersApprove sends POST /api/v1/users/{id}/approve with an empty body and returns the decoded decision and meta payloads, or an *APIError on failure. Unverified emails and non-pending users read 409/400.
func (*Client) UsersList ¶
func (c *Client) UsersList( ctx context.Context, status string, limit int, offset int, ) (json.RawMessage, json.RawMessage, error)
UsersList sends GET /api/v1/users with optional status, limit, and offset filters and returns the decoded data (user summaries) and meta payloads, or an *APIError on failure. Empty filters are omitted.
func (*Client) UsersMarkSpam ¶
func (c *Client) UsersMarkSpam( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
UsersMarkSpam sends POST /api/v1/users/{id}/mark-spam with the confirmation body and returns the decoded decision and meta payloads, or an *APIError on failure.
func (*Client) UsersPending ¶
func (c *Client) UsersPending( ctx context.Context, ) (json.RawMessage, json.RawMessage, error)
UsersPending sends GET /api/v1/users/pending and returns the decoded registration queue and meta payloads, or an *APIError on failure.
func (*Client) UsersReject ¶
func (c *Client) UsersReject( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
UsersReject sends POST /api/v1/users/{id}/reject with the confirmation body and returns the decoded decision and meta payloads, or an *APIError on failure. Unconfirmed calls read 400.
func (*Client) UsersSoftDelete ¶
func (c *Client) UsersSoftDelete( ctx context.Context, id int64, reason string, ) (json.RawMessage, json.RawMessage, error)
UsersSoftDelete sends POST /api/v1/users/{id}/soft-delete with the confirmation body and returns the decoded decision and meta payloads, or an *APIError on failure. Unconfirmed calls read 400.
func (*Client) UsersSuspend ¶
func (c *Client) UsersSuspend( ctx context.Context, id int64, reason string, ) (json.RawMessage, json.RawMessage, error)
UsersSuspend sends POST /api/v1/users/{id}/suspend with an optional reason and returns the decoded decision and meta payloads, or an *APIError on failure. Settled states read 409.
func (*Client) UsersUnsuspend ¶
func (c *Client) UsersUnsuspend( ctx context.Context, id int64, ) (json.RawMessage, json.RawMessage, error)
UsersUnsuspend sends POST /api/v1/users/{id}/unsuspend with an empty body and returns the decoded decision and meta payloads, or an *APIError on failure.
type CreateCommentRequest ¶
type CreateCommentRequest struct {
Comment string `json:"comment"`
}
CreateCommentRequest is the agent comment-create payload. It mirrors the {data, error, meta} contract documented in docs/api-reference.md — the client hard-codes it (it cannot import the server's DTO types).
type CreateContentRequest ¶
type CreateContentRequest struct {
Title string `json:"title"`
Slug string `json:"slug,omitempty"`
Body string `json:"body"`
Format string `json:"format,omitempty"`
PostType string `json:"postType,omitempty"`
Tags []string `json:"tags,omitempty"`
Language string `json:"language,omitempty"`
IsPublished bool `json:"isPublished,omitempty"`
CustomFields map[string]any `json:"customFields,omitempty"`
TranslationGroupID *int `json:"translationGroupId,omitempty"`
}
CreateContentRequest is the agent content-create payload. It mirrors the {data, error, meta} contract documented in docs/api-reference.md — the client hard-codes it (it cannot import the server's DTO types).
All metadata fields (PostType, Tags, Language) use `omitempty` so an unset value is identical on the wire to a default-zero request. Tags must already be normalized by the caller (the CLI's normalizeTags helper trims, drops empties, and dedupes); the server re-validates via contentdomain.ValidateTags. Language is forwarded as-given — the server is the single source of truth for the configured-languages list (it returns ErrInvalidLanguage for an unknown code, mapped to 400 VALIDATION_ERROR by the CLI's exit code map).
type DownloadOptions ¶
DownloadOptions bounds a tarball download. Timeout caps the whole request (dial through body); MaxBytes caps the body size — a limit the operator can raise with --max-download-size for genuinely huge sites. Zero values mean unbounded (the historical behavior); prefer explicit bounds against untrusted servers.
type GenerateThemeRequest ¶ added in v1.5.0
type GenerateThemeRequest struct {
Description string `json:"description"`
Style string `json:"style,omitempty"`
TemplateOverrides bool `json:"templateOverrides,omitempty"`
Edition string `json:"edition,omitempty"`
}
GenerateThemeRequest is the agent theme-generate payload. It mirrors the {description, style, templateOverrides, edition} contract documented in docs/api-reference.md — the client hard-codes it (it cannot import the server's DTO types). Empty style means auto; edition "" asks for the server's default.
type ImportHugoRequest ¶
type ImportHugoRequest struct {
// File is the tar.gz archive reader.
File io.Reader
// Filename is the archive file name used in the multipart form.
Filename string
// SkipMedia, when true, tells the server to skip migrating static
// images into Lesstruct media; images stay linked to their original
// paths or URLs.
SkipMedia bool
}
ImportHugoRequest is the multipart payload sent to POST /api/v1/hugo/import. It carries a tar.gz archive of the Hugo project (containing at least a content/ directory) and an optional skipMedia flag.
type ImportJobStatus ¶
type ImportJobStatus struct {
State string `json:"state"`
Imported int `json:"imported"`
Skipped int `json:"skipped"`
UsersImported int `json:"usersImported"`
Total int `json:"total"`
Errors []string `json:"errors,omitempty"`
StartedAt string `json:"startedAt"`
FinishedAt string `json:"finishedAt,omitempty"`
}
ImportJobStatus reflects the current state of an in-flight or completed WordPress import job, mirroring the server's importJob JSON shape.
type ImportWordPressRequest ¶
type ImportWordPressRequest struct {
// File is the WXR XML file reader.
File io.Reader
// Filename is the file name used in the multipart form.
Filename string
// SkipMedia, when true, tells the server to skip downloading
// inline images and featured images during import.
SkipMedia bool
}
ImportWordPressRequest is the multipart payload sent to POST /api/v1/wordpress/import. It carries the WXR XML file and optional skipMedia flag.
type ListContentFilters ¶
type ListContentFilters struct {
Tags []string
Language string
Status string
PostType string
Author string
Search string
}
ListContentFilters is the cmd-layer projection of contentdomain.ContentFilters for the agent List endpoint. The CLI re-declares the shape (it cannot import server-internal types) so the wire contract is the source of truth, and only the fields used by the agent v1 surface are exposed here. Tags is intentionally a slice — the wire format uses repeated ?tag= keys (one per tag, AND-of-tags on the server). An empty / zero struct produces a no-filter call (server returns the unfiltered list).
type UpdateContentRequest ¶
type UpdateContentRequest struct {
Title string `json:"title"`
Body string `json:"body"`
Format string `json:"format,omitempty"`
PostType string `json:"postType,omitempty"`
Tags []string `json:"tags,omitempty"`
Language string `json:"language,omitempty"`
IsPublished bool `json:"isPublished,omitempty"`
CustomFields map[string]any `json:"customFields,omitempty"`
}
UpdateContentRequest is the agent content-update payload. It carries the same fields as CreateContentRequest because the server's PUT /api/v1/content/{id} accepts the same ContentRequest shape. The server preserves the server-managed fields (SEO metadata — metaDescription / ogTitle / ogDescription, allowComments, translationGroupId) from the existing item; the client does not surface a flag for translationGroupId on update (the server ignores it). CustomFields may be set: when non-nil it replaces the item's custom fields (preserving plugin-managed system fields); when nil the existing custom fields are preserved. The client cannot import the server's DTO types so the subset is re-declared here.
type UploadMediaRequest ¶
UploadMediaRequest is the multipart payload sent to POST /api/v1/media. It is built in memory by UploadMedia — callers supply the file reader + filename and an optional metadata map (the server reads `altText` today; the map values are passed through as typed JSON so non-string values such as numbers or booleans are accepted, even though the server currently persists only `altText`). The client validates that File is non-nil and Filename is non-empty so a bad call site fails fast with a clear error instead of a runtime panic.