Skip to main content

FuncspecClient

Struct FuncspecClient 

Source
pub struct FuncspecClient { /* private fields */ }
Expand description

FuncSpec API client.

Implementations§

Source§

impl FuncspecClient

Source

pub fn new(base_url: &str, api_key: &str) -> Result<Self, Error>

Create a new client for the given host and API key.

Source

pub fn with_timeout( base_url: &str, api_key: &str, timeout: Duration, ) -> Result<Self, Error>

Create a client with a custom request timeout.

Source

pub async fn validate_auth(&self) -> Result<UserInfo, Error>

Validate the API key and return user/org info.

Source

pub async fn list_projects(&self) -> Result<Vec<Project>, Error>

Source

pub async fn list_projects_paged( &self, page: u32, per_page: u32, ) -> Result<PagedResponse<Project>, Error>

Source

pub async fn get_project(&self, slug_or_id: &str) -> Result<Project, Error>

Source

pub async fn create_project( &self, params: &CreateProjectParams, ) -> Result<Project, Error>

Source

pub async fn delete_project(&self, slug_or_id: &str) -> Result<(), Error>

Source

pub async fn list_items( &self, project_id: u64, filter: &ItemFilter, ) -> Result<(Vec<SpecItem>, Option<PaginationMeta>), Error>

Source

pub async fn list_items_paged( &self, project_id: u64, filter: &ItemFilter, page: u32, per_page: u32, ) -> Result<PagedResponse<SpecItem>, Error>

Source

pub async fn list_all_items( &self, project_id: u64, filter: &ItemFilter, ) -> Result<Vec<SpecItem>, Error>

Fetch every item matching filter by walking all pages to exhaustion.

The server caps per at 100, so a large project needs several round-trips. This loops list_items_paged using the pagination meta’s total_pages (falling back to “stop on a short page”) so callers get the complete set in one call.

Source

pub async fn search_items( &self, project_id: u64, query: &str, filter: &ItemFilter, ) -> Result<PagedResponse<SpecItem>, Error>

Search spec items by full-text query, with optional type/tag filters.

Calls GET /projects/{project_id}/spec/items?q=[&type_of=…][&tag=…]

Source

pub async fn resolve_item_id( &self, project_id: u64, id_or_permalink: &str, ) -> Result<u64, Error>

Resolve an item identifier to a numeric ID.

Accepts either a numeric ID (passed through) or a permalink like F-123 / T-456. Permalinks are resolved by paginating through items until found.

Source

pub async fn get_item( &self, project_id: u64, id_or_permalink: &str, ) -> Result<SpecItem, Error>

Source

pub async fn create_item( &self, project_id: u64, params: &CreateItemParams, ) -> Result<SpecItem, Error>

Source

pub async fn update_item( &self, project_id: u64, item_id: u64, params: &UpdateItemParams, ) -> Result<SpecItem, Error>

Source

pub async fn delete_item( &self, project_id: u64, item_id: u64, ) -> Result<(), Error>

Source

pub async fn deprecate_item( &self, project_id: u64, permalink: &str, reason: Option<&str>, confirm: bool, ) -> Result<(), Error>

Mark a spec item out-of-scope (deprecated). Optional reason; confirm=true is required by the server when the item has active children (cascade). POST /projects/:pid/spec/items/:permalink/deprecate

Source

pub async fn undeprecate_item( &self, project_id: u64, permalink: &str, ) -> Result<(), Error>

Restore a previously out-of-scope (deprecated) spec item to active scope. POST /projects/:pid/spec/items/:permalink/undeprecate

Source

pub async fn transition_item_state( &self, project_id: u64, permalink: &str, state: &str, ) -> Result<SpecItem, Error>

Transition a spec item’s workflow state.

Valid states: inbox, draft, accepted, integrated. Allowed transitions: inbox→draft, draft→accepted/inbox, accepted→integrated/draft, integrated→accepted.

Calls POST /projects/:project_id/spec/items/:permalink/transition.

Source

pub async fn list_reviews( &self, spec_item_id: u64, ) -> Result<Vec<Review>, Error>

Source

