CareflowDocumentation

Python SDK Change Log

All notable changes to this project will be documented in this file.

[4.0.0] - 2026-10-14

Changed

  • get_deployment() now matches the renamed catalogue keys: DeploymentModel.images is now artifacts, and DeploymentImage, DeploymentImageTopics and DeploymentImageConfiguration are now DeploymentArtifact, DeploymentArtifactTopics and DeploymentArtifactConfiguration. DeploymentArtifact.artifact_id replaces image_id.

Removed

  • DeploymentImage.deployment_image_id. The backend no longer returns it; use deployment_instance_id.
  • PipelineCommand.STATUS_GET, deprecated in 3.0.0; use PipelineCommand.RUN_STATUS.

[3.0.0] - 2026-09-28

Added

  • PipelineCommand.DEPLOYMENT_STATUS (pipeline.deployment.status) and PipelineCommand.ARTIFACT_GET (pipeline.artifact.get), the controller server's single-pipeline status and artifact-file download commands. Both take deployment_instance_uuid in parameters; ARTIFACT_GET also takes config_file, one of the names DEPLOYMENT_STATUS returns under artifact_files, and returns the file base64-encoded in result.content. As before, plain strings work equally and nothing validates against the enum.
  • PipelineCommand.RUN_STATUS (pipeline.run.status), the run-state command's current name.

Changed

  • DeploymentStorage.storage_type and database_type are now the StorageType and DatabaseType StrEnums instead of strings. Unrecognised values parse as UNKNOWN.

Deprecated

  • PipelineCommand.STATUS_GET. The broker renamed pipeline.status.get to pipeline.run.status and no longer serves the old name, so the member is now an alias of RUN_STATUS: existing code keeps working and sends the live command, PipelineCommand.STATUS_GET is PipelineCommand.RUN_STATUS, and it no longer appears when iterating the enum. It will be removed in the next major release.
  • client.app.publish, subscribe and flush; use client.connector instead. They now call the connector service, so they require connector_base_url, connector_secret and mTLS settings, and emit a DeprecationWarning (plus a logged warning on first use). Return types are unchanged, but subscribe now returns one connector page per call instead of every waiting record.

Removed

  • client.app.control and get_stream_url, with ControlRequestModel, GetStreamUrlRequestModel and StreamUrlData. get_stream_url's endpoint never existed; control had no deployed consumer.

[2.0.2] - 2026-09-16

Fixed

  • Environment variables that are set but blank now read as "not configured" rather than as the empty string. A deployment that emits a key for every option, valued or not, previously broke every connector request with CA bundle not found at path: (note the empty path) while App requests kept working, because only connector requests read the CA bundle. Blank CAREFLOW_SDK_CA_BUNDLE_PATH, CAREFLOW_SDK_CLIENT_CERT_PATH and CAREFLOW_SDK_CLIENT_KEY_PATH are now unset, and surrounding whitespace is stripped from all three. Matches the .NET SDK, which runs these through string.IsNullOrWhiteSpace.
  • CAREFLOW_SDK_VERIFY_SSL, CAREFLOW_SDK_TIMEOUT and CAREFLOW_SDK_MAX_RETRY_COUNT fall back to their defaults when blank or malformed instead of raising CareflowInvalidDataError, so a bad value can no longer stop a client from starting. The rejected value is logged at WARNING on the careflow_sdk logger, so a typo is visible rather than silent. Matches the .NET SDK's TryParse-with-default reads.
  • Connector requests with verify_ssl=False no longer read ca_bundle_path at all: with verification off the bundle would never be consulted, so a configured-but-unresolvable path can no longer fail a request that .NET sends happily (it checks !VerifySsl before loading the bundle).

[2.0.1] - 2026-09-16

Changed

  • App and pipeline requests are now signed by default: require_signing defaults to True on AppRequestModel (and therefore every App request model plus PipelineExecuteRequestModel), and on pipeline.execute(...). The controller rejects unsigned App requests, so the previous False default produced requests that could not succeed; callers who were passing require_signing=True explicitly are unaffected. Pass require_signing=False to suppress the HMAC headers and exercise the rejection path. Signing resolves client_id/client_secret, so a client configured without them now raises CareflowInvalidDataError when the request is built rather than being rejected by the broker. Matches the same change in the .NET SDK.

