Skip to main content

FabricClient

Struct FabricClient 

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

Synchronous-style Fabric API client.

Configure scoping defaults (organization_id, team_id, user_id) via set_organization_id, set_team_id, and set_user_id. Methods like list_runs auto-inject these as query params, and per-call arguments override them.

Implementations§

Source§

impl FabricClient

Source

pub async fn stream_workflow_run( &self, run_id: &str, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Stream events for a single workflow run as they happen.

Returns a stream of SseEvents. The stream terminates when the server closes the connection (typically when the run reaches a terminal state).

Internal SDK shim node events (_fabric_capture_input, _fabric_finalize_output) are hidden by default. Use Self::stream_workflow_run_with_internal when debugging the finalizer to see them.

Source

pub async fn stream_workflow_run_with_internal( &self, run_id: &str, include_internal: bool, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Same as Self::stream_workflow_run but explicitly opts in to (or out of) internal SDK shim events.

Source

pub async fn stream_job( &self, job_id: &str, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Stream events for a single job as they happen.

Hides internal SDK shim node events by default; use Self::stream_job_with_internal to opt back in.

Source

pub async fn stream_job_with_internal( &self, job_id: &str, include_internal: bool, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Same as Self::stream_job with explicit internal-shim opt-in.

Source

pub async fn stream_events( &self, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Subscribe to the global event firehose.

Hides internal SDK shim node events by default; use Self::stream_events_with_internal to opt back in.

Source

pub async fn stream_events_with_internal( &self, include_internal: bool, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Same as Self::stream_events with explicit internal-shim opt-in.

Source

pub async fn stream_provider_execute( &self, body: Value, ) -> Result<impl Stream<Item = Result<SseEvent>>>

Execute a provider and stream partial results (e.g. token-by-token LLM output).

Source§

impl FabricClient

Source

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

Create a new client authenticated with an API key.

Source

pub fn with_principal(base_url: &str, principal_id: &str) -> Result<Self>

Create a new client authenticated with a principal ID header.

Source

pub fn set_organization_id(&mut self, org_id: &str)

Set the organization ID used for scoped requests (e.g. workflow runs).

Source

pub fn set_team_id(&mut self, team_id: Option<&str>)

Set the default team ID used for scoped run queries.

Source

pub fn set_user_id(&mut self, user_id: Option<&str>)

Set the default user ID (Fabric principal UUID matching fabric_workflow_runs.created_by) used for scoped run queries.

Source

pub async fn health_check(&self) -> Result<Value>

Source

pub async fn system_status(&self) -> Result<Value>

Source

pub async fn get_me(&self) -> Result<Value>

Source

pub async fn get_my_organizations(&self) -> Result<Vec<Value>>

Source

pub async fn get_my_teams(&self) -> Result<Vec<Value>>

Source

pub async fn get_my_permissions(&self) -> Result<Vec<Value>>

Source

pub async fn create_organization(&self, slug: &str, name: &str) -> Result<Value>

Source

pub async fn list_organizations(&self) -> Result<Vec<Value>>

Source

pub async fn get_organization(&self, org_id: Option<&str>) -> Result<Value>

Get an organization by ID. Falls back to the client’s organization ID when None.

Source

pub async fn list_org_teams(&self, org_id: Option<&str>) -> Result<Vec<Value>>

List teams in an organization. Falls back to the client’s organization ID when None.

Source

pub async fn list_org_members(&self, org_id: Option<&str>) -> Result<Vec<Value>>

List members in an organization. Falls back to the client’s organization ID when None.

Source

pub async fn create_team( &self, org_id: Option<&str>, slug: &str, name: &str, ) -> Result<Value>

Create a team. Falls back to the client’s organization ID when None.

Source

pub async fn get_team(&self, team_id: &str) -> Result<Value>

Source

pub async fn create_invitation( &self, org_id: Option<&str>, email: &str, role: &str, ) -> Result<Value>

Create an invitation. Falls back to the client’s organization ID when None.

Source

pub async fn accept_invitation(&self, invitation_id: &str) -> Result<()>

Source

pub async fn revoke_invitation(&self, invitation_id: &str) -> Result<()>

Revoke an outstanding invitation. (POST to /revoke — not DELETE.)

Source

pub async fn check_permission( &self, action: &str, resource: Option<&str>, ) -> Result<bool>

Source

pub async fn check_permissions(&self, checks: Vec<Value>) -> Result<Vec<Value>>

Source

pub async fn create_api_key( &self, name: &str, org_id: Option<&str>, scopes: Option<Vec<&str>>, ) -> Result<Value>

Create an API key. Falls back to the client’s organization ID when None.

Source

pub async fn list_api_keys(&self) -> Result<Vec<Value>>

Source

pub async fn get_api_key(&self, key_id: &str) -> Result<Value>

Source

pub async fn delete_api_key(&self, key_id: &str) -> Result<()>

Source

pub async fn disable_api_key(&self, key_id: &str) -> Result<()>

Source

pub async fn rotate_api_key(&self, key_id: &str) -> Result<Value>

Source

pub async fn upsert_workflow(&self, name: &str, body: Value) -> Result<String>

Create or update a workflow in the registry.

Posts to /v1/workflow-registry. The body should match CreateRegistryRequest on the API side (name, language, source, entry_point, etc.).

Source

pub async fn list_workflows(&self) -> Result<Vec<Value>>

List workflows in the registry (hierarchical: global > org > team).

Always passes limit=500 because the API’s default of 50 silently truncates the dropdown for any installation with more than ~50 registered workflows. The API caps the value at 200 internally as of writing — passing 500 just means “give me as many as you can”. A pagination-aware variant can be added if anyone needs to scroll past page one, but no current consumer does.

Source

pub async fn run_workflow( &self, workflow_name: &str, input: Value, ) -> Result<String>

Submit a workflow run by name.

Posts to POST /v1/workflows/run?name=<workflow_name> and returns the resulting run ID immediately.

Source

pub async fn run_workflow_validated( &self, workflow_name: &str, input: Value, ) -> Result<String>

Like run_workflow with server-side input validation against the workflow’s registered input_schema (plan 038 §5). Returns 400 with per-field errors if the payload doesn’t conform. Workflows without a schema are unaffected.

Source

pub async fn run_workflow_with_variants( &self, workflow_name: &str, input: Value, variants: u16, ) -> Result<String>

Submit a workflow with variants parallel executions (1–10).

variants is part of the workflow input contract — it’s set as input.variants on the wire. This helper inserts the value into a clone of input for callers that prefer the named arg. The engine fans out N parallel runs and the run-output API always returns an outputs: [{variant_index, output, artifacts}] array, with one entry per variant.

Source

pub async fn run_regenerate( &self, workflow_name: &str, input: Value, regenerate: Regenerate, variants: Option<u16>, ) -> Result<String>

Submit a regeneration of an earlier run/variant.

Lifts the Regenerate hints into input.regenerate and the optional variants count into input.variants. The server validates the parent reference (same org, in-range variant index) and persists parent_run_id / parent_variant_index as run lineage.

Source

pub async fn run_bundle(&self, bundle: Vec<BundleEntry>) -> Result<String>

Submit a heterogeneous bundle — N different workflows running in parallel — and return the run id.

Each BundleEntry runs as its own subprocess; the engine aggregates per-entry outputs into the run’s outputs array. Use get_run_output to fetch the typed RunOutput when the run completes; each VariantOutput carries the producing sub-workflow_name and (when declared) kind. For one creative brief that should produce multiple kinds of artifact (video + carousel + thread), this is the primitive — run_workflow_with_variants is N copies of one workflow, this is N different workflows.

Source

pub async fn get_run(&self, run_id: &str) -> Result<Value>

Source

pub async fn get_run_output( &self, run_id: &str, expires_in_secs: Option<u32>, ) -> Result<RunOutput>

Fetch a run’s final output, per-task timeline, and artifacts.

Hits GET /v1/workflows/runs/{id}/output. Unlike get_run, which returns the bare fabric_workflow_runs row, this endpoint returns the workflow’s terminal output (sourced from the canonical store, falling back to Sayiir’s snapshot when the eager finalizer hasn’t run yet) along with any artifacts the workflow registered.

Returns a typed RunOutput whose outputs array always has variants entries (default 1). Each VariantOutput carries its output and the RunArtifacts produced by that variant, each with a signed download_url.

expires_in_secs controls the signed URL TTL (server clamps to [1, 86_400], defaults to 3600). u32 is used so the generated wasm-bindgen type comes out as number | null in TypeScript rather than bigint | null.

Source

pub async fn get_workflow_schemas(&self, name: &str) -> Result<Value>

Fetch the input/output/task schemas registered for a workflow.

Hits the dedicated GET /v1/workflow-schemas/{name} endpoint (plan 038 §3e) rather than pulling the whole registry entry. Returns { name, input_schema, output_schema, task_schemas, warnings } — the same shape the TypeScript SDK’s workflows.registry.getSchemas() returns.

Workflows that don’t declare Pydantic types come back with all three schema fields set to null. The call still succeeds, the consumer just learns there’s no machine-readable contract.

Source

pub async fn cancel_run(&self, run_id: &str) -> Result<()>

Source

pub async fn pause_run(&self, run_id: &str) -> Result<()>

Source

pub async fn resume_run(&self, run_id: &str) -> Result<()>

Source

pub async fn wait_for_run(&self, run_id: &str) -> Result<Value>

Source

pub async fn run_workflow_and_get_output( &self, workflow_name: &str, input: Value, expires_in_secs: Option<u32>, ) -> Result<RunOutput>

Submit a workflow, wait for it to finish, and return the full output with artifacts that have signed download URLs.

Combines run_workflow + wait_for_run + get_run_output so callers get downloadable artifact URLs in a single call.

expires_in_secs controls the signed URL TTL (default 3600, max 86400).

Source

pub async fn run_bundle_and_get_output( &self, bundle: Vec<BundleEntry>, expires_in_secs: Option<u32>, ) -> Result<RunOutput>

Submit a bundle, wait for every sub-workflow to finish, and return the typed RunOutput with one entry per bundle entry.

Source

pub async fn download_artifact(&self, download_url: &str) -> Result<Vec<u8>>

Download an artifact’s binary content using its signed download URL.

Pass a download_url from the artifacts returned by get_run_output. Returns None if the URL is empty. The signed URL requires no auth headers — it is self-contained.

Source

pub async fn list_runs( &self, organization_id: Option<&str>, team_id: Option<&str>, created_by: Option<&str>, limit: Option<i64>, offset: Option<i64>, ) -> Result<Vec<Value>>

List workflow runs scoped by org / team / creator.

Each of organization_id, team_id, and created_by falls back to the client’s configured defaults when None. To list across all users of a team without the client’s default user filter, clear the default via set_user_id(None) first.

created_by must be the Fabric principal UUID stored in fabric_workflow_runs.created_by — the same UUID that the submitter’s principal had at run submit time.

Source

pub async fn list_waiting_runs( &self, organization_id: Option<&str>, team_id: Option<&str>, created_by: Option<&str>, ) -> Result<Vec<Value>>

List workflow runs waiting for a signal (pending approvals).

Source

pub async fn cancel_run_with_reason( &self, run_id: &str, reason: Option<&str>, ) -> Result<()>

Cancel a workflow run with an optional reason.

Source

pub async fn face_swap( &self, source_url: &str, target_url: Option<&str>, persona_gallery_id: Option<&str>, ) -> Result<Value>

Run the video/face-swap workflow.

Swaps a persona face onto a source image/video. Provide either target_url (direct face URL) or persona_gallery_id (to pull from an org gallery).

Source

pub async fn motion_transfer( &self, driving_video_url: &str, source_image_url: Option<&str>, persona_gallery_id: Option<&str>, motion_model: Option<&str>, ) -> Result<Value>

Run the video/motion-transfer workflow.

Animates a persona image using a reference video’s motion (dance, gestures, expressions).

Source

pub async fn list_providers(&self) -> Result<Vec<Value>>

Source

pub async fn execute_provider(&self, body: Value) -> Result<Value>

Source

pub async fn estimate_cost(&self, body: Value) -> Result<Value>

Source

pub async fn get_org_usage(&self, org_id: Option<&str>) -> Result<Value>

Get usage summary. Falls back to the client’s organization ID when None.

Source

pub async fn get_org_usage_daily( &self, org_id: Option<&str>, ) -> Result<Vec<Value>>

Get daily usage rollup. Falls back to the client’s organization ID when None.

Source

pub async fn get_org_audit_logs( &self, org_id: Option<&str>, ) -> Result<Vec<Value>>

Get audit logs. Falls back to the client’s organization ID when None.

Source

pub async fn get_audit_logs(&self) -> Result<Vec<Value>>

Source

pub async fn create_webhook( &self, org_id: Option<&str>, url: &str, events: Vec<&str>, ) -> Result<Value>

Create a webhook subscription. Falls back to the client’s organization ID when None.

The signing secret is generated server-side and returned once in the response as data.secret. Store it securely — it cannot be retrieved again.

Source

pub async fn list_webhooks(&self, org_id: Option<&str>) -> Result<Vec<Value>>

List webhooks. Falls back to the client’s organization ID when None.

Source

pub async fn get_webhook(&self, webhook_id: &str) -> Result<Value>

Source

pub async fn delete_webhook(&self, webhook_id: &str) -> Result<()>

Source

pub async fn set_secret( &self, org_id: Option<&str>, name: &str, value: &str, ) -> Result<()>

Set a secret. Falls back to the client’s organization ID when None.

Source

pub async fn list_secrets(&self, org_id: Option<&str>) -> Result<Vec<String>>

List secrets. Falls back to the client’s organization ID when None.

Source

pub async fn delete_secret( &self, org_id: Option<&str>, name: &str, ) -> Result<()>

Delete a secret. Falls back to the client’s organization ID when None.

Source

pub async fn create_schedule( &self, workflow_definition_id: &str, cron: &str, input_context: Option<Value>, ) -> Result<Value>

Create a schedule for a workflow definition.

Note: schedules are still mounted at /v1/workflow-definitions/{id}/schedules in the current API, not /v1/workflows/{id}/schedules.

Source

pub async fn list_schedules( &self, workflow_definition_id: &str, ) -> Result<Vec<Value>>

Source

pub async fn delete_schedule(&self, schedule_id: &str) -> Result<()>

Auto Trait Implementations§

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> 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: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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