pub async fn create_review( &self, spec_item_id: u64, params: &CreateReviewParams, ) -> Result<Review, Error>

Source

pub async fn list_jobs(&self) -> Result<Vec<Job>, Error>

Source

pub async fn get_job(&self, project_id: u64, job_id: u64) -> Result<Job, Error>

Source

pub async fn review_item( &self, project_id: u64, item_id: u64, ) -> Result<Review, Error>

Trigger AI review of a single spec item.

Calls POST /projects/:project_id/work_package/:item_id/review.

Source

pub async fn review_all(&self, project_id: u64) -> Result<u64, Error>

Trigger batch AI review of all items in a project.

Calls POST /projects/:project_id/work_package/review_all and returns an async Job that can be polled via [poll_job_until_done].

Source

pub async fn propose_improvement( &self, project_id: u64, item_id: u64, ) -> Result<Proposal, Error>

Propose an AI-generated improvement for a spec item.

Calls POST /projects/:project_id/work_package/:item_id/propose.

Source

pub async fn accept_proposal( &self, project_id: u64, item_id: u64, ) -> Result<(), Error>

Accept a pending improvement proposal for a spec item.

Calls POST /projects/:project_id/work_package/:item_id/accept.

Source

pub async fn reject_proposal( &self, project_id: u64, item_id: u64, ) -> Result<(), Error>

Reject a pending improvement proposal for a spec item.

Calls POST /projects/:project_id/work_package/:item_id/reject.

Source

pub async fn generate_tech( &self, project_id: u64, item_id: u64, ) -> Result<TechProposals, Error>

Generate technical spec proposals from a functional spec item.

Calls POST /projects/:project_id/work_package/:item_id/generate_tech.

Source

pub async fn audit_item( &self, project_id: u64, item_id: u64, ) -> Result<AuditResult, Error>

Run a code audit for a spec item.

Calls POST /projects/:project_id/work_package/:item_id/audit.

Source

pub async fn get_project_job( &self, project_id: u64, job_id: u64, ) -> Result<Job, Error>

Fetch a job by ID within a project context.

Calls GET /projects/:project_id/jobs/:job_id.

Source

pub async fn poll_job_until_done( &self, project_id: u64, job_id: u64, timeout: Duration, ) -> Result<Job, Error>

Poll a job until it reaches a terminal state (Completed or Failed).

Returns the final Job on completion, or Error::Timeout if timeout elapses before the job finishes. Polls every 500 ms.

Source

pub async fn transition_item_implementation( &self, project_id: u64, item_id: u64, status: &str, ) -> Result<(), Error>

Transition an item’s implementation status one step at a time. API: POST /projects/:project_id/spec/items/:item_id/transition_implementation

Associate a git commit with a spec item. API: POST /projects/:project_id/work_package/:item_id/link_commit

Source

pub async fn record_run( &self, project_id: u64, item_id: u64, params: &RecordRunParams, ) -> Result<Option<u64>, Error>

Record an agent run against a spec item. Returns the run ID if the API provides one. API: POST /projects/:project_id/work_package/:item_id/record_run

Source

pub async fn review_item_functional( &self, project_id: u64, item_id: u64, ) -> Result<Review, Error>

Trigger a functional AI review for a spec item. API: POST /projects/:project_id/work_package/:item_id/func_review

Source

pub async fn list_usage(&self) -> Result<Vec<UsageLogEntry>, Error>

Source

pub async fn get_project_stats( &self, project_id: u64, release_version: Option<&str>, ) -> Result<ProjectStats, Error>

Fetch aggregated dashboard stats for a project.

When release_version is Some, the server scopes every figure (item counts, reviews, verdicts, coverage) to that version’s member items. The response type becomes release_version_stats.

Source

pub async fn get_usage_logs( &self, project_id: u64, filter: &UsageFilter, ) -> Result<PagedResponse<UsageLogEntry>, Error>

Fetch LLM usage logs for a project (flat rows, no JSON:API wrapper).

Source

pub async fn get_usage_stats( &self, project_id: u64, year: Option<i32>, month: Option<u32>, ) -> Result<UsageStats, Error>