[2.0.0] - 2026-09-13

Changed

  • Breaking: the HTTP layer moved from requests to httpx2. The session option is gone from ClientOptions (which is now inert configuration holding no live resources); to customize the transport (proxy, TLS, test stubbing), pass a pre-configured httpx2.Client via CareflowClient(options, http_client=...) — it is used as-is for every request and never closed by the SDK. Transport failures still raise CareflowIOError/CareflowSslError, but the wrapped cause is now an httpx2 exception.
  • Request models are inert: sending a request no longer mutates the model (prepare() and the internal wire-state caching are gone), so one model instance can be reused safely across retries, threads, and clients. The pipeline is split into a pure request builder, a single-attempt transport, and response processing, with the retry loop in the client.
  • Breaking: client.streaming.connect() now returns the gateway's wsgateway.WSGatewayStream directly (backed by wsgateway 2.0's stream()) instead of a bare async iterator. Existing async for msg in connect(...) loops are unaffected; the returned stream is also an async context manager and adds close() for a graceful, lossless shutdown (stop receiving, keep iterating to drain the buffered backlog, then end) alongside async with / aclose() for deterministic abrupt teardown. Reconnection, backpressure (a slow consumer is throttled, never dropped), and terminal-error delivery are handled by the gateway client.
  • Breaking: streaming messages are now wsgateway.WsMessage (a typed dataclass: topic/key/value/partition/offset/timestamp), yielded directly by the gateway. The SDK's own WsMessage is removed — import it from wsgateway, not careflow_sdk.models.
  • Requires careflow-wsgateway-client>=2.0.0,<3.
  • Breaking: with_options (on the client and each service) now takes **overrides typed via a shared TypedDict instead of a repeated explicit signature. Passing an explicit None now clears the option back to env-var/default resolution; previously it meant "keep the current value". Omitting an option carries the current value over, as before.
  • The User-Agent header is now Careflow-SDK-Python/<version> (was a stale hardcoded Careflow-SDK/1.0), so the server can distinguish SDK implementations and versions.
  • The package version is single-sourced from careflow_sdk/version.py (pyproject.toml resolves it dynamically).
  • Importing careflow_sdk now installs a filter on the httpx2 logger that redacts the connector secret from its request log line, as httpx2 logs every request at INFO with the full URL. Connector subscribe/flush carry the secret as a clientSecret query parameter, so any app enabling INFO logging would otherwise record a live credential; the value is now written as clientSecret=REDACTED. The logger's level is not changed, and records from the application's own httpx2 calls are never rewritten — the filter acts only while the SDK has a request in flight, tracked per-task so concurrent requests cannot affect each other.
  • BaseClient and AsyncBaseClient each gain a pipeline abstract accessor; any third-party implementation of those ABCs must provide it.

