Overview
PlaneClient is an HTTP client for interacting with self-hosted Plane instances. It provides methods for creating issues, updating issue state, and adding comments. Used by Magpie to track pipeline runs as Plane work items.
Configuration
PlaneConfig
Base URL of the Plane instance (e.g.,
https://plane.example.com).API key for authentication. Sent as
X-API-Key header.Workspace identifier (e.g.,
my-workspace).Project identifier (e.g.,
proj-abc).IssueUpdate
None values are sent to the API.
Client Creation
Create a new PlaneClient instance.Parameters:
config- Plane configuration with base URL, API key, workspace, and project
Ok(PlaneClient)- Configured client ready for useErr(_)- If API key is invalid or client creation fails
Methods
Create a new work item. Returns the issue ID.Parameters:
title- Issue title (plain text)description_html- Issue description in HTML format
Ok(String)- The created issue IDErr(_)- If creation fails (network error, authentication, etc.)
POST {base_url}/api/v1/workspaces/{workspace}/projects/{project}/work-items/Example:Update an existing issue with partial fields.Parameters:
issue_id- The issue ID to updateupdate- Partial update fields (only non-None fields are sent)
Ok(())- Update successfulErr(_)- If update fails
PATCH {base_url}/api/v1/workspaces/{workspace}/projects/{project}/work-items/{issue_id}/Example:Add a comment to an issue.Parameters:
issue_id- The issue ID to comment onbody_html- Comment body in HTML format
Ok(())- Comment added successfullyErr(_)- If adding comment fails
POST {base_url}/api/v1/workspaces/{workspace}/projects/{project}/issues/{issue_id}/comments/Example:Complete Example
Usage in Pipeline
ThePlaneClient is integrated into the pipeline to track progress:
Error Handling
All methods returnanyhow::Result for flexible error handling. The client:
- Returns errors for non-2xx HTTP status codes with response body details
- Validates API key format during client creation
- Includes context in errors (e.g., “Plane create_issue failed (500): error details”)
Design Notes
- All HTTP requests include
X-API-KeyandContent-Type: application/jsonheaders - Built on
reqwestwith default headers configured at client creation - Serialization uses
serde_jsonwithskip_serializing_iffor optional fields - Issue IDs are returned as strings (Plane uses UUID format)
- HTML descriptions allow rich formatting in the Plane UI