Fetch LLM usage summary for a project (flat JSON, no JSON:API wrapper). Pass year and month as integers to filter; defaults to the current month.

Source

pub async fn export_project( &self, project_id: u64, format: &str, item_type: Option<&str>, tag: Option<&str>, release_version: Option<&str>, ) -> Result<ExportData, Error>

Export a project spec in the specified format.

Text formats (markdown, json, csv, html) return ExportData::Text. Binary formats (pdf, docx) return ExportData::Binary.

Optional item_type ("functional" / "technical") and tag filters are forwarded as query parameters to the API.

Source

pub async fn get_viewable_html(&self, project_id: u64) -> Result<String, Error>

Fetch the viewable HTML spec for a project.

Calls GET /projects/:id/spec/view and returns the response body as a UTF-8 string.

Source

pub async fn list_snapshots( &self, project_id: u64, ) -> Result<Vec<Snapshot>, Error>

List all snapshots for a project.

Calls GET /projects/:project_id/snapshots.

Source

pub async fn create_snapshot( &self, project_id: u64, params: &CreateSnapshotParams, ) -> Result<Snapshot, Error>

Create a new snapshot for a project.

Calls POST /projects/:project_id/snapshots.

Source

pub async fn get_snapshot( &self, project_id: u64, snapshot_id: u64, ) -> Result<Snapshot, Error>

Get a single snapshot by ID.

Calls GET /projects/:project_id/snapshots/:snapshot_id.

Source

pub async fn restore_snapshot( &self, project_id: u64, snapshot_id: u64, ) -> Result<(), Error>

Restore project to the state captured in a snapshot.

Calls POST /projects/:project_id/snapshots/:snapshot_id/restore.

Source

pub async fn delete_snapshot( &self, project_id: u64, snapshot_id: u64, ) -> Result<(), Error>

Delete a snapshot.

Calls DELETE /projects/:project_id/snapshots/:snapshot_id.

Source

pub async fn diff_snapshot( &self, project_id: u64, snapshot_id: u64, ) -> Result<SnapshotDiff, Error>

Get the diff between a snapshot and the current project state.

Calls GET /projects/:project_id/snapshots/:snapshot_id/diff.

Source

pub async fn list_edges( &self, project_id: u64, source_id: Option<u64>, target_id: Option<u64>, edge_type: Option<&str>, ) -> Result<Vec<DependencyEdge>, Error>

List dependency edges for a project, with optional filters.

Calls GET /projects/:project_id/graph/edges.

Source

pub async fn create_edge( &self, project_id: u64, params: &CreateEdgeParams, ) -> Result<DependencyEdge, Error>

Create a dependency edge between two spec items.

Calls POST /projects/:project_id/graph/edges.

Source

pub async fn get_edge( &self, project_id: u64, edge_id: u64, ) -> Result<DependencyEdge, Error>

Get a single dependency edge by ID.

Calls GET /projects/:project_id/graph/edges/:id.

Source

pub async fn delete_edge( &self, project_id: u64, edge_id: u64, ) -> Result<(), Error>

Delete a dependency edge by ID.

Calls DELETE /projects/:project_id/graph/edges/:id.

Source

pub async fn get_org_slug(&self) -> Result<String, Error>

Return the org slug for the authenticated user.

Calls GET /settings which returns data.attributes.slug.

Source

pub async fn get_agent_instructions( &self, project_slug: &str, ) -> Result<Value, Error>

Fetch live agent instructions for a project.

Calls GET /projects/:project_slug/agent_instructions and returns the raw JSON response. Callers extract content for display or use the full value for --raw output.

Source

pub async fn list_runs( &self, project_id: u64, page: u32, per: u32, ) -> Result<(Vec<AuditRun>, Option<PaginationMeta>), Error>

Source

pub async fn preview_run( &self, project_id: u64, params: &CreateRunParams, ) -> Result<RunPreview, Error>

Resolve filter criteria into the matching item set without creating a run.

Source

pub async fn create_run( &self, project_id: u64, params: &CreateRunParams, ) -> Result<AuditRun, Error>

Source