Added

  • client.pipeline and AsyncCareflowClient.pipeline — a request namespace alongside app and connector, constructed lazily and cached like the others.
  • pipeline.execute(command, parameters=None, *, require_signing=False), sync and awaitable — dispatches any broker command via POST /api/v1/pipeline. The request body is exactly {"command": ..., "parameters": ...}, with parameters defaulting to {} when omitted. Returns ResponseModel[dict[str, Any]] carrying the server's decoded JSON, unmodelled and unvalidated, so new broker commands work without an SDK release — there are deliberately no per-command methods.
  • PipelineCommand — StrEnum of the commands known at release time (pipeline.deployment.get, pipeline.deployment.list, pipeline.status.get, pipeline.run.start, pipeline.run.stop), for autocomplete and typo safety. A convenience listing, not a whitelist: nothing validates against it and execute still accepts any string.
  • PipelineService / CareflowPipelineService and AsyncPipelineService / CareflowAsyncPipelineService — service ABCs and implementations, with the same with_options scoping as the other services.
  • PipelineExecuteRequestModel — request model for the pipeline endpoint, subclassing AppRequestModel so it shares the /api/v1 namespace, controller host and HMAC scheme with the App API. It overrides wire_content to validate input and to put the default parameters {} on the wire; RESPONSE_BODY_MODEL is left None, so responses pass through as a plain dict.
  • Local input validation on pipeline requests — command must be a non-empty string and parameters a dict; either failure raises CareflowInvalidDataError before anything reaches the wire.
  • careflow_sdk.models now exports PipelineCommand and PipelineExecuteRequestModel.
  • AsyncCareflowClient — an async/await client mirroring CareflowClient, for use in asyncio applications (matches the .NET SDK, whose API is async-only). Same app/connector services and options, with awaitable methods (await client.app.publish(...)); teardown is await client.aclose() or async with AsyncCareflowClient(...) as client. The streaming service is shared with the sync client (the gateway stream is already async). The synchronous CareflowClient is unchanged.
  • close() and context-manager support on CareflowClient. The client owns its HTTP connection pools; scoped with_options copies share them, and the original owner closes.
  • ConnectOptions.max_queue_size (backpressure buffer depth ahead of a slow consumer; 0 = unbounded) and ConnectOptions.close_timeout (how long a graceful stream close() waits to finish draining before force-closing). Both default to the gateway's values when unset.
  • ConnectOptions.keepalive_interval and ConnectOptions.keepalive_timeout for streaming keepalive/liveness, forwarded to the WS Gateway client: it pings an idle connection every keepalive_interval and treats a missing pong within keepalive_timeout as a dead connection (reported via on_error, then reconnected). Both default to the gateway's values when unset (15.0 / 20.0 seconds). Mirrors the .NET SDK's ConnectOptions.KeepAliveInterval.
  • py.typed marker (PEP 561): the package now advertises its inline type hints, so consumers' type checkers (mypy, pyright) use the SDK's annotations instead of treating it as untyped.
  • DeploymentImage.storages — the storages array now returned per image by get_deployment(), exposing storage/database provisioning metadata (label, storage_type, database_type, size, provider, version, instance_type, root_disk_size, share_key, is_primary_share) via the new DeploymentStorage model. It was previously parsed and silently discarded. Mirrors the .NET SDK's DeploymentImage.Storages (2.6.0).
  • Request/response logging: each attempt logs its method, request URL, whether it was signed, the attempt number, and the response status at DEBUG under the careflow_sdk logger, and retries (transport error or retryable status) at WARNING, so a retry is visible without turning on DEBUG. Silent by default (a NullHandler is attached, which also suppresses logging.lastResort, so no level reaches stderr on its own); enable with logging.getLogger("careflow_sdk").setLevel(logging.DEBUG). Query strings (which carry the connector secret), request bodies, and header values are never logged — only the base URL + path, method, status, and whether the request was signed.

