prefactor_http.client module
prefactor_http.client module
Section titled “prefactor_http.client module”HTTP client for Prefactor API.
class prefactor_http.client.PrefactorHttpClient(config: HttpClientConfig, sdk_header: str | None = None)
Section titled “class prefactor_http.client.PrefactorHttpClient(config: HttpClientConfig, sdk_header: str | None = None)”Bases: object
Main HTTP client for interacting with the Prefactor API.
This client provides high-level methods for all API endpoints with built-in retry logic, error handling, and idempotency support.
Usage: : async with PrefactorHttpClient(config) as client: : instance = await client.agent_instances.register(…) span = await client.agent_spans.create(…)
property agent_instances : AgentInstanceClient
Section titled “property agent_instances : AgentInstanceClient”Access the agent instance endpoint client.
Provides methods to interact with agent instances:
- register: Create a new agent instance
- start: Mark an instance as started
- finish: Mark an instance as finished
Example
Section titled “Example”instance = await client.agent_instances.register(agent_id, agent_version)
property agent_spans : AgentSpanClient
Section titled “property agent_spans : AgentSpanClient”Access the agent span endpoint client.
Provides methods to interact with agent spans:
- create: Create a new agent span
- finish: Mark a span as finished
Example
Section titled “Example”span = await client.agent_spans.create( : agent_instance_id, schema_name, payload
)
property bulk : BulkClient
Section titled “property bulk : BulkClient”Access the bulk endpoint client.
Provides methods to execute multiple queries/actions in a single request:
- execute: Execute bulk operations
Example
Section titled “Example”response = await client.bulk.execute(bulk_request)
async close() → None
Section titled “async close() → None”Close the HTTP session.
async request(method: str, path: str, , params: dict[str, Any] | None = None, json_data: dict[str, Any] | None = None, idempotency_key: str | None = None) → dict[str, Any]
Section titled “async request(method: str, path: str, , params: dict[str, Any] | None = None, json_data: dict[str, Any] | None = None, idempotency_key: str | None = None) → dict[str, Any]”Make an HTTP request with retry logic.
This is the public request method that wraps the core request with retry handling.
- Parameters:
- method – HTTP method (GET, POST, PUT, DELETE).
- path – API path.
- params – Query parameters.
- json_data – JSON body data.
- idempotency_key – Optional idempotency key.
- Returns: Parsed JSON response.
- Raises:
- PrefactorRetryExhaustedError – When retries are exhausted.
- PrefactorApiError – On API errors.