pub async fn get_run( &self, project_id: u64, run_id: u64, page: u32, per: u32, ) -> Result<AuditRun, Error>

Source

pub async fn update_run( &self, project_id: u64, run_id: u64, params: &UpdateRunParams, ) -> Result<AuditRun, Error>

Source

pub async fn start_run( &self, project_id: u64, run_id: u64, ) -> Result<AuditRun, Error>

Source

pub async fn pause_run( &self, project_id: u64, run_id: u64, ) -> Result<AuditRun, Error>

Source

pub async fn resume_run( &self, project_id: u64, run_id: u64, ) -> Result<AuditRun, Error>

Source

pub async fn cancel_run( &self, project_id: u64, run_id: u64, ) -> Result<AuditRun, Error>

Source

pub async fn delete_run( &self, project_id: u64, run_id: u64, ) -> Result<(), Error>

Source

pub async fn add_items_to_version( &self, project_id: u64, version: &str, spec_item_keys: &[String], ) -> Result<(), Error>

Add one or more spec items to a release version (by semver or id). Items are identified by permalink (e.g. “T-414”) or numeric id. F-517 membership: POST /projects/:pid/release_versions/:ver/items

Source

pub async fn remove_item_from_version( &self, project_id: u64, version: &str, spec_item_key: &str, ) -> Result<(), Error>

Remove a spec item from a release version (by semver or id). DELETE /projects/:pid/release_versions/:ver/items/:spec_item_key

Source

pub async fn diff_versions( &self, project_id: u64, version: &str, other: &str, ) -> Result<VersionDiff, Error>

T-509: diff two release versions by membership. GET /projects/:pid/release_versions/:ver/diff/:other

Source

pub async fn clone_version( &self, project_id: u64, version: &str, semver: &str, name: Option<&str>, description: Option<&str>, branch: Option<&str>, ) -> Result<ReleaseVersion, Error>

T-509: clone a release version into a new one (copies memberships). POST /projects/:pid/release_versions/:ver/clone

Source

pub async fn delete_version( &self, project_id: u64, version: &str, ) -> Result<(), Error>

Delete a release version (does not delete its member items). DELETE /projects/:pid/release_versions/:ver

Source

pub async fn create_version( &self, project_id: u64, semver: &str, name: Option<&str>, description: Option<&str>, branch: Option<&str>, ) -> Result<ReleaseVersion, Error>

Create a new release version from scratch (F-503). POST /projects/:pid/release_versions { release_version: { semver, name, description, branch } }

Source

pub async fn update_version( &self, project_id: u64, version: &str, semver: Option<&str>, name: Option<&str>, description: Option<&str>, branch: Option<&str>, ) -> Result<ReleaseVersion, Error>

Update a release version’s metadata (F-503). PATCH /projects/:pid/release_versions/:ver { release_version: { name, semver, description, branch } } Only supplied fields are sent (and thus changed).

Source

pub async fn transition_version( &self, project_id: u64, version: &str, lifecycle_state: &str, ) -> Result<ReleaseVersion, Error>

Step a release version’s lifecycle (F-503): planned -> in_progress -> shipped. POST /projects/:pid/release_versions/:ver/transition { lifecycle_state }

Source

pub async fn move_item_in_version( &self, project_id: u64, version: &str, spec_item_key: &str, position: i64, ) -> Result<ReleaseVersion, Error>

Reorder a member item within a release version (F-503 ordered membership). PATCH /projects/:pid/release_versions/:ver/items/:spec_item_key { position }

Source

pub async fn list_versions( &self, project_id: u64, ) -> Result<Vec<ReleaseVersion>, Error>

List all release versions for a project. GET /projects/:pid/release_versions

Source

pub async fn get_version( &self, project_id: u64, version: &str, include_deprecated: bool, ) -> Result<ReleaseVersion, Error>

Fetch one release version (by semver or id) WITH its member items. GET /projects/:pid/release_versions/:ver[?include_deprecated=true]

Source

pub async fn report_implementation( &self, project_id: u64, report: &ImplementationReport, ) -> Result<ImplementationReportResult, Error>

T-511: batch implementation report-back ingest. Posts a structured report (items with status/drift/notes + newly-created items) to the server’s implementation_reports endpoint, which records drift history and steps each item’s implementation status via the state machine. POST /projects/:pid/implementation_reports

Source

pub async fn preview_import( &self, project_id: u64, raw_body: &str, ) -> Result<ImportPreview, Error>

Validate a CSV or JSON import file without committing.

Sends the raw file contents to POST /projects/:id/import/preview. The server detects the format (CSV vs JSON) from the body content and returns a preview with counts, duplicate titles, parsed items, and warnings.

Source

pub async fn commit_import( &self, project_id: u64, items: &[ImportItem], ) -> Result<ImportResult, Error>

Commit a set of parsed import items, creating spec items in the project.

Calls POST /projects/{project_id}/import/commit with JSON body {{"items":[...]}}. Returns an ImportResult with the count of created items and their permalinks. NOTE: the commit endpoint does not accept a release version — use add_items_to_version after commit to assign the created items.

Source

pub async fn upload_document( &self, project_id: u64, filename: &str, mime_type: &str, bytes: Vec<u8>, ) -> Result<DocumentUpload, Error>

Upload a raw document (PDF / DOCX / Markdown / text) to start an import session. POST /projects/:id/import/upload (multipart field file).

Source

pub async fn start_extract( &self, project_id: u64, session_id: u64, ) -> Result<ImportStageStarted, Error>

Queue pass-1 extraction. POST .../import/sessions/:sid/extract (202). A 409 (invalid_state) means a run is already in progress.

Source

pub async fn start_enrich( &self, project_id: u64, session_id: u64, ) -> Result<ImportStageStarted, Error>

Queue the optional pass-2 enrichment. POST .../import/sessions/:sid/enrich (202).

Source

pub async fn poll_import_session( &self, project_id: u64, session_id: u64, ) -> Result<ImportSession, Error>

Fetch a document import session’s status, candidate items, cost and errors. GET /projects/:id/import/sessions/:sid.

Source

pub async fn commit_import_session( &self, project_id: u64, session_id: u64, items: Option<&[DocumentImportItem]>, ) -> Result<DocumentImportCommit, Error>

Commit a reviewed session, creating spec items. POST .../import/sessions/:sid/commit. With items: None the server commits the session’s extracted items; otherwise items with included: Some(false) are skipped.

Source

pub async fn list_repositories( &self, project_id: u64, ) -> Result<Vec<ProjectRepository>, Error>

Source

pub async fn get_repository( &self, project_id: u64, repo_id: u64, ) -> Result<ProjectRepository, Error>

Source

pub async fn create_repository( &self, project_id: u64, params: &CreateRepositoryParams, ) -> Result<ProjectRepository, Error>

Source

pub async fn update_repository( &self, project_id: u64, repo_id: u64, params: &UpdateRepositoryParams, ) -> Result<ProjectRepository, Error>

Source

pub async fn delete_repository( &self, project_id: u64, repo_id: u64, ) -> Result<(), Error>

Source

pub async fn sync_repository( &self, project_id: u64, repo_id: u64, ) -> Result<ProjectRepository, Error>

Source

pub async fn set_primary_repository( &self, project_id: u64, repo_id: u64, ) -> Result<ProjectRepository, Error>

Trait Implementations§

Source§

impl Clone for FuncspecClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for FuncspecClient

§

impl !UnwindSafe for FuncspecClient

§

impl Forget for FuncspecClient

§

impl Freeze for FuncspecClient
where *const ArcInner<ClientRef> is !null: Freeze, PhantomData<ArcInner<ClientRef>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for FuncspecClient

§

impl Send for FuncspecClient
where Arc<ClientRef>: Send, RawVecInner: Send,

§

impl Sync for FuncspecClient
where Arc<ClientRef>: Sync, RawVecInner: Sync,

§

impl Unpin for FuncspecClient
where Arc<ClientRef>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for FuncspecClient
where *const ArcInner<ClientRef> is !null: UnsafeUnpin, PhantomData<ArcInner<ClientRef>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more