Fixed

  • mTLS misconfiguration now fails fast with CareflowInvalidDataError: setting only one of cert/key raises (previously the pair was silently ignored), and both paths are checked to exist (matching the .NET SDK). ~ is expanded in cert, key, and ca_bundle_path.
  • A negative numeric Retry-After or Retry-After-Ms response header (from a buggy or clock-skewed upstream) crashed the retry loop via time.sleep(negative); numeric values are now clamped to >= 0 like the HTTP-date form already was.
  • TLS/certificate failures (CareflowSslError) are no longer retried. They are deterministic, so retrying only delayed the real error by the full backoff schedule.
  • Signed requests now sign the full request path — including any path prefix on the base URL (e.g. https://host/controller, where /controller is part of the route) — instead of only the route (/api/v1/...). The request kept the prefix but the HMAC signature omitted it, and since the server verifies the signature over the path it receives, signed requests through a prefixed base URL failed with INVALID_SIGNATURE. The request path and the signed path are now always identical.
  • streaming.connect() now appends /ws to ws_gateway_base_url instead of replacing the base URL's path with it, so a gateway mounted under a path prefix is reachable — e.g. wss://host/wsgateway now connects to wss://host/wsgateway/ws rather than wss://host/ws. Bare-host gateway URLs are unaffected.
  • Connector response bodies now deserialize their camelCase keys. The connector does not share the controller's snake_case convention — a live subscribe returns dataSetMeta, not data_set_meta — so SubscribeResult.data_set_meta was always None and, within it, data_type / created_time / last_modified_time were dropped. No error was raised: the keys were simply unmodelled and every field is optional, making the loss indistinguishable from a field the server omitted. Records and totals were unaffected (their names are single words, identical under either convention). The snake_case spelling is still accepted.

Removed

  • Breaking: ConnectorStreamModel no longer has prepare() or a connector_secret property; the streaming service resolves the connector secret from ClientOptions at connect() time. The model is now an inert description of what to stream (topics, seek_to_latest), and no credential is stored on it.
  • pip.ini at the repo root; the Azure Artifacts feed setup lives in the README (per-OS pip config instructions) instead.
  • Breaking: custom request headers are no longer supported: the custom_headers field and add_headers() on request models are gone, along with the forbidden-header filter list. Request headers are owned entirely by the SDK, matching the .NET SDK (which has no custom-header API).
  • SignatureError from careflow_sdk.utils (defined but never raised; verify_signature returns a bool and never raises).

[1.1.0] - 2026-07-08

Added

  • ConnectOptions (in careflow_sdk.models) for tuning a streaming connection, accepted as an optional second argument to client.streaming.connect(stream_model, options). Exposes reconnection/timeout settings (reconnect_enabled, reconnect_interval, reconnect_max_interval, reconnect_max_attempts, connection_timeout, auth_timeout) and lifecycle callbacks (on_connect, on_disconnect, on_reconnect, on_error). Omitting it preserves the previous behaviour, so this is backward compatible. An unhandled exception in a callback terminates the stream and propagates unwrapped out of the iterator (.NET parity).
  • Default request headers User-Agent: Careflow-SDK/1.0 and Request-Timeout: <seconds> (computed from timeout) are now sent on every HTTP request, matching the .NET SDK.

[1.0.0] - 2026-06-29

Added

  • Initial release. Feature parity with the .NET Careflow SDK.
  • CareflowClient exposing app, connector, and streaming services (constructed lazily and cached).
  • App service (client.app): get_deployment, publish, subscribe, flush, control, get_stream_url, get_users, get_session, request_patients. Each returns a typed ResponseModel[T] with .status_code and .body.
  • Connector service (client.connector): publish, subscribe, flush, plus iter_subscribe for draining a topic up to an optional limit.
  • Streaming (client.streaming.connect): async-iterator WebSocket streaming over the WS Gateway, authenticated by connector secret, yielding WsMessage objects. ConnectorStreamModel.seek_to_latest skips the topic backlog and receives only data published after connecting (defaults to False).
  • HMAC-SHA256 request signing — opt-in per App request via require_signing.
  • mTLS support via client certificate/key and CA-bundle paths.
  • with_options on the client and each service for scoped option overrides; the connection pool is shared with copies unless a new session is supplied.
  • Configuration via constructor arguments or CAREFLOW_SDK_* environment variables.
  • Typed exception hierarchy:
    • Transport: CareflowIOError, CareflowSslError.
    • API: CareflowApiError base with CareflowClientError / CareflowServerError and HTTP-status subclasses (CareflowBadRequestError, CareflowUnauthorizedError, CareflowForbiddenError, CareflowNotFoundError, CareflowRateLimitError, CareflowUnexpectedStatusCodeError).
    • Broker error codes: CareflowMissingHeadersError, CareflowInvalidTimestampError, CareflowExpiredTimestampError, CareflowInvalidSignatureError, CareflowUnknownAppIdError, CareflowAuthInternalError.
    • Patient requests: CareflowMissingProjectError (server code 611), CareflowMissingPatientListError (server code 612).
    • Validation: CareflowValidationError with structured field_errors.
    • Local input validation: CareflowInvalidDataError.
  • responseStatus envelope handling: numeric and string error-code dispatch, field-validation arrays, the human-readable responseStatus.message surfaced on the exception, and HTML error pages (from a proxy or misconfigured route) surfaced as CareflowNotFoundError.
  • Automatic retries with capped exponential backoff and jitter; honors Retry-After / Retry-After-Ms and x-should-retry response headers.