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
impl FabricClient
Sourcepub async fn stream_workflow_run(
&self,
run_id: &str,
) -> Result<impl Stream<Item = Result<SseEvent>>>
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.
Sourcepub async fn stream_workflow_run_with_internal(
&self,
run_id: &str,
include_internal: bool,
) -> Result<impl Stream<Item = Result<SseEvent>>>
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.
Sourcepub async fn stream_job(
&self,
job_id: &str,
) -> Result<impl Stream<Item = Result<SseEvent>>>
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.
Sourcepub async fn stream_job_with_internal(
&self,
job_id: &str,
include_internal: bool,
) -> Result<impl Stream<Item = Result<SseEvent>>>
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.
Sourcepub async fn stream_events(
&self,
) -> Result<impl Stream<Item = Result<SseEvent>>>
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.
Sourcepub async fn stream_events_with_internal(
&self,
include_internal: bool,
) -> Result<impl Stream<Item = Result<SseEvent>>>
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§impl FabricClient
impl FabricClient
Sourcepub fn new(base_url: &str, api_key: &str) -> Result<Self>
pub fn new(base_url: &str, api_key: &str) -> Result<Self>
Create a new client authenticated with an API key.
Sourcepub fn with_principal(base_url: &str, principal_id: &str) -> Result<Self>
pub fn with_principal(base_url: &str, principal_id: &str) -> Result<Self>
Create a new client authenticated with a principal ID header.
Sourcepub fn set_organization_id(&mut self, org_id: &str)
pub fn set_organization_id(&mut self, org_id: &str)
Set the organization ID used for scoped requests (e.g. workflow runs).
Sourcepub fn set_team_id(&mut self, team_id: Option<&str>)
pub fn set_team_id(&mut self, team_id: Option<&str>)
Set the default team ID used for scoped run queries.
Sourcepub fn set_user_id(&mut self, user_id: Option<&str>)
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.
pub async fn health_check(&self) -> Result<Value>
pub async fn system_status(&self) -> Result<Value>
pub async fn get_me(&self) -> Result<Value>
pub async fn get_my_organizations(&self) -> Result<Vec<Value>>
pub async fn get_my_teams(&self) -> Result<Vec<Value>>
pub async fn get_my_permissions(&self) -> Result<Vec<Value>>
pub async fn create_organization(&self, slug: &str, name: &str) -> Result<Value>
pub async fn list_organizations(&self) -> Result<Vec<Value>>
Sourcepub async fn get_organization(&self, org_id: Option<&str>) -> Result<Value>
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.
Sourcepub async fn list_org_teams(&self, org_id: Option<&str>) -> Result<Vec<Value>>
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.
Sourcepub async fn list_org_members(&self, org_id: Option<&str>) -> Result<Vec<Value>>
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.
Sourcepub async fn create_team(
&self,
org_id: Option<&str>,
slug: &str,
name: &str,
) -> Result<Value>
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.
pub async fn get_team(&self, team_id: &str) -> Result<Value>
Sourcepub async fn create_invitation(
&self,
org_id: Option<&str>,
email: &str,
role: &str,
) -> Result<Value>
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.
pub async fn accept_invitation(&self, invitation_id: &str) -> Result<()>
Sourcepub async fn revoke_invitation(&self, invitation_id: &str) -> Result<()>
pub async fn revoke_invitation(&self, invitation_id: &str) -> Result<()>
Revoke an outstanding invitation. (POST to /revoke — not DELETE.)
pub async fn check_permission( &self, action: &str, resource: Option<&str>, ) -> Result<bool>
pub async fn check_permissions(&self, checks: Vec<Value>) -> Result<Vec<Value>>
Sourcepub async fn create_api_key(
&self,
name: &str,
org_id: Option<&str>,
scopes: Option<Vec<&str>>,
) -> Result<Value>
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.
pub async fn list_api_keys(&self) -> Result<Vec<Value>>
pub async fn get_api_key(&self, key_id: &str) -> Result<Value>
pub async fn delete_api_key(&self, key_id: &str) -> Result<()>
pub async fn disable_api_key(&self, key_id: &str) -> Result<()>
pub async fn rotate_api_key(&self, key_id: &str) -> Result<Value>
Sourcepub async fn upsert_workflow(&self, name: &str, body: Value) -> Result<String>
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.).
Sourcepub async fn list_workflows(&self) -> Result<Vec<Value>>
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.
Sourcepub async fn run_workflow(
&self,
workflow_name: &str,
input: Value,
) -> Result<String>
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.
Sourcepub async fn run_workflow_validated(
&self,
workflow_name: &str,
input: Value,
) -> Result<String>
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.
Sourcepub async fn run_workflow_with_variants(
&self,
workflow_name: &str,
input: Value,
variants: u16,
) -> Result<String>
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.
Sourcepub async fn run_regenerate(
&self,
workflow_name: &str,
input: Value,
regenerate: Regenerate,
variants: Option<u16>,
) -> Result<String>
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.
Sourcepub async fn run_bundle(&self, bundle: Vec<BundleEntry>) -> Result<String>
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.
pub async fn get_run(&self, run_id: &str) -> Result<Value>
Sourcepub async fn get_run_output(
&self,
run_id: &str,
expires_in_secs: Option<u32>,
) -> Result<RunOutput>
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.
Sourcepub async fn get_workflow_schemas(&self, name: &str) -> Result<Value>
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.
pub async fn cancel_run(&self, run_id: &str) -> Result<()>
pub async fn pause_run(&self, run_id: &str) -> Result<()>
pub async fn resume_run(&self, run_id: &str) -> Result<()>
pub async fn wait_for_run(&self, run_id: &str) -> Result<Value>
Sourcepub async fn run_workflow_and_get_output(
&self,
workflow_name: &str,
input: Value,
expires_in_secs: Option<u32>,
) -> Result<RunOutput>
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).
Sourcepub async fn run_bundle_and_get_output(
&self,
bundle: Vec<BundleEntry>,
expires_in_secs: Option<u32>,
) -> Result<RunOutput>
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.
Sourcepub async fn download_artifact(&self, download_url: &str) -> Result<Vec<u8>>
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.
Sourcepub 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>>
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.
Sourcepub async fn list_waiting_runs(
&self,
organization_id: Option<&str>,
team_id: Option<&str>,
created_by: Option<&str>,
) -> Result<Vec<Value>>
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).
Sourcepub async fn cancel_run_with_reason(
&self,
run_id: &str,
reason: Option<&str>,
) -> Result<()>
pub async fn cancel_run_with_reason( &self, run_id: &str, reason: Option<&str>, ) -> Result<()>
Cancel a workflow run with an optional reason.
Sourcepub async fn face_swap(
&self,
source_url: &str,
target_url: Option<&str>,
persona_gallery_id: Option<&str>,
) -> Result<Value>
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).
Sourcepub 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>
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).
pub async fn list_providers(&self) -> Result<Vec<Value>>
pub async fn execute_provider(&self, body: Value) -> Result<Value>
pub async fn estimate_cost(&self, body: Value) -> Result<Value>
Sourcepub async fn get_org_usage(&self, org_id: Option<&str>) -> Result<Value>
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.
Sourcepub async fn get_org_usage_daily(
&self,
org_id: Option<&str>,
) -> Result<Vec<Value>>
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.
Sourcepub async fn get_org_audit_logs(
&self,
org_id: Option<&str>,
) -> Result<Vec<Value>>
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.
pub async fn get_audit_logs(&self) -> Result<Vec<Value>>
Sourcepub async fn create_webhook(
&self,
org_id: Option<&str>,
url: &str,
events: Vec<&str>,
) -> Result<Value>
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.
Sourcepub async fn list_webhooks(&self, org_id: Option<&str>) -> Result<Vec<Value>>
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.
pub async fn get_webhook(&self, webhook_id: &str) -> Result<Value>
pub async fn delete_webhook(&self, webhook_id: &str) -> Result<()>
Sourcepub async fn set_secret(
&self,
org_id: Option<&str>,
name: &str,
value: &str,
) -> Result<()>
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.
Sourcepub async fn list_secrets(&self, org_id: Option<&str>) -> Result<Vec<String>>
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.
Sourcepub async fn delete_secret(
&self,
org_id: Option<&str>,
name: &str,
) -> Result<()>
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.
Sourcepub async fn create_schedule(
&self,
workflow_definition_id: &str,
cron: &str,
input_context: Option<Value>,
) -> Result<Value